From 7824dbb70547d2af7b62db590ce578f0355e6fb0 Mon Sep 17 00:00:00 2001 From: Jasmine-Lee-2026 Date: Sat, 26 Sep 2026 22:23:12 +0800 Subject: [PATCH 1/5] fix(captcha): cap main-thread blocking windows in happy solver - syncFetchBlocking timeout 30s -> 12s (CAPTCHA_SYNC_FETCH_TIMEOUT_MS) - solveTraceless overall timeout 30s -> 20s (CAPTCHA_SOLVE_TIMEOUT_MS) Mitigation only: these bounds reduce how long a single solve can stall the proxy event loop, they do not remove the stall. --- src/proxy/captcha-happy.ts | 119 ++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/src/proxy/captcha-happy.ts b/src/proxy/captcha-happy.ts index 91ca102..e56a47c 100644 --- a/src/proxy/captcha-happy.ts +++ b/src/proxy/captcha-happy.ts @@ -1,6 +1,6 @@ -// @ts-nocheck — ported from the proven Node happy-dom solver (solve-happy-lib.js) +// @ts-nocheck -- ported from the proven Node happy-dom solver (solve-happy-lib.js) /** - * captcha-happy.ts — in-process happy-dom Aliyun captcha solver. + * captcha-happy.ts -- in-process happy-dom Aliyun captcha solver. * * Ported from the production-proven standalone happy-dom solver to run * INSIDE the Bun process so the release binary stays self-contained: @@ -28,10 +28,15 @@ import { Worker } from "node:worker_threads"; // which fails inside a compiled Bun binary (argv[0] is the binary; `-e` is // not supported). We instead run the request on a worker thread that writes // the result into a SharedArrayBuffer and wakes the blocked host thread via -// Atomics — no child processes, no main-thread event loop dependency (a +// Atomics -- no child processes, no main-thread event loop dependency (a // postMessage-based handshake would deadlock: the main thread is blocked). const SYNC_FETCH_BUF_BYTES = 8 * 1024 * 1024; const SYNC_FETCH_HEADER_BYTES = 64; +// Fork patch: each sync XHR blocks the HOST main thread (Atomics.wait) -- the +// whole proxy event loop freezes for the duration. Upstream default was 30s; +// cap at 12s so a stalled aliyuncs POST can never wedge every connection for +// half a minute. Override: CAPTCHA_SYNC_FETCH_TIMEOUT_MS. +const SYNC_FETCH_TIMEOUT_MS = Number(process.env.CAPTCHA_SYNC_FETCH_TIMEOUT_MS || 12_000); // SAB layout (Int32 words): [0]=state (0=wait,1=done,2=error), [1]=httpStatus, // [2]=statusTextLen, [3]=headersJsonLen, [4]=setCookieJsonLen, [5]=bodyLen, // [6..]=payload bytes (statusText, headersJson, setCookieJson, body) @@ -44,7 +49,7 @@ const SYNC_WORKER_SRC = ` (async () => { const i32 = new Int32Array(m.sab); const u8 = new Uint8Array(m.sab); - // Fixed-size header (bytes), NOT i32.length * 4 — that is the whole SAB. + // Fixed-size header (bytes), NOT i32.length * 4 -- that is the whole SAB. const payloadAt = 64; const fail = (msg) => { const b = enc.encode(msg); @@ -81,7 +86,7 @@ function ensureSyncFetchWorker(): Worker { return _syncFetchWorker; } -function syncFetchBlocking(url: string, init: Record, timeoutMs = 30_000): { +function syncFetchBlocking(url: string, init: Record, timeoutMs = SYNC_FETCH_TIMEOUT_MS): { status: number; statusText: string; headers: Record; setCookie: string[]; body: Buffer; } | { error: string } { @@ -108,7 +113,7 @@ function syncFetchBlocking(url: string, init: Record, timeoutMs if (i32[0] === 2) return { error: dec.decode(u8.subarray(payloadAt, payloadAt + i32[5])) || "sync fetch failed" }; return { status: i32[1], statusText, headers, setCookie, body }; } catch (err: any) { - // A crashed worker must not poison later solves — reset it. + // A crashed worker must not poison later solves -- reset it. try { _syncFetchWorker?.terminate(); } catch {} _syncFetchWorker = null; return { error: `sync fetch error: ${err?.message ?? err}` }; @@ -124,7 +129,7 @@ const CDN_CACHE_DIR = path.join(os.homedir(), ".zcode-captcha-cdn-cache"); const _memCdnCache = new Map(); // pe bundles rotate (pe.0xx…); every rotation would otherwise pin a fresh // multi-hundred-KB body for the process lifetime (issue #50). Insertion-ordered -// FIFO — the oldest rotation ages out first; disk cache still serves re-reads. +// FIFO -- the oldest rotation ages out first; disk cache still serves re-reads. const MEM_CDN_CACHE_CAP = 16; function rememberCdnBody(url, body) { _memCdnCache.set(url, body); @@ -150,7 +155,7 @@ if (proxyUrl) { // ── Globals shared across solves ──────────────────────────────────────────── // Ring buffer: the stall detector reads only the newest entry and failure -// diagnostics the last ~12 entries of the CURRENT solve — anything older is +// diagnostics the last ~12 entries of the CURRENT solve -- anything older is // dead weight. Unbounded it grew for the process lifetime (issue #50). const REQUEST_LOG_CAP = 256; const _requestLog = []; @@ -176,7 +181,7 @@ function noteStallAndMaybeEvict(peUrl) { const n = (_stallCounts.get(peUrl) || 0) + 1; _stallCounts.set(peUrl, n); if (n >= 2 && !_DEBUG) { - process.stderr.write(`[pe-cache-evict] ${peUrl.split("/").pop()} stalled ${n}x — evicting cache\n`); + process.stderr.write(`[pe-cache-evict] ${peUrl.split("/").pop()} stalled ${n}x -- evicting cache\n`); } if (n >= 2) { _memCdnCache.delete(peUrl); @@ -267,7 +272,7 @@ async function fetchAndStore(url) { // verify write completed (no partial file) const stat = fs.statSync(p); if (stat.size !== buf.length) { - process.stderr.write(`[cache-write-short] ${url} wrote ${stat.size}/${buf.length}b — rewrite\n`); + process.stderr.write(`[cache-write-short] ${url} wrote ${stat.size}/${buf.length}b -- rewrite\n`); fs.writeFileSync(p, buf); } } catch (err) { @@ -369,7 +374,7 @@ function makeInterceptor(bypassPeCache = false) { try { new Function(body.toString("utf8")); } catch (parseErr) { - process.stderr.write(`[cache-bad-js] ${url} len=${body.length} ${parseErr.message} — refetch fresh\n`); + process.stderr.write(`[cache-bad-js] ${url} len=${body.length} ${parseErr.message} -- refetch fresh\n`); _memCdnCache.delete(url); try { fs.unlinkSync(diskPathFor(url)); } catch (_) {} body = null; @@ -445,7 +450,7 @@ function makeInterceptor(bypassPeCache = false) { try { new Function(body.toString("utf8")); } catch (parseErr) { - process.stderr.write(`[cache-bad-js:sync] ${url} len=${body.length} ${parseErr.message} — refetch fresh\n`); + process.stderr.write(`[cache-bad-js:sync] ${url} len=${body.length} ${parseErr.message} -- refetch fresh\n`); _memCdnCache.delete(url); try { fs.unlinkSync(diskPathFor(url)); } catch (_) {} body = null; @@ -471,7 +476,7 @@ function makeInterceptor(bypassPeCache = false) { }; } // Non-CDN sync request: serve it blocking via a worker thread. Never - // fall through to happy-dom's own sync fetch — it spawns a child + // fall through to happy-dom's own sync fetch -- it spawns a child // process with `process.argv[0] -e`, which breaks compiled binaries. const init = { method: request.method, headers: {} as Record }; request.headers.forEach((value, key) => { @@ -542,23 +547,23 @@ function makeInterceptor(bypassPeCache = false) { // inside SDK code resolves to the host's. Host timers outlive the window: // a stray FeiLin callback that re-arms its 2s heartbeat (feilin008.js: // `tV = setInterval(tE, 2e3)`) after destroyDom keeps firing forever and -// eventually dereferences a torn-down global — the field-reported +// eventually dereferences a torn-down global -- the field-reported // "ReferenceError: moveBy is not defined" that killed the TUI. // // Guest timers must therefore land on the WINDOW registry, which happy-dom // clears in happyDOM.close(). The previous approach decided this at CALL time // by sniffing `new Error().stack` for a CDN frame, but a stack describes the // call chain, not ownership, and it misjudges BOTH ways: -// • false negative — guest code built via `new Function` carries no CDN +// • false negative -- guest code built via `new Function` carries no CDN // frame, so its heartbeat escaped onto the immortal host lane; -// • false positive — host runtime code invoked beneath a guest frame was +// • false positive -- host runtime code invoked beneath a guest frame was // handed a window timer with no `.unref()`, the v4.5.2 crash shape. // Ownership is a property of where CODE COMES FROM, so we bind it lexically. // Each guest script is evaluated inside `with (scope) { … }`, where `scope` // carries this window's timer methods. Identifier resolution is settled by the // scope chain at parse time; no stack is ever consulted, so neither misjudgement // is expressible. `with` (not an IIFE wrapper) because guest top-level `var` and -// `function` declarations must keep escaping to the global object — an IIFE +// `function` declarations must keep escaping to the global object -- an IIFE // swallows them and `initAliyunCaptcha` never appears (measured: every solve // timed out). The FeiLin/pe bundles have no top-level "use strict" (their // `"use strict"` directives sit inside module functions, which is fine), so @@ -646,7 +651,7 @@ function makeScopedFunction(w) { * - **Top-level declarations keep escaping.** `with` introduces an object * environment, not a variable one, so guest `var`/`function` declarations * still land on the global object. A function wrapper swallows them and - * `initAliyunCaptcha` never appears — every solve then timed out waiting + * `initAliyunCaptcha` never appears -- every solve then timed out waiting * for it (measured: ok=0 fail=3). * * - **The completion value still flows out.** happy-dom's JavaScriptCompiler @@ -655,7 +660,7 @@ function makeScopedFunction(w) { * value, and a block completes with its last expression statement, so the * compiler's function expression is returned through the `with` unchanged. * (Declarations produce no completion value, so a script ending in one is - * also fine — the preceding expression's value stands.) + * also fine -- the preceding expression's value stands.) */ function wrapGuestSource(code, filename, scopeId) { const sourceUrl = filename && /^https?:/.test(String(filename)) ? `\n//# sourceURL=${filename}` : ""; @@ -690,7 +695,7 @@ function installEvalInstrumentation(w) { return orig.call(this, wrapGuestSource(String(code ?? ""), options && options.filename, scopeId), options); } catch (scopeErr) { // Only a wrapper-induced parse failure (e.g. a top-level "use - // strict" making `with` illegal) falls back — a genuine error from + // strict" making `with` illegal) falls back -- a genuine error from // the guest body must propagate to the diagnostics path below. if (!(scopeErr instanceof SyntaxError)) throw scopeErr; process.stderr.write( @@ -802,7 +807,7 @@ function installNativeToString(w) { // (WHATWG stream `closed`/`ready` reject when the receiver is the // prototype, not an instance). Nobody awaits these, so without a // sink each probe surfaced as an unhandledRejection during every - // solve — noise that buried real diagnostics. + // solve -- noise that buried real diagnostics. else if (v && typeof v.then === "function") v.catch(() => {}); } catch {} } @@ -856,7 +861,7 @@ const GUEST_EVAL_PATCH = ` } catch (e) {} // Guest errors are RECORDED, not printed: the Aliyun/FeiLin SDKs throw // benign uncaught TypeErrors inside happy-dom on every solve (imperfect DOM - // emulation) while the solve still succeeds — printing them flooded the + // emulation) while the solve still succeeds -- printing them flooded the // console with [WINDOW-ERROR] spam. They land in window.__capErrs (capped, // deduped) which solveTraceless surfaces only when a solve FAILS. // CAPTCHA_DEBUG=1 streams them live again. @@ -981,7 +986,7 @@ function applyPolyfills(w) { try { Object.defineProperty(w, "close", { value: w.close, configurable: true, writable: true }); } catch (_) {} // happy-dom lacks browser globals that FeiLin / the pe risk engine probe. - // A missing one throws ReferenceError inside the VM machine → breaks the + // A missing one throws ReferenceError inside the VM machine -> breaks the // collection chain. Ported from solve-shim.js's stub list. const extraGlobals = { print: () => {}, @@ -995,7 +1000,7 @@ function applyPolyfills(w) { try { Object.defineProperty(w, k, { value: v, configurable: true, writable: true }); } catch (_) {} } // happy-dom's own open()/close() are destructive (close() tears the window - // down); the risk engine probes them → neutralize. + // down); the risk engine probes them -> neutralize. try { Object.defineProperty(w, "open", { value: () => null, configurable: true, writable: true }); } catch (_) {} try { Object.defineProperty(w, "close", { value: () => {}, configurable: true, writable: true }); } catch (_) {} @@ -1776,7 +1781,7 @@ async function createDom(region, prefix) { const interceptor = makeInterceptor(_bypassPeCacheOnce); _bypassPeCacheOnce = false; - // Registered once per process — adding it inside createDom leaked a new + // Registered once per process -- adding it inside createDom leaked a new // EventEmitter listener per solve (MaxListenersExceededWarning + growth). if (!process.__capUnhandledRejectionHooked) { process.__capUnhandledRejectionHooked = true; @@ -1789,7 +1794,7 @@ async function createDom(region, prefix) { }); // Guest scripts (rotated pe/FeiLin bundles) can throw synchronous errors // that surface as uncaughtExceptions. Without a handler, happy-dom's - // exception observer (or Bun's default) terminates the whole proxy — + // exception observer (or Bun's default) terminates the whole proxy -- // a single bad pe version must only fail that one solve, not the server. process.on("uncaughtException", (err) => { try { @@ -1798,7 +1803,7 @@ async function createDom(region, prefix) { } catch (_) {} }); } - // Guest console is silent unless CAPTCHA_DEBUG — piping every SDK log to + // Guest console is silent unless CAPTCHA_DEBUG -- piping every SDK log to // stderr spams journald and slows mints under systemd. const noop = () => {}; const guestConsole = _DEBUG @@ -1876,7 +1881,7 @@ async function createDom(region, prefix) { // Apply polyfills + masking BEFORE the SDK script runs. // Bun compatibility: happy-dom's VM realm isolation doesn't apply under - // Bun — script tags execute against the host globalThis, where bare + // Bun -- script tags execute against the host globalThis, where bare // `window`/`document`/`location` identifiers don't exist. Node needs none // of this (its VM context resolves them natively). We alias the current // solve's window on globalThis and remove the aliases when the window is @@ -1944,7 +1949,7 @@ async function createDom(region, prefix) { // getter so guest scripts resolving bare identifiers (window, document, // XMLHttpRequest, Range, HTMLElement, ...) find them, exactly as Node's VM // realm would. Removed again in destroyDom. -// Names that must NOT be shadowed on globalThis — Bun/Node host internals the +// Names that must NOT be shadowed on globalThis -- Bun/Node host internals the // window happens to expose but the host runtime depends on. const HOST_CRITICAL_GLOBALS = new Set([ "process", "Bun", "console", "performance", "crypto", "fetch", @@ -1955,21 +1960,21 @@ const HOST_CRITICAL_GLOBALS = new Set([ // NOTE: requestAnimationFrame/cancelAnimationFrame were removed from this // list (2026-09-06). Bun has no native rAF, so skipping the alias left a // bare `requestAnimationFrame` in the FeiLin bundle unresolvable (9 call - // sites, only one `typeof`-guarded) — the same silent fingerprint + // sites, only one `typeof`-guarded) -- the same silent fingerprint // degradation that `print` caused. Aliasing the window's implementation // shadows nothing on the host. // NOTE: `print` was removed from this list (2026-08-29). The polyfill // defines a harmless no-op on the window, but the alias pass skipped it, // so under Bun (guest scripts run in the HOST realm) the Aliyun pe risk - // engine hit a bare `print` reference → ReferenceError → broken - // fingerprint chain → degraded solve success rate (711 WINDOW-ERRORs in + // engine hit a bare `print` reference -> ReferenceError -> broken + // fingerprint chain -> degraded solve success rate (711 WINDOW-ERRORs in // one day). Bun's host global has no native `print`, so aliasing the // stub shadows nothing critical. "URL", "URLSearchParams", "AbortController", "AbortSignal", "ReadableStream", "WritableStream", "TransformStream", "Blob", "File", "FormData", "Headers", "Request", "Response", "Event", "EventTarget", "MessageChannel", "MessagePort", "Buffer", "global", "globalThis", - // JS intrinsics — GlobalWindow re-exposes them as class fields; the host + // JS intrinsics -- GlobalWindow re-exposes them as class fields; the host // versions are fine, so never shadow them. "Array", "ArrayBuffer", "Boolean", "DataView", "Date", "Error", "EvalError", "Float32Array", "Float64Array", "Function", "Infinity", @@ -1981,7 +1986,7 @@ const HOST_CRITICAL_GLOBALS = new Set([ "encodeURIComponent", "escape", "isFinite", "isNaN", "parseFloat", "parseInt", "unescape", "eval", ]); -// Window methods that exist as prototype members, not own props — the alias +// Window methods that exist as prototype members, not own props -- the alias // pass must include them so guest bare-name references resolve (moveBy, // scrollTo, ... are referenced by the FeiLin fingerprint SDK). const EXTRA_WINDOW_PROPS = [ @@ -2001,7 +2006,7 @@ const INERT_WINDOW_METHODS = new Set(EXTRA_WINDOW_PROPS); let _aliasRefCount = 0; // Post-teardown tombstone (see removeGlobalWindowAlias): how long window- -// sourced alias getters keep resolving — to the CLOSED window — after the +// sourced alias getters keep resolving -- to the CLOSED window -- after the // last destroyDom. Guest (FeiLin) async fingerprint chains ride host // machinery (fetch/promise continuations) and can outlive the window; a // hard delete turns their next bare `Text`/`document` reference into an @@ -2009,7 +2014,7 @@ let _aliasRefCount = 0; // feilin005.js). The closed window's objects stay readable, so stragglers // run harmlessly to completion; a new solve wave (generation bump) cancels // the pending deletion entirely. The pristine host setTimeout captured at -// module load schedules it — never the aliased one. +// module load schedules it -- never the aliased one. const ALIAS_TOMBSTONE_MS = 30_000; let _aliasGeneration = 0; let _tombstoneMs = ALIAS_TOMBSTONE_MS; @@ -2019,7 +2024,7 @@ const _hostSetTimeout = globalThis.setTimeout; // host-global snapshot skips descriptors whose getter is in here: a wave // that starts inside a previous wave's grace period finds OUR OWN stale // accessors still on `g`, and saving them would "restore" window accessors -// at removal — permanently pinning the first closed window (review-caught +// at removal -- permanently pinning the first closed window (review-caught // 2026-08-31). Host getters (Bun's navigator/self accessors) are never in // this set and always flow to the restore path. const _aliasGetters = new WeakSet(); @@ -2032,7 +2037,7 @@ let _savedHostGlobalDescriptors: Record | undefined; // Guest timer/console routing is LEXICAL (see the guest scope section above): // bare `setTimeout`/`console` inside guest source resolve through the `with` -// scope to this window's own objects. No stack sniffing — the previous +// scope to this window's own objects. No stack sniffing -- the previous // `/alicdn/.test(new Error().stack)` predicate answered "who is calling?" when // the question is "who owns this?", and got both directions wrong (immortal // guest heartbeats; host timers stripped of `.unref`). @@ -2056,9 +2061,9 @@ export function installGlobalWindowAlias(g, w, tombstoneMs?) { // them with window-forwarding accessors (GlobalWindow own props outside // HOST_CRITICAL_GLOBALS); a capture taken after it would save those // accessors and the post-remove restore would reinstate accessors onto a - // closed window. The snapshot covers atob/btoa (client-signing's base64 — + // closed window. The snapshot covers atob/btoa (client-signing's base64 -- // field-reported ReferenceError), WebSocket, MessageEvent, CustomEvent, - // navigator, self, ... — every host global the window happens to expose. + // navigator, self, ... -- every host global the window happens to expose. const props = new Set(Object.getOwnPropertyNames(w)); for (const name of EXTRA_WINDOW_PROPS) props.add(name); // also walk the prototype chain one level (BrowserWindow getters like @@ -2077,7 +2082,7 @@ export function installGlobalWindowAlias(g, w, tombstoneMs?) { // cancelled mid-grace (retry ladder / pool bursts start the next // wave within the 30s tombstone): saving them would "restore" // window-forwarding accessors at removal and permanently pin the - // first closed window on globalThis. They are window-sourced — the + // first closed window on globalThis. They are window-sourced -- the // new wave's tombstone owns their cleanup. Host getters (Bun's // navigator/self accessors) are never in the WeakSet and keep // flowing to the restore path. @@ -2137,7 +2142,7 @@ export function removeGlobalWindowAlias(g, w) { _aliasRefCount -= 1; if (_aliasRefCount > 0) return; // Host-contract globals come back IMMEDIATELY: every HOST-EXISTING global - // the wave overwrote — atob/btoa (client-signing's JWT base64 — the + // the wave overwrote -- atob/btoa (client-signing's JWT base64 -- the // field-reported ReferenceError), WebSocket/MessageEvent/navigator/self/... // The timers and console were never aliased, so nothing to restore there. const restored = new Set(); @@ -2150,7 +2155,7 @@ export function removeGlobalWindowAlias(g, w) { } // Window-sourced globals get a TOMBSTONE grace period instead of an // immediate delete (see the ALIAS_TOMBSTONE_MS comment). Collect what is - // still accessor-aliased, EXCLUDING the restored set — a restored host + // still accessor-aliased, EXCLUDING the restored set -- a restored host // descriptor may itself be a getter (Bun's navigator/self are accessors) // and must never be tombstone-deleted. const generation = _aliasGeneration; @@ -2177,7 +2182,7 @@ export function removeGlobalWindowAlias(g, w) { if (!Object.getOwnPropertyDescriptor(g, name)?.get) continue; // Do NOT `delete`: a straggler still reading the name would get a // ReferenceError, which is fatal in the host realm. Leave an inert - // value instead — the reference resolves, the call is a no-op, and + // value instead -- the reference resolves, the call is a no-op, and // nothing keeps the closed window alive. The window methods guest // fingerprint code probes (moveBy/scrollTo/...) are no-ops in a real // browser anyway, so `undefined` is a faithful stand-in for the rest. @@ -2201,7 +2206,7 @@ export function removeGlobalWindowAlias(g, w) { // pe VM, intervals, XHR buffers). JSC only hands pages back to the OS on a // FULL synchronous collection, so without this the serve process ratchets: // every window generation's allocation peak becomes the permanent RSS floor -// (issue #50: 2.9 days → 9.95GB resident). Throttled because pe-storm retry +// (issue #50: 2.9 days -> 9.95GB resident). Throttled because pe-storm retry // ladders destroy several windows back-to-back and Bun.gc(true) is a // stop-the-world pass that gets heavier at large heaps. const _gcStats = { calls: 0, lastAt: 0 }; @@ -2254,11 +2259,11 @@ function extractVerifyParam(param) { // Strict validation: a REAL Aliyun verify param is ~280 chars of base64 // JSON containing certifyId + sceneId + isSign + a long securityToken. // Len-76 junk like {"certifyId":"70bdb",...,"isSign":true} (no securityToken) - // comes from a degraded SDK result path and WILL 3007 upstream — never let + // comes from a degraded SDK result path and WILL 3007 upstream -- never let // it out of the solver. if (str.length < 200) { throw new Error( - "verify param too short (" + str.length + " chars) — degraded result, refusing: " + str.slice(0, 80), + "verify param too short (" + str.length + " chars) -- degraded result, refusing: " + str.slice(0, 80), ); } try { @@ -2266,7 +2271,7 @@ function extractVerifyParam(param) { const secTok = decoded && (decoded.securityToken || decoded.SecurityToken); if (!secTok || String(secTok).length < 50) { throw new Error( - "verify param missing securityToken — refusing degraded result: " + str.slice(0, 80), + "verify param missing securityToken -- refusing degraded result: " + str.slice(0, 80), ); } } catch (err) { @@ -2296,7 +2301,7 @@ function handleCaptchaResult(result) { // default; opt out with CAPTCHA_WINDOW_REUSE=0 (or per-call // solveTraceless({reuseWindow:false})). The window // is discarded after `maxSolves` (each solve leaves SDK instance graphs -// resident in the window — issue #50 measured tens of MB per solve), after +// resident in the window -- issue #50 measured tens of MB per solve), after // any stall/failure (fresh InitCaptchaV3 rolls a new pe version), or after // `maxIdleMs` idle. 8 keeps most of the amortization win while capping a // generation's retention peak at ~1/3 of the old 25-solve default. @@ -2336,7 +2341,7 @@ function noteWindowSolved() { // (capped, deduped) instead of console-printing them: the Aliyun/FeiLin SDKs // throw benign uncaught TypeErrors inside happy-dom on every solve and the // solve still succeeds, so printing them is pure console spam. The buffer is -// surfaced only when a solve FAILS — that's when guest errors are +// surfaced only when a solve FAILS -- that's when guest errors are // actionable. CAPTCHA_DEBUG=1 streams them live again as // [WINDOW-ERROR]/[UH-REASON]. function guestErrorSummary(w, max = 4) { @@ -2358,7 +2363,11 @@ async function solveTraceless(opts) { const scene = opts.scene || "11xygtvd"; const region = opts.region || "sgp"; const prefix = opts.prefix || "no8xfe"; - const timeoutMs = opts.timeoutMs ?? 30_000; + // Fork patch: overall solve deadline default 30s -> 20s. With in-process + // solving on the main thread, a hung solve stalls every proxied connection; + // fail faster and let the pool's retry ladder handle it. + // Override: CAPTCHA_SOLVE_TIMEOUT_MS. + const timeoutMs = opts.timeoutMs ?? Number(process.env.CAPTCHA_SOLVE_TIMEOUT_MS || 20_000); const wantReuse = opts.reuseWindow ?? process.env.CAPTCHA_WINDOW_REUSE !== "0"; let dom; @@ -2389,11 +2398,11 @@ async function solveTraceless(opts) { reject(new Error(`captcha solve timeout pe=${peUrl.split("/").pop() || peUrl} reqs=${JSON.stringify(reqs)}`)); }, timeoutMs); // Fail-fast stall detector: healthy solves keep firing XHRs until verify // (~3s). If no XHR for stallMs and none pending, this pe-VM variant - // stalled (seen across rotated pe.0xx versions) — abort early so the + // stalled (seen across rotated pe.0xx versions) -- abort early so the // caller can retry with a fresh InitCaptchaV3 (new pe version). // Fail-fast stall detector: healthy solves keep firing XHRs until // verify (~3s, gaps <2s). If no XHR for 6s, this pe-VM variant stalled - // (seen across rotated pe.0xx versions) — abort early so the caller + // (seen across rotated pe.0xx versions) -- abort early so the caller // can retry with a fresh InitCaptchaV3 (new pe version). const stallMs = opts.stallMs ?? Number(process.env.CAPTCHA_STALL_MS || 6_000); const stallTimer = setInterval(() => { @@ -2479,7 +2488,7 @@ async function solveTraceless(opts) { } return out; } catch (err) { - // Attach captured guest window errors to the failure — the only situation + // Attach captured guest window errors to the failure -- the only situation // where they are actionable (a successful solve makes them irrelevant). const summary = guestErrorSummary(w); if (summary) { @@ -2490,7 +2499,7 @@ async function solveTraceless(opts) { throw err; } finally { // Reuse mode: on success the window stays pooled (keepWindow) for the next - // solve — a ~48% CPU cut. On failure it is destroyed: a stalled window must + // solve -- a ~48% CPU cut. On failure it is destroyed: a stalled window must // not poison later solves, and the retry rolls a fresh pe anyway. if (!keepWindow) { if (_reusePool.window === w) _reusePool.window = null; From 5d58e8c19c4bb0ef2dabd534b7438214efd8046c Mon Sep 17 00:00:00 2001 From: Jasmine-Lee-2026 Date: Sat, 26 Sep 2026 22:23:12 +0800 Subject: [PATCH 2/5] fix(captcha): bound config fetch with AbortSignal and negative cache - fetchCaptchaConfig: 5s abort timeout (CAPTCHA_CONFIG_TIMEOUT_MS) - 15s negative cache after a failed fetch so a dead configs endpoint cannot repeatedly wedge request handling --- src/proxy/captcha.ts | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/proxy/captcha.ts b/src/proxy/captcha.ts index 7756d7d..16cdb58 100644 --- a/src/proxy/captcha.ts +++ b/src/proxy/captcha.ts @@ -1,15 +1,15 @@ -/** - * Aliyun Captcha V3 front-end — config fetch + pre-solved token pool. +/** + * Aliyun Captcha V3 front-end -- config fetch + pre-solved token pool. * * Solving itself lives in captcha-happy.ts (in-process happy-dom solver, * production-proven, self-contained: bundled into the single-file release - * binary — no external Node.js, no browser, no jsdom). Tokens are minted + * binary -- no external Node.js, no browser, no jsdom). Tokens are minted * into a pool (captcha-pool.ts); requests take an already-solved token - * (sub-ms) while background refills keep the pool warm — the hot path + * (sub-ms) while background refills keep the pool warm -- the hot path * never waits on a solve. * * Fingerprint stability: the happy-dom solver's polyfill/guest-patch values - * are deterministic and STABLE (never randomized) — Aliyun's risk engine + * are deterministic and STABLE (never randomized) -- Aliyun's risk engine * correlates fingerprint stability across requests; randomizing per-solve * flags it as `verifyCode: F001`. See captcha-happy.ts. */ @@ -31,6 +31,9 @@ const CONFIGS_API = "https://zcode.z.ai/api/v1/client/configs"; interface FetchedCaptchaConfig { enabled: boolean; prefix: string; sceneId: string; region: string; } let cachedConfig: { value: FetchedCaptchaConfig | null; expiresAt: number } = { value: null, expiresAt: 0 }; +// Fork patch: short negative cache so a network outage doesn't make every +// request pay the config-fetch timeout before falling back. +let cfgNegUntil = 0; export function detectCaptchaChallenge(resp: Response): string | null { const v = resp.headers.get(CAPTCHA_HEADER); @@ -40,13 +43,30 @@ export function detectCaptchaChallenge(resp: Response): string | null { async function fetchCaptchaConfig(appVersion: string): Promise { if (cachedConfig.value && cachedConfig.expiresAt > Date.now()) return cachedConfig.value; + if (Date.now() < cfgNegUntil) return null; try { - const resp = await fetch(`${CONFIGS_API}?app_version=${encodeURIComponent(appVersion)}&platform=win32-x64`); + // Fork patch: bounded fetch -- the hot path awaits this (60s cache) and an + // unbounded fetch against zcode.z.ai stalls every request while the + // network is down. 5s cap + fail-open (returns null on error). + // Override: CAPTCHA_CONFIG_TIMEOUT_MS. + const cfgTimeoutMs = Number(process.env.CAPTCHA_CONFIG_TIMEOUT_MS || 5_000); + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), cfgTimeoutMs); + let resp: Response; + try { + resp = await fetch(`${CONFIGS_API}?app_version=${encodeURIComponent(appVersion)}&platform=win32-x64`, { signal: controller.signal }); + } finally { + clearTimeout(timer); + } const json = (await resp.json()) as { data?: { configs?: { captcha?: FetchedCaptchaConfig } } }; const cfg = json?.data?.configs?.captcha ?? null; cachedConfig = { value: cfg, expiresAt: Date.now() + 60000 }; + if (!cfg) cfgNegUntil = Date.now() + 15_000; return cfg; - } catch { return null; } + } catch { + cfgNegUntil = Date.now() + 15_000; + return null; + } } /** @@ -58,7 +78,7 @@ export async function getCaptchaToken(appVersion: string): Promise<{ verifyParam const cfg = await fetchCaptchaConfig(appVersion); if (!cfg || !cfg.enabled || !cfg.prefix || !cfg.sceneId) throw new Error("Captcha config unavailable"); // Pre-solved token pool: requests take an already-minted token (sub-ms) - // while background solves refill — the hot path never waits on a solve. + // while background solves refill -- the hot path never waits on a solve. const verifyParam = await takeCaptchaToken(cfg); return { verifyParam, region: cfg.region }; } @@ -79,7 +99,7 @@ export async function startCaptchaPool(appVersion: string): Promise { // first configure() so a cold boot doesn't mint a storm of soon-expired // tokens. Defaults are sized for start-plan's 5-concurrent-request ceiling: // worst case ~10 instantaneous takes (5 requests + challenge retries), with - // ~8-24 tokens circulating per 95s TTL — 15 covers that plus F008/expiry + // ~8-24 tokens circulating per 95s TTL -- 15 covers that plus F008/expiry // discards and bridges a pe-storm mint outage (~30-45s). Mint capacity // (~4-6/s at concurrency 3) stays an order of magnitude above demand. // CAPTCHA_POOL_MIN/CAPTCHA_POOL_MAX env vars override the defaults. From c3e2aee2933dca654e6ccdaa80db8a935d2af2fc Mon Sep 17 00:00:00 2001 From: Jasmine-Lee-2026 Date: Sat, 26 Sep 2026 22:23:12 +0800 Subject: [PATCH 3/5] fix(captcha): move happy-dom solve off the proxy event loop into workers Root cause of idle stalls: solveTraceless ran happy-dom + sync XHR (Atomics.wait) on the proxy main thread. After deep idle emptied the token pool, the next burst of requests spawned up to 8 concurrent solves x 6 retries, freezing the event loop for tens of seconds each time. Every connection hung until restart. Now each solve runs in a dedicated worker: - captcha-worker-entry.ts: worker entry running solveTraceless over postMessage (ESM) - build-fork-worker.ts: pre-bundles the entry into a self-contained captcha-worker-entry.bundle.js (bun --target=bun --bundle), embedded into the compiled exe via with { type: file } - captcha-solver.ts: worker-per-solve scheduler with 20s hard terminate, spawn/exit/error fallbacks A hung solve can no longer wedge anything outside its own worker. Verified: real request 200 with worker decode path, 3 concurrent requests all 200, error log clean; upstream tsc --noEmit clean, captcha unit tests 28/28. --- scripts/build-fork-worker.ts | 24 + src/proxy/captcha-happy.ts | 50 +- src/proxy/captcha-solver.ts | 101 +- src/proxy/captcha-worker-entry.bundle.js | 49846 +++++++++++++++++++++ src/proxy/captcha-worker-entry.ts | 32 + src/proxy/captcha.ts | 2 +- 6 files changed, 50018 insertions(+), 37 deletions(-) create mode 100644 scripts/build-fork-worker.ts create mode 100644 src/proxy/captcha-worker-entry.bundle.js create mode 100644 src/proxy/captcha-worker-entry.ts diff --git a/scripts/build-fork-worker.ts b/scripts/build-fork-worker.ts new file mode 100644 index 0000000..0bc31a9 --- /dev/null +++ b/scripts/build-fork-worker.ts @@ -0,0 +1,24 @@ +/** + * Build script -- fork patch: bundle the captcha worker entry into a + * self-contained ESM file so it can be embedded as a `with { type: "file" }` + * asset in the compiled single-file binary. Raw .ts assets are NOT parsed by + * Bun at extraction (they'd be evaluated as plain JS and fail on type + * annotations), so the worker must be pre-bundled to plain JS. + * + * Run before `bun build --compile`: bun run scripts/build-fork-worker.ts + * Output: src/proxy/captcha-worker-entry.bundle.mjs (gitignored build input) + */ +import { build } from "bun"; + +const result = await build({ + entrypoints: ["./src/proxy/captcha-worker-entry.ts"], + outdir: "./src/proxy", + target: "bun", + format: "esm", + naming: { entry: "[dir]/[name].bundle.[ext]" }, + minify: false, + external: [], +}); + +for (const log of result.logs) console.log(String(log)); +console.log(`captcha worker bundled: ${result.outputs.map((o) => o.path).join(", ")}`); diff --git a/src/proxy/captcha-happy.ts b/src/proxy/captcha-happy.ts index e56a47c..38aba7f 100644 --- a/src/proxy/captcha-happy.ts +++ b/src/proxy/captcha-happy.ts @@ -1,4 +1,4 @@ -// @ts-nocheck -- ported from the proven Node happy-dom solver (solve-happy-lib.js) +// @ts-nocheck -- ported from the proven Node happy-dom solver (solve-happy-lib.js) /** * captcha-happy.ts -- in-process happy-dom Aliyun captcha solver. * @@ -23,7 +23,7 @@ import os from "node:os"; import path from "node:path"; import { Worker } from "node:worker_threads"; -// ── Blocking fetch for sync XHR (self-contained builds) ──────────────────── +// -- Blocking fetch for sync XHR (self-contained builds) -------------------- // happy-dom implements sync XHR by spawning `process.argv[0] -e +`; +function diskPathFor(url) { + return path.join(CDN_CACHE_DIR, crypto.createHash("sha1").update(String(url)).digest("hex")); +} +function sniffMime(url) { + if (/\.js(\?|$)/i.test(url)) + return "application/javascript"; + if (/\.css(\?|$)/i.test(url)) + return "text/css"; + if (/\.png(\?|$)/i.test(url)) + return "image/png"; + if (/\.(jpg|jpeg)(\?|$)/i.test(url)) + return "image/jpeg"; + if (/\.json(\?|$)/i.test(url)) + return "application/json"; + return "application/octet-stream"; +} +var peVmCallRegex = /55==A\?\(f=r\[n\+\+\],l=e\.pop\(\),h=e\.pop\(\),o=\[\],\w+\(f\)\.forEach\(function\(\)\{o\.unshift\(e\.pop\(\)\)\}\),p=null===h\?l\.apply\((\w+),o\):h\[l\]\.apply\(h,o\),r\[n\+\+\]&&e\.push\(p\)\):/; +function patchPeBundle(buf, url) { + if (process.env.PE_PATCH === "off") + return buf; + if (!/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) + return buf; + let src = buf.toString("utf8"); + if (src.includes("__DBT")) + return buf; + const m = src.match(peVmCallRegex); + if (!m) + return buf; + const locals = m[1]; + const hook = `55==A?(f=r[n++],l=e.pop(),h=e.pop(),o=[],v(f).forEach(function(){o.unshift(e.pop())}),p=null===h?l.apply(${locals},o):h[l].apply(h,o),r[n++]&&e.push(p),function(){try{if(l===window.btoa||l===window.atob){window.__DBT=window.__DBT||[];var __sav=[];for(var __i=0;__i 0) { + return cookies.map((c) => `${c.name}=${c.value}`).join("; "); + } + } catch (_) {} + return null; +} +function storeSetCookies(res, url) { + try { + const list = typeof res.headers.getSetCookie === "function" ? res.headers.getSetCookie() : []; + if (list.length) { + const cookieContainer = global.__cookieContainer; + if (cookieContainer) { + for (const raw of list) { + const u = new URL(url); + const parts = raw.split(";"); + const pair = parts[0].split("="); + const cookie = { + name: pair[0].trim(), + value: pair.slice(1).join("=").trim(), + url: u.origin, + domain: u.hostname, + path: "/" + }; + for (const p of parts.slice(1)) { + const kv = p.trim().split(/=(.*)/s); + const k = (kv[0] || "").toLowerCase(); + if (k === "domain" && kv[1]) + cookie.domain = kv[1]; + if (k === "path" && kv[1]) + cookie.path = kv[1]; + if (k === "expires") + cookie.expires = new Date(kv[1]).getTime(); + if (k === "max-age") + cookie.maxAge = parseInt(kv[1], 10); + if (k === "httponly") + cookie.httpOnly = true; + if (k === "secure") + cookie.secure = true; + if (k === "samesite") + cookie.sameSite = kv[1]; + } + try { + cookieContainer.addCookies([cookie]); + } catch (_) {} + } + } + } + } catch (_) {} +} +function makeInterceptor(bypassPeCache = false) { + const skipPeCache = (url) => bypassPeCache && /dynamicJS\/.*\/pe\.\d+\./.test(url); + return { + async beforeAsyncRequest({ request, window: w }) { + const url = request.url; + noteRequest({ at: Date.now(), method: request.method, url }); + injectRequestHeaders(request); + if (/\balicdn\.com/i.test(url)) { + let body = skipPeCache(url) ? null : getCachedBody(url); + if (body && /\.js(\?|$)/i.test(url)) { + try { + new Function(body.toString("utf8")); + } catch (parseErr) { + process.stderr.write(`[cache-bad-js] ${url} len=${body.length} ${parseErr.message} \u2014 refetch fresh +`); + _memCdnCache.delete(url); + try { + fs.unlinkSync(diskPathFor(url)); + } catch (_) {} + body = null; + } + } + if (body) { + if (/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) { + try { + w.__lastPeUrl = url; + } catch (_) {} + } + return new w.Response(patchPeBundle(Buffer.from(body), url), { + status: 200, + statusText: "OK", + headers: { "content-type": sniffMime(url) } + }); + } + } + try { + const init = { method: request.method, headers: {} }; + request.headers.forEach((value, key) => { + init.headers[key] = value; + }); + const bs = new URL(url); + const cookie = cookieHeader(request, w, global.__browserFrame); + if (cookie) + init.headers.cookie = cookie; + let hasBody = false; + try { + if (request.body) { + const ab = await request.arrayBuffer(); + if (ab && ab.byteLength > 0) { + init.body = ab; + hasBody = true; + } + } + } catch (_) {} + const res = await fetch(url, init); + const buf = Buffer.from(await res.arrayBuffer()); + storeSetCookies(res, url); + if (_DEBUG && /captcha-open|verify\.|device\.saf|cloudauth-device|upload\./i.test(url) && buf.length && buf.length < 4096) { + try { + process.stderr.write(`[xhr-body] ${request.method} ${bs.hostname}${bs.pathname}-> ${res.status} ${buf.toString("utf8").slice(0, 1200)} +`); + } catch (_) {} + } + const headers = {}; + const ct = res.headers.get("content-type"); + if (ct) + headers["content-type"] = ct; + const logHost = bs.hostname; + if (_DEBUG) + process.stderr.write(`[xhr] ${request.method} ${logHost}${bs.pathname} -> ${res.status} (${buf.length}b) +`); + return new w.Response(buf, { + status: res.status, + statusText: res.statusText || "", + headers + }); + } catch (err) { + if (_DEBUG) + process.stderr.write(`[xhr-err] ${url}: ${err.message} +`); + return new w.Response("", { status: 503, statusText: "passthrough failed" }); + } + }, + beforeSyncRequest({ request, window: w }) { + const url = request.url; + noteRequest({ at: Date.now(), method: request.method, url, sync: true }); + injectRequestHeaders(request); + let body = null; + if (/\balicdn\.com/i.test(url)) { + body = skipPeCache(url) ? null : getCachedBody(url); + if (body && /\.js(\?|$)/i.test(url)) { + try { + new Function(body.toString("utf8")); + } catch (parseErr) { + process.stderr.write(`[cache-bad-js:sync] ${url} len=${body.length} ${parseErr.message} \u2014 refetch fresh +`); + _memCdnCache.delete(url); + try { + fs.unlinkSync(diskPathFor(url)); + } catch (_) {} + body = null; + } + } + } + if (body) { + if (/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) { + try { + w.__lastPeUrl = url; + } catch (_) {} + } + return { + status: 200, + statusText: "OK", + ok: true, + url, + redirected: false, + headers: new w.Headers({ "content-type": sniffMime(url) }), + body: patchPeBundle(Buffer.from(body), url), + [virtualServerFile]: null + }; + } + const init = { method: request.method, headers: {} }; + request.headers.forEach((value, key) => { + init.headers[key] = value; + }); + const cookie = cookieHeader(request, w, global.__browserFrame); + if (cookie) + init.headers.cookie = cookie; + try { + if (request.body) { + const ab = request.body; + if (ab && ab.byteLength > 0) + init.body = ab; + } + } catch (_) {} + const res = syncFetchBlocking(url, init); + if (res.error) { + process.stderr.write(`[sync-xhr-err] ${url}: ${res.error} +`); + return new w.Response("", { status: 503, statusText: "sync fetch failed" }); + } + try { + for (const raw of res.setCookie || []) { + const cookieContainer = global.__cookieContainer; + if (!cookieContainer) + break; + const u = new URL(url); + const parts = raw.split(";"); + const pair = parts[0].split("="); + const cookie = { + name: pair[0].trim(), + value: pair.slice(1).join("=").trim(), + url: u.origin, + domain: u.hostname, + path: "/" + }; + for (const p of parts.slice(1)) { + const kv = p.trim().split(/=(.*)/s); + const k = (kv[0] || "").toLowerCase(); + if (k === "domain" && kv[1]) + cookie.domain = kv[1]; + if (k === "path" && kv[1]) + cookie.path = kv[1]; + if (k === "expires") + cookie.expires = new Date(kv[1]).getTime(); + if (k === "max-age") + cookie.maxAge = parseInt(kv[1], 10); + if (k === "httponly") + cookie.httpOnly = true; + if (k === "secure") + cookie.secure = true; + if (k === "samesite") + cookie.sameSite = kv[1]; + } + try { + cookieContainer.addCookies([cookie]); + } catch (_) {} + } + } catch (_) {} + const hdrs = {}; + for (const [k, v] of Object.entries(res.headers || {})) + hdrs[k] = String(v); + return { + status: res.status, + statusText: res.statusText || "", + ok: res.status >= 200 && res.status < 300, + url, + redirected: false, + headers: new w.Headers(hdrs), + body: Buffer.from(res.body), + [virtualServerFile]: null + }; + } + }; +} +var GUEST_TIMER_PROPS = ["setTimeout", "setInterval", "clearTimeout", "clearInterval"]; +var GUEST_SCOPE_ROOT = "__capGuestScopes"; +var _guestScopeSeq = 0; +function installGuestScope(w) { + const root = globalThis[GUEST_SCOPE_ROOT] ??= Object.create(null); + const id = `w${++_guestScopeSeq}`; + const scope = Object.create(null); + for (const name of GUEST_TIMER_PROPS) { + const fn = w[name]; + scope[name] = typeof fn === "function" ? fn.bind(w) : fn; + } + scope.Function = makeScopedFunction(w); + if (!_DEBUG && w.console) + scope.console = w.console; + root[id] = scope; + w.__capScopeId = id; + return id; +} +function removeGuestScope(w) { + try { + const id = w && w.__capScopeId; + const root = globalThis[GUEST_SCOPE_ROOT]; + if (id && root) + delete root[id]; + } catch {} +} +function makeScopedFunction(w) { + const Scoped = function(...args) { + const body = args.length ? String(args[args.length - 1]) : ""; + const params = args.slice(0, -1).map(String).join(","); + const id = w.__capScopeId; + const source = `return function(${params}){with(globalThis.${GUEST_SCOPE_ROOT}[${JSON.stringify(id)}]){ +${body} +}}`; + return Function(source)(); + }; + Scoped.prototype = Function.prototype; + try { + Object.defineProperty(Scoped, "name", { value: "Function", configurable: true }); + Object.defineProperty(Scoped, "toString", { + value: () => "function Function() { [native code] }", + configurable: true, + writable: true + }); + } catch {} + return Scoped; +} +function wrapGuestSource(code, filename, scopeId) { + const sourceUrl = filename && /^https?:/.test(String(filename)) ? ` +//# sourceURL=${filename}` : ""; + const scopeRef = `globalThis.${GUEST_SCOPE_ROOT}[${JSON.stringify(scopeId)}]`; + return `with(${scopeRef}){ +${code} +}${sourceUrl}`; +} +function installEvalInstrumentation(w) { + const sym = exports_PropertySymbol && evaluateScript; + if (!sym || typeof w[sym] !== "function") { + process.stderr.write(`[instr] no evaluateScript symbol, host hook skipped +`); + return; + } + const orig = w[sym]; + w[sym] = function(code, options) { + const scopeId = w.__capScopeId; + try { + if (scopeId) { + try { + return orig.call(this, wrapGuestSource(String(code ?? ""), options && options.filename, scopeId), options); + } catch (scopeErr) { + if (!(scopeErr instanceof SyntaxError)) + throw scopeErr; + process.stderr.write(`[instr] guest scope rejected (${scopeErr.message.slice(0, 80)}), evaluating unwrapped +`); + } + } + return orig.call(this, code, options); + } catch (err) { + try { + const src = String(code || ""); + const filename = options && options.filename || "?"; + const sha1 = crypto.createHash("sha1").update(src).digest("hex"); + process.stderr.write(` +[EVAL-PARSE-FAIL] file=${filename} len=${src.length} sha1=${sha1} +` + ` head300: ${JSON.stringify(src.slice(0, 300))} +` + ` tail100: ${JSON.stringify(src.slice(-100))} +` + ` err: ${err && err.message} +`); + if (/^https?:/.test(filename)) { + (async () => { + try { + const res = await fetch(filename, { headers: { "user-agent": fp.userAgent } }); + const fresh = Buffer.from(await res.arrayBuffer()); + process.stderr.write(`[EVAL-CACHE-COMPARE] cachedLen=${src.length} freshLen=${fresh.length} freshSha1=${crypto.createHash("sha1").update(fresh).digest("hex")} http=${res.status} +`); + if (fresh.length > 0 && fresh.length !== src.length) { + process.stderr.write(`[EVAL-CACHE-MISMATCH] deleting ${diskPathFor(filename)} (stale/truncated cache) +`); + try { + fs.unlinkSync(diskPathFor(filename)); + } catch (_) {} + _memCdnCache.delete(filename); + } + } catch (fetchErr) { + process.stderr.write(`[EVAL-CACHE-COMPARE-ERR] ${fetchErr.message} +`); + } + })(); + } + } catch (e2) {} + throw err; + } + }; +} +function installNativeToString(w) { + const realToString = Function.prototype.toString; + const nativeRe = /\[native code\]/; + const mask = (fn) => { + if (typeof fn !== "function") + return; + try { + if (nativeRe.test(realToString.call(fn))) + return; + const name = fn.name || ""; + const nativeStr = `function ${name}() { [native code] }`; + Object.defineProperty(fn, "toString", { + value: () => nativeStr, + configurable: true, + writable: true + }); + } catch (_) {} + }; + const seen = new w.Set; + const maskObj = (obj, depth) => { + if (!obj || typeof obj !== "object" && typeof obj !== "function" || depth > 5) + return; + try { + if (obj.constructor && obj.constructor.prototype !== Object.prototype) { + const ctorName = obj.constructor.name; + if (/^(WriteStream|ReadStream|Socket|Process|Timeout|Immediate)$/.test(ctorName)) + return; + } + } catch (_) {} + if (seen.has(obj)) + return; + try { + seen.add(obj); + } catch (_) { + return; + } + let names = []; + try { + names = Object.getOwnPropertyNames(obj); + } catch (_) { + return; + } + for (const name of names) { + if (name === "toString" || name === "constructor") + continue; + let desc; + try { + desc = Object.getOwnPropertyDescriptor(obj, name); + } catch (_) { + continue; + } + if (!desc) + continue; + if (typeof desc.value === "function") { + mask(desc.value); + } else if (typeof desc.get === "function") { + mask(desc.get); + try { + const v = desc.get.call(obj); + if (typeof v === "function") + mask(v); + else if (v && typeof v.then === "function") + v.catch(() => {}); + } catch {} + } + if (depth < 3) { + try { + const v = desc.value; + if (v && (typeof v === "function" || typeof v === "object")) + maskObj(v, depth + 1); + } catch (_) {} + } + } + }; + const targets = [ + w, + w.navigator, + w.document, + w.Document && w.Document.prototype, + w.Element && w.Element.prototype, + w.HTMLElement && w.HTMLElement.prototype, + w.Node && w.Node.prototype, + w.EventTarget && w.EventTarget.prototype, + w.HTMLCanvasElement && w.HTMLCanvasElement.prototype, + w.XMLHttpRequest && w.XMLHttpRequest.prototype, + w.Event && w.Event.prototype, + w.Window && w.Window.prototype + ].filter(Boolean); + for (const t of targets) { + try { + maskObj(t, 0); + } catch (_) {} + } +} +var GUEST_EVAL_PATCH = ` +(function() { + try { + Object.defineProperty(Event.prototype, "isTrusted", { + get() { return true; }, + configurable: true + }); + } catch (e) {} + try { + if (window.HTMLDocument) { + Object.defineProperty(window.HTMLDocument, "name", { value: "HTMLDocument", configurable: true }); + Object.defineProperty(window.HTMLDocument.prototype, Symbol.toStringTag, { value: "HTMLDocument", configurable: true }); + } + } catch (e) {} + try { + Object.defineProperty(window.Document.prototype, Symbol.toStringTag, { value: "HTMLDocument", configurable: true }); + } catch (e) {} + // Guest errors are RECORDED, not printed: the Aliyun/FeiLin SDKs throw + // benign uncaught TypeErrors inside happy-dom on every solve (imperfect DOM + // emulation) while the solve still succeeds \u2014 printing them flooded the + // console with [WINDOW-ERROR] spam. They land in window.__capErrs (capped, + // deduped) which solveTraceless surfaces only when a solve FAILS. + // CAPTCHA_DEBUG=1 streams them live again. + var __capDebug = ${_DEBUG ? "true" : "false"}; + function __capRecord(kind, msg, stack) { + try { + var m = String(msg || "?"); + var s = String(stack || "").split("\\n").slice(0, 2).join(" | "); + if (!window.__capErrs) window.__capErrs = []; + var last = window.__capErrs[window.__capErrs.length - 1]; + if (last && last.k === kind && last.m === m) { + last.n = (last.n || 1) + 1; + } else { + window.__capErrs.push({ k: kind, m: m, s: s, n: 1 }); + if (window.__capErrs.length > 8) window.__capErrs.shift(); + } + if (__capDebug) console.error("[" + kind + "]", m, s); + } catch (e2) {} + } + try { + window.addEventListener("unhandledrejection", function(e) { + var r = e && e.reason; + __capRecord("UH-REASON", (r && r.message) || typeof r, r && r.stack); + }); + } catch (e) {} + try { + window.addEventListener("error", function(e) { + __capRecord("WINDOW-ERROR", e && e.message, e && e.error && e.error.stack); + }); + } catch (e) {} + // ---- eval/Function parse-fail instrumentation (installed before pe chain) ---- + // Catches SyntaxError from guest-side eval()/new Function() (the dynamic pe.* + // chunk is evaluated this way in some SDK paths). Host-side twin: the + // PropertySymbol.evaluateScript wrapper in installEvalInstrumentation(). + function __capFailDump(kind, code) { + try { + var src = String(code || ""); + if (typeof window.__capDebugDump === "function") { + window.__capDebugDump(window.__lastPeUrl || "?", src, kind); + } else { + console.error("[" + kind + "] url=" + (window.__lastPeUrl || "?") + " len=" + src.length + " head=" + JSON.stringify(src.slice(0, 300)) + " tail=" + JSON.stringify(src.slice(-100))); + } + } catch (e2) {} + } + try { + var _origEval2 = window.eval; + if (_origEval2) { + window.eval = function(code) { + try { return _origEval2.call(window, code); } + catch (e) { + if (e && (/unexpected|invalid|parse|syntax/i.test(String((e && e.message) || e)))) { + __capFailDump("REALM-EVAL-FAIL", code); + } + throw e; + } + }; + } + } catch (e) {} + try { + var _of = window.Function; + if (_of) { + var _WF = function() { + var args = Array.prototype.slice.call(arguments); + var body = args.length ? String(args[args.length - 1]) : ""; + try { return _of.apply(this, args); } + catch (e) { + if (e && (/unexpected|invalid|parse|syntax/i.test(String((e && e.message) || e)))) { + __capFailDump("REALM-FN-FAIL", body); + } + throw e; + } + }; + _WF.prototype = _of.prototype; + try { Object.defineProperty(_WF, "name", { value: "Function", configurable: true }); } catch (e) {} + window.Function = _WF; + } + } catch (e) {} +})(); +`; +function applyPolyfills(w) { + if (process.env.CAPTCHA_DEBUG_BODIES === "1") { + installTrafficLogger(w); + } + if (typeof w.Option !== "function") { + w.Option = class Option extends w.HTMLOptionElement { + constructor(text, value, defaultSelected, selected) { + super(); + if (text !== undefined) { + const el = w.document.createElement("option"); + el.text = text; + if (value !== undefined) + el.value = value; + if (defaultSelected) + el.defaultSelected = true; + if (selected) + el.selected = true; + return el; + } + } + }; + } + if (typeof w.Video !== "function" && w.HTMLVideoElement) { + w.Video = class Video extends w.HTMLVideoElement { + constructor() { + return w.document.createElement("video"); + } + }; + } + if (typeof w.alert !== "function") + w.alert = () => {}; + if (typeof w.prompt !== "function") + w.prompt = () => null; + if (typeof w.confirm !== "function") + w.confirm = () => false; + if (typeof w.open !== "function") + w.open = () => null; + if (typeof w.close !== "function") + w.close = () => {}; + try { + Object.defineProperty(w, "alert", { value: w.alert, configurable: true, writable: true }); + } catch (_) {} + try { + Object.defineProperty(w, "prompt", { value: w.prompt, configurable: true, writable: true }); + } catch (_) {} + try { + Object.defineProperty(w, "confirm", { value: w.confirm, configurable: true, writable: true }); + } catch (_) {} + try { + Object.defineProperty(w, "open", { value: w.open, configurable: true, writable: true }); + } catch (_) {} + try { + Object.defineProperty(w, "close", { value: w.close, configurable: true, writable: true }); + } catch (_) {} + const extraGlobals = { + print: () => {}, + stop: () => {}, + moveTo: () => {}, + moveBy: () => {}, + showModalDialog: () => null, + find: () => false + }; + for (const [k, v] of Object.entries(extraGlobals)) { + try { + Object.defineProperty(w, k, { value: v, configurable: true, writable: true }); + } catch (_) {} + } + try { + Object.defineProperty(w, "open", { value: () => null, configurable: true, writable: true }); + } catch (_) {} + try { + Object.defineProperty(w, "close", { value: () => {}, configurable: true, writable: true }); + } catch (_) {} + if (!w.Option) { + w.Option = class { + constructor(text, value, defaultSelected, selected) { + this.text = text ?? ""; + this.value = value ?? ""; + this.selected = selected ?? defaultSelected ?? false; + this.defaultSelected = !!defaultSelected; + this.disabled = false; + this.label = this.text; + this.index = 0; + } + }; + } + if (!w.EventSource) { + w.EventSource = class { + constructor() { + this.readyState = 2; + this.onopen = null; + this.onmessage = null; + this.onerror = null; + } + close() { + this.readyState = 2; + } + addEventListener() {} + removeEventListener() {} + }; + } + if (!w.Beacon) + w.Beacon = class { + }; + if (!w.RTCPeerConnection) { + w.RTCPeerConnection = class { + constructor() {} + createDataChannel() { + return {}; + } + close() {} + createOffer() { + return Promise.resolve({}); + } + setLocalDescription() { + return Promise.resolve(); + } + addEventListener() {} + removeEventListener() {} + }; + } + if (!w.MessageChannel) { + w.MessageChannel = class { + constructor() { + this.port1 = { onmessage: null, postMessage() {}, start() {}, close() {}, addEventListener() {}, removeEventListener() {} }; + this.port2 = { onmessage: null, postMessage() {}, start() {}, close() {}, addEventListener() {}, removeEventListener() {} }; + } + }; + } + w.IntersectionObserver = w.IntersectionObserver || class { + constructor(cb) { + this.cb = cb; + } + observe() {} + unobserve() {} + disconnect() {} + takeRecords() { + return []; + } + }; + w.ResizeObserver = w.ResizeObserver || class { + observe() {} + unobserve() {} + disconnect() {} + }; + w.DeviceOrientationEvent = w.DeviceOrientationEvent || class extends w.Event { + constructor(type, opts) { + super(type, opts); + } + alpha = null; + beta = null; + gamma = null; + absolute = false; + }; + w.DeviceMotionEvent = w.DeviceMotionEvent || class extends w.Event { + constructor(type, opts) { + super(type, opts); + } + acceleration = null; + accelerationIncludingGravity = null; + rotationRate = null; + interval = 16; + }; + w.requestIdleCallback = w.requestIdleCallback || ((cb) => w.setTimeout(() => cb({ didTimeout: false, timeRemaining: () => 10 }), 1)); + w.cancelIdleCallback = w.cancelIdleCallback || ((id) => w.clearTimeout(id)); + w.matchMedia = w.matchMedia || (() => ({ + matches: false, + media: "", + onchange: null, + addListener() {}, + removeListener() {}, + addEventListener() {}, + removeEventListener() {}, + dispatchEvent() { + return false; + } + })); + if (!w.visualViewport) { + const VisualViewport = function() {}; + VisualViewport.prototype = { + width: fp.screen.w - 16, + height: fp.screen.h - 120, + scale: 1, + offsetLeft: 0, + offsetTop: 0, + pageLeft: 0, + pageTop: 0, + onresize: null, + onscroll: null, + onscrollend: null + }; + w.VisualViewport = VisualViewport; + w.visualViewport = Object.create(w.VisualViewport.prototype); + } + if (!w.indexedDB) { + const IDBFactory = function() {}; + IDBFactory.prototype = { + open: () => ({ onupgradeneeded: null, onsuccess: null, onerror: null }), + deleteDatabase: () => ({}), + databases: () => Promise.resolve([]) + }; + w.IDBFactory = IDBFactory; + w.indexedDB = Object.create(w.IDBFactory.prototype); + } + if (!w.speechSynthesis) { + const SpeechSynthesis = function() {}; + SpeechSynthesis.prototype = { + speak() {}, + cancel() {}, + pause() {}, + resume() {}, + getVoices: () => [] + }; + w.SpeechSynthesis = SpeechSynthesis; + w.speechSynthesis = Object.create(w.SpeechSynthesis.prototype); + w.SpeechSynthesisUtterance = function() {}; + } + w.Worker = w.Worker || class { + postMessage() {} + terminate() {} + addEventListener() {} + removeEventListener() {} + }; + w.Notification = w.Notification || class { + static permission = "default"; + static requestPermission() { + return Promise.resolve("default"); + } + close() {} + }; + const proto = w.HTMLCanvasElement.prototype; + const nativeGetContext = typeof proto.getContext === "function" ? proto.getContext : null; + proto.getContext = function(type, ...rest) { + if (/webgl/i.test(type)) { + return makeWebGLMock(this); + } + if (nativeGetContext) { + try { + const ctx = nativeGetContext.call(this, type, ...rest); + if (ctx) + return ctx; + } catch (_) {} + } + return make2DStub(this); + }; + function makeWebGLMock(canvas) { + return { + canvas, + getParameter(p) { + if (p === 7936) + return "WebKit"; + if (p === 7937) + return "WebKit WebGL"; + if (p === 7938) + return "WebGL 1.0 (OpenGL ES 2.0 Chromium)"; + if (p === 35724) + return "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)"; + if (p === 37445) + return fp.webglUnmaskedVendor; + if (p === 37446) + return fp.webglUnmaskedRenderer; + return "Intel Inc."; + }, + getExtension(name) { + if (name === "WEBGL_debug_renderer_info") { + return { UNMASKED_VENDOR_WEBGL: 37445, UNMASKED_RENDERER_WEBGL: 37446 }; + } + return null; + }, + getSupportedExtensions() { + return [ + "ANGLE_instanced_arrays", + "EXT_blend_minmax", + "EXT_color_buffer_half_float", + "EXT_disjoint_timer_query", + "EXT_float_blend", + "EXT_frag_depth", + "EXT_shader_texture_lod", + "EXT_texture_compression_bptc", + "EXT_texture_compression_rgtc", + "EXT_texture_filter_anisotropic", + "EXT_sRGB", + "KHR_parallel_shader_compile", + "OES_element_index_uint", + "OES_fbo_render_mipmap", + "OES_standard_derivatives", + "OES_texture_float", + "OES_texture_float_linear", + "OES_texture_half_float", + "OES_texture_half_float_linear", + "OES_vertex_array_object", + "WEBGL_color_buffer_float", + "WEBGL_compressed_texture_astc", + "WEBGL_compressed_texture_etc", + "WEBGL_compressed_texture_etc1", + "WEBGL_compressed_texture_s3tc", + "WEBGL_compressed_texture_s3tc_srgb", + "WEBGL_debug_renderer_info", + "WEBGL_debug_shaders", + "WEBGL_depth_texture", + "WEBGL_draw_buffers", + "WEBGL_lose_context", + "WEBGL_multi_draw" + ]; + }, + getContextAttributes() { + return { + alpha: true, + antialias: true, + depth: true, + failIfMajorPerformanceCaveat: false, + powerPreference: "default", + premultipliedAlpha: true, + preserveDrawingBuffer: false, + stencil: false, + desynchronized: false + }; + }, + getShaderPrecisionFormat() { + return { precision: 23, rangeMin: 127, rangeMax: 127 }; + } + }; + } + function make2DStub(canvas) { + return { + canvas, + fillRect() {}, + clearRect() {}, + getImageData: (_x, _y, w2 = 1, h2 = 1) => new w.ImageData(w2, h2), + putImageData() {}, + createImageData: (w2 = 1, h2 = 1) => new w.ImageData(w2, h2), + setTransform() {}, + transform() {}, + drawImage() {}, + save() {}, + restore() {}, + beginPath() {}, + moveTo() {}, + lineTo() {}, + bezierCurveTo() {}, + quadraticCurveTo() {}, + closePath() {}, + clip() {}, + stroke() {}, + fill() {}, + arc() {}, + rect() {}, + ellipse() {}, + translate() {}, + scale() {}, + rotate() {}, + fillText() {}, + strokeText() {}, + measureText: (t) => ({ width: String(t).length * 8 }), + createLinearGradient: () => ({ addColorStop() {} }), + createRadialGradient: () => ({ addColorStop() {} }), + createPattern: () => ({}), + isPointInPath: () => false, + font: "10px sans-serif", + textBaseline: "alphabetic", + textAlign: "start", + fillStyle: "#000", + strokeStyle: "#000", + globalAlpha: 1, + lineWidth: 1, + shadowBlur: 0, + shadowColor: "" + }; + } + const nativeToDataURL = typeof proto.toDataURL === "function" ? proto.toDataURL : null; + proto.toDataURL = function(...a) { + try { + if (nativeToDataURL) + return nativeToDataURL.apply(this, a); + } catch (_) {} + return fp.canvasImage; + }; + if (typeof proto.toBlob !== "function") { + proto.toBlob = (cb) => cb && cb(new w.Blob); + } + w.OffscreenCanvas = w.OffscreenCanvas || class { + constructor(width, height) { + this.width = width; + this.height = height; + } + getContext() { + return proto.getContext.call(this); + } + }; + const audioMock = class { + constructor() { + this.sampleRate = 44100; + this.currentTime = 0; + this.state = "suspended"; + } + createOscillator() { + return { + type: "sine", + frequency: { value: 440, setValueAtTime() {} }, + connect() {}, + start() {}, + stop() {} + }; + } + createDynamicsCompressor() { + return { + threshold: { value: -24, setValueAtTime() {} }, + knee: { value: 30, setValueAtTime() {} }, + ratio: { value: 12, setValueAtTime() {} }, + attack: { value: 0.003, setValueAtTime() {} }, + release: { value: 0.25, setValueAtTime() {} }, + connect() {} + }; + } + createAnalyser() { + return { + fftSize: 2048, + frequencyBinCount: 1024, + getByteFrequencyData() {}, + getByteTimeDomainData() {}, + connect() {} + }; + } + createGain() { + return { gain: { value: 1 }, connect() {} }; + } + destination = {}; + resume() { + this.state = "running"; + return Promise.resolve(); + } + close() { + this.state = "closed"; + return Promise.resolve(); + } + }; + w.AudioContext = w.AudioContext || audioMock; + w.OfflineAudioContext = w.OfflineAudioContext || class extends audioMock { + constructor(_channels, length, sampleRate) { + super(); + this.length = length; + this.sampleRate = sampleRate; + } + startRendering() { + const len = this.length || 44100; + const sr = this.sampleRate || 44100; + const buf = new Float32Array(len); + for (let i = 0;i < len; i += 1) { + const t = i / sr; + buf[i] = Math.sin(2 * Math.PI * 1000 * t) * Math.exp(-t * 1.2) * 0.6 + Math.sin(2 * Math.PI * 3000 * t) * Math.exp(-t * 1.5) * 0.25 + Math.sin(2 * Math.PI * 5000 * t) * Math.exp(-t * 2) * 0.12; + } + return Promise.resolve({ + numberOfChannels: 1, + length: len, + sampleRate: sr, + getChannelData: () => buf + }); + } + }; + w.requestAnimationFrame = w.requestAnimationFrame || ((cb) => w.setTimeout(() => cb(Date.now()), 16)); + w.cancelAnimationFrame = w.cancelAnimationFrame || ((id) => w.clearTimeout(id)); + try { + Object.defineProperty(w.document, "hidden", { value: false, configurable: true }); + Object.defineProperty(w.document, "visibilityState", { + value: "visible", + configurable: true + }); + } catch (_) {} + if (!w.document.fonts) { + w.document.fonts = { + ready: Promise.resolve(), + check: () => true, + addEventListener() {}, + removeEventListener() {} + }; + } + if (!w.chrome) { + w.chrome = { + app: { + isInstalled: false, + InstallState: { DISABLED: "disabled", INSTALLED: "installed", NOT_INSTALLED: "not_installed" }, + RunningState: { CANNOT_RUN: "cannot_run", CAN_RUN: "can_run", RUNNING: "running" }, + getDetails() { + return null; + }, + getIsInstalled() { + return false; + }, + installState(cb) { + if (cb) + cb("not_installed"); + }, + runningState(cb) { + if (cb) + cb("cannot_run"); + } + }, + csi() { + const now = Date.now(); + return { startE: now - 100, onloadT: now, pageT: 100, tran: 15 }; + }, + loadTimes() { + const now = Date.now() / 1000; + return { + requestTime: now - 0.1, + startLoadTime: now - 0.1, + commitLoadTime: now - 0.05, + finishDocumentLoadTime: now, + finishLoadTime: now, + firstPaintTime: now - 0.02, + firstPaintAfterLoadTime: 0, + navigationType: "Other", + wasFetchedViaSpdy: true, + wasNpnNegotiated: true, + npnNegotiatedProtocol: "h2", + wasAlternateProtocolAvailable: false, + connectionInfo: "h2" + }; + } + }; + } + const nav = w.navigator; + const plugins = createNavigatorPlugins(w); + const navPatch = { + userAgent: fp.userAgent, + platform: fp.platform, + language: "en-US", + languages: ["en-US", "en"], + vendor: "Google Inc.", + webdriver: false, + hardwareConcurrency: 12, + deviceMemory: 8, + maxTouchPoints: 0, + cookieEnabled: true, + plugins: plugins.plugins, + mimeTypes: plugins.mimeTypes, + appVersion: fp.userAgent.replace(/^Mozilla\//, ""), + appName: "Netscape", + appCodeName: "Mozilla", + product: "Gecko", + productSub: "20030107", + vendorSub: "", + oscpu: undefined, + doNotTrack: null, + sendBeacon: (url, data) => { + try { + const xhr = new w.XMLHttpRequest; + xhr.open("POST", url, true); + xhr.send(data); + return true; + } catch (_) { + return false; + } + } + }; + for (const [k, v] of Object.entries(navPatch)) { + try { + Object.defineProperty(nav, k, { value: v, configurable: true }); + } catch (_) {} + } + const makeNS = (protoObj) => { + const C = new w.Function; + C.prototype = protoObj; + return new C; + }; + if (!nav.connection) { + const NetInfo = () => {}; + NetInfo.prototype = { onchange: null, effectiveType: "4g", rtt: 50, downlink: 10, saveData: false }; + w.NetworkInformation = NetInfo; + try { + Object.defineProperty(nav, "connection", { value: makeNS(NetInfo.prototype), configurable: true }); + } catch (_) {} + } + if (!nav.userAgentData) { + const UAData = function() {}; + UAData.prototype = { + brands: [ + { brand: "Chromium", version: fp.uaMajor }, + { brand: "Not)A;Brand", version: "24" } + ], + mobile: false, + platform: "Linux", + getHighEntropyValues: () => Promise.resolve({ + brands: [ + { brand: "Chromium", version: fp.uaMajor }, + { brand: "Not)A;Brand", version: "24" } + ], + mobile: false, + platform: "Linux", + platformVersion: "6.5.0", + architecture: "x86", + model: "", + uaFullVersion: fp.uaFull, + fullVersionList: [ + { brand: "Chromium", version: fp.uaFull }, + { brand: "Not)A;Brand", version: "24.0.0.0" } + ] + }) + }; + try { + Object.defineProperty(nav, "userAgentData", { value: makeNS(UAData.prototype), configurable: true }); + } catch (_) {} + } + if (!w.Permissions) { + const Perms = () => {}; + Perms.prototype = { + query: (param) => Promise.resolve({ state: param.name === "notifications" ? "prompt" : "granted", onchange: null }) + }; + w.Permissions = Perms; + } + try { + if (!nav.permissions) + Object.defineProperty(nav, "permissions", { value: makeNS(w.Permissions.prototype), configurable: true }); + } catch (_) {} + try { + if (!nav.clipboard) + Object.defineProperty(nav, "clipboard", { + value: makeNS({ readText: () => Promise.resolve(""), writeText: () => Promise.resolve() }), + configurable: true + }); + } catch (_) {} + try { + if (!nav.geolocation) + Object.defineProperty(nav, "geolocation", { + value: makeNS({ + getCurrentPosition: (s) => s && s({ coords: { latitude: 0, longitude: 0, accuracy: 1 } }), + watchPosition: () => 1, + clearWatch: () => {} + }), + configurable: true + }); + } catch (_) {} + try { + if (!nav.credentials) + Object.defineProperty(nav, "credentials", { + value: makeNS({ get: () => Promise.resolve(null), create: () => Promise.resolve(null), store: () => Promise.resolve(), preventSilentAccess: () => Promise.resolve() }), + configurable: true + }); + } catch (_) {} + try { + if (!nav.storage) + Object.defineProperty(nav, "storage", { + value: makeNS({ estimate: () => Promise.resolve({ quota: 1e8, usage: 0 }), persisted: () => Promise.resolve(false), persist: () => Promise.resolve(false) }), + configurable: true + }); + } catch (_) {} + try { + if (!nav.usb) + Object.defineProperty(nav, "usb", { + value: makeNS({ getDevices: () => Promise.resolve([]), requestDevice: () => Promise.reject(new Error("no devices")) }), + configurable: true + }); + } catch (_) {} + try { + if (!nav.mediaDevices) + Object.defineProperty(nav, "mediaDevices", { + value: makeNS({ enumerateDevices: () => Promise.resolve([]), getUserMedia: () => Promise.reject(new Error("NotAllowedError")) }), + configurable: true + }); + } catch (_) {} + const screenPatch = { + width: fp.screen.w, + height: fp.screen.h, + availWidth: fp.screen.w, + availHeight: fp.screen.ah, + availLeft: 0, + availTop: 0, + colorDepth: 24, + pixelDepth: 24, + orientation: { angle: 0, type: "landscape-primary", onchange: null } + }; + for (const [k, v] of Object.entries(screenPatch)) { + try { + Object.defineProperty(w.screen, k, { get: () => v, configurable: true }); + } catch (_) {} + } + w.outerWidth = fp.screen.w; + w.outerHeight = fp.screen.h - 40; + w.innerWidth = fp.screen.w - 16; + w.innerHeight = fp.screen.h - 120; + w.devicePixelRatio = 1; +} +function createNavigatorPlugins(w) { + const indexed = [ + { name: "PDF Viewer", filename: "internal-pdf-viewer", description: "Portable Document Format" }, + { name: "Chrome PDF Viewer", filename: "mhjfbmdgcfjbbpaeojofohoefgiehjai", description: "" }, + { name: "Chromium PDF Viewer", filename: "mhjfbmdgcfjbbpaeojofohoefgiehjai", description: "" } + ]; + const plugins = w.PluginArray ? Object.create(w.PluginArray.prototype) : {}; + const mockIndexed = []; + for (let i = 0;i < indexed.length; i++) { + const p = Object.create(w.Plugin && w.Plugin.prototype || Object.prototype); + Object.defineProperty(p, "name", { value: indexed[i].name, configurable: true, enumerable: true }); + Object.defineProperty(p, "filename", { value: indexed[i].filename, configurable: true, enumerable: true }); + Object.defineProperty(p, "description", { value: indexed[i].description, configurable: true, enumerable: true }); + Object.defineProperty(p, "length", { value: 1, configurable: true, enumerable: true }); + Object.defineProperty(p, "0", { value: p, configurable: true, enumerable: true }); + p.item = () => p; + p.namedItem = () => p; + plugins[i] = p; + mockIndexed.push(p); + } + Object.defineProperty(plugins, "length", { value: indexed.length, configurable: true, enumerable: true }); + plugins.item = (i) => plugins[i] ?? null; + plugins.namedItem = (name) => mockIndexed.find((p) => p.name === name) ?? null; + plugins.refresh = () => {}; + const mimeTypes = w.MimeTypeArray ? Object.create(w.MimeTypeArray.prototype) : {}; + Object.defineProperty(mimeTypes, "length", { value: 0, configurable: true, enumerable: true }); + mimeTypes.item = () => null; + mimeTypes.namedItem = () => null; + return { plugins, mimeTypes }; +} +function installTrafficLogger(w) { + const origOpen = w.XMLHttpRequest.prototype.open; + const origSend = w.XMLHttpRequest.prototype.send; + w.XMLHttpRequest.prototype.open = function(method, url, ...rest) { + this.__capMethod = method; + this.__capUrl = url; + return origOpen.call(this, method, url, ...rest); + }; + w.XMLHttpRequest.prototype.send = function(body) { + const url = String(this.__capUrl || ""); + const DEBUG_HOSTS = /(cloudauth-device|captcha-open|verify|upload|nocaptcha|aliyuncs)/i; + if (DEBUG_HOSTS.test(url)) { + this.addEventListener("load", () => { + let respPreview = ""; + try { + respPreview = String(this.responseText || "").slice(0, 3000); + } catch (_) {} + try { + process.stderr.write(` +===== XHR ${String(this.__capMethod || "?")} ${url} +--- RESP (${respPreview.length}b) --- +${respPreview} +===== +`); + } catch (_) {} + }); + } + return origSend.call(this, body); + }; +} +function safeJson(x) { + try { + if (x instanceof Error) + return `Error: ${x.message} +${(x.stack || "").slice(0, 1500)}`; + const s = JSON.stringify(x); + return s !== undefined && s.length < 3000 ? s : String(x); + } catch (_) { + return String(x); + } +} +function simulateBehavior(w, durationMs = 600) { + const { document, MouseEvent, KeyboardEvent, UIEvent } = w; + if (!document || !MouseEvent) + return; + const fire = (type, ctor, opts) => { + try { + const Ctor = ctor || UIEvent; + const ev = new Ctor(type, { bubbles: true, cancelable: true, view: w, ...opts }); + document.dispatchEvent(ev); + if (document.body) + document.body.dispatchEvent(ev); + } catch (_) {} + }; + let x = 140 + Math.random() * 30; + let y = 110 + Math.random() * 20; + const targetX = 540 + Math.random() * 40; + const targetY = 380 + Math.random() * 30; + const steps = 22; + let i = 0; + const start = Date.now(); + const moveStep = () => { + if (i > steps) + return; + x += (targetX - x) * 0.16 + (Math.random() - 0.5) * 5; + y += (targetY - y) * 0.16 + (Math.random() - 0.5) * 4; + fire("mousemove", MouseEvent, { + screenX: Math.round(x), + screenY: Math.round(y), + clientX: Math.round(x), + clientY: Math.round(y), + button: 0, + buttons: 1 + }); + i += 1; + const done = Date.now() - start >= durationMs; + if (i <= steps && !done) { + w.setTimeout(moveStep, 26 + Math.floor(Math.random() * 32)); + } else { + fire("mousedown", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0, buttons: 1 }); + fire("mouseup", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0, buttons: 0 }); + fire("click", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0 }); + try { + fire("keyup", KeyboardEvent, { key: "a", code: "KeyA", keyCode: 65, which: 65 }); + } catch (_) {} + } + }; + moveStep(); +} +function waitFor(cond, timeoutMs = 15000, intervalMs = 40) { + return new Promise((res, rej) => { + const started = Date.now(); + const timer = setInterval(() => { + let ok = false; + try { + ok = cond(); + } catch (_) {} + if (ok) { + clearInterval(timer); + res(); + } else if (Date.now() - started > timeoutMs) { + clearInterval(timer); + rej(new Error("timeout")); + } + }, intervalMs); + }); +} +async function createDom(region, prefix) { + let cookies = []; + const now = Date.now(); + if (_cookieCache.ts > 0 && now - _cookieCache.ts < COOKIE_CACHE_TTL_MS) { + cookies = _cookieCache.cookies; + } else { + try { + const res = await fetch("https://zcode.z.ai/", { + headers: { + "User-Agent": fp.userAgent, + "sec-ch-ua": '"Chromium";v="' + fp.uaMajor + '", "Not)A;Brand";v="24"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Linux"', + "Accept-Language": "en-US,en;q=0.9" + } + }); + cookies = typeof res.headers.getSetCookie === "function" ? res.headers.getSetCookie() : []; + _cookieCache = { cookies, ts: Date.now() }; + } catch (_) {} + } + const interceptor = makeInterceptor(_bypassPeCacheOnce); + _bypassPeCacheOnce = false; + if (!process.__capUnhandledRejectionHooked) { + process.__capUnhandledRejectionHooked = true; + process.on("unhandledRejection", (reason) => { + if (!_DEBUG) + return; + try { + const r = reason && reason.stack ? reason.stack : String(reason); + process.stderr.write(`[host-unhandledRejection] ${typeof reason} ${JSON.stringify(reason).slice(0, 200)} ${r} +`); + } catch (_) {} + }); + process.on("uncaughtException", (err) => { + try { + const msg = err && err.message ? err.message : String(err); + process.stderr.write(`[captcha-guest-uncaught] ${msg} +`); + } catch (_) {} + }); + } + const noop = () => {}; + const guestConsole = _DEBUG ? { + log: (...a) => process.stderr.write(`[guest-log] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`), + warn: (...a) => process.stderr.write(`[guest-warn] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`), + error: (...a) => process.stderr.write(`[guest-err] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`), + info: (...a) => process.stderr.write(`[guest-info] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`), + debug: (...a) => process.stderr.write(`[guest-debug] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`), + trace: (...a) => process.stderr.write(`[guest-trace] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} +`) + } : { log: noop, warn: noop, error: noop, info: noop, debug: noop, trace: noop }; + const w = new GlobalWindow({ + url: "https://zcode.z.ai/", + console: guestConsole, + settings: { + enableJavaScriptEvaluation: true, + enableImageFileLoading: true, + suppressInsecureJavaScriptEnvironmentWarning: true, + navigator: { userAgent: fp.userAgent }, + viewport: { width: fp.screen.w, height: fp.screen.h, devicePixelRatio: 1 }, + fetch: { + disableSameOriginPolicy: true, + interceptor + } + } + }); + const browserFrame = new WindowBrowserContext(w).getBrowserFrame(); + global.__browserFrame = browserFrame; + global.__cookieContainer = browserFrame.page.context.cookieContainer; + for (const raw of cookies) { + try { + const u = new URL("https://zcode.z.ai/"); + const parts = raw.split(";"); + const pair = parts[0].split("="); + const cookie = { + name: pair[0].trim(), + value: pair.slice(1).join("=").trim(), + url: u.origin, + domain: u.hostname, + path: "/" + }; + for (const p of parts.slice(1)) { + const kv = p.trim().split(/=(.*)/s); + const k = (kv[0] || "").toLowerCase(); + if (k === "domain" && kv[1]) + cookie.domain = kv[1]; + if (k === "path" && kv[1]) + cookie.path = kv[1]; + if (k === "expires") + cookie.expires = new Date(kv[1]).getTime(); + if (k === "max-age") + cookie.maxAge = parseInt(kv[1], 10); + if (k === "httponly") + cookie.httpOnly = true; + if (k === "secure") + cookie.secure = true; + if (k === "samesite") + cookie.sameSite = kv[1]; + } + browserFrame.page.context.cookieContainer.addCookies([cookie]); + } catch (_) {} + } + const visitorId = crypto.randomUUID(); + const deviceMid = crypto.randomUUID(); + const pre = [ + { name: "zcode_visitor_id", value: visitorId, domain: "zcode.z.ai" }, + { name: "zcode_device_mid", value: deviceMid, domain: "zcode.z.ai" }, + { name: "visitor_id", value: visitorId, domain: "zcode.z.ai", httpOnly: true } + ]; + for (const c of pre) { + try { + browserFrame.page.context.cookieContainer.addCookies([{ ...c, url: "https://zcode.z.ai", path: "/" }]); + } catch (_) {} + } + applyPolyfills(w); + installNativeToString(w); + installGuestScope(w); + installEvalInstrumentation(w); + const needsGlobalAlias = typeof Bun !== "undefined"; + if (needsGlobalAlias) { + const g = globalThis; + installGlobalWindowAlias(g, w); + } + if (w.Error) { + w.Error.prepareStackTrace = Error.prepareStackTrace; + } + w.__capDebugDump = (url, src, kind) => { + try { + const s = String(src || ""); + const sha1 = crypto.createHash("sha1").update(s).digest("hex"); + process.stderr.write(` +[${kind}] url=${url} len=${s.length} sha1=${sha1} +` + ` head300: ${JSON.stringify(s.slice(0, 300))} +` + ` tail100: ${JSON.stringify(s.slice(-100))} +`); + if (/^https?:/.test(String(url))) { + (async () => { + try { + const res = await fetch(url, { headers: { "user-agent": fp.userAgent } }); + const fresh = Buffer.from(await res.arrayBuffer()); + process.stderr.write(`[${kind}-CACHE-COMPARE] cachedLen=${s.length} freshLen=${fresh.length} freshSha1=${crypto.createHash("sha1").update(fresh).digest("hex")} http=${res.status} +`); + if (fresh.length > 0 && fresh.length !== s.length) { + process.stderr.write(`[${kind}-MISMATCH] deleting ${diskPathFor(url)} (stale/truncated cache) +`); + try { + fs.unlinkSync(diskPathFor(url)); + } catch (_) {} + _memCdnCache.delete(url); + } + } catch (fetchErr) { + process.stderr.write(`[${kind}-CACHE-COMPARE-ERR] ${fetchErr.message} +`); + } + })(); + } + } catch (_) {} + }; + w.eval(GUEST_EVAL_PATCH); + w.document.write(HTML); + w.AliyunCaptchaConfig = { region, prefix }; + return { window: w, browserFrame }; +} +var HOST_CRITICAL_GLOBALS = new Set([ + "process", + "Bun", + "console", + "performance", + "crypto", + "fetch", + "queueMicrotask", + "structuredClone", + "TextEncoder", + "TextDecoder", + "setTimeout", + "setInterval", + "clearTimeout", + "clearInterval", + "URL", + "URLSearchParams", + "AbortController", + "AbortSignal", + "ReadableStream", + "WritableStream", + "TransformStream", + "Blob", + "File", + "FormData", + "Headers", + "Request", + "Response", + "Event", + "EventTarget", + "MessageChannel", + "MessagePort", + "Buffer", + "global", + "globalThis", + "Array", + "ArrayBuffer", + "Boolean", + "DataView", + "Date", + "Error", + "EvalError", + "Float32Array", + "Float64Array", + "Function", + "Infinity", + "Int8Array", + "Int16Array", + "Int32Array", + "Intl", + "JSON", + "Map", + "Math", + "NaN", + "Number", + "Object", + "Promise", + "RangeError", + "ReferenceError", + "RegExp", + "Reflect", + "Set", + "String", + "Symbol", + "SyntaxError", + "TypeError", + "URIError", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "WeakMap", + "WeakSet", + "decodeURI", + "decodeURIComponent", + "encodeURI", + "encodeURIComponent", + "escape", + "isFinite", + "isNaN", + "parseFloat", + "parseInt", + "unescape", + "eval" +]); +var EXTRA_WINDOW_PROPS = [ + "moveBy", + "moveTo", + "resizeBy", + "resizeTo", + "scrollTo", + "scrollBy", + "scroll", + "open", + "close", + "stop", + "focus", + "blur", + "print", + "alert", + "confirm", + "prompt", + "getSelection", + "find" +]; +var INERT_WINDOW_METHODS = new Set(EXTRA_WINDOW_PROPS); +var _aliasRefCount = 0; +var ALIAS_TOMBSTONE_MS = 30000; +var _aliasGeneration = 0; +var _tombstoneMs = ALIAS_TOMBSTONE_MS; +var _hostSetTimeout = globalThis.setTimeout; +var _aliasGetters = new WeakSet; +var _savedHostGlobalDescriptors; +function installGlobalWindowAlias(g, w, tombstoneMs) { + if (_aliasRefCount < 0) + _aliasRefCount = 0; + _aliasRefCount += 1; + _aliasGeneration += 1; + _tombstoneMs = typeof tombstoneMs === "number" ? tombstoneMs : ALIAS_TOMBSTONE_MS; + const props = new Set(Object.getOwnPropertyNames(w)); + for (const name of EXTRA_WINDOW_PROPS) + props.add(name); + for (const proto = Object.getPrototypeOf(w);proto && proto !== Object.prototype; ) { + for (const name of Object.getOwnPropertyNames(proto)) + props.add(name); + break; + } + if (_aliasRefCount === 1 && !_savedHostGlobalDescriptors) { + const saved = {}; + for (const prop of props) { + if (prop === "constructor" || HOST_CRITICAL_GLOBALS.has(prop)) + continue; + try { + const d = Object.getOwnPropertyDescriptor(g, prop); + if (d && d.get && _aliasGetters.has(d.get)) + continue; + if (d) + saved[prop] = d; + } catch (_) {} + } + for (const prop of ["window", "self", "top", "parent", "__capWindowFor"]) { + try { + const d = Object.getOwnPropertyDescriptor(g, prop); + if (d && d.get && _aliasGetters.has(d.get)) + continue; + if (d && !saved[prop]) + saved[prop] = d; + } catch (_) {} + } + _savedHostGlobalDescriptors = saved; + } + for (const prop of props) { + if (HOST_CRITICAL_GLOBALS.has(prop)) + continue; + try { + const getter = function() { + return w[prop]; + }; + _aliasGetters.add(getter); + Object.defineProperty(g, prop, { + get: getter, + set(v) { + try { + w[prop] = v; + } catch (_) {} + }, + configurable: true + }); + } catch (_) {} + } + for (const prop of ["window", "self", "top", "parent"]) { + try { + const getter = function() { + return w; + }; + _aliasGetters.add(getter); + Object.defineProperty(g, prop, { get: getter, configurable: true }); + } catch (_) {} + } + try { + const capGetter = function() { + return w; + }; + _aliasGetters.add(capGetter); + Object.defineProperty(g, "__capWindowFor", { + get: capGetter, + configurable: true + }); + } catch (_) {} +} +function removeGlobalWindowAlias(g, w) { + _aliasRefCount -= 1; + if (_aliasRefCount > 0) + return; + const restored = new Set; + if (_savedHostGlobalDescriptors) { + for (const [name, desc] of Object.entries(_savedHostGlobalDescriptors)) { + try { + Object.defineProperty(g, name, desc); + } catch (_) {} + restored.add(name); + } + _savedHostGlobalDescriptors = undefined; + } + const generation = _aliasGeneration; + const names = []; + try { + for (const name of Object.getOwnPropertyNames(w)) { + if (restored.has(name)) + continue; + try { + if (Object.getOwnPropertyDescriptor(g, name)?.get) + names.push(name); + } catch (_) {} + } + for (const prop of ["window", "self", "top", "parent", "__capWindowFor"]) { + if (restored.has(prop)) + continue; + try { + if (Object.getOwnPropertyDescriptor(g, prop)?.get) + names.push(prop); + } catch (_) {} + } + } catch (_) {} + try { + const t = _hostSetTimeout(() => { + if (generation !== _aliasGeneration || _aliasRefCount > 0) + return; + for (const name of names) { + try { + if (!Object.getOwnPropertyDescriptor(g, name)?.get) + continue; + const stub = INERT_WINDOW_METHODS.has(name) ? () => {} : undefined; + Object.defineProperty(g, name, { + value: stub, + configurable: true, + writable: true + }); + } catch (_) {} + } + }, _tombstoneMs); + try { + if (t && typeof t.unref === "function") + t.unref(); + } catch (_) {} + } catch (_) {} +} +var _gcStats = { calls: 0, lastAt: 0 }; +function reclaimCaptchaHeap() { + try { + const gc = typeof Bun !== "undefined" && typeof Bun.gc === "function" && Bun.gc || typeof globalThis.gc === "function" && globalThis.gc; + if (!gc) + return; + const raw = Number(process.env.CAPTCHA_GC_MIN_INTERVAL_MS); + const minMs = Number.isFinite(raw) && raw >= 0 ? raw : 5000; + const now = Date.now(); + if (now - _gcStats.lastAt < minMs) + return; + _gcStats.lastAt = now; + _gcStats.calls += 1; + gc(true); + } catch (_) {} +} +function destroyDom(win) { + try { + const cap = win.document.getElementById("cap"); + if (cap) + cap.replaceChildren(); + win.happyDOM.close(); + } catch (_) {} + try { + global.__cookieContainer = null; + global.__browserFrame = null; + } catch (_) {} + try { + if (typeof Bun !== "undefined") + removeGlobalWindowAlias(globalThis, win); + } catch (_) {} + removeGuestScope(win); + try { + shutdownSyncFetchWorker(); + } catch (_) {} + reclaimCaptchaHeap(); +} +function extractVerifyParam(param) { + let verifyParam = param; + if (param && typeof param === "object") { + verifyParam = param.verifyParam || param.data || param.param; + } + if (!verifyParam || String(verifyParam).length < 20) { + throw new Error("solver returned empty param: " + JSON.stringify(param)); + } + const str = String(verifyParam); + if (str.length < 200) { + throw new Error("verify param too short (" + str.length + " chars) \u2014 degraded result, refusing: " + str.slice(0, 80)); + } + try { + const decoded = JSON.parse(Buffer.from(str, "base64").toString("utf8")); + const secTok = decoded && (decoded.securityToken || decoded.SecurityToken); + if (!secTok || String(secTok).length < 50) { + throw new Error("verify param missing securityToken \u2014 refusing degraded result: " + str.slice(0, 80)); + } + } catch (err) { + if (err instanceof SyntaxError || /securityToken/.test(String(err.message))) { + throw err instanceof SyntaxError ? new Error("verify param not base64-JSON: " + str.slice(0, 80)) : err; + } + throw err; + } + return str; +} +function handleCaptchaResult(result) { + if (result && typeof result === "object" && result.verifyResult === false) { + throw new Error("verify rejected: " + JSON.stringify({ verifyCode: result.verifyCode, certifyId: result.certifyId })); + } + return result; +} +var _reusePool = { window: null, browserFrame: null, solves: 0, lastUsedAt: 0 }; +var REUSE_MAX_SOLVES = Number(process.env.CAPTCHA_REUSE_MAX_SOLVES || 8); +var REUSE_MAX_IDLE_MS = Number(process.env.CAPTCHA_REUSE_MAX_IDLE_MS || 120000); +function takeReusableWindow() { + const p = _reusePool; + if (!p.window) + return null; + if (p.solves >= REUSE_MAX_SOLVES) { + discardReusableWindow(); + return null; + } + if (Date.now() - p.lastUsedAt > REUSE_MAX_IDLE_MS) { + discardReusableWindow(); + return null; + } + return { window: p.window, browserFrame: p.browserFrame, reused: true }; +} +function stageReusableWindow(window, browserFrame) { + _reusePool.window = window; + _reusePool.browserFrame = browserFrame; + _reusePool.solves = 0; + _reusePool.lastUsedAt = Date.now(); +} +function discardReusableWindow() { + const p = _reusePool; + if (p.window) { + try { + destroyDom(p.window); + } catch (_) {} + } + p.window = null; + p.browserFrame = null; + p.solves = 0; +} +function noteWindowSolved() { + _reusePool.solves += 1; + _reusePool.lastUsedAt = Date.now(); +} +function guestErrorSummary(w, max = 4) { + try { + const errs = w && w.__capErrs; + if (!errs || !errs.length) + return ""; + const total = errs.reduce((a, e) => a + (e && e.n || 1), 0); + const parts = errs.slice(0, max).map((e) => { + const n = e && e.n && e.n > 1 ? `x${e.n}` : ""; + return `${e && e.k || "?"}${n}: ${String(e && e.m || "?").slice(0, 120)}`; + }); + return ` guestErrors(${total}): ${parts.join(" || ")}`; + } catch (_) { + return ""; + } +} +async function solveTraceless(opts) { + const scene = opts.scene || "11xygtvd"; + const region = opts.region || "sgp"; + const prefix = opts.prefix || "no8xfe"; + const timeoutMs = opts.timeoutMs ?? Number(process.env.CAPTCHA_SOLVE_TIMEOUT_MS || 20000); + const wantReuse = opts.reuseWindow ?? process.env.CAPTCHA_WINDOW_REUSE !== "0"; + let dom; + let reused = false; + if (wantReuse) { + dom = takeReusableWindow(); + if (dom) + reused = true; + } + if (!dom) { + dom = await createDom(region, prefix); + } + const { window: w, browserFrame } = dom; + const solveStart = Date.now(); + let solveSucceeded = false; + let keepWindow = false; + try { + await waitFor(() => typeof w.initAliyunCaptcha === "function", timeoutMs, 50); + simulateBehavior(w, 600); + const param = await new Promise((resolve, reject) => { + const timer = setTimeout(() => { + const peUrl = (() => { + try { + return w.__lastPeUrl || "?"; + } catch (_) { + return "?"; + } + })(); + const reqs = _requestLog.filter((r) => r.at >= solveStart).map((r) => `${r.at - solveStart}ms ${r.method} ${String(r.url).replace(/^https?:\/\//, "").slice(0, 60)}`).slice(-12); + reject(new Error(`captcha solve timeout pe=${peUrl.split("/").pop() || peUrl} reqs=${JSON.stringify(reqs)}`)); + }, timeoutMs); + const stallMs = opts.stallMs ?? Number(process.env.CAPTCHA_STALL_MS || 6000); + const stallTimer = setInterval(() => { + const last = _requestLog[_requestLog.length - 1]; + if (last && Date.now() - last.at > stallMs) { + const peUrl = (() => { + try { + return w.__lastPeUrl || "?"; + } catch (_) { + return "?"; + } + })(); + noteStallAndMaybeEvict(peUrl); + const reqs = _requestLog.filter((r) => r.at >= solveStart).map((r) => `${r.at - solveStart}ms ${r.method} ${String(r.url).replace(/^https?:\/\//, "").slice(0, 60)}`).slice(-12); + clearTimeout(timer); + clearInterval(stallTimer); + reject(new Error(`captcha solve stall pe=${peUrl.split("/").pop() || peUrl} lastXhr=${last.at - solveStart}ms reqs=${JSON.stringify(reqs)}`)); + } + }, 500); + const finish = (fn) => (value) => { + clearTimeout(timer); + clearInterval(stallTimer); + fn(value); + }; + try { + w.initAliyunCaptcha({ + SceneId: scene, + mode: "popup", + region, + prefix, + language: "en", + element: "#cap", + button: "#btn", + captchaLogoImg: "", + showErrorTip: false, + getInstance: (inst) => { + try { + (inst.startTracelessVerification || inst.show).call(inst); + } catch (e) { + finish(reject)(new Error(`start: ${e.message}`)); + } + }, + success: (result) => { + try { + finish(resolve)(handleCaptchaResult(result)); + } catch (err) { + finish(reject)(err); + } + }, + fail: (err) => finish(reject)(new Error(`fail: ${JSON.stringify(err)}`)), + onError: (err) => finish(reject)(new Error(`onError: ${JSON.stringify(err)}`)) + }); + } catch (err) { + clearTimeout(timer); + reject(err); + } + }); + try { + const okPe = w.__lastPeUrl; + if (okPe) + _stallCounts.delete(okPe); + w.__capErrs = []; + } catch (_) {} + if (process.env.CAPTCHA_DUMP_DBT === "1") { + try { + const dbt = w.__DBT || []; + fs.writeFileSync(process.env.CAPTCHA_DBT_FILE || "/tmp/pe-dbt.json", JSON.stringify({ count: dbt.length, last: dbt.slice(-8), all: dbt }, null, 1)); + } catch (_) {} + } + solveSucceeded = true; + const out = extractVerifyParam(param); + if (wantReuse) { + if (reused) + noteWindowSolved(); + else + stageReusableWindow(w, browserFrame); + keepWindow = true; + } + return out; + } catch (err) { + const summary = guestErrorSummary(w); + if (summary) { + try { + err.message = `${err && err.message ? err.message : String(err)} |${summary}`; + } catch (_) {} + } + throw err; + } finally { + if (!keepWindow) { + if (_reusePool.window === w) + _reusePool.window = null; + destroyDom(w); + } + } +} + +// src/proxy/captcha-worker-entry.ts +var port = parentPort; +if (!port) + throw new Error("captcha worker entry requires a worker_threads parent"); +port.on("message", (m) => { + (async () => { + try { + const param = await solveTraceless({ scene: m.scene, region: m.region, prefix: m.prefix }); + port.postMessage({ id: m.id, ok: true, param }); + } catch (err) { + port.postMessage({ id: m.id, ok: false, error: String(err?.message ?? err) }); + } + })(); +}); diff --git a/src/proxy/captcha-worker-entry.ts b/src/proxy/captcha-worker-entry.ts new file mode 100644 index 0000000..e6a8189 --- /dev/null +++ b/src/proxy/captcha-worker-entry.ts @@ -0,0 +1,32 @@ +/** + * Captcha solver worker entry -- fork patch. + * + * Runs the happy-dom solver (captcha-happy.ts) inside a worker thread so the + * proxy's main event loop NEVER blocks on Atomics.wait sync XHRs. One solve + * per worker at a time: the module's global browser-frame/cookie state is + * per-worker, which also removes the cross-solve global races of in-process + * parallel solving. + * + * Protocol: {id, scene, region, prefix} in -> {id, ok, param|error} out. + * Spawned by captcha-solver.ts via a build-time FILE ASSET import + * (`with { type: "file" }`) -- the only worker mechanism that survives + * `bun build --compile` single-file binaries (verified on Bun 1.4). + */ +import { parentPort } from "node:worker_threads"; +import { solveTraceless } from "./captcha-happy.js"; + +type SolveMsg = { id: number; scene: string; region: string; prefix: string }; + +const port = parentPort; +if (!port) throw new Error("captcha worker entry requires a worker_threads parent"); + +port.on("message", (m: SolveMsg) => { + void (async () => { + try { + const param = await solveTraceless({ scene: m.scene, region: m.region, prefix: m.prefix }); + port.postMessage({ id: m.id, ok: true, param }); + } catch (err) { + port.postMessage({ id: m.id, ok: false, error: String((err as Error)?.message ?? err) }); + } + })(); +}); diff --git a/src/proxy/captcha.ts b/src/proxy/captcha.ts index 16cdb58..a4dcf81 100644 --- a/src/proxy/captcha.ts +++ b/src/proxy/captcha.ts @@ -1,4 +1,4 @@ -/** +/** * Aliyun Captcha V3 front-end -- config fetch + pre-solved token pool. * * Solving itself lives in captcha-happy.ts (in-process happy-dom solver, From a1c201bd3632806e4185498790e1206a7c5e7d4d Mon Sep 17 00:00:00 2001 From: Jasmine-Lee-2026 Date: Sat, 26 Sep 2026 23:27:13 +0800 Subject: [PATCH 4/5] docs: document no-telemetry privacy posture State explicitly that this fork adds no telemetry, analytics, or outbound reporting of any kind, and that debug/dump logs auto-redact secrets (inherited from upstream). --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2123733..0240d5c 100644 --- a/README.md +++ b/README.md @@ -240,6 +240,13 @@ bun run dev # 开发模式启动面板 架构与实现细节见 [`src/`](src/) 下各源码文件内的注释。 +## Privacy + +This fork adds **no telemetry, no analytics, and no outbound reporting** of +any kind. Nothing about your usage, device, or configuration leaves your +machine. (Inherited from upstream: the proxy is fully local; debug/dump logs +auto-redact API keys, JWTs, and proxy keys.) + ## License MIT From bd07d6e731b7ff4d9dbe1dc4908429a56c5023c3 Mon Sep 17 00:00:00 2001 From: Jasmine-Lee-2026 Date: Sun, 27 Sep 2026 00:37:23 +0800 Subject: [PATCH 5/5] build(captcha): generate worker bundle via prebuild, untrack artifact The bundled worker (captcha-worker-entry.bundle.js, ~1.7MB / ~50k lines minified-free) was committed as a build artifact. Upstream convention keeps generated bundles out of git (.gitignore: Android server.cjs -- 'CI/local builds regenerate it'), and PR CI only runs tsc + tests, so the committed artifact added 50k lines of review noise without helping any automated check. - .gitignore: ignore src/proxy/captcha-worker-entry.bundle.js - package.json: prebuild hook runs scripts/build-fork-worker.ts before every bun run build, so the artifact always exists at compile time - captcha-solver.ts: comment points contributors to the regen path Verified: fresh checkout without the bundle -> prebuild regenerates it (1,683,850 bytes) -> tsc clean, full suite 885 pass / 0 fail. --- .gitignore | 4 + package.json | 1 + src/proxy/captcha-solver.ts | 8 +- src/proxy/captcha-worker-entry.bundle.js | 49846 --------------------- 4 files changed, 10 insertions(+), 49849 deletions(-) delete mode 100644 src/proxy/captcha-worker-entry.bundle.js diff --git a/.gitignore b/.gitignore index 6c6bd27..707a362 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ Android-APP/gradlew.bat # "bun run build:android-bundle" + copy; see Android-APP/AGENTS.md BUILD section. Android-APP/app/src/main/assets/server_bundle/server.cjs /Android-APP/design/previews + +# Fork: captcha worker bundle is a build artifact -- regenerated by +# scripts/build-fork-worker.ts (prebuild hook), never committed. +src/proxy/captcha-worker-entry.bundle.js diff --git a/package.json b/package.json index ead62ba..166bb6b 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dev": "bun run src/index.ts", "start": "bun run src/index.ts", "test": "bun test", + "prebuild": "bun run scripts/build-fork-worker.ts", "build": "bun build --compile --define \"require.resolve=undefined\" src/index.ts --outfile zcode-proxy.exe", "build:linux-x64": "bun build --compile --target bun-linux-x64 --define \"require.resolve=undefined\" src/index.ts --outfile zcode-proxy-linux-x64", "build:linux-arm64": "bun build --compile --target bun-linux-arm64 --define \"require.resolve=undefined\" src/index.ts --outfile zcode-proxy-linux-arm64", diff --git a/src/proxy/captcha-solver.ts b/src/proxy/captcha-solver.ts index 97687a5..cd006d0 100644 --- a/src/proxy/captcha-solver.ts +++ b/src/proxy/captcha-solver.ts @@ -22,9 +22,11 @@ import { Worker } from "node:worker_threads"; // Asset import: embeds the PRE-BUNDLED worker (plain JS, self-contained ESM -- // built by scripts/build-fork-worker.ts before compilation; raw .ts assets -// are not parsed by the compiled runtime). @ts-expect-error -- Bun's -// `with { type: "file" }` asset import has no DOM-lib type declaration; the -// default export is the extracted file path at runtime. +// are not parsed by the compiled runtime). If the bundle is missing, run +// scripts/build-fork-worker.ts to regenerate it (package.json wires it as +// the prebuild hook). @ts-expect-error -- Bun's `with { type: "file" }` +// asset import has no DOM-lib type declaration; the default export is the +// extracted file path at runtime. // @ts-expect-error asset import import captchaWorkerEntryPath from "./captcha-worker-entry.bundle.js" with { type: "file" }; diff --git a/src/proxy/captcha-worker-entry.bundle.js b/src/proxy/captcha-worker-entry.bundle.js deleted file mode 100644 index a145ebf..0000000 --- a/src/proxy/captcha-worker-entry.bundle.js +++ /dev/null @@ -1,49846 +0,0 @@ -// @bun -var __create = Object.create; -var __getProtoOf = Object.getPrototypeOf; -var __defProp = Object.defineProperty; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __hasOwnProp = Object.prototype.hasOwnProperty; -function __accessProp(key) { - return this[key]; -} -var __toESMCache_node; -var __toESMCache_esm; -var __toESM = (mod, isNodeMode, target) => { - var canCache = mod != null && typeof mod === "object"; - if (canCache) { - var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap; - var cached = cache.get(mod); - if (cached) - return cached; - } - target = mod != null ? __create(__getProtoOf(mod)) : {}; - const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target; - if (mod && typeof mod === "object" || typeof mod === "function") { - for (let key of __getOwnPropNames(mod)) - if (!__hasOwnProp.call(to, key)) - __defProp(to, key, { - get: __accessProp.bind(mod, key), - enumerable: true - }); - } - if (canCache) - cache.set(mod, to); - return to; -}; -var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); -var __returnValue = (v) => v; -function __exportSetter(name, newValue) { - this[name] = __returnValue.bind(null, newValue); -} -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { - get: all[name], - enumerable: true, - configurable: true, - set: __exportSetter.bind(all, name) - }); -}; - -// node_modules/buffer-image-size/lib/types/bmp.js -var require_bmp = __commonJS(function(exports, module) { - function isBMP(buffer) { - return buffer.toString("ascii", 0, 2) === "BM"; - } - function calculate(buffer) { - return { - width: buffer.readUInt32LE(18), - height: Math.abs(buffer.readInt32LE(22)) - }; - } - module.exports = { - detect: isBMP, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/ico.js -var require_ico = __commonJS(function(exports, module) { - var TYPE_ICON = 1; - var SIZE_HEADER = 2 + 2 + 2; - var SIZE_IMAGE_ENTRY = 1 + 1 + 1 + 1 + 2 + 2 + 4 + 4; - function isICO(buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_ICON; - } - function getSizeFromOffset(buffer, offset) { - var value = buffer.readUInt8(offset); - return value === 0 ? 256 : value; - } - function getImageSize(buffer, imageIndex) { - var offset = SIZE_HEADER + imageIndex * SIZE_IMAGE_ENTRY; - return { - width: getSizeFromOffset(buffer, offset), - height: getSizeFromOffset(buffer, offset + 1) - }; - } - function calculate(buffer) { - var nbImages = buffer.readUInt16LE(4), result = getImageSize(buffer, 0), imageIndex; - if (nbImages === 1) { - return result; - } - result.images = [{ - width: result.width, - height: result.height - }]; - for (imageIndex = 1;imageIndex < nbImages; imageIndex += 1) { - result.images.push(getImageSize(buffer, imageIndex)); - } - return result; - } - module.exports = { - detect: isICO, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/cur.js -var require_cur = __commonJS(function(exports, module) { - var TYPE_CURSOR = 2; - function isCUR(buffer) { - var type; - if (buffer.readUInt16LE(0) !== 0) { - return false; - } - type = buffer.readUInt16LE(2); - return type === TYPE_CURSOR; - } - module.exports = { - detect: isCUR, - calculate: require_ico().calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/dds.js -var require_dds = __commonJS(function(exports, module) { - function isDDS(buffer) { - return buffer.readUInt32LE(0) === 542327876; - } - function calculate(buffer) { - return { - height: buffer.readUInt32LE(12), - width: buffer.readUInt32LE(16) - }; - } - module.exports = { - detect: isDDS, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/gif.js -var require_gif = __commonJS(function(exports, module) { - var gifRegexp = /^GIF8[79]a/; - function isGIF(buffer) { - var signature = buffer.toString("ascii", 0, 6); - return gifRegexp.test(signature); - } - function calculate(buffer) { - return { - width: buffer.readUInt16LE(6), - height: buffer.readUInt16LE(8) - }; - } - module.exports = { - detect: isGIF, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/jpg.js -var require_jpg = __commonJS(function(exports, module) { - function isJPG(buffer) { - var SOIMarker = buffer.toString("hex", 0, 2); - return SOIMarker === "ffd8"; - } - function extractSize(buffer, i) { - return { - height: buffer.readUInt16BE(i), - width: buffer.readUInt16BE(i + 2) - }; - } - function validateBuffer(buffer, i) { - if (i > buffer.length) { - throw new TypeError("Corrupt JPG, exceeded buffer limits"); - } - if (buffer[i] !== 255) { - throw new TypeError("Invalid JPG, marker table corrupted"); - } - } - function calculate(buffer) { - buffer = buffer.slice(4); - var i, next; - while (buffer.length) { - i = buffer.readUInt16BE(0); - validateBuffer(buffer, i); - next = buffer[i + 1]; - if (next === 192 || next === 193 || next === 194) { - return extractSize(buffer, i + 5); - } - buffer = buffer.slice(i + 2); - } - throw new TypeError("Invalid JPG, no size found"); - } - module.exports = { - detect: isJPG, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/png.js -var require_png = __commonJS(function(exports, module) { - var pngSignature = `PNG\r -\x1A -`; - var pngImageHeaderChunkName = "IHDR"; - var pngFriedChunkName = "CgBI"; - function isPNG(buffer) { - if (pngSignature === buffer.toString("ascii", 1, 8)) { - var chunkName = buffer.toString("ascii", 12, 16); - if (chunkName === pngFriedChunkName) { - chunkName = buffer.toString("ascii", 28, 32); - } - if (chunkName !== pngImageHeaderChunkName) { - throw new TypeError("invalid png"); - } - return true; - } - } - function calculate(buffer) { - if (buffer.toString("ascii", 12, 16) === pngFriedChunkName) { - return { - width: buffer.readUInt32BE(32), - height: buffer.readUInt32BE(36) - }; - } - return { - width: buffer.readUInt32BE(16), - height: buffer.readUInt32BE(20) - }; - } - module.exports = { - detect: isPNG, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/psd.js -var require_psd = __commonJS(function(exports, module) { - function isPSD(buffer) { - return buffer.toString("ascii", 0, 4) === "8BPS"; - } - function calculate(buffer) { - return { - width: buffer.readUInt32BE(18), - height: buffer.readUInt32BE(14) - }; - } - module.exports = { - detect: isPSD, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/svg.js -var require_svg = __commonJS(function(exports, module) { - var svgReg = /]+[^>]*>/; - function isSVG(buffer) { - return svgReg.test(buffer); - } - var extractorRegExps = { - root: /]+>/, - width: /\bwidth=(['"])([^%]+?)\1/, - height: /\bheight=(['"])([^%]+?)\1/, - viewbox: /\bviewBox=(['"])(.+?)\1/ - }; - function parseViewbox(viewbox) { - var bounds = viewbox.split(" "); - return { - width: parseInt(bounds[2], 10), - height: parseInt(bounds[3], 10) - }; - } - function parseAttributes(root) { - var width = root.match(extractorRegExps.width); - var height = root.match(extractorRegExps.height); - var viewbox = root.match(extractorRegExps.viewbox); - return { - width: width && parseInt(width[2], 10), - height: height && parseInt(height[2], 10), - viewbox: viewbox && parseViewbox(viewbox[2]) - }; - } - function calculateByDimensions(attrs) { - return { - width: attrs.width, - height: attrs.height - }; - } - function calculateByViewbox(attrs) { - var ratio = attrs.viewbox.width / attrs.viewbox.height; - if (attrs.width) { - return { - width: attrs.width, - height: Math.floor(attrs.width / ratio) - }; - } - if (attrs.height) { - return { - width: Math.floor(attrs.height * ratio), - height: attrs.height - }; - } - return { - width: attrs.viewbox.width, - height: attrs.viewbox.height - }; - } - function calculate(buffer) { - var root = buffer.toString("utf8").match(extractorRegExps.root); - if (root) { - var attrs = parseAttributes(root[0]); - if (attrs.width && attrs.height) { - return calculateByDimensions(attrs); - } - if (attrs.viewbox) { - return calculateByViewbox(attrs); - } - } - throw new TypeError("invalid svg"); - } - module.exports = { - detect: isSVG, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types/webp.js -var require_webp = __commonJS(function(exports, module) { - function isWebP(buffer) { - var riffHeader = buffer.toString("ascii", 0, 4) === "RIFF"; - var webpHeader = buffer.toString("ascii", 8, 12) === "WEBP"; - var vp8Header = buffer.toString("ascii", 12, 15) === "VP8"; - return riffHeader && webpHeader && vp8Header; - } - function calculate(buffer) { - var chunkHeader = buffer.toString("ascii", 12, 16); - buffer = buffer.slice(20, 30); - if (chunkHeader === "VP8X") { - var extendedHeader = buffer[0]; - var validStart = (extendedHeader & 192) === 0; - var validEnd = (extendedHeader & 1) === 0; - if (validStart && validEnd) { - return calculateExtended(buffer); - } else { - return false; - } - } - if (chunkHeader === "VP8 " && buffer[0] !== 47) { - return calculateLossy(buffer); - } - var signature = buffer.toString("hex", 3, 6); - if (chunkHeader === "VP8L" && signature !== "9d012a") { - return calculateLossless(buffer); - } - return false; - } - function calculateExtended(buffer) { - return { - width: 1 + buffer.readUIntLE(4, 3), - height: 1 + buffer.readUIntLE(7, 3) - }; - } - function calculateLossless(buffer) { - return { - width: 1 + ((buffer[2] & 63) << 8 | buffer[1]), - height: 1 + ((buffer[4] & 15) << 10 | buffer[3] << 2 | (buffer[2] & 192) >> 6) - }; - } - function calculateLossy(buffer) { - return { - width: buffer.readInt16LE(6) & 16383, - height: buffer.readInt16LE(8) & 16383 - }; - } - module.exports = { - detect: isWebP, - calculate - }; -}); - -// node_modules/buffer-image-size/lib/types.js -var require_types = __commonJS(function(exports, module) { - var typeHandlers = { - bmp: require_bmp(), - cur: require_cur(), - dds: require_dds(), - gif: require_gif(), - ico: require_ico(), - jpg: require_jpg(), - png: require_png(), - psd: require_psd(), - svg: require_svg(), - webp: require_webp() - }; - module.exports = typeHandlers; -}); - -// node_modules/buffer-image-size/lib/detector.js -var require_detector = __commonJS(function(exports, module) { - var typeHandlers = require_types(); - module.exports = function(buffer) { - var type, result; - for (type in typeHandlers) { - result = typeHandlers[type].detect(buffer); - if (result) { - return type; - } - } - }; -}); - -// node_modules/buffer-image-size/lib/index.js -var require_lib = __commonJS(function(exports, module) { - var typeHandlers = require_types(); - var detector = require_detector(); - function lookup(buffer) { - var type = detector(buffer); - if (type in typeHandlers) { - var size = typeHandlers[type].calculate(buffer); - if (size !== false) { - size.type = type; - return size; - } - } - throw new TypeError("unsupported file type: " + type); - } - module.exports = function(input) { - if (Buffer.isBuffer(input)) { - return lookup(input); - } - throw new TypeError("expecting only a buffer as input"); - }; - module.exports.types = Object.keys(typeHandlers); -}); - -// node_modules/whatwg-mimetype/lib/utils.js -var require_utils = __commonJS(function(exports) { - exports.removeLeadingAndTrailingHTTPWhitespace = (string) => { - return string.replace(/^[ \t\n\r]+/u, "").replace(/[ \t\n\r]+$/u, ""); - }; - exports.removeTrailingHTTPWhitespace = (string) => { - return string.replace(/[ \t\n\r]+$/u, ""); - }; - exports.isHTTPWhitespaceChar = (char) => { - return char === " " || char === "\t" || char === ` -` || char === "\r"; - }; - exports.solelyContainsHTTPTokenCodePoints = (string) => { - return /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(string); - }; - exports.soleyContainsHTTPQuotedStringTokenCodePoints = (string) => { - return /^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(string); - }; - exports.asciiLowercase = (string) => { - return string.replace(/[A-Z]/ug, (l) => l.toLowerCase()); - }; - exports.collectAnHTTPQuotedString = (input, position) => { - let value = ""; - position++; - while (true) { - while (position < input.length && input[position] !== '"' && input[position] !== "\\") { - value += input[position]; - ++position; - } - if (position >= input.length) { - break; - } - const quoteOrBackslash = input[position]; - ++position; - if (quoteOrBackslash === "\\") { - if (position >= input.length) { - value += "\\"; - break; - } - value += input[position]; - ++position; - } else { - break; - } - } - return [value, position]; - }; -}); - -// node_modules/whatwg-mimetype/lib/mime-type-parameters.js -var require_mime_type_parameters = __commonJS(function(exports, module) { - var { - asciiLowercase, - solelyContainsHTTPTokenCodePoints, - soleyContainsHTTPQuotedStringTokenCodePoints - } = require_utils(); - module.exports = class MIMETypeParameters { - constructor(map) { - this._map = map; - } - get size() { - return this._map.size; - } - get(name) { - name = asciiLowercase(String(name)); - return this._map.get(name); - } - has(name) { - name = asciiLowercase(String(name)); - return this._map.has(name); - } - set(name, value) { - name = asciiLowercase(String(name)); - value = String(value); - if (!solelyContainsHTTPTokenCodePoints(name)) { - throw new Error(`Invalid MIME type parameter name "${name}": only HTTP token code points are valid.`); - } - if (!soleyContainsHTTPQuotedStringTokenCodePoints(value)) { - throw new Error(`Invalid MIME type parameter value "${value}": only HTTP quoted-string token code points are ` + `valid.`); - } - return this._map.set(name, value); - } - clear() { - this._map.clear(); - } - delete(name) { - name = asciiLowercase(String(name)); - return this._map.delete(name); - } - forEach(callbackFn, thisArg) { - this._map.forEach(callbackFn, thisArg); - } - keys() { - return this._map.keys(); - } - values() { - return this._map.values(); - } - entries() { - return this._map.entries(); - } - [Symbol.iterator]() { - return this._map[Symbol.iterator](); - } - }; -}); - -// node_modules/whatwg-mimetype/lib/parser.js -var require_parser = __commonJS(function(exports, module) { - var { - removeLeadingAndTrailingHTTPWhitespace, - removeTrailingHTTPWhitespace, - isHTTPWhitespaceChar, - solelyContainsHTTPTokenCodePoints, - soleyContainsHTTPQuotedStringTokenCodePoints, - asciiLowercase, - collectAnHTTPQuotedString - } = require_utils(); - module.exports = (input) => { - input = removeLeadingAndTrailingHTTPWhitespace(input); - let position = 0; - let type = ""; - while (position < input.length && input[position] !== "/") { - type += input[position]; - ++position; - } - if (type.length === 0 || !solelyContainsHTTPTokenCodePoints(type)) { - return null; - } - if (position >= input.length) { - return null; - } - ++position; - let subtype = ""; - while (position < input.length && input[position] !== ";") { - subtype += input[position]; - ++position; - } - subtype = removeTrailingHTTPWhitespace(subtype); - if (subtype.length === 0 || !solelyContainsHTTPTokenCodePoints(subtype)) { - return null; - } - const mimeType = { - type: asciiLowercase(type), - subtype: asciiLowercase(subtype), - parameters: new Map - }; - while (position < input.length) { - ++position; - while (isHTTPWhitespaceChar(input[position])) { - ++position; - } - let parameterName = ""; - while (position < input.length && input[position] !== ";" && input[position] !== "=") { - parameterName += input[position]; - ++position; - } - parameterName = asciiLowercase(parameterName); - if (position < input.length) { - if (input[position] === ";") { - continue; - } - ++position; - } - let parameterValue = null; - if (input[position] === '"') { - [parameterValue, position] = collectAnHTTPQuotedString(input, position); - while (position < input.length && input[position] !== ";") { - ++position; - } - } else { - parameterValue = ""; - while (position < input.length && input[position] !== ";") { - parameterValue += input[position]; - ++position; - } - parameterValue = removeTrailingHTTPWhitespace(parameterValue); - if (parameterValue === "") { - continue; - } - } - if (parameterName.length > 0 && solelyContainsHTTPTokenCodePoints(parameterName) && soleyContainsHTTPQuotedStringTokenCodePoints(parameterValue) && !mimeType.parameters.has(parameterName)) { - mimeType.parameters.set(parameterName, parameterValue); - } - } - return mimeType; - }; -}); - -// node_modules/whatwg-mimetype/lib/serializer.js -var require_serializer = __commonJS(function(exports, module) { - var { solelyContainsHTTPTokenCodePoints } = require_utils(); - module.exports = (mimeType) => { - let serialization = `${mimeType.type}/${mimeType.subtype}`; - if (mimeType.parameters.size === 0) { - return serialization; - } - for (let [name, value] of mimeType.parameters) { - serialization += ";"; - serialization += name; - serialization += "="; - if (!solelyContainsHTTPTokenCodePoints(value) || value.length === 0) { - value = value.replace(/(["\\])/ug, "\\$1"); - value = `"${value}"`; - } - serialization += value; - } - return serialization; - }; -}); - -// node_modules/whatwg-mimetype/lib/mime-type.js -var require_mime_type = __commonJS(function(exports, module) { - var MIMETypeParameters = require_mime_type_parameters(); - var parse = require_parser(); - var serialize = require_serializer(); - var { - asciiLowercase, - solelyContainsHTTPTokenCodePoints - } = require_utils(); - module.exports = class MIMEType { - constructor(string) { - string = String(string); - const result = parse(string); - if (result === null) { - throw new Error(`Could not parse MIME type string "${string}"`); - } - this._type = result.type; - this._subtype = result.subtype; - this._parameters = new MIMETypeParameters(result.parameters); - } - static parse(string) { - try { - return new this(string); - } catch (e) { - return null; - } - } - get essence() { - return `${this.type}/${this.subtype}`; - } - get type() { - return this._type; - } - set type(value) { - value = asciiLowercase(String(value)); - if (value.length === 0) { - throw new Error("Invalid type: must be a non-empty string"); - } - if (!solelyContainsHTTPTokenCodePoints(value)) { - throw new Error(`Invalid type ${value}: must contain only HTTP token code points`); - } - this._type = value; - } - get subtype() { - return this._subtype; - } - set subtype(value) { - value = asciiLowercase(String(value)); - if (value.length === 0) { - throw new Error("Invalid subtype: must be a non-empty string"); - } - if (!solelyContainsHTTPTokenCodePoints(value)) { - throw new Error(`Invalid subtype ${value}: must contain only HTTP token code points`); - } - this._subtype = value; - } - get parameters() { - return this._parameters; - } - toString() { - return serialize(this); - } - isJavaScript({ prohibitParameters = false } = {}) { - switch (this._type) { - case "text": { - switch (this._subtype) { - case "ecmascript": - case "javascript": - case "javascript1.0": - case "javascript1.1": - case "javascript1.2": - case "javascript1.3": - case "javascript1.4": - case "javascript1.5": - case "jscript": - case "livescript": - case "x-ecmascript": - case "x-javascript": { - return !prohibitParameters || this._parameters.size === 0; - } - default: { - return false; - } - } - } - case "application": { - switch (this._subtype) { - case "ecmascript": - case "javascript": - case "x-ecmascript": - case "x-javascript": { - return !prohibitParameters || this._parameters.size === 0; - } - default: { - return false; - } - } - } - default: { - return false; - } - } - } - isXML() { - return this._subtype === "xml" && (this._type === "text" || this._type === "application") || this._subtype.endsWith("+xml"); - } - isHTML() { - return this._subtype === "html" && this._type === "text"; - } - }; -}); - -// src/proxy/captcha-worker-entry.ts -import { parentPort } from "worker_threads"; - -// node_modules/happy-dom/lib/PropertySymbol.js -var exports_PropertySymbol = {}; -__export(exports_PropertySymbol, { - abort: () => abort, - aborted: () => aborted, - accessKey: () => accessKey, - accessKeyLabel: () => accessKeyLabel, - activeCues: () => activeCues, - activeElement: () => activeElement, - adoptedStyleSheets: () => adoptedStyleSheets, - affectsCache: () => affectsCache, - affectsComputedStyleCache: () => affectsComputedStyleCache, - amplitude: () => amplitude, - angle: () => angle, - animVal: () => animVal, - animatedPoints: () => animatedPoints, - appendChild: () => appendChild, - areas: () => areas, - assignedNodes: () => assignedNodes, - assignedToSlot: () => assignedToSlot, - asyncTaskManager: () => asyncTaskManager, - attributeName: () => attributeName, - attributeValue: () => attributeValue, - attributes: () => attributes, - attributesProxy: () => attributesProxy, - azimuth: () => azimuth, - baseFrequencyX: () => baseFrequencyX, - baseFrequencyY: () => baseFrequencyY, - baseVal: () => baseVal, - bias: () => bias, - bindMethods: () => bindMethods, - blocking: () => blocking, - body: () => body, - bodyBuffer: () => bodyBuffer, - bodyUsed: () => bodyUsed, - browserFrames: () => browserFrames, - bubbles: () => bubbles, - buffer: () => buffer, - buffered: () => buffered, - cache: () => cache, - cachedResponse: () => cachedResponse, - callbacks: () => callbacks, - cancelable: () => cancelable, - canvas: () => canvas, - capabilities: () => capabilities, - cells: () => cells, - checked: () => checked, - childNodes: () => childNodes, - children: () => children, - classList: () => classList, - classRegistry: () => classRegistry, - clearCache: () => clearCache, - clientHeight: () => clientHeight, - clientLeft: () => clientLeft, - clientTop: () => clientTop, - clientWidth: () => clientWidth, - clipPathUnits: () => clipPathUnits, - clonable: () => clonable, - clone: () => clone, - cloneNode: () => cloneNode, - complete: () => complete, - composed: () => composed, - computedStyle: () => computedStyle, - conditionText: () => conditionText, - connectedToDocument: () => connectedToDocument, - connectedToNode: () => connectedToNode, - constraints: () => constraints, - content: () => content, - contentLength: () => contentLength, - contentType: () => contentType, - context: () => context, - controlsList: () => controlsList, - cookieStore: () => cookieStore, - credentials: () => credentials, - crossOrigin: () => crossOrigin, - cssParser: () => cssParser, - cssRule: () => cssRule, - cssRules: () => cssRules, - cssText: () => cssText, - cues: () => cues, - currentNode: () => currentNode, - currentScale: () => currentScale, - currentScript: () => currentScript, - currentTarget: () => currentTarget, - currentTime: () => currentTime, - customElementReactionStack: () => customElementReactionStack, - cx: () => cx, - cy: () => cy, - data: () => data, - dataset: () => dataset, - defaultChecked: () => defaultChecked, - defaultMuted: () => defaultMuted, - defaultPlaybackRate: () => defaultPlaybackRate, - defaultPrevented: () => defaultPrevented, - defaultValue: () => defaultValue, - defaultView: () => defaultView, - delegatesFocus: () => delegatesFocus, - destroy: () => destroy, - destroyed: () => destroyed, - detail: () => detail, - diffuseConstant: () => diffuseConstant, - dirtyness: () => dirtyness, - disableEvaluation: () => disableEvaluation, - disabled: () => disabled, - disconnectedFromDocument: () => disconnectedFromDocument, - disconnectedFromNode: () => disconnectedFromNode, - dispatchError: () => dispatchError, - dispatching: () => dispatching, - divisor: () => divisor, - domMatrix: () => domMatrix, - duration: () => duration, - dx: () => dx, - dy: () => dy, - edgeMode: () => edgeMode, - elementArray: () => elementArray, - elementIdMap: () => elementIdMap, - elements: () => elements, - elevation: () => elevation, - end: () => end, - ended: () => ended, - entries: () => entries, - error: () => error, - evaluateCSS: () => evaluateCSS, - evaluateScript: () => evaluateScript, - eventPhase: () => eventPhase, - exceptionObserver: () => exceptionObserver, - exponent: () => exponent, - files: () => files, - filterNode: () => filterNode, - filterUnits: () => filterUnits, - flipXSelf: () => flipXSelf, - flipYSelf: () => flipYSelf, - formNode: () => formNode, - forms: () => forms, - frames: () => frames, - fromArray: () => fromArray, - fromString: () => fromString, - fx: () => fx, - fy: () => fy, - getAttribute: () => getAttribute, - getDOMMatrix: () => getDOMMatrix, - getFormControlItems: () => getFormControlItems, - getFormControlNamedItem: () => getFormControlNamedItem, - getItemList: () => getItemList, - getLength: () => getLength, - getNamedItemKey: () => getNamedItemKey, - getNamespaceItemKey: () => getNamespaceItemKey, - getTokenList: () => getTokenList, - globalObject: () => globalObject, - gradientTransform: () => gradientTransform, - gradientUnits: () => gradientUnits, - headers: () => headers, - height: () => height, - history: () => history, - host: () => host, - href: () => href, - id: () => id, - illegalConstructor: () => illegalConstructor, - immediatePropagationStopped: () => immediatePropagationStopped, - implementation: () => implementation, - in1: () => in1, - in2: () => in2, - indeterminate: () => indeterminate, - insertBefore: () => insertBefore, - intercept: () => intercept, - internalId: () => internalId, - invertSelf: () => invertSelf, - isConnected: () => isConnected, - isFirstWrite: () => isFirstWrite, - isFirstWriteAfterOpen: () => isFirstWriteAfterOpen, - isInPassiveEventListener: () => isInPassiveEventListener, - isValue: () => isValue, - items: () => items, - itemsByName: () => itemsByName, - itemsByNamespaceURI: () => itemsByNamespaceURI, - kernelMatrix: () => kernelMatrix, - kernelUnitLengthX: () => kernelUnitLengthX, - kernelUnitLengthY: () => kernelUnitLengthY, - keyText: () => keyText, - kind: () => kind, - label: () => label, - language: () => language, - length: () => length, - lengthAdjust: () => lengthAdjust, - limitingConeAngle: () => limitingConeAngle, - links: () => links, - listenerOptions: () => listenerOptions, - listeners: () => listeners, - loading: () => loading, - localName: () => localName, - localStorage: () => localStorage, - location: () => location, - m11: () => m11, - m12: () => m12, - m13: () => m13, - m14: () => m14, - m21: () => m21, - m22: () => m22, - m23: () => m23, - m24: () => m24, - m31: () => m31, - m32: () => m32, - m33: () => m33, - m34: () => m34, - m41: () => m41, - m42: () => m42, - m43: () => m43, - m44: () => m44, - markerHeight: () => markerHeight, - markerUnits: () => markerUnits, - markerWidth: () => markerWidth, - maskContentUnits: () => maskContentUnits, - maskUnits: () => maskUnits, - matrix: () => matrix, - media: () => media, - mediaKeys: () => mediaKeys, - method: () => method, - mode: () => mode, - moduleCache: () => moduleCache, - moduleImportMap: () => moduleImportMap, - modules: () => modules, - multiplySelf: () => multiplySelf, - mutationListeners: () => mutationListeners, - mutationObservers: () => mutationObservers, - muted: () => muted, - name: () => name, - namespaceURI: () => namespaceURI, - naturalHeight: () => naturalHeight, - naturalWidth: () => naturalWidth, - navigator: () => navigator, - networkState: () => networkState, - nextActiveElement: () => nextActiveElement, - nodeArray: () => nodeArray, - nodeStream: () => nodeStream, - nodeType: () => nodeType, - numOctaves: () => numOctaves, - observeMutations: () => observeMutations, - offset: () => offset, - offsetHeight: () => offsetHeight, - offsetLeft: () => offsetLeft, - offsetTop: () => offsetTop, - offsetWidth: () => offsetWidth, - onRemoveAttribute: () => onRemoveAttribute, - onSetAttribute: () => onSetAttribute, - openWebSockets: () => openWebSockets, - openerFrame: () => openerFrame, - openerWindow: () => openerWindow, - operator: () => operator, - options: () => options, - orderX: () => orderX, - orderY: () => orderY, - orientAngle: () => orientAngle, - orientType: () => orientType, - ownerDocument: () => ownerDocument, - ownerElement: () => ownerElement, - parent: () => parent, - parentNode: () => parentNode, - parentRule: () => parentRule, - parentStyleSheet: () => parentStyleSheet, - pathLength: () => pathLength, - patternContentUnits: () => patternContentUnits, - patternTransform: () => patternTransform, - patternUnits: () => patternUnits, - paused: () => paused, - playbackRate: () => playbackRate, - played: () => played, - pointerCaptures: () => pointerCaptures, - points: () => points, - pointsAtX: () => pointsAtX, - pointsAtY: () => pointsAtY, - pointsAtZ: () => pointsAtZ, - popoverTargetElement: () => popoverTargetElement, - popup: () => popup, - prefix: () => prefix, - preloads: () => preloads, - preserveAlpha: () => preserveAlpha, - preserveAspectRatio: () => preserveAspectRatio, - preservesPitch: () => preservesPitch, - primitiveUnits: () => primitiveUnits, - propagationStopped: () => propagationStopped, - propertyEventListeners: () => propertyEventListeners, - proxy: () => proxy, - publicId: () => publicId, - query: () => query, - querySelectorCache: () => querySelectorCache, - r: () => r, - radiusX: () => radiusX, - radiusY: () => radiusY, - readOnly: () => readOnly, - readyState: () => readyState, - readyStateManager: () => readyStateManager, - reason: () => reason, - redirect: () => redirect, - refX: () => refX, - refY: () => refY, - referrer: () => referrer, - referrerPolicy: () => referrerPolicy, - registry: () => registry, - relList: () => relList, - remote: () => remote, - removeChild: () => removeChild, - removeNamedItem: () => removeNamedItem, - replaceChild: () => replaceChild, - reportMutation: () => reportMutation, - requiredExtensions: () => requiredExtensions, - resetSelection: () => resetSelection, - result: () => result, - returnValue: () => returnValue, - root: () => root, - rootNode: () => rootNode, - rotate: () => rotate, - rotateAxisAngleSelf: () => rotateAxisAngleSelf, - rotateFromVectorSelf: () => rotateFromVectorSelf, - rotateSelf: () => rotateSelf, - rows: () => rows, - rulePrefix: () => rulePrefix, - rx: () => rx, - ry: () => ry, - sandbox: () => sandbox, - scale: () => scale, - scale3dSelf: () => scale3dSelf, - scaleNonUniformSelf: () => scaleNonUniformSelf, - scaleSelf: () => scaleSelf, - screen: () => screen, - scrollHeight: () => scrollHeight, - scrollLeft: () => scrollLeft, - scrollTop: () => scrollTop, - scrollWidth: () => scrollWidth, - seed: () => seed, - seekable: () => seekable, - seeking: () => seeking, - selectNode: () => selectNode, - selectedIndex: () => selectedIndex, - selectedOptions: () => selectedOptions, - selectedness: () => selectedness, - selection: () => selection, - selectorText: () => selectorText, - self: () => self, - serializable: () => serializable, - sessionStorage: () => sessionStorage, - setAttribute: () => setAttribute, - setDOMMatrix: () => setDOMMatrix, - setMatrixValue: () => setMatrixValue, - setNamedItem: () => setNamedItem, - setURL: () => setURL, - settings: () => settings, - setupVMContext: () => setupVMContext, - shadowRoot: () => shadowRoot, - sheet: () => sheet, - signal: () => signal, - sinkId: () => sinkId, - skewXSelf: () => skewXSelf, - skewYSelf: () => skewYSelf, - slope: () => slope, - slotAssignment: () => slotAssignment, - spacing: () => spacing, - specified: () => specified, - specularConstant: () => specularConstant, - specularExponent: () => specularExponent, - spreadMethod: () => spreadMethod, - srcObject: () => srcObject, - start: () => start, - startOffset: () => startOffset, - state: () => state, - stdDeviationX: () => stdDeviationX, - stdDeviationY: () => stdDeviationY, - stitchTiles: () => stitchTiles, - style: () => style, - styleMap: () => styleMap, - styleNode: () => styleNode, - supports: () => supports, - surfaceScale: () => surfaceScale, - systemId: () => systemId, - systemLanguage: () => systemLanguage, - tBodies: () => tBodies, - tableValues: () => tableValues, - tagName: () => tagName, - target: () => target, - targetX: () => targetX, - targetY: () => targetY, - textAreaNode: () => textAreaNode, - textLength: () => textLength, - textTracks: () => textTracks, - timeStamp: () => timeStamp, - toArray: () => toArray, - top: () => top, - track: () => track, - tracks: () => tracks, - transform: () => transform, - translateSelf: () => translateSelf, - type: () => type, - unitType: () => unitType, - unobserveMutations: () => unobserveMutations, - updateSelectedness: () => updateSelectedness, - updateSheet: () => updateSheet, - url: () => url, - validateJavaScriptExecutionEnvironment: () => validateJavaScriptExecutionEnvironment, - validationMessage: () => validationMessage, - validity: () => validity, - value: () => value, - values: () => values, - viewBox: () => viewBox, - virtualServerFile: () => virtualServerFile, - volume: () => volume, - w: () => w, - webSocket: () => webSocket, - width: () => width, - window: () => window, - windowInternalId: () => windowInternalId, - windowResizeListener: () => windowResizeListener, - x: () => x, - x1: () => x1, - x2: () => x2, - xChannelSelector: () => xChannelSelector, - xmlProcessingInstruction: () => xmlProcessingInstruction, - y: () => y, - y1: () => y1, - y2: () => y2, - yChannelSelector: () => yChannelSelector, - z: () => z -}); -var abort = Symbol("abort"); -var activeElement = Symbol("activeElement"); -var asyncTaskManager = Symbol("asyncTaskManager"); -var bodyBuffer = Symbol("bodyBuffer"); -var buffer = Symbol("buffer"); -var cachedResponse = Symbol("cachedResponse"); -var callbacks = Symbol("callbacks"); -var checked = Symbol("checked"); -var childNodes = Symbol("childNodes"); -var children = Symbol("children"); -var classList = Symbol("classList"); -var connectedToNode = Symbol("connectedToNode"); -var disconnectedFromNode = Symbol("disconnectedFromNode"); -var connectedToDocument = Symbol("connectedToDocument"); -var disconnectedFromDocument = Symbol("disconnectedFromDocument"); -var contentLength = Symbol("contentLength"); -var contentType = Symbol("contentType"); -var cssText = Symbol("cssText"); -var currentScript = Symbol("currentScript"); -var currentTarget = Symbol("currentTarget"); -var data = Symbol("data"); -var defaultView = Symbol("defaultView"); -var destroy = Symbol("destroy"); -var dirtyness = Symbol("dirtyness"); -var end = Symbol("end"); -var entries = Symbol("entries"); -var evaluateCSS = Symbol("evaluateCSS"); -var evaluateScript = Symbol("evaluateScript"); -var exceptionObserver = Symbol("exceptionObserver"); -var formNode = Symbol("formNode"); -var internalId = Symbol("internalId"); -var height = Symbol("height"); -var immediatePropagationStopped = Symbol("immediatePropagationStopped"); -var indeterminate = Symbol("indeterminate"); -var isFirstWrite = Symbol("isFirstWrite"); -var isFirstWriteAfterOpen = Symbol("isFirstWriteAfterOpen"); -var isInPassiveEventListener = Symbol("isInPassiveEventListener"); -var isValue = Symbol("isValue"); -var listenerOptions = Symbol("listenerOptions"); -var listeners = Symbol("listeners"); -var itemsByName = Symbol("itemsByName"); -var nextActiveElement = Symbol("nextActiveElement"); -var observeMutations = Symbol("observeMutations"); -var mutationListeners = Symbol("mutationListeners"); -var ownerDocument = Symbol("ownerDocument"); -var ownerElement = Symbol("ownerElement"); -var propagationStopped = Symbol("propagationStopped"); -var readyStateManager = Symbol("readyStateManager"); -var referrer = Symbol("referrer"); -var registry = Symbol("registry"); -var relList = Symbol("relList"); -var resetSelection = Symbol("resetSelection"); -var rootNode = Symbol("rootNode"); -var selectNode = Symbol("selectNode"); -var selectedness = Symbol("selectedness"); -var selection = Symbol("selection"); -var setupVMContext = Symbol("setupVMContext"); -var shadowRoot = Symbol("shadowRoot"); -var start = Symbol("start"); -var style = Symbol("style"); -var target = Symbol("target"); -var textAreaNode = Symbol("textAreaNode"); -var unobserveMutations = Symbol("unobserveMutations"); -var reportMutation = Symbol("reportMutation"); -var updateSelectedness = Symbol("updateSelectedness"); -var url = Symbol("url"); -var value = Symbol("value"); -var width = Symbol("width"); -var window = Symbol("window"); -var windowResizeListener = Symbol("windowResizeListener"); -var mutationObservers = Symbol("mutationObservers"); -var openerFrame = Symbol("openerFrame"); -var openerWindow = Symbol("openerWindow"); -var pointerCaptures = Symbol("pointerCaptures"); -var popup = Symbol("popup"); -var isConnected = Symbol("isConnected"); -var parentNode = Symbol("parentNode"); -var nodeType = Symbol("nodeType"); -var tagName = Symbol("tagName"); -var prefix = Symbol("prefix"); -var scrollHeight = Symbol("scrollHeight"); -var scrollWidth = Symbol("scrollWidth"); -var scrollTop = Symbol("scrollTop"); -var scrollLeft = Symbol("scrollLeft"); -var attributes = Symbol("attributes"); -var attributesProxy = Symbol("attributesProxy"); -var namespaceURI = Symbol("namespaceURI"); -var accessKey = Symbol("accessKey"); -var accessKeyLabel = Symbol("accessKeyLabel"); -var offsetHeight = Symbol("offsetHeight"); -var offsetWidth = Symbol("offsetWidth"); -var offsetLeft = Symbol("offsetLeft"); -var offsetTop = Symbol("offsetTop"); -var clientHeight = Symbol("clientHeight"); -var clientWidth = Symbol("clientWidth"); -var clientLeft = Symbol("clientLeft"); -var clientTop = Symbol("clientTop"); -var name = Symbol("name"); -var specified = Symbol("specified"); -var adoptedStyleSheets = Symbol("adoptedStyleSheets"); -var implementation = Symbol("implementation"); -var readyState = Symbol("readyState"); -var publicId = Symbol("publicId"); -var systemId = Symbol("systemId"); -var validationMessage = Symbol("validationMessage"); -var validity = Symbol("validity"); -var returnValue = Symbol("returnValue"); -var elements = Symbol("elements"); -var length = Symbol("length"); -var complete = Symbol("complete"); -var naturalHeight = Symbol("naturalHeight"); -var naturalWidth = Symbol("naturalWidth"); -var loading = Symbol("loading"); -var x = Symbol("x"); -var y = Symbol("y"); -var defaultChecked = Symbol("defaultChecked"); -var files = Symbol("files"); -var sheet = Symbol("sheet"); -var volume = Symbol("volume"); -var paused = Symbol("paused"); -var currentTime = Symbol("currentTime"); -var playbackRate = Symbol("playbackRate"); -var defaultPlaybackRate = Symbol("defaultPlaybackRate"); -var muted = Symbol("muted"); -var defaultMuted = Symbol("defaultMuted"); -var preservesPitch = Symbol("preservesPitch"); -var buffered = Symbol("buffered"); -var duration = Symbol("duration"); -var error = Symbol("error"); -var ended = Symbol("ended"); -var networkState = Symbol("networkState"); -var textTracks = Symbol("textTracks"); -var seeking = Symbol("seeking"); -var seekable = Symbol("seekable"); -var played = Symbol("played"); -var options = Symbol("options"); -var content = Symbol("content"); -var mode = Symbol("mode"); -var host = Symbol("host"); -var setURL = Symbol("setURL"); -var localName = Symbol("localName"); -var classRegistry = Symbol("classRegistry"); -var nodeStream = Symbol("nodeStream"); -var location = Symbol("location"); -var history = Symbol("history"); -var navigator = Symbol("navigator"); -var screen = Symbol("screen"); -var sessionStorage = Symbol("sessionStorage"); -var localStorage = Symbol("localStorage"); -var sandbox = Symbol("sandbox"); -var cloneNode = Symbol("cloneNode"); -var appendChild = Symbol("appendChild"); -var removeChild = Symbol("removeChild"); -var insertBefore = Symbol("insertBefore"); -var replaceChild = Symbol("replaceChild"); -var tracks = Symbol("tracks"); -var constraints = Symbol("constraints"); -var capabilities = Symbol("capabilities"); -var settings = Symbol("settings"); -var clone = Symbol("clone"); -var removeNamedItem = Symbol("removeNamedItem"); -var items = Symbol("items"); -var selectedOptions = Symbol("selectedOptions"); -var styleNode = Symbol("styleNode"); -var updateSheet = Symbol("updateSheet"); -var clearCache = Symbol("clearCache"); -var onSetAttribute = Symbol("onSetAttribute"); -var onRemoveAttribute = Symbol("onRemoveAttribute"); -var nodeArray = Symbol("nodeArray"); -var elementArray = Symbol("elementArray"); -var cache = Symbol("cache"); -var affectsCache = Symbol("affectsCache"); -var forms = Symbol("forms"); -var links = Symbol("links"); -var affectsComputedStyleCache = Symbol("affectsComputedStyleCache"); -var query = Symbol("query"); -var computedStyle = Symbol("computedStyle"); -var getFormControlItems = Symbol("getFormControlItems"); -var getFormControlNamedItem = Symbol("getFormControlNamedItem"); -var dataset = Symbol("dataset"); -var getNamespaceItemKey = Symbol("getNamespaceItemKey"); -var getNamedItemKey = Symbol("getNamedItemKey"); -var itemsByNamespaceURI = Symbol("itemsByNamespaceURI"); -var proxy = Symbol("proxy"); -var setNamedItem = Symbol("setNamedItem"); -var getTokenList = Symbol("getTokenList"); -var attributeName = Symbol("attributeName"); -var selectedIndex = Symbol("selectedIndex"); -var self = Symbol("self"); -var parent = Symbol("parent"); -var top = Symbol("top"); -var areas = Symbol("areas"); -var defaultValue = Symbol("defaultValue"); -var elementIdMap = Symbol("elementIdMap"); -var clonable = Symbol("clonable"); -var delegatesFocus = Symbol("delegatesFocus"); -var serializable = Symbol("serializable"); -var slotAssignment = Symbol("slotAssignment"); -var assignedNodes = Symbol("assignedNodes"); -var assignedToSlot = Symbol("assignedToSlot"); -var cells = Symbol("cells"); -var rows = Symbol("rows"); -var headers = Symbol("headers"); -var tBodies = Symbol("tBodies"); -var track = Symbol("track"); -var controlsList = Symbol("controlsList"); -var mediaKeys = Symbol("mediaKeys"); -var remote = Symbol("remote"); -var sinkId = Symbol("sinkId"); -var srcObject = Symbol("srcObject"); -var cues = Symbol("cues"); -var activeCues = Symbol("activeCues"); -var kind = Symbol("kind"); -var label = Symbol("label"); -var language = Symbol("language"); -var id = Symbol("id"); -var illegalConstructor = Symbol("illegalConstructor"); -var state = Symbol("state"); -var canvas = Symbol("canvas"); -var popoverTargetElement = Symbol("popoverTargetElement"); -var composed = Symbol("composed"); -var bubbles = Symbol("bubbles"); -var cancelable = Symbol("cancelable"); -var defaultPrevented = Symbol("defaultPrevented"); -var eventPhase = Symbol("eventPhase"); -var timeStamp = Symbol("timeStamp"); -var type = Symbol("type"); -var detail = Symbol("detail"); -var globalObject = Symbol("globalObject"); -var destroyed = Symbol("destroyed"); -var aborted = Symbol("aborted"); -var browserFrames = Symbol("browserFrames"); -var windowInternalId = Symbol("windowInternalId"); -var getItemList = Symbol("getItemList"); -var requiredExtensions = Symbol("requiredExtensions"); -var systemLanguage = Symbol("systemLanguage"); -var transform = Symbol("transform"); -var baseVal = Symbol("baseVal"); -var animVal = Symbol("animVal"); -var pathLength = Symbol("pathLength"); -var unitType = Symbol("unitType"); -var viewBox = Symbol("viewBox"); -var markerUnits = Symbol("markerUnits"); -var markerWidth = Symbol("markerWidth"); -var markerHeight = Symbol("markerHeight"); -var values = Symbol("values"); -var orientType = Symbol("orientType"); -var orientAngle = Symbol("orientAngle"); -var refX = Symbol("refX"); -var refY = Symbol("refY"); -var readOnly = Symbol("readOnly"); -var preserveAspectRatio = Symbol("preserveAspectRatio"); -var animatedPoints = Symbol("animatedPoints"); -var points = Symbol("points"); -var rx = Symbol("rx"); -var ry = Symbol("ry"); -var cx = Symbol("cx"); -var cy = Symbol("cy"); -var r = Symbol("r"); -var clipPathUnits = Symbol("clipPathUnits"); -var maskUnits = Symbol("maskUnits"); -var maskContentUnits = Symbol("maskContentUnits"); -var filterUnits = Symbol("filterUnits"); -var primitiveUnits = Symbol("primitiveUnits"); -var href = Symbol("href"); -var x1 = Symbol("x1"); -var y1 = Symbol("y1"); -var x2 = Symbol("x2"); -var y2 = Symbol("y2"); -var gradientUnits = Symbol("gradientUnits"); -var gradientTransform = Symbol("gradientTransform"); -var spreadMethod = Symbol("spreadMethod"); -var patternUnits = Symbol("patternUnits"); -var patternContentUnits = Symbol("patternContentUnits"); -var patternTransform = Symbol("patternTransform"); -var fx = Symbol("fx"); -var fy = Symbol("fy"); -var offset = Symbol("offset"); -var disabled = Symbol("disabled"); -var textLength = Symbol("textLength"); -var lengthAdjust = Symbol("lengthAdjust"); -var getAttribute = Symbol("getAttribute"); -var setAttribute = Symbol("setAttribute"); -var z = Symbol("z"); -var w = Symbol("w"); -var toArray = Symbol("toArray"); -var fromString = Symbol("fromString"); -var fromArray = Symbol("fromArray"); -var angle = Symbol("angle"); -var m11 = Symbol("m11"); -var m12 = Symbol("m12"); -var m13 = Symbol("m13"); -var m14 = Symbol("m14"); -var m21 = Symbol("m21"); -var m22 = Symbol("m22"); -var m23 = Symbol("m23"); -var m24 = Symbol("m24"); -var m31 = Symbol("m31"); -var m32 = Symbol("m32"); -var m33 = Symbol("m33"); -var m34 = Symbol("m34"); -var m41 = Symbol("m41"); -var m42 = Symbol("m42"); -var m43 = Symbol("m43"); -var m44 = Symbol("m44"); -var setMatrixValue = Symbol("setMatrixValue"); -var translateSelf = Symbol("translateSelf"); -var rotateSelf = Symbol("rotateSelf"); -var rotateAxisAngleSelf = Symbol("rotateAxisAngleSelf"); -var scaleSelf = Symbol("scaleSelf"); -var scale3dSelf = Symbol("scale3dSelf"); -var scaleNonUniformSelf = Symbol("scaleNonUniformSelf"); -var skewXSelf = Symbol("skewXSelf"); -var skewYSelf = Symbol("skewYSelf"); -var multiplySelf = Symbol("multiplySelf"); -var matrix = Symbol("matrix"); -var domMatrix = Symbol("domMatrix"); -var getDOMMatrix = Symbol("getDOMMatrix"); -var setDOMMatrix = Symbol("setDOMMatrix"); -var attributeValue = Symbol("attributeValue"); -var startOffset = Symbol("startOffset"); -var method = Symbol("method"); -var spacing = Symbol("spacing"); -var in1 = Symbol("in1"); -var in2 = Symbol("in2"); -var result = Symbol("result"); -var bias = Symbol("bias"); -var divisor = Symbol("divisor"); -var edgeMode = Symbol("edgeMode"); -var kernelMatrix = Symbol("kernelMatrix"); -var kernelUnitLengthX = Symbol("kernelUnitLengthX"); -var kernelUnitLengthY = Symbol("kernelUnitLengthY"); -var orderX = Symbol("orderX"); -var orderY = Symbol("orderY"); -var preserveAlpha = Symbol("preserveAlpha"); -var targetX = Symbol("targetX"); -var targetY = Symbol("targetY"); -var diffuseConstant = Symbol("diffuseConstant"); -var surfaceScale = Symbol("surfaceScale"); -var scale = Symbol("scale"); -var xChannelSelector = Symbol("xChannelSelector"); -var yChannelSelector = Symbol("yChannelSelector"); -var azimuth = Symbol("azimuth"); -var elevation = Symbol("elevation"); -var dx = Symbol("dx"); -var dy = Symbol("dy"); -var stdDeviationX = Symbol("stdDeviationX"); -var stdDeviationY = Symbol("stdDeviationY"); -var tableValues = Symbol("tableValues"); -var slope = Symbol("slope"); -var intercept = Symbol("intercept"); -var amplitude = Symbol("amplitude"); -var exponent = Symbol("exponent"); -var crossOrigin = Symbol("crossOrigin"); -var operator = Symbol("operator"); -var radiusX = Symbol("radiusX"); -var radiusY = Symbol("radiusY"); -var specularConstant = Symbol("specularConstant"); -var specularExponent = Symbol("specularExponent"); -var pointsAtX = Symbol("pointsAtX"); -var pointsAtY = Symbol("pointsAtY"); -var pointsAtZ = Symbol("pointsAtZ"); -var limitingConeAngle = Symbol("limitingConeAngle"); -var baseFrequencyX = Symbol("baseFrequencyX"); -var baseFrequencyY = Symbol("baseFrequencyY"); -var numOctaves = Symbol("numOctaves"); -var seed = Symbol("seed"); -var stitchTiles = Symbol("stitchTiles"); -var rotateFromVectorSelf = Symbol("rotateFromVectorSelf"); -var flipXSelf = Symbol("flipXSelf"); -var flipYSelf = Symbol("flipYSelf"); -var invertSelf = Symbol("invertSelf"); -var getLength = Symbol("getLength"); -var currentScale = Symbol("currentScale"); -var rotate = Symbol("rotate"); -var bindMethods = Symbol("bindMethods"); -var xmlProcessingInstruction = Symbol("xmlProcessingInstruction"); -var root = Symbol("root"); -var filterNode = Symbol("filterNode"); -var customElementReactionStack = Symbol("customElementReactionStack"); -var dispatching = Symbol("dispatching"); -var modules = Symbol("modules"); -var preloads = Symbol("preloads"); -var body = Symbol("body"); -var redirect = Symbol("redirect"); -var referrerPolicy = Symbol("referrerPolicy"); -var signal = Symbol("signal"); -var bodyUsed = Symbol("bodyUsed"); -var credentials = Symbol("credentials"); -var blocking = Symbol("blocking"); -var moduleImportMap = Symbol("moduleImportMap"); -var dispatchError = Symbol("dispatchError"); -var supports = Symbol("supports"); -var reason = Symbol("reason"); -var propertyEventListeners = Symbol("propertyEventListeners"); -var cssRules = Symbol("cssRules"); -var parentRule = Symbol("parentRule"); -var parentStyleSheet = Symbol("parentStyleSheet"); -var conditionText = Symbol("conditionText"); -var keyText = Symbol("keyText"); -var media = Symbol("media"); -var styleMap = Symbol("styleMap"); -var selectorText = Symbol("selectorText"); -var cssParser = Symbol("cssParser"); -var cssRule = Symbol("cssRule"); -var rulePrefix = Symbol("rulePrefix"); -var virtualServerFile = Symbol("virtualServerFile"); -var frames = Symbol("frames"); -var disableEvaluation = Symbol("disableEvaluation"); -var validateJavaScriptExecutionEnvironment = Symbol("validateJavaScriptExecutionEnvironment"); -var currentNode = Symbol("currentNode"); -var openWebSockets = Symbol("openWebSockets"); -var webSocket = Symbol("webSocket"); -var moduleCache = Symbol("moduleCache"); -var cookieStore = Symbol("cookieStore"); -var context = Symbol("context"); -var querySelectorCache = Symbol("querySelectorCache"); - -// node_modules/happy-dom/lib/cookie/enums/CookieSameSiteEnum.js -var CookieSameSiteEnum; -(function(CookieSameSiteEnum) { - CookieSameSiteEnum["strict"] = "Strict"; - CookieSameSiteEnum["lax"] = "Lax"; - CookieSameSiteEnum["none"] = "None"; -})(CookieSameSiteEnum || (CookieSameSiteEnum = {})); -var CookieSameSiteEnum_default = CookieSameSiteEnum; - -// node_modules/happy-dom/lib/cookie/DefaultCookie.js -var DefaultCookie_default = { - key: null, - originURL: null, - value: null, - domain: "", - path: "", - expires: null, - httpOnly: false, - secure: false, - sameSite: CookieSameSiteEnum_default.lax -}; - -// node_modules/happy-dom/lib/cookie/urilities/CookieExpireUtility.js -class CookieExpireUtility { - static hasExpired(cookie) { - return cookie.expires && cookie.expires.getTime() < Date.now(); - } -} - -// node_modules/happy-dom/lib/cookie/urilities/CookieURLUtility.js -class CookieURLUtility { - static cookieMatchesURL(cookie, url) { - const isLocalhost = url.hostname === "localhost" || url.hostname?.endsWith(".localhost"); - return (!cookie.secure || url.protocol === "https:" || isLocalhost) && (!cookie.domain || url.hostname?.endsWith(cookie.domain)) && (!cookie.path || url.pathname?.startsWith(cookie.path)) && (cookie.sameSite === CookieSameSiteEnum_default.none && cookie.secure || cookie.originURL?.hostname === url.hostname); - } -} - -// node_modules/happy-dom/lib/cookie/CookieContainer.js -class CookieContainer { - #cookies = []; - addCookies(cookies) { - const changedCookies = { - changed: [], - deleted: [] - }; - const allCookies = this.#cookies; - for (const cookie of cookies) { - const newCookie = Object.assign({}, DefaultCookie_default, cookie); - if (newCookie && newCookie.key && newCookie.originURL) { - const hasExpired = CookieExpireUtility.hasExpired(newCookie); - for (let i = 0, max = allCookies.length;i < max; i++) { - const existingCookie = allCookies[i]; - if (existingCookie.key === newCookie.key && existingCookie.originURL.hostname === newCookie.originURL.hostname && existingCookie.path === newCookie.path && typeof existingCookie.value === typeof newCookie.value) { - if (hasExpired) { - changedCookies.deleted.push(existingCookie); - } - allCookies.splice(i, 1); - break; - } - } - if (!hasExpired) { - allCookies.push(newCookie); - changedCookies.changed.push(newCookie); - } - } - } - return changedCookies; - } - getCookies(url = null, clientSide = false) { - const cookies = []; - for (const cookie of this.#cookies) { - if (!CookieExpireUtility.hasExpired(cookie) && (!clientSide || !cookie.httpOnly) && (!url || CookieURLUtility.cookieMatchesURL(cookie, url))) { - cookies.push(cookie); - } - } - return cookies; - } - clearCookies() { - this.#cookies = []; - } -} - -// node_modules/happy-dom/lib/fetch/cache/response/CachedResponseStateEnum.js -var CachedResponseStateEnum; -(function(CachedResponseStateEnum) { - CachedResponseStateEnum["fresh"] = "fresh"; - CachedResponseStateEnum["stale"] = "stale"; -})(CachedResponseStateEnum || (CachedResponseStateEnum = {})); -var CachedResponseStateEnum_default = CachedResponseStateEnum; - -// node_modules/happy-dom/lib/exception/DOMExceptionNameEnum.js -var DOMExceptionNameEnum; -(function(DOMExceptionNameEnum) { - DOMExceptionNameEnum["invalidStateError"] = "InvalidStateError"; - DOMExceptionNameEnum["indexSizeError"] = "IndexSizeError"; - DOMExceptionNameEnum["syntaxError"] = "SyntaxError"; - DOMExceptionNameEnum["hierarchyRequestError"] = "HierarchyRequestError"; - DOMExceptionNameEnum["notSupportedError"] = "NotSupportedError"; - DOMExceptionNameEnum["wrongDocumentError"] = "WrongDocumentError"; - DOMExceptionNameEnum["invalidNodeTypeError"] = "InvalidNodeTypeError"; - DOMExceptionNameEnum["invalidCharacterError"] = "InvalidCharacterError"; - DOMExceptionNameEnum["notFoundError"] = "NotFoundError"; - DOMExceptionNameEnum["securityError"] = "SecurityError"; - DOMExceptionNameEnum["networkError"] = "NetworkError"; - DOMExceptionNameEnum["domException"] = "DOMException"; - DOMExceptionNameEnum["invalidAccessError"] = "InvalidAccessError"; - DOMExceptionNameEnum["unknownError"] = "UnknownError"; - DOMExceptionNameEnum["abortError"] = "AbortError"; - DOMExceptionNameEnum["timeoutError"] = "TimeoutError"; - DOMExceptionNameEnum["encodingError"] = "EncodingError"; - DOMExceptionNameEnum["uriMismatchError"] = "URIMismatchError"; - DOMExceptionNameEnum["inUseAttributeError"] = "InUseAttributeError"; - DOMExceptionNameEnum["namespaceError"] = "NamespaceError"; -})(DOMExceptionNameEnum || (DOMExceptionNameEnum = {})); -var DOMExceptionNameEnum_default = DOMExceptionNameEnum; - -// node_modules/happy-dom/lib/exception/DOMException.js -class DOMException extends Error { - constructor(message, name = null) { - super(message); - this.name = name || DOMExceptionNameEnum_default.domException; - } -} - -// node_modules/happy-dom/lib/fetch/Headers.js -class Headers { - [entries] = {}; - constructor(init) { - if (init) { - if (init instanceof Headers) { - this[entries] = JSON.parse(JSON.stringify(init[entries])); - } else if (Array.isArray(init)) { - for (const entry of init) { - if (entry.length !== 2) { - throw new DOMException('Failed to construct "Headers": The provided init is not a valid array.', DOMExceptionNameEnum_default.invalidStateError); - } - this.append(entry[0], entry[1]); - } - } else { - for (const name of Object.keys(init)) { - this.set(name, init[name]); - } - } - } - } - append(name, value) { - const lowerName = name.toLowerCase(); - if (this[entries][lowerName]) { - this[entries][lowerName].value.push(value); - } else { - this[entries][lowerName] = { - name, - value: [value] - }; - } - } - delete(name) { - delete this[entries][name.toLowerCase()]; - } - get(name) { - return this[entries][name.toLowerCase()]?.value.join(", ") ?? null; - } - set(name, value) { - this[entries][name.toLowerCase()] = { - name, - value: [value] - }; - } - getSetCookie() { - const entry = this[entries]["set-cookie"]; - if (!entry) { - return []; - } - return entry.value; - } - has(name) { - return !!this[entries][name.toLowerCase()]; - } - forEach(callback, thisArg) { - const thisArgValue = thisArg ?? this[window]; - for (const header of Object.values(this[entries])) { - callback.call(thisArgValue, header.value.join(", "), header.name, this); - } - } - *keys() { - for (const header of Object.values(this[entries])) { - yield header.name; - } - } - *values() { - for (const header of Object.values(this[entries])) { - yield header.value.join(", "); - } - } - *entries() { - for (const header of Object.values(this[entries])) { - yield [header.name, header.value.join(", ")]; - } - } - *[Symbol.iterator]() { - for (const header of Object.values(this[entries])) { - yield [header.name, header.value.join(", ")]; - } - } -} - -// node_modules/happy-dom/lib/fetch/cache/response/ResponseCacheFileSystem.js -import FS from "fs"; -import Path from "path"; -import Crypto from "crypto"; - -class ResponseCacheFileSystem { - #createdDirectories = new Set; - #hashes = new Set; - #entries; - constructor(entries) { - this.#entries = entries; - } - async load(directory) { - if (!directory) { - throw new Error("Failed to execute 'load' on 'ResponseCacheFileSystem': Directory is not specified."); - } - const absoluteDirectory = Path.resolve(directory); - let files = []; - try { - files = await FS.promises.readdir(absoluteDirectory); - } catch (error) { - return; - } - const promises = []; - const entries = this.#entries; - for (const file of files) { - if (file.endsWith(".json")) { - promises.push(FS.promises.readFile(Path.join(absoluteDirectory, file), "utf8").then((content) => { - const cachedResponse = JSON.parse(content); - if (cachedResponse.response && cachedResponse.request && !cachedResponse.virtual) { - cachedResponse.response.headers = new Headers(cachedResponse.response.headers); - cachedResponse.request.headers = new Headers(cachedResponse.request.headers); - return FS.promises.readFile(Path.join(absoluteDirectory, file.split(".")[0] + ".data")).then((body) => { - cachedResponse.response.body = body; - let entry = entries.get(cachedResponse.response.url); - if (!entry) { - entry = []; - entries.set(cachedResponse.response.url, entry); - } - entry.push(cachedResponse); - }).catch(() => { - let entry = entries.get(cachedResponse.response.url); - if (!entry) { - entry = []; - entries.set(cachedResponse.response.url, entry); - } - entry.push(cachedResponse); - }); - } - }).catch(() => {})); - } - } - await Promise.all(promises); - } - async save(directory) { - if (!directory) { - throw new Error("Failed to execute 'store' on 'ResponseCacheFileSystem': Directory is not specified."); - } - if (!this.#entries.size) { - return; - } - const absoluteDirectory = Path.resolve(directory); - const isDirectoryCreated = this.#createdDirectories.has(absoluteDirectory); - if (!isDirectoryCreated) { - this.#createdDirectories.add(absoluteDirectory); - try { - await FS.promises.mkdir(absoluteDirectory, { - recursive: true - }); - } catch (error) {} - } - const entries = this.#entries; - const promises = []; - for (const entry of entries.values()) { - for (const cachedResponse of entry) { - if (!cachedResponse.virtual) { - const responseHeaders = {}; - const requestHeaders = {}; - for (const [key, value] of cachedResponse.response.headers.entries()) { - responseHeaders[key] = value; - } - for (const [key, value] of cachedResponse.request.headers.entries()) { - requestHeaders[key] = value; - } - const cacheableEntry = { - ...cachedResponse, - response: { - ...cachedResponse.response, - headers: responseHeaders, - body: null - }, - request: { - ...cachedResponse.request, - headers: requestHeaders - } - }; - const json = JSON.stringify(cacheableEntry, null, 3); - const hash = Crypto.createHash("md5").update(json).digest("hex"); - if (!this.#hashes.has(hash)) { - this.#hashes.add(hash); - promises.push(FS.promises.writeFile(Path.join(absoluteDirectory, `${hash}.json`), json)); - if (cachedResponse.response.body) { - promises.push(FS.promises.writeFile(Path.join(absoluteDirectory, `${hash}.data`), cachedResponse.response.body)); - } - } - } - } - } - await Promise.all(promises); - } -} - -// node_modules/happy-dom/lib/fetch/cache/response/ResponseCache.js -var UPDATE_RESPONSE_HEADERS = ["Cache-Control", "Last-Modified", "Vary", "ETag"]; - -class ResponseCache { - fileSystem; - #entries = new Map; - constructor() { - this.fileSystem = new ResponseCacheFileSystem(this.#entries); - } - get(request) { - if (request.headers.get("Cache-Control")?.includes("no-cache")) { - return null; - } - const url = request.url; - const entries = this.#entries.get(url); - if (entries) { - for (let i = 0, max = entries.length;i < max; i++) { - const entry = entries[i]; - let isMatch = entry.request.method === request.method; - if (isMatch) { - for (const header of Object.keys(entry.vary)) { - const requestHeader = request.headers.get(header); - if (requestHeader !== null && entry.vary[header] !== requestHeader) { - isMatch = false; - break; - } - } - } - if (isMatch) { - if (entry.expires && entry.expires < Date.now()) { - if (entry.lastModified) { - entry.state = CachedResponseStateEnum_default.stale; - } else if (!entry.etag) { - entries.splice(i, 1); - return null; - } - } - return entry; - } - } - } - return null; - } - add(request, response) { - if (request.method !== "GET" && request.method !== "HEAD" || request.headers.get("Cache-Control")?.includes("no-cache")) { - return null; - } - const url = request.url; - let cachedResponse = this.get(request); - if (response.status === 304) { - if (!cachedResponse) { - throw new Error("ResponseCache: Cached response not found."); - } - for (const name of UPDATE_RESPONSE_HEADERS) { - if (response.headers.has(name)) { - cachedResponse.response.headers.set(name, response.headers.get(name)); - } - } - cachedResponse.cacheUpdateTime = Date.now(); - cachedResponse.state = CachedResponseStateEnum_default.fresh; - } else { - if (cachedResponse) { - const entries = this.#entries.get(url); - if (entries) { - const index = entries.indexOf(cachedResponse); - if (index !== -1) { - entries.splice(index, 1); - } - } - } - cachedResponse = { - response: { - status: response.status, - statusText: response.statusText, - url: response.url, - headers: new Headers(response.headers), - waitingForBody: response.waitingForBody, - body: response.body ?? null - }, - request: { - headers: request.headers, - method: request.method - }, - vary: {}, - expires: null, - etag: null, - cacheUpdateTime: Date.now(), - lastModified: null, - mustRevalidate: false, - staleWhileRevalidate: false, - state: CachedResponseStateEnum_default.fresh, - virtual: response.virtual ?? false - }; - let entries = this.#entries.get(url); - if (!entries) { - entries = []; - this.#entries.set(url, entries); - } - entries.push(cachedResponse); - } - if (response.headers.has("Cache-Control")) { - const age = response.headers.get("Age"); - for (const part of response.headers.get("Cache-Control").split(",")) { - const [key, value] = part.trim().split("="); - switch (key) { - case "max-age": - cachedResponse.expires = Date.now() + parseFloat(value) * 1000 - (age ? parseFloat(age) * 1000 : 0); - break; - case "no-cache": - case "no-store": - const entries = this.#entries.get(url); - if (entries) { - const index = entries.indexOf(cachedResponse); - if (index !== -1) { - entries.splice(index, 1); - } - } - return null; - case "must-revalidate": - cachedResponse.mustRevalidate = true; - break; - case "stale-while-revalidate": - cachedResponse.staleWhileRevalidate = true; - break; - } - } - } - if (response.headers.has("Last-Modified")) { - cachedResponse.lastModified = Date.parse(response.headers.get("Last-Modified")); - } - if (response.headers.has("Vary")) { - for (const header of response.headers.get("Vary").split(",")) { - const name = header.trim(); - const value = request.headers.get(name); - if (value) { - cachedResponse.vary[name] = value; - } - } - } - if (response.headers.has("ETag")) { - cachedResponse.etag = response.headers.get("ETag"); - } - if (!cachedResponse.expires) { - const expires = response.headers.get("Expires"); - if (expires) { - cachedResponse.expires = Date.parse(expires); - } - } - if (!cachedResponse.etag && (!cachedResponse.expires || cachedResponse.expires < Date.now())) { - const entries = this.#entries.get(url); - if (entries) { - const index = entries.indexOf(cachedResponse); - if (index !== -1) { - entries.splice(index, 1); - } - } - return null; - } - return cachedResponse; - } - clear(options) { - if (options) { - if (options.toTime) { - for (const key of options.url ? [options.url] : this.#entries.keys()) { - const entry = this.#entries.get(key); - if (entry) { - for (let i = 0, max = entry.length;i < max; i++) { - if (entry[i].cacheUpdateTime < options.toTime) { - entry.splice(i, 1); - i--; - max--; - } - } - } - } - } else if (options.url) { - this.#entries.delete(options.url); - } - } else { - this.#entries.clear(); - } - } -} - -// node_modules/happy-dom/lib/console/enums/VirtualConsoleLogLevelEnum.js -var VirtualConsoleLogLevelEnum; -(function(VirtualConsoleLogLevelEnum) { - VirtualConsoleLogLevelEnum[VirtualConsoleLogLevelEnum["log"] = 0] = "log"; - VirtualConsoleLogLevelEnum[VirtualConsoleLogLevelEnum["info"] = 1] = "info"; - VirtualConsoleLogLevelEnum[VirtualConsoleLogLevelEnum["warn"] = 2] = "warn"; - VirtualConsoleLogLevelEnum[VirtualConsoleLogLevelEnum["error"] = 3] = "error"; -})(VirtualConsoleLogLevelEnum || (VirtualConsoleLogLevelEnum = {})); -var VirtualConsoleLogLevelEnum_default = VirtualConsoleLogLevelEnum; - -// node_modules/happy-dom/lib/nodes/node/NodeTypeEnum.js -var NodeTypeEnum; -(function(NodeTypeEnum) { - NodeTypeEnum[NodeTypeEnum["elementNode"] = 1] = "elementNode"; - NodeTypeEnum[NodeTypeEnum["attributeNode"] = 2] = "attributeNode"; - NodeTypeEnum[NodeTypeEnum["textNode"] = 3] = "textNode"; - NodeTypeEnum[NodeTypeEnum["cdataSectionNode"] = 4] = "cdataSectionNode"; - NodeTypeEnum[NodeTypeEnum["commentNode"] = 8] = "commentNode"; - NodeTypeEnum[NodeTypeEnum["documentNode"] = 9] = "documentNode"; - NodeTypeEnum[NodeTypeEnum["documentTypeNode"] = 10] = "documentTypeNode"; - NodeTypeEnum[NodeTypeEnum["documentFragmentNode"] = 11] = "documentFragmentNode"; - NodeTypeEnum[NodeTypeEnum["processingInstructionNode"] = 7] = "processingInstructionNode"; -})(NodeTypeEnum || (NodeTypeEnum = {})); -var NodeTypeEnum_default = NodeTypeEnum; - -// node_modules/happy-dom/lib/event/EventPhaseEnum.js -var EventPhaseEnum; -(function(EventPhaseEnum) { - EventPhaseEnum[EventPhaseEnum["none"] = 0] = "none"; - EventPhaseEnum[EventPhaseEnum["capturing"] = 1] = "capturing"; - EventPhaseEnum[EventPhaseEnum["atTarget"] = 2] = "atTarget"; - EventPhaseEnum[EventPhaseEnum["bubbling"] = 3] = "bubbling"; -})(EventPhaseEnum || (EventPhaseEnum = {})); -var EventPhaseEnum_default = EventPhaseEnum; - -// node_modules/happy-dom/lib/event/Event.js -class Event { - static NONE = EventPhaseEnum_default.none; - static CAPTURING_PHASE = EventPhaseEnum_default.capturing; - static AT_TARGET = EventPhaseEnum_default.atTarget; - static BUBBLING_PHASE = EventPhaseEnum_default.bubbling; - NONE = Event.NONE; - CAPTURING_PHASE = Event.CAPTURING_PHASE; - AT_TARGET = Event.AT_TARGET; - BUBBLING_PHASE = Event.BUBBLING_PHASE; - [composed] = false; - [bubbles] = false; - [cancelable] = false; - [defaultPrevented] = false; - [eventPhase] = EventPhaseEnum_default.none; - [timeStamp] = performance.now(); - [type]; - [dispatching] = false; - [immediatePropagationStopped] = false; - [propagationStopped] = false; - [target] = null; - [currentTarget] = null; - [isInPassiveEventListener] = false; - constructor(type2, eventInit = null) { - this[type] = type2; - this[bubbles] = eventInit?.bubbles ?? false; - this[cancelable] = eventInit?.cancelable ?? false; - this[composed] = eventInit?.composed ?? false; - } - get composed() { - return this[composed]; - } - get bubbles() { - return this[bubbles]; - } - get cancelable() { - return this[cancelable]; - } - get defaultPrevented() { - return this[defaultPrevented]; - } - get eventPhase() { - return this[eventPhase]; - } - get timeStamp() { - return this[timeStamp]; - } - get type() { - return this[type]; - } - get target() { - return this[target]; - } - get currentTarget() { - return this[currentTarget]; - } - get cancelBubble() { - return this[propagationStopped]; - } - composedPath() { - if (!this[target]) { - return []; - } - const composedPath = []; - let eventTarget = this[target]; - while (eventTarget) { - composedPath.push(eventTarget); - if (eventTarget.parentNode) { - eventTarget = eventTarget.parentNode; - } else if (this[composed] && eventTarget[nodeType] === NodeTypeEnum_default.documentFragmentNode && eventTarget.host) { - eventTarget = eventTarget.host; - } else if (eventTarget[nodeType] === NodeTypeEnum_default.documentNode && this[type] !== "load") { - eventTarget = eventTarget[window]; - } else { - break; - } - } - return composedPath; - } - initEvent(type2, bubbles2 = false, cancelable2 = false) { - this[type] = type2; - this[bubbles] = bubbles2; - this[cancelable] = cancelable2; - this[propagationStopped] = false; - this[immediatePropagationStopped] = false; - this[defaultPrevented] = false; - } - preventDefault() { - if (!this[isInPassiveEventListener] && this.cancelable) { - this[defaultPrevented] = true; - } - } - stopImmediatePropagation() { - this[immediatePropagationStopped] = true; - } - stopPropagation() { - this[propagationStopped] = true; - } -} - -// node_modules/happy-dom/lib/console/enums/VirtualConsoleLogTypeEnum.js -var VirtualConsoleLogTypeEnum; -(function(VirtualConsoleLogTypeEnum) { - VirtualConsoleLogTypeEnum["log"] = "log"; - VirtualConsoleLogTypeEnum["table"] = "table"; - VirtualConsoleLogTypeEnum["trace"] = "trace"; - VirtualConsoleLogTypeEnum["dir"] = "dir"; - VirtualConsoleLogTypeEnum["dirxml"] = "dirxml"; - VirtualConsoleLogTypeEnum["group"] = "group"; - VirtualConsoleLogTypeEnum["groupCollapsed"] = "groupCollapsed"; - VirtualConsoleLogTypeEnum["debug"] = "debug"; - VirtualConsoleLogTypeEnum["timeLog"] = "timeLog"; - VirtualConsoleLogTypeEnum["info"] = "info"; - VirtualConsoleLogTypeEnum["count"] = "count"; - VirtualConsoleLogTypeEnum["timeEnd"] = "timeEnd"; - VirtualConsoleLogTypeEnum["warn"] = "warn"; - VirtualConsoleLogTypeEnum["countReset"] = "countReset"; - VirtualConsoleLogTypeEnum["error"] = "error"; - VirtualConsoleLogTypeEnum["assert"] = "assert"; -})(VirtualConsoleLogTypeEnum || (VirtualConsoleLogTypeEnum = {})); -var VirtualConsoleLogTypeEnum_default = VirtualConsoleLogTypeEnum; - -// node_modules/happy-dom/lib/console/utilities/VirtualConsoleLogEntryStringifier.js -class VirtualConsoleLogEntryStringifier { - static toString(logEntry) { - if (this.isLogEntryCollapsed(logEntry)) { - return ""; - } - const tabbing = this.getLogEntryGroupTabbing(logEntry); - let output = tabbing; - for (const part of logEntry.message) { - output += output !== "" && output !== tabbing ? " " : ""; - if (typeof part === "object" && (part === null || part.constructor.name === "Object" || Array.isArray(part))) { - try { - output += JSON.stringify(part); - } catch (error) { - output += new Error("Failed to JSON stringify object in log entry.").stack.replace(/\n at/gm, ` - ` + tabbing + "at"); - } - } else if (typeof part === "object" && part["message"] && part["stack"]) { - output += part["stack"].replace(/\n at/gm, ` - ` + tabbing + "at"); - } else { - output += this.getLogEntryIcon(logEntry) + String(part); - } - } - return output + ` -`; - } - static getLogEntryIcon(logEntry) { - switch (logEntry.type) { - case VirtualConsoleLogTypeEnum_default.group: - return "\u25BC "; - case VirtualConsoleLogTypeEnum_default.groupCollapsed: - return "\u25B6 "; - } - return ""; - } - static getLogEntryGroupTabbing(logEntry) { - let tabs = ""; - let group = logEntry.type === VirtualConsoleLogTypeEnum_default.group || logEntry.type === VirtualConsoleLogTypeEnum_default.groupCollapsed ? logEntry.group?.parent : logEntry.group; - while (group) { - tabs += " "; - group = group.parent; - } - return tabs; - } - static isLogEntryCollapsed(logEntry) { - let group = logEntry.type === VirtualConsoleLogTypeEnum_default.group || logEntry.type === VirtualConsoleLogTypeEnum_default.groupCollapsed ? logEntry.group?.parent : logEntry.group; - while (group) { - if (group.collapsed) { - return true; - } - group = group.parent; - } - return false; - } -} - -// node_modules/happy-dom/lib/console/VirtualConsolePrinter.js -class VirtualConsolePrinter { - #logEntries = []; - #listeners = { print: [], clear: [] }; - #closed = false; - get closed() { - return this.#closed; - } - print(logEntry) { - if (this.#closed) { - return; - } - this.#logEntries.push(logEntry); - this.dispatchEvent(new Event("print")); - } - clear() { - if (this.#closed) { - return; - } - this.#logEntries = []; - this.dispatchEvent(new Event("clear")); - } - close() { - if (this.#closed) { - return; - } - this.#logEntries = []; - this.#listeners = { print: [], clear: [] }; - this.#closed = true; - } - addEventListener(eventType, listener) { - if (this.#closed) { - return; - } - if (!this.#listeners[eventType]) { - throw new Error(`Event type "${eventType}" is not supported.`); - } - this.#listeners[eventType].push(listener); - } - removeEventListener(eventType, listener) { - if (this.#closed) { - return; - } - if (!this.#listeners[eventType]) { - throw new Error(`Event type "${eventType}" is not supported.`); - } - const index = this.#listeners[eventType].indexOf(listener); - if (index !== -1) { - this.#listeners[eventType].splice(index, 1); - } - } - dispatchEvent(event) { - if (this.#closed) { - return; - } - switch (event.type) { - case "print": - case "clear": - for (const listener of this.#listeners[event.type]) { - listener(event); - } - break; - default: - throw new Error(`Event type "${event.type}" is not supported.`); - } - } - read() { - const logEntries = this.#logEntries; - this.#logEntries = []; - return logEntries; - } - readAsString(logLevel = VirtualConsoleLogLevelEnum_default.log) { - const logEntries = this.read(); - let output = ""; - for (const logEntry of logEntries) { - if (logEntry.level >= logLevel) { - output += VirtualConsoleLogEntryStringifier.toString(logEntry); - } - } - return output; - } -} - -// node_modules/happy-dom/lib/async-task-manager/AsyncTaskManagerDebugError.js -class AsyncTaskManagerDebugError extends Error { - constructor(message) { - super(message); - this.name = "AsyncTaskManagerDebugError"; - } -} - -// node_modules/happy-dom/lib/async-task-manager/AsyncTaskManager.js -var TIMER = { - setTimeout: globalThis.setTimeout.bind(globalThis), - clearTimeout: globalThis.clearTimeout.bind(globalThis), - clearImmediate: globalThis.clearImmediate.bind(globalThis) -}; - -class AsyncTaskManager { - static taskID = 0; - runningTasks = {}; - runningTaskCount = 0; - runningTimers = []; - runningImmediates = []; - debugTrace = new Map; - waitUntilCompleteTimer = null; - waitUntilCompleteResolvers = []; - destroyed = false; - #debugTimeout = null; - #browserFrame; - constructor(browserFrame) { - this.#browserFrame = browserFrame; - } - waitUntilComplete() { - return new Promise((resolve, reject) => { - this.waitUntilCompleteResolvers.push({ resolve, reject }); - this.resolveWhenComplete(); - }); - } - abort() { - if (this.destroyed) { - return new Promise((resolve, reject) => { - this.waitUntilCompleteResolvers.push({ resolve, reject }); - this.resolveWhenComplete(); - }); - } - return this.abortAll(false); - } - destroy() { - if (this.destroyed) { - return new Promise((resolve, reject) => { - this.waitUntilCompleteResolvers.push({ resolve, reject }); - this.resolveWhenComplete(); - }); - } - return this.abortAll(true); - } - startTimer(timerID) { - if (this.destroyed) { - TIMER.clearTimeout(timerID); - return; - } - if (this.waitUntilCompleteTimer) { - TIMER.clearTimeout(this.waitUntilCompleteTimer); - this.waitUntilCompleteTimer = null; - } - this.runningTimers.push(timerID); - if (this.#browserFrame.page.context.browser.settings.debug.traceWaitUntilComplete > 0) { - this.debugTrace.set(timerID, new AsyncTaskManagerDebugError().stack); - } - } - endTimer(timerID) { - if (this.destroyed) { - TIMER.clearTimeout(timerID); - return; - } - const index = this.runningTimers.indexOf(timerID); - if (index !== -1) { - this.runningTimers.splice(index, 1); - this.resolveWhenComplete(); - } - if (this.#browserFrame.page.context.browser.settings.debug.traceWaitUntilComplete > 0) { - this.debugTrace.delete(timerID); - } - } - startImmediate(immediateID) { - if (this.destroyed) { - TIMER.clearImmediate(immediateID); - return; - } - if (this.waitUntilCompleteTimer) { - TIMER.clearTimeout(this.waitUntilCompleteTimer); - this.waitUntilCompleteTimer = null; - } - this.runningImmediates.push(immediateID); - if (this.#browserFrame.page?.context?.browser?.settings?.debug?.traceWaitUntilComplete > 0) { - this.debugTrace.set(immediateID, new AsyncTaskManagerDebugError().stack); - } - } - endImmediate(immediateID) { - if (this.destroyed) { - TIMER.clearImmediate(immediateID); - return; - } - const index = this.runningImmediates.indexOf(immediateID); - if (index !== -1) { - this.runningImmediates.splice(index, 1); - this.resolveWhenComplete(); - } - if (this.#browserFrame.page.context.browser.settings.debug.traceWaitUntilComplete > 0) { - this.debugTrace.delete(immediateID); - } - } - startTask(abortHandler) { - if (this.destroyed) { - if (abortHandler) { - abortHandler(this.destroyed); - } - throw new this.#browserFrame.window.Error(`Failed to execute 'startTask()' on 'AsyncTaskManager': The asynchronous task manager has been destroyed. This error can be thrown if scripts continue to run while a browser frame is closed.`); - } - if (this.waitUntilCompleteTimer) { - TIMER.clearTimeout(this.waitUntilCompleteTimer); - this.waitUntilCompleteTimer = null; - } - const taskID = this.newTaskID(); - this.runningTasks[taskID] = abortHandler ? abortHandler : () => {}; - this.runningTaskCount++; - if (this.#browserFrame.page.context.browser.settings.debug.traceWaitUntilComplete > 0) { - this.debugTrace.set(taskID, new AsyncTaskManagerDebugError().stack); - } - return taskID; - } - endTask(taskID) { - if (this.destroyed) { - return; - } - if (this.runningTasks[taskID]) { - delete this.runningTasks[taskID]; - this.runningTaskCount--; - this.resolveWhenComplete(); - } - if (this.#browserFrame.page.context.browser.settings.debug.traceWaitUntilComplete > 0) { - this.debugTrace.delete(taskID); - } - } - getTaskCount() { - return this.runningTaskCount; - } - newTaskID() { - this.constructor.taskID++; - return this.constructor.taskID; - } - resolveWhenComplete() { - this.applyDebugging(); - if (this.runningTaskCount || this.runningTimers.length || this.runningImmediates.length) { - return; - } - if (this.waitUntilCompleteTimer) { - TIMER.clearTimeout(this.waitUntilCompleteTimer); - this.waitUntilCompleteTimer = null; - } - this.waitUntilCompleteTimer = TIMER.setTimeout(() => { - this.waitUntilCompleteTimer = null; - if (!this.runningTaskCount && !this.runningTimers.length && !this.runningImmediates.length) { - if (this.#debugTimeout) { - TIMER.clearTimeout(this.#debugTimeout); - } - const resolvers = this.waitUntilCompleteResolvers; - this.waitUntilCompleteResolvers = []; - for (const resolver of resolvers) { - resolver.resolve(); - } - this.destroyed = false; - } else { - this.applyDebugging(); - } - }, 1); - } - applyDebugging() { - const debug = this.#browserFrame.page.context.browser.settings.debug; - if (!debug?.traceWaitUntilComplete || debug.traceWaitUntilComplete < 1) { - return; - } - if (this.#debugTimeout) { - return; - } - this.#debugTimeout = TIMER.setTimeout(() => { - this.#debugTimeout = null; - let errorMessage = `The maximum time was reached for "waitUntilComplete()". - -${this.debugTrace.size} task${this.debugTrace.size === 1 ? "" : "s"} did not end in time. - -The following traces were recorded: - -`; - let number = 1; - for (const [key, value] of this.debugTrace.entries()) { - const type = typeof key === "number" ? "Task" : "Timer"; - errorMessage += `${type} #${number} -\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E\u203E${value.replace(/AsyncTaskManagerDebugError:{0,1}/, "").replace(/\s+at /gm, ` -> `)} - -`; - number++; - } - const error = new Error(errorMessage); - for (const resolver of this.waitUntilCompleteResolvers) { - resolver.reject(error); - } - this.abortAll(true); - }, debug.traceWaitUntilComplete); - } - abortAll(destroy) { - const runningTimers = this.runningTimers; - const runningImmediates = this.runningImmediates; - const runningTasks = this.runningTasks; - if (destroy) { - this.destroyed = true; - } - this.runningTasks = {}; - this.runningTaskCount = 0; - this.runningImmediates = []; - this.runningTimers = []; - this.debugTrace = new Map; - if (this.waitUntilCompleteTimer) { - TIMER.clearTimeout(this.waitUntilCompleteTimer); - this.waitUntilCompleteTimer = null; - } - for (const immediate of runningImmediates) { - TIMER.clearImmediate(immediate); - } - for (const timer of runningTimers) { - TIMER.clearTimeout(timer); - } - for (const key of Object.keys(runningTasks)) { - runningTasks[key](destroy); - } - return new Promise((resolve, reject) => { - this.waitUntilCompleteResolvers.push({ resolve, reject }); - this.resolveWhenComplete(); - }); - } -} - -// node_modules/happy-dom/lib/window/BrowserWindow.js -import { Buffer as Buffer8 } from "buffer"; -import { webcrypto } from "crypto"; -import { TextEncoder, TextDecoder as TextDecoder2 } from "util"; -import Stream3 from "stream"; -import { ReadableStream as ReadableStream4 } from "stream/web"; -import { URLSearchParams as URLSearchParams4 } from "url"; -import VM from "vm"; - -// node_modules/happy-dom/lib/base64/Base64.js -var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - -class Base64 { - static btoa(data) { - const str = data.toString(); - if (/[^\u0000-\u00ff]/.test(str)) { - throw new DOMException("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.", DOMExceptionNameEnum_default.invalidCharacterError); - } - let t = ""; - let p = -6; - let a = 0; - let i = 0; - let v = 0; - let c; - while (i < str.length || p > -6) { - if (p < 0) { - if (i < str.length) { - c = str.charCodeAt(i++); - v += 8; - } else { - c = 0; - } - a = (a & 255) << 8 | c & 255; - p += 8; - } - t += BASE64_CHARS.charAt(v > 0 ? a >> p & 63 : 64); - p -= 6; - v -= 6; - } - return t; - } - static atob(data) { - const str = data.toString(); - if (/[^\u0000-\u00ff]/.test(str)) { - throw new DOMException("Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range.", DOMExceptionNameEnum_default.invalidCharacterError); - } - if (/[^A-Za-z\d+/=]/.test(str) || str.length % 4 == 1) { - throw new DOMException("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.", DOMExceptionNameEnum_default.invalidCharacterError); - } - let t = ""; - let p = -8; - let a = 0; - let c; - let d; - for (let i = 0;i < str.length; i++) { - if ((c = BASE64_CHARS.indexOf(str.charAt(i))) < 0) { - continue; - } - a = a << 6 | c & 63; - if ((p += 6) >= 0) { - d = a >> p & 255; - if (c !== 64) { - t += String.fromCharCode(d); - } - a &= 63; - p -= 8; - } - } - return t; - } -} - -// node_modules/happy-dom/lib/browser/enums/BrowserErrorCaptureEnum.js -var BrowserErrorCaptureEnum; -(function(BrowserErrorCaptureEnum) { - BrowserErrorCaptureEnum["tryAndCatch"] = "tryAndCatch"; - BrowserErrorCaptureEnum["processLevel"] = "processLevel"; - BrowserErrorCaptureEnum["disabled"] = "disabled"; -})(BrowserErrorCaptureEnum || (BrowserErrorCaptureEnum = {})); -var BrowserErrorCaptureEnum_default = BrowserErrorCaptureEnum; - -// node_modules/happy-dom/lib/file/Blob.js -import { Buffer as Buffer2 } from "buffer"; -import { ReadableStream } from "stream/web"; -class Blob { - type = ""; - [buffer]; - constructor(bits, options) { - const buffers = []; - if (bits) { - for (const bit of bits) { - let buffer2; - if (bit instanceof ArrayBuffer) { - buffer2 = Buffer2.from(new Uint8Array(bit)); - } else if (bit instanceof Blob) { - buffer2 = bit[buffer]; - } else if (bit instanceof Buffer2) { - buffer2 = bit; - } else if (ArrayBuffer.isView(bit)) { - buffer2 = Buffer2.from(new Uint8Array(bit.buffer, bit.byteOffset, bit.byteLength)); - } else { - buffer2 = Buffer2.from(typeof bit === "string" ? bit : String(bit)); - } - buffers.push(buffer2); - } - } - this[buffer] = Buffer2.concat(buffers); - if (options && options.type && options.type.match(/^[\u0020-\u007E]*$/)) { - this.type = String(options.type).toLowerCase(); - } - } - get size() { - return this[buffer].length; - } - slice(start = 0, end = null, contentType = "") { - const size = this.size; - let relativeStart; - let relativeEnd; - let relativeContentType; - if (start === undefined) { - relativeStart = 0; - } else if (start < 0) { - relativeStart = Math.max(size + start, 0); - } else { - relativeStart = Math.min(start, size); - } - if (end === null) { - relativeEnd = size; - } else if (end < 0) { - relativeEnd = Math.max(size + end, 0); - } else { - relativeEnd = Math.min(end, size); - } - if (contentType === undefined) { - relativeContentType = ""; - } else { - relativeContentType = contentType; - } - const span = Math.max(relativeEnd - relativeStart, 0); - const buffer2 = this[buffer]; - const slicedBuffer = buffer2.slice(relativeStart, relativeStart + span); - const blob = new Blob([], { type: relativeContentType }); - blob[buffer] = slicedBuffer; - return blob; - } - async arrayBuffer() { - return new Uint8Array(this[buffer]).buffer; - } - async text() { - return this[buffer].toString(); - } - stream() { - const buffer2 = this[buffer]; - return new ReadableStream({ - start(controller) { - controller.enqueue(buffer2); - controller.close(); - } - }); - } - toString() { - return "[object Blob]"; - } -} - -// node_modules/happy-dom/lib/clipboard/Clipboard.js -class Clipboard { - #window; - #data = []; - constructor(window) { - if (!window) { - throw new TypeError("Illegal constructor"); - } - this.#window = window; - } - async read() { - const permissionStatus = await this.#window.navigator.permissions.query({ - name: "clipboard-read" - }); - if (permissionStatus.state === "denied") { - throw new this.#window.DOMException(`Failed to execute 'read' on 'Clipboard': The request is not allowed`); - } - return this.#data; - } - async readText() { - const permissionStatus = await this.#window.navigator.permissions.query({ - name: "clipboard-read" - }); - if (permissionStatus.state === "denied") { - throw new this.#window.DOMException(`Failed to execute 'readText' on 'Clipboard': The request is not allowed`); - } - let text = ""; - for (const item of this.#data) { - if (item.types.includes("text/plain")) { - const data = await item.getType("text/plain"); - if (typeof data === "string") { - text += data; - } else { - text += await data.text(); - } - } - } - return text; - } - async write(data) { - const permissionStatus = await this.#window.navigator.permissions.query({ - name: "clipboard-write" - }); - if (permissionStatus.state === "denied") { - throw new this.#window.DOMException(`Failed to execute 'write' on 'Clipboard': The request is not allowed`); - } - this.#data = data; - } - async writeText(text) { - const permissionStatus = await this.#window.navigator.permissions.query({ - name: "clipboard-write" - }); - if (permissionStatus.state === "denied") { - throw new this.#window.DOMException(`Failed to execute 'writeText' on 'Clipboard': The request is not allowed`); - } - this.#data = [ - new this.#window.ClipboardItem({ "text/plain": new Blob([text], { type: "text/plain" }) }) - ]; - } -} - -// node_modules/happy-dom/lib/clipboard/ClipboardItem.js -class ClipboardItem { - presentationStyle = "unspecified"; - #data; - constructor(data, options) { - this.#data = data; - if (options?.presentationStyle) { - this.presentationStyle = options.presentationStyle; - } - } - get types() { - return Object.keys(this.#data); - } - async getType(type) { - if (!this.#data[type]) { - throw new DOMException(`Failed to execute 'getType' on 'ClipboardItem': The type '${type}' was not found`); - } - if (this.#data[type] instanceof Blob) { - return this.#data[type]; - } - return new Blob([await this.#data[type]], { type }); - } -} - -// node_modules/happy-dom/lib/window/WindowBrowserContext.js -class WindowBrowserContext { - static [browserFrames] = new Map; - static [windowInternalId] = 0; - #window; - constructor(window) { - this.#window = window; - } - getSettings() { - return this.getBrowserFrame()?.page.context.browser.settings || null; - } - getBrowser() { - return this.getBrowserFrame()?.page.context.browser || null; - } - getBrowserPage() { - return this.getBrowserFrame()?.page || null; - } - getBrowserContext() { - return this.getBrowserFrame()?.page.context || null; - } - getBrowserFrame() { - if (!this.#window) { - return null; - } - return this.constructor[browserFrames].get(this.#window[internalId]) || null; - } - getAsyncTaskManager() { - return this.getBrowserFrame()?.[asyncTaskManager] || null; - } - static setWindowBrowserFrameRelation(window, browserFrame) { - const browserFrames2 = this[browserFrames]; - if (window[internalId] === -1) { - window[internalId] = this[windowInternalId]; - this[windowInternalId]++; - } - browserFrames2.set(window[internalId], browserFrame); - } - static removeWindowBrowserFrameRelation(window) { - this[browserFrames].delete(window[internalId]); - } -} - -// node_modules/happy-dom/lib/event/EventTarget.js -class EventTarget { - [listeners] = { - capturing: new Map, - bubbling: new Map - }; - [listenerOptions] = { - capturing: new Map, - bubbling: new Map - }; - get [Symbol.toStringTag]() { - return "EventTarget"; - } - addEventListener(type, listener, options) { - options = typeof options === "boolean" ? { capture: options } : options || {}; - const eventPhase = options.capture ? "capturing" : "bubbling"; - let listeners2 = this[listeners][eventPhase].get(type); - let listenerOptions2; - if (listeners2) { - listenerOptions2 = this[listenerOptions][eventPhase].get(type); - } else { - listeners2 = []; - listenerOptions2 = []; - this[listeners][eventPhase].set(type, listeners2); - this[listenerOptions][eventPhase].set(type, listenerOptions2); - } - if (listeners2.includes(listener)) { - return; - } - listeners2.push(listener); - listenerOptions2.push(options); - if (options.signal && !options.signal.aborted) { - options.signal.addEventListener("abort", () => { - this.removeEventListener(type, listener); - }); - } - } - removeEventListener(type, listener) { - const bubblingListeners = this[listeners].bubbling.get(type); - if (bubblingListeners) { - const index = bubblingListeners.indexOf(listener); - if (index !== -1) { - bubblingListeners.splice(index, 1); - this[listenerOptions].bubbling.get(type).splice(index, 1); - return; - } - } - const capturingListeners = this[listeners].capturing.get(type); - if (capturingListeners) { - const index = capturingListeners.indexOf(listener); - if (index !== -1) { - capturingListeners.splice(index, 1); - this[listenerOptions].capturing.get(type).splice(index, 1); - } - } - } - dispatchEvent(event) { - if (!(event instanceof Event)) { - throw new this[window].TypeError(`Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`); - } - if (!event[dispatching] && (event[type] !== "load" || !event[target])) { - event[dispatching] = true; - event[target] = this[proxy] || this; - this.#goThroughDispatchEventPhases(event); - event[dispatching] = false; - return !(event[cancelable] && event[defaultPrevented]); - } - this.#callDispatchEventListeners(event); - return !(event[cancelable] && event[defaultPrevented]); - } - attachEvent(type, listener) { - this.addEventListener(type.replace("on", ""), listener); - } - detachEvent(type, listener) { - this.removeEventListener(type.replace("on", ""), listener); - } - [destroy]() { - this[listeners].capturing.clear(); - this[listeners].bubbling.clear(); - this[listenerOptions].capturing.clear(); - this[listenerOptions].bubbling.clear(); - } - #goThroughDispatchEventPhases(event) { - const composedPath = event.composedPath(); - event[eventPhase] = EventPhaseEnum_default.capturing; - for (let i = composedPath.length - 1;i >= 0; i--) { - event[currentTarget] = composedPath[i]; - composedPath[i].dispatchEvent(event); - if (event[propagationStopped] || event[immediatePropagationStopped]) { - event[eventPhase] = EventPhaseEnum_default.none; - event[currentTarget] = null; - return; - } - } - event[eventPhase] = EventPhaseEnum_default.atTarget; - event[currentTarget] = this[proxy] || this; - event[target].dispatchEvent(event); - event[eventPhase] = EventPhaseEnum_default.bubbling; - if (event[bubbles] && !event[propagationStopped] && !event[immediatePropagationStopped]) { - for (let i = 1, max = composedPath.length;i < max; i++) { - event[currentTarget] = composedPath[i]; - composedPath[i].dispatchEvent(event); - if (event[propagationStopped] || event[immediatePropagationStopped]) { - event[eventPhase] = EventPhaseEnum_default.none; - event[currentTarget] = null; - return; - } - } - } - event[eventPhase] = EventPhaseEnum_default.none; - event[currentTarget] = null; - } - #callDispatchEventListeners(event) { - const window2 = this[window]; - const browserSettings = window2 ? new WindowBrowserContext(window2).getSettings() : null; - const eventPhase = event.eventPhase === EventPhaseEnum_default.capturing ? "capturing" : "bubbling"; - const listeners2 = this[listeners][eventPhase].get(event.type)?.slice(); - if (listeners2 && listeners2.length) { - const listenerOptions2 = this[listenerOptions][eventPhase].get(event.type).slice(); - for (let i = 0, max = listeners2.length;i < max; i++) { - const listener = listeners2[i]; - const options = listenerOptions2[i]; - if (options?.passive) { - event[isInPassiveEventListener] = true; - } - if (window2 && (this !== window2 || event.type !== "error") && !browserSettings?.disableErrorCapturing && browserSettings?.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - if (listener.handleEvent) { - let result; - try { - result = listener.handleEvent.call(listener, event); - } catch (error) { - window2[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => window2[dispatchError](error)); - } - } else { - let result; - try { - result = listener.call(this, event); - } catch (error) { - window2[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => window2[dispatchError](error)); - } - } - } else { - if (listener.handleEvent) { - listener.handleEvent.call(listener, event); - } else { - listener.call(this, event); - } - } - event[isInPassiveEventListener] = false; - if (options?.once) { - listeners2.splice(i, 1); - listenerOptions2.splice(i, 1); - this.removeEventListener(event.type, listener); - i--; - max--; - } - if (event[immediatePropagationStopped]) { - return; - } - } - } - if (event.eventPhase !== EventPhaseEnum_default.capturing) { - const onEventName = "on" + event.type.toLowerCase(); - const propertyEventListeners2 = this[propertyEventListeners]; - const hasClassDefinedHandler = !propertyEventListeners2 && Object.hasOwn(this, onEventName) && this.constructor.name !== "EventTarget"; - if (propertyEventListeners2 || hasClassDefinedHandler) { - const eventListener = propertyEventListeners2?.get(onEventName) ?? this[onEventName]; - if (typeof eventListener === "function") { - if (window2 && (this !== window2 || event.type !== "error") && !browserSettings?.disableErrorCapturing && browserSettings?.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - let result; - try { - result = eventListener(event); - } catch (error) { - window2[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => window2[dispatchError](error)); - } - } else { - eventListener(event); - } - } - } - } - } -} - -// node_modules/happy-dom/lib/event/events/CookieChangeEvent.js -class CookieChangeEvent extends Event { - changed; - deleted; - constructor(type, eventInit = null) { - super(type, eventInit); - this.changed = eventInit?.changed ?? []; - this.deleted = eventInit?.deleted ?? []; - } -} - -// node_modules/happy-dom/lib/url/URL.js -import { URL as NodeJSURL } from "url"; -import { Blob as NodeJSBlob } from "buffer"; -class URL2 extends NodeJSURL { - constructor(url, base) { - try { - super(url, base); - } catch (error) { - super("about:blank"); - if (this[window]) { - throw new this[window].TypeError("Invalid URL"); - } - throw error; - } - } - static createObjectURL(object) { - if (object instanceof Blob) { - const blob = new NodeJSBlob([object[buffer]], { type: object.type }); - return super.createObjectURL(blob); - } - return super.createObjectURL(object); - } -} - -// node_modules/happy-dom/lib/cookie-store/CookieStore.js -class CookieStore extends EventTarget { - #window; - constructor(illegalConstructorSymbol, window) { - super(); - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this.#window = window; - } - async get(nameOrOptions) { - const cookies = await this.getAll(nameOrOptions); - return cookies.length > 0 ? cookies[0] : null; - } - async getAll(nameOrOptions) { - const browserFrame = new WindowBrowserContext(this.#window).getBrowserFrame(); - if (!browserFrame) { - return []; - } - const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions || {}; - let targetURL; - if (options.url) { - targetURL = new URL2(options.url, this.#window.location.href); - if (targetURL.origin !== this.#window.location.origin) { - throw new this.#window.DOMException(`Failed to execute 'getAll' on 'CookieStore': URL must match the document origin`, DOMExceptionNameEnum_default.securityError); - } - } else { - targetURL = this.#window.location; - } - const internalCookies = browserFrame.page.context.cookieContainer.getCookies(targetURL, true); - const result = []; - for (const cookie of internalCookies) { - if (!options.name || cookie.key === options.name) { - result.push(this.#convertToStoreItem(cookie)); - } - } - return result; - } - async set(nameOrOptions, value) { - const browserFrame = new WindowBrowserContext(this.#window).getBrowserFrame(); - if (!browserFrame) { - return; - } - let options; - if (typeof nameOrOptions === "string") { - if (value === undefined) { - throw new this.#window.TypeError(`Failed to execute 'set' on 'CookieStore': Value is required when name is provided as a string.`); - } - options = { name: nameOrOptions, value }; - } else { - options = { ...nameOrOptions, value: nameOrOptions.value ?? "" }; - } - if (!options.name) { - throw new this.#window.TypeError(`Failed to execute 'set' on 'CookieStore': Required member name is undefined.`); - } - const originURL = this.#window.location; - let expires = null; - if (options.expires !== undefined && options.expires !== null) { - expires = options.expires instanceof Date ? options.expires : new Date(options.expires); - } - let sameSite = CookieSameSiteEnum_default.strict; - if (options.sameSite) { - switch (options.sameSite.toLowerCase()) { - case "strict": - sameSite = CookieSameSiteEnum_default.strict; - break; - case "lax": - sameSite = CookieSameSiteEnum_default.lax; - break; - case "none": - sameSite = CookieSameSiteEnum_default.none; - break; - } - } - const cookie = { - key: options.name, - value: options.value ?? "", - originURL, - domain: options.domain || "", - path: options.path || "/", - expires, - httpOnly: false, - secure: true, - sameSite - }; - const cookieContainer = browserFrame.page.context.cookieContainer; - const changedCookies = cookieContainer.addCookies([cookie]); - if (changedCookies.changed.length > 0 || changedCookies.deleted.length > 0) { - this.dispatchEvent(new CookieChangeEvent("change", { - changed: changedCookies.changed.map((cookie) => this.#convertToStoreItem(cookie)), - deleted: changedCookies.deleted.map((cookie) => this.#convertToStoreItem(cookie)) - })); - } - } - async delete(nameOrOptions) { - const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions; - await this.set({ - name: options.name, - value: "", - domain: options.domain ?? undefined, - path: options.path, - partitioned: options.partitioned, - expires: new Date(0) - }); - } - #convertToStoreItem(cookie) { - let sameSite = "lax"; - switch (cookie.sameSite) { - case CookieSameSiteEnum_default.strict: - sameSite = "strict"; - break; - case CookieSameSiteEnum_default.lax: - sameSite = "lax"; - break; - case CookieSameSiteEnum_default.none: - sameSite = "none"; - break; - } - return { - name: cookie.key, - value: cookie.value ?? "", - domain: cookie.domain, - path: cookie.path, - expires: cookie.expires ? cookie.expires.getTime() : null, - secure: cookie.secure, - sameSite, - partitioned: false - }; - } -} - -// node_modules/happy-dom/lib/css/utilities/CSSEscaper.js -class CSSEscaper { - static escape(cssText) { - if (arguments.length == 0) { - throw new TypeError("`CSS.escape` requires an argument."); - } - const returnValue = String(cssText); - const length = returnValue.length; - let index = -1; - let codeUnit; - let result = ""; - const firstCodeUnit = returnValue.charCodeAt(0); - if (length == 1 && firstCodeUnit == 45) { - return "\\" + returnValue; - } - while (++index < length) { - codeUnit = returnValue.charCodeAt(index); - if (codeUnit == 0) { - result += "\uFFFD"; - continue; - } - if (codeUnit >= 1 && codeUnit <= 31 || codeUnit == 127 || index == 0 && codeUnit >= 48 && codeUnit <= 57 || index == 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit == 45) { - result += "\\" + codeUnit.toString(16) + " "; - continue; - } - if (codeUnit >= 128 || codeUnit == 45 || codeUnit == 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) { - result += returnValue.charAt(index); - continue; - } - result += "\\" + returnValue.charAt(index); - } - return result; - } -} - -// node_modules/happy-dom/lib/css/CSSUnits.js -var CSSUnits_default = [ - "Hz", - "Q", - "ch", - "cm", - "deg", - "dpcm", - "dpi", - "dppx", - "em", - "ex", - "fr", - "grad", - "in", - "kHz", - "mm", - "ms", - "number", - "pc", - "percent", - "pt", - "px", - "rad", - "rem", - "s", - "turn", - "vh", - "vmax", - "vmin", - "vw" -]; - -// node_modules/happy-dom/lib/css/CSSUnitValue.js -class CSSUnitValue { - unit; - value; - constructor(value, unit) { - if (typeof value !== "number") { - throw new TypeError("The provided double value is non-finite"); - } - if (!CSSUnits_default.includes(unit)) { - throw new TypeError("Invalid unit: " + unit); - } - this.value = value; - this.unit = unit; - } -} - -// node_modules/happy-dom/lib/css/CSS.js -class CSS { - Hz = (value) => new CSSUnitValue(value, "Hz"); - Q = (value) => new CSSUnitValue(value, "Q"); - ch = (value) => new CSSUnitValue(value, "ch"); - cm = (value) => new CSSUnitValue(value, "cm"); - deg = (value) => new CSSUnitValue(value, "deg"); - dpcm = (value) => new CSSUnitValue(value, "dpcm"); - dpi = (value) => new CSSUnitValue(value, "dpi"); - dppx = (value) => new CSSUnitValue(value, "dppx"); - em = (value) => new CSSUnitValue(value, "em"); - ex = (value) => new CSSUnitValue(value, "ex"); - fr = (value) => new CSSUnitValue(value, "fr"); - grad = (value) => new CSSUnitValue(value, "grad"); - in = (value) => new CSSUnitValue(value, "in"); - kHz = (value) => new CSSUnitValue(value, "kHz"); - mm = (value) => new CSSUnitValue(value, "mm"); - ms = (value) => new CSSUnitValue(value, "ms"); - number = (value) => new CSSUnitValue(value, "number"); - pc = (value) => new CSSUnitValue(value, "pc"); - percent = (value) => new CSSUnitValue(value, "percent"); - pt = (value) => new CSSUnitValue(value, "pt"); - px = (value) => new CSSUnitValue(value, "px"); - rad = (value) => new CSSUnitValue(value, "rad"); - rem = (value) => new CSSUnitValue(value, "rem"); - s = (value) => new CSSUnitValue(value, "s"); - turn = (value) => new CSSUnitValue(value, "turn"); - vh = (value) => new CSSUnitValue(value, "vh"); - vmax = (value) => new CSSUnitValue(value, "vmax"); - vmin = (value) => new CSSUnitValue(value, "vmin"); - vw = (value) => new CSSUnitValue(value, "vw"); - supports(_condition, _value) { - return true; - } - escape(value) { - return CSSEscaper.escape(value); - } -} - -// node_modules/happy-dom/lib/css/CSSRuleTypeEnum.js -var CSSRuleTypeEnum; -(function(CSSRuleTypeEnum) { - CSSRuleTypeEnum[CSSRuleTypeEnum["containerRule"] = 0] = "containerRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["styleRule"] = 1] = "styleRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["importRule"] = 3] = "importRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["mediaRule"] = 4] = "mediaRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["fontFaceRule"] = 5] = "fontFaceRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["pageRule"] = 6] = "pageRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["keyframesRule"] = 7] = "keyframesRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["keyframeRule"] = 8] = "keyframeRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["namespaceRule"] = 10] = "namespaceRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["counterStyleRule"] = 11] = "counterStyleRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["supportsRule"] = 12] = "supportsRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["documentRule"] = 13] = "documentRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["fontFeatureValuesRule"] = 14] = "fontFeatureValuesRule"; - CSSRuleTypeEnum[CSSRuleTypeEnum["regionStyleRule"] = 16] = "regionStyleRule"; -})(CSSRuleTypeEnum || (CSSRuleTypeEnum = {})); -var CSSRuleTypeEnum_default = CSSRuleTypeEnum; - -// node_modules/happy-dom/lib/css/CSSRule.js -class CSSRule { - static CONTAINER_RULE = CSSRuleTypeEnum_default.containerRule; - static STYLE_RULE = CSSRuleTypeEnum_default.styleRule; - static IMPORT_RULE = CSSRuleTypeEnum_default.importRule; - static MEDIA_RULE = CSSRuleTypeEnum_default.mediaRule; - static FONT_FACE_RULE = CSSRuleTypeEnum_default.fontFaceRule; - static PAGE_RULE = CSSRuleTypeEnum_default.pageRule; - static KEYFRAMES_RULE = CSSRuleTypeEnum_default.keyframesRule; - static KEYFRAME_RULE = CSSRuleTypeEnum_default.keyframeRule; - static NAMESPACE_RULE = CSSRuleTypeEnum_default.namespaceRule; - static COUNTER_STYLE_RULE = CSSRuleTypeEnum_default.counterStyleRule; - static SUPPORTS_RULE = CSSRuleTypeEnum_default.supportsRule; - static DOCUMENT_RULE = CSSRuleTypeEnum_default.documentRule; - static FONT_FEATURE_VALUES_RULE = CSSRuleTypeEnum_default.fontFeatureValuesRule; - static REGION_STYLE_RULE = CSSRuleTypeEnum_default.regionStyleRule; - [window]; - [cssParser]; - [parentRule] = null; - [parentStyleSheet] = null; - constructor(illegalConstructorSymbol, window2, cssParser2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[cssParser] = cssParser2; - } - get parentRule() { - return this[parentRule]; - } - get parentStyleSheet() { - return this[parentStyleSheet]; - } -} - -// node_modules/happy-dom/lib/css/declaration/property-manager/CSSStyleDeclarationValueUtility.js -var SPLIT_BY_COMMA_REGEXP = /[,()]/gm; -var SPLIT_BY_SPACE_REGEXP = /[()]|\s+/gm; - -class CSSStyleDeclarationValueUtility { - static splitByComma(value) { - const parts = []; - const regexp = new RegExp(SPLIT_BY_COMMA_REGEXP); - let match; - let depth = 0; - let lastIndex = 0; - while (match = regexp.exec(value)) { - switch (match[0]) { - case "(": - depth++; - break; - case ")": - depth--; - break; - case ",": - if (depth === 0) { - const part = value.substring(lastIndex, match.index).trim(); - if (part) { - parts.push(part); - } - lastIndex = regexp.lastIndex; - } - break; - } - } - if (lastIndex < value.length) { - parts.push(value.substring(lastIndex).trim()); - } - return parts; - } - static splitBySpace(value) { - const parts = []; - const regexp = new RegExp(SPLIT_BY_SPACE_REGEXP); - let match; - let depth = 0; - let lastIndex = 0; - while (match = regexp.exec(value)) { - switch (match[0]) { - case "(": - depth++; - break; - case ")": - depth--; - break; - default: - if (depth === 0) { - const part = value.substring(lastIndex, match.index).trim(); - if (part) { - parts.push(part); - } - lastIndex = regexp.lastIndex; - } - break; - } - } - if (lastIndex < value.length) { - const part = value.substring(lastIndex).trim(); - if (part) { - parts.push(part); - } - } - return parts; - } -} - -// node_modules/happy-dom/lib/css/declaration/property-manager/CSSStyleDeclarationValueParser.js -var COLOR_REGEXP = /^#([0-9a-fA-F]{3,4}){1,2}$|^rgb\(([^)]*)\)$|^rgba\(([^)]*)\)$|^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)|(?:(rgba?|hsla?)\((var\(\s*(--[^)\s]+)\))\))/; -var LENGTH_REGEXP = /^(0|[-+]?[0-9]*\.?[0-9]+)(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw|ch|vw|vh|vmin|vmax|Q)$/; -var PERCENTAGE_REGEXP = /^[-+]?[0-9]*\.?[0-9]+%$/; -var DEGREE_REGEXP = /^[0-9]+deg$/; -var URL_REGEXP = /^url\(\s*([^)]*)\s*\)$/; -var INTEGER_REGEXP = /^[0-9]+$/; -var FLOAT_REGEXP = /^[0-9.]+$/; -var CALC_REGEXP = /^calc\([^^)]+\)$/; -var CSS_VARIABLE_REGEXP = /^var\(\s*(--[^)\s]+)\)$/; -var FIT_CONTENT_REGEXP = /^fit-content\([^^)]+\)$/; -var GRADIENT_REGEXP = /^((repeating-linear|linear|radial|repeating-radial|conic|repeating-conic)-gradient)\(((?:[^()]|\([^()]*\))*)\)$/; -var GLOBALS = ["inherit", "initial", "unset", "revert"]; -var COLORS = [ - "none", - "currentcolor", - "transparent", - "silver", - "gray", - "white", - "maroon", - "red", - "purple", - "fuchsia", - "green", - "lime", - "olive", - "yellow", - "navy", - "blue", - "teal", - "aliceblue", - "aqua", - "antiquewhite", - "aquamarine", - "azure", - "beige", - "bisque", - "black", - "blanchedalmond", - "blueviolet", - "brown", - "burlywood", - "cadetblue", - "chartreuse", - "chocolate", - "coral", - "cornflowerblue", - "cornsilk", - "crimson", - "cyan", - "darkblue", - "darkcyan", - "darkgoldenrod", - "darkgray", - "darkgreen", - "darkgrey", - "darkkhaki", - "darkmagenta", - "darkolivegreen", - "darkorange", - "darkorchid", - "darkred", - "darksalmon", - "darkseagreen", - "darkslateblue", - "darkslategray", - "darkslategrey", - "darkturquoise", - "darkviolet", - "deeppink", - "deepskyblue", - "dimgray", - "dimgrey", - "dodgerblue", - "firebrick", - "floralwhite", - "forestgreen", - "gainsboro", - "ghostwhite", - "gold", - "goldenrod", - "greenyellow", - "grey", - "honeydew", - "hotpink", - "indianred", - "indigo", - "ivory", - "khaki", - "lavender", - "lavenderblush", - "lawngreen", - "lemonchiffon", - "lightblue", - "lightcoral", - "lightcyan", - "lightgoldenrodyellow", - "lightgray", - "lightgreen", - "lightgrey", - "lightpink", - "lightsalmon", - "lightseagreen", - "lightskyblue", - "lightslategray", - "lightslategrey", - "lightsteelblue", - "lightyellow", - "limegreen", - "linen", - "magenta", - "mediumaquamarine", - "mediumblue", - "mediumorchid", - "mediumpurple", - "mediumseagreen", - "mediumslateblue", - "mediumspringgreen", - "mediumturquoise", - "mediumvioletred", - "midnightblue", - "mintcream", - "mistyrose", - "moccasin", - "navajowhite", - "oldlace", - "olivedrab", - "orange", - "orangered", - "orchid", - "palegoldenrod", - "palegreen", - "paleturquoise", - "palevioletred", - "papayawhip", - "peachpuff", - "peru", - "pink", - "plum", - "powderblue", - "rebeccapurple", - "rosybrown", - "royalblue", - "saddlebrown", - "salmon", - "sandybrown", - "seagreen", - "seashell", - "sienna", - "skyblue", - "slateblue", - "slategray", - "slategrey", - "snow", - "springgreen", - "steelblue", - "tan", - "thistle", - "tomato", - "turquoise", - "violet", - "wheat", - "whitesmoke", - "yellowgreen" -]; - -class CSSStyleDeclarationValueParser { - static getLength(value) { - if (value === "0") { - return "0px"; - } - const match = value.match(LENGTH_REGEXP); - if (match) { - const number = parseFloat(match[1]); - if (isNaN(number)) { - return null; - } - const unit = match[2]; - return `${Math.round(number * 1e6) / 1e6}${unit}`; - } - return null; - } - static getPercentage(value) { - if (value === "0") { - return "0%"; - } - if (PERCENTAGE_REGEXP.test(value)) { - return value; - } - return null; - } - static getDegree(value) { - if (value === "0") { - return "0deg"; - } - if (DEGREE_REGEXP.test(value)) { - return value; - } - return null; - } - static getCalc(value) { - if (CALC_REGEXP.test(value)) { - return value; - } - return null; - } - static getFitContent(value) { - const lowerValue = value.toLowerCase(); - if (lowerValue === "auto" || lowerValue === "max-content" || lowerValue === "min-content" || lowerValue === "fit-content") { - return lowerValue; - } - if (FIT_CONTENT_REGEXP.test(lowerValue)) { - return lowerValue; - } - return null; - } - static getMeasurement(value) { - return this.getLength(value) || this.getPercentage(value) || this.getCalc(value); - } - static getContentMeasurement(value) { - return this.getFitContent(value) || this.getMeasurement(value); - } - static getAutoMeasurement(value) { - if (value.toLocaleLowerCase() === "auto") { - return "auto"; - } - return this.getMeasurement(value); - } - static getInteger(value) { - if (INTEGER_REGEXP.test(value)) { - return value; - } - return null; - } - static getFloat(value) { - if (FLOAT_REGEXP.test(value)) { - const number = parseFloat(value); - if (isNaN(number)) { - return null; - } - return String(Math.round(number * 1e6) / 1e6); - } - return null; - } - static getGradient(value) { - const match = value.match(GRADIENT_REGEXP); - if (match) { - const args = match[3].trim(); - const parts = CSSStyleDeclarationValueUtility.splitByComma(args); - return `${match[1]}(${parts.join(", ")})`; - } - return null; - } - static getColor(value) { - const lowerValue = value.toLowerCase(); - if (COLORS.includes(lowerValue)) { - return lowerValue; - } - if (COLOR_REGEXP.test(value)) { - return value.replace(/,([^ ])/g, ", $1"); - } - return null; - } - static getURL(value) { - if (!value) { - return null; - } - if (value.toLowerCase() === "none") { - return "none"; - } - const result = URL_REGEXP.exec(value); - if (!result) { - return null; - } - let url = result[1].trim(); - if ((url[0] === '"' || url[0] === "'") && url[0] !== url[url.length - 1]) { - return null; - } - if (url[0] === '"' || url[0] === "'") { - url = url.substring(1, url.length - 1); - } - for (let i = 0;i < url.length; i++) { - switch (url[i]) { - case "(": - case ")": - case " ": - case "\t": - case ` -`: - case "'": - case '"': - return null; - case "\\": - i++; - break; - } - } - return `url("${url}")`; - } - static getInitial(value) { - return value.toLowerCase() === "initial" ? "initial" : null; - } - static getVariable(value) { - const cssVariableMatch = value.match(CSS_VARIABLE_REGEXP); - if (cssVariableMatch) { - return `var(${cssVariableMatch[1]})`; - } - return null; - } - static getGlobal(value) { - const lowerValue = value.toLowerCase(); - return GLOBALS.includes(lowerValue) ? lowerValue : null; - } - static getGlobalExceptInitial(value) { - const lowerValue = value.toLowerCase(); - return lowerValue !== "initial" && GLOBALS.includes(lowerValue) ? lowerValue : null; - } -} - -// node_modules/happy-dom/lib/css/declaration/property-manager/CSSStyleDeclarationPropertySetParser.js -var RECT_REGEXP = /^rect\((.*)\)$/i; -var SPLIT_COMMA_SEPARATED_WITH_PARANTHESES_REGEXP = /,(?=(?:(?:(?!\))[\s\S])*\()|[^\(\)]*$)/; -var SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP = /\s+(?=(?:(?:(?!\))[\s\S])*\()|[^\(\)]*$)/; -var WHITE_SPACE_GLOBAL_REGEXP = /\s+/gm; -var BORDER_STYLE = [ - "none", - "hidden", - "dotted", - "dashed", - "solid", - "double", - "groove", - "ridge", - "inset", - "outset" -]; -var BORDER_WIDTH = ["thin", "medium", "thick"]; -var BORDER_COLLAPSE = ["separate", "collapse"]; -var BACKGROUND_REPEAT = ["repeat", "repeat-x", "repeat-y", "no-repeat"]; -var BACKGROUND_ORIGIN = ["border-box", "padding-box", "content-box"]; -var BACKGROUND_CLIP = ["border-box", "padding-box", "content-box"]; -var BACKGROUND_ATTACHMENT = ["scroll", "fixed"]; -var FLEX_BASIS = ["auto", "fill", "content"]; -var CLEAR = ["none", "left", "right", "both"]; -var FLOAT = ["none", "left", "right", "inline-start", "inline-end"]; -var SYSTEM_FONT = ["caption", "icon", "menu", "message-box", "small-caption", "status-bar"]; -var FONT_WEIGHT = ["normal", "bold", "bolder", "lighter"]; -var FONT_STYLE = ["normal", "italic", "oblique"]; -var FONT_SIZE = [ - "xx-small", - "x-small", - "small", - "medium", - "large", - "x-large", - "xx-large", - "xxx-large", - "smaller", - "larger" -]; -var FONT_STRETCH = [ - "ultra-condensed", - "extra-condensed", - "condensed", - "semi-condensed", - "normal", - "semi-expanded", - "expanded", - "extra-expanded", - "ultra-expanded" -]; -var DISPLAY = [ - "block", - "inline", - "inline-block", - "flex", - "inline-flex", - "grid", - "inline-grid", - "flow-root", - "none", - "contents", - "block flow", - "inline flow", - "inline flow-root", - "block flex", - "inline flex", - "block grid", - "inline grid", - "block flow-root", - "table", - "table-row", - "list-item" -]; -var BORDER_IMAGE_REPEAT = ["stretch", "repeat", "round", "space"]; -var TEXT_TRANSFORM = [ - "capitalize", - "uppercase", - "lowercase", - "none", - "full-width", - "full-size-kana" -]; -var VISIBILITY = ["visible", "hidden", "collapse"]; - -class CSSStyleDeclarationPropertySetParser { - static getBorderCollapse(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-collapse": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_COLLAPSE.includes(lowerValue)) { - return { "border-collapse": { value: lowerValue, important } }; - } - return null; - } - static getDisplay(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { display: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || DISPLAY.includes(lowerValue)) { - return { display: { value: lowerValue, important } }; - } - return null; - } - static getDirection(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { direction: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "ltr" || lowerValue === "rtl") { - return { direction: { value: lowerValue, important } }; - } - return null; - } - static getLetterSpacing(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { "letter-spacing": { value: parsedValue, important } } : null; - } - static getWordSpacing(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { "word-spacing": { value: parsedValue, important } } : null; - } - static getTextIndent(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { "text-indent": { value: parsedValue, important } } : null; - } - static getWidth(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { width: { value: parsedValue, important } } : null; - } - static getHeight(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { height: { value: parsedValue, important } } : null; - } - static getTop(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { top: { value: parsedValue, important } } : null; - } - static getRight(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { right: { value: parsedValue, important } } : null; - } - static getBottom(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { bottom: { value: parsedValue, important } } : null; - } - static getLeft(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getContentMeasurement(value); - return parsedValue ? { left: { value: parsedValue, important } } : null; - } - static getClear(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { clear: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || CLEAR.includes(lowerValue)) { - return { clear: { value: lowerValue, important } }; - } - return null; - } - static getClip(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { clip: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "auto") { - return { clip: { value: lowerValue, important } }; - } - const matches = lowerValue.match(RECT_REGEXP); - if (!matches) { - return null; - } - const parts = matches[1].split(/\s*,\s*/); - if (parts.length !== 4) { - return null; - } - for (const part of parts) { - if (!CSSStyleDeclarationValueParser.getMeasurement(part)) { - return null; - } - } - return { clip: { value, important } }; - } - static getFloat(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { float: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FLOAT.includes(lowerValue)) { - return { float: { value: lowerValue, important } }; - } - return null; - } - static getCSSFloat(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "css-float": { value: variable, important } }; - } - const float = this.getFloat(value, important); - return float ? { "css-float": float["float"] } : null; - } - static getOutline(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { outline: { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getOutlineColor(globalValue, important), - ...this.getOutlineStyle(globalValue, important), - ...this.getOutlineWidth(globalValue, important) - }; - } - const properties = { - ...this.getOutlineColor("initial", important), - ...this.getOutlineStyle("initial", important), - ...this.getOutlineWidth("initial", important) - }; - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getOutlineWidth(part, important); - const style = this.getOutlineStyle(part, important); - const color = this.getOutlineColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getOutlineColor(value, important) { - const color = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - "outline-color": { value: color, important } - } : null; - } - static getOutlineOffset(value, important) { - const parsedValue = CSSStyleDeclarationValueParser.getVariable(value) || CSSStyleDeclarationValueParser.getLength(value); - return parsedValue ? { "outline-offset": { value: parsedValue, important } } : null; - } - static getOutlineStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "outline-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) { - return { - "outline-style": { value: lowerValue, important } - }; - } - return null; - } - static getOutlineWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "outline-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue) ? lowerValue : CSSStyleDeclarationValueParser.getLength(value); - if (parsedValue) { - return { - "outline-width": { value: parsedValue, important } - }; - } - return null; - } - static getBorder(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { border: { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderWidth(globalValue, important), - ...this.getBorderStyle(globalValue, important), - ...this.getBorderColor(globalValue, important), - ...this.getBorderImage(globalValue, important) - }; - } - const properties = { - ...this.getBorderWidth("initial", important), - ...this.getBorderStyle("initial", important), - ...this.getBorderColor("initial", important), - ...this.getBorderImage("initial", important) - }; - const parts = value.replace(/\s*,\s*/g, ",").split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getBorderWidth(part, important); - const style = this.getBorderStyle(part, important); - const color = this.getBorderColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getBorderWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-width": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderTopWidth(globalValue, important), - ...this.getBorderRightWidth(globalValue, important), - ...this.getBorderBottomWidth(globalValue, important), - ...this.getBorderLeftWidth(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const top = this.getBorderTopWidth(parts[0], important); - const right = this.getBorderRightWidth(parts[1] || parts[0], important); - const bottom = this.getBorderBottomWidth(parts[2] || parts[0], important); - const left = this.getBorderLeftWidth(parts[3] || parts[1] || parts[0], important); - if (!top || !right || !bottom || !left) { - return null; - } - return { - ...top, - ...right, - ...bottom, - ...left - }; - } - static getBorderStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-style": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderTopStyle(globalValue, important), - ...this.getBorderRightStyle(globalValue, important), - ...this.getBorderBottomStyle(globalValue, important), - ...this.getBorderLeftStyle(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const top = this.getBorderTopStyle(parts[0], important); - const right = this.getBorderRightStyle(parts[1] || parts[0], important); - const bottom = this.getBorderBottomStyle(parts[2] || parts[0], important); - const left = this.getBorderLeftStyle(parts[3] || parts[1] || parts[0], important); - if (!top || !right || !bottom || !left) { - return null; - } - return { - ...top, - ...right, - ...bottom, - ...left - }; - } - static getBorderColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-color": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderTopColor(globalValue, important), - ...this.getBorderRightColor(globalValue, important), - ...this.getBorderBottomColor(globalValue, important), - ...this.getBorderLeftColor(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const top = this.getBorderTopColor(parts[0], important); - const right = this.getBorderRightColor(parts[1] || parts[0], important); - const bottom = this.getBorderBottomColor(parts[2] || parts[0], important); - const left = this.getBorderLeftColor(parts[3] || parts[1] || parts[0], important); - if (!top || !right || !bottom || !left) { - return null; - } - return { - ...top, - ...right, - ...bottom, - ...left - }; - } - static getBorderImage(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderImageSource(globalValue, important), - ...this.getBorderImageSlice(globalValue, important), - ...this.getBorderImageWidth(globalValue, important), - ...this.getBorderImageOutset(globalValue, important), - ...this.getBorderImageRepeat(globalValue, important) - }; - } - let parsedValue = value.replace(/\s\/\s/g, "/"); - const sourceMatch = parsedValue.match(/\s*([a-zA-Z-]+\([^)]*\))\s*/); - if (sourceMatch) { - parsedValue = parsedValue.replace(sourceMatch[0], ""); - } - const parts = parsedValue.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (sourceMatch) { - parts.push(sourceMatch[1]); - } - const properties = { - ...this.getBorderImageSource("none", important), - ...this.getBorderImageSlice("100%", important), - ...this.getBorderImageWidth("1", important), - ...this.getBorderImageOutset("0", important), - ...this.getBorderImageRepeat("stretch", important) - }; - for (let i = 0, max = parts.length;i < max; i++) { - const part = parts[i]; - const previousPart = i > 0 ? parts[i - 1] : ""; - if (!part.startsWith("url") && part.includes("/")) { - const [slice, width, outset] = part.split("/"); - const borderImageSlice = this.getBorderImageSlice(`${previousPart} ${slice}`, important) || this.getBorderImageSlice(slice, important); - const borderImageWidth = this.getBorderImageWidth(width, important); - const borderImageOutset = outset && this.getBorderImageOutset(outset, important); - if (!borderImageSlice || !borderImageWidth || borderImageOutset === null) { - return null; - } - Object.assign(properties, borderImageSlice, borderImageWidth, borderImageOutset); - } else { - const slice = this.getBorderImageSlice(`${previousPart} ${part}`, important) || this.getBorderImageSlice(part, important); - const source = this.getBorderImageSource(part, important); - const repeat = this.getBorderImageRepeat(part, important); - if (!slice && !source && !repeat) { - return null; - } - Object.assign(properties, slice, source, repeat); - } - } - return properties; - } - static getBorderImageSource(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image-source": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "none") { - return { - "border-image-source": { - important, - value: lowerValue - } - }; - } - const parsedValue = CSSStyleDeclarationValueParser.getURL(value) || CSSStyleDeclarationValueParser.getGradient(value); - if (!parsedValue) { - return null; - } - return { - "border-image-source": { - important, - value: parsedValue - } - }; - } - static getBorderImageSlice(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image-slice": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { - "border-image-slice": { - important, - value: lowerValue - } - }; - } - if (lowerValue !== lowerValue.trim()) { - return null; - } - const regexp = /(fill)|(calc\([^^)]+\))|([0-9]+%)|([0-9]+)/g; - const values = []; - let match; - while (match = regexp.exec(lowerValue)) { - const previousCharacter = lowerValue[match.index - 1]; - const nextCharacter = lowerValue[match.index + match[0].length]; - if (previousCharacter && previousCharacter !== " " || nextCharacter && nextCharacter !== " ") { - return null; - } - const fill = match[1] && "fill"; - const calc = match[2] && CSSStyleDeclarationValueParser.getCalc(match[2]); - const percentage = match[3] && CSSStyleDeclarationValueParser.getPercentage(match[3]); - const integer = match[4] && CSSStyleDeclarationValueParser.getInteger(match[4]); - if (!fill && !calc && !percentage && !integer) { - return null; - } - values.push(fill || calc || percentage || integer); - } - if (!values.length || values.length > 4) { - return null; - } - return { - "border-image-slice": { - important, - value: values.join(" ") - } - }; - } - static getBorderImageWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { - "border-image-width": { - important, - value: lowerValue - } - }; - } - const parts = lowerValue.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parts.length > 4) { - return null; - } - for (const part of parts) { - if (!CSSStyleDeclarationValueParser.getInteger(part) && !CSSStyleDeclarationValueParser.getAutoMeasurement(part)) { - return null; - } - } - return { - "border-image-width": { - important, - value - } - }; - } - static getBorderImageOutset(value, important) { - if (value === "0") { - return { - "border-image-outset": { - important, - value - } - }; - } - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image-outset": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { - "border-image-outset": { - important, - value: lowerValue - } - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parts.length > 4) { - return null; - } - const newParts = []; - for (const part of parts) { - const parsedValue = CSSStyleDeclarationValueParser.getLength(part) || CSSStyleDeclarationValueParser.getFloat(part); - if (!parsedValue) { - return null; - } - newParts.push(parsedValue === "0px" ? "0" : parsedValue); - } - return { - "border-image-outset": { - important, - value: newParts.join(" ") - } - }; - } - static getBorderImageRepeat(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-image-repeat": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { - "border-image-repeat": { - important, - value: lowerValue - } - }; - } - const parts = lowerValue.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parts.length > 2) { - return null; - } - for (const part of parts) { - if (!BORDER_IMAGE_REPEAT.includes(part)) { - return null; - } - } - return { - "border-image-repeat": { - important, - value - } - }; - } - static getBorderTopWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue) ? lowerValue : CSSStyleDeclarationValueParser.getLength(value); - if (parsedValue) { - return { - "border-top-width": { value: parsedValue, important } - }; - } - return null; - } - static getBorderRightWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-right-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue) ? lowerValue : CSSStyleDeclarationValueParser.getLength(value); - if (parsedValue) { - return { - "border-right-width": { value: parsedValue, important } - }; - } - return null; - } - static getBorderBottomWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue) ? lowerValue : CSSStyleDeclarationValueParser.getLength(value); - if (parsedValue) { - return { - "border-bottom-width": { value: parsedValue, important } - }; - } - return null; - } - static getBorderLeftWidth(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-left-width": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = BORDER_WIDTH.includes(lowerValue) || CSSStyleDeclarationValueParser.getGlobal(lowerValue) ? lowerValue : CSSStyleDeclarationValueParser.getLength(value); - if (parsedValue) { - return { - "border-left-width": { value: parsedValue, important } - }; - } - return null; - } - static getBorderTopStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) { - return { - "border-top-style": { value: lowerValue, important } - }; - } - return null; - } - static getBorderRightStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-right-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) { - return { - "border-right-style": { value: lowerValue, important } - }; - } - return null; - } - static getBorderBottomStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) { - return { - "border-bottom-style": { value: lowerValue, important } - }; - } - return null; - } - static getBorderLeftStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-left-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BORDER_STYLE.includes(lowerValue)) { - return { - "border-left-style": { value: lowerValue, important } - }; - } - return null; - } - static getBorderTopColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - "border-top-color": { value: color, important } - } : null; - } - static getBorderRightColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-right-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - "border-right-color": { value: color, important } - } : null; - } - static getBorderBottomColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - "border-bottom-color": { value: color, important } - } : null; - } - static getBorderLeftColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-left-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - "border-left-color": { value: color, important } - } : null; - } - static getBorderRadius(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-radius": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderTopLeftRadius(globalValue, important), - ...this.getBorderTopRightRadius(globalValue, important), - ...this.getBorderBottomRightRadius(globalValue, important), - ...this.getBorderBottomLeftRadius(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const topLeft = this.getBorderTopLeftRadius(parts[0], important); - const topRight = this.getBorderTopRightRadius(parts[1] || parts[0], important); - const bottomRight = this.getBorderBottomRightRadius(parts[2] || parts[0], important); - const bottomLeft = this.getBorderBottomLeftRadius(parts[3] || parts[1] || parts[0], important); - if (!topLeft || !topRight || !bottomRight || !bottomLeft) { - return null; - } - return { - ...topLeft, - ...topRight, - ...bottomRight, - ...bottomLeft - }; - } - static getBorderTopLeftRadius(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top-left-radius": { value: variable, important } }; - } - const radius = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return radius ? { "border-top-left-radius": { important, value: radius } } : null; - } - static getBorderTopRightRadius(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top-right-radius": { value: variable, important } }; - } - const radius = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return radius ? { "border-top-right-radius": { important, value: radius } } : null; - } - static getBorderBottomRightRadius(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom-right-radius": { value: variable, important } }; - } - const radius = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return radius ? { "border-bottom-right-radius": { important, value: radius } } : null; - } - static getBorderBottomLeftRadius(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom-left-radius": { value: variable, important } }; - } - const radius = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return radius ? { "border-bottom-left-radius": { important, value: radius } } : null; - } - static getBorderTop(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-top": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderTopWidth(globalValue, important), - ...this.getBorderTopStyle(globalValue, important), - ...this.getBorderTopColor(globalValue, important) - }; - } - const properties = { - ...this.getBorderTopWidth("initial", important), - ...this.getBorderTopStyle("initial", important), - ...this.getBorderTopColor("initial", important) - }; - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getBorderTopWidth(part, important); - const style = this.getBorderTopStyle(part, important); - const color = this.getBorderTopColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getBorderRight(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-right": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderRightWidth(globalValue, important), - ...this.getBorderRightStyle(globalValue, important), - ...this.getBorderRightColor(globalValue, important) - }; - } - const properties = { - ...this.getBorderRightWidth("initial", important), - ...this.getBorderRightStyle("initial", important), - ...this.getBorderRightColor("initial", important) - }; - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getBorderRightWidth(part, important); - const style = this.getBorderRightStyle(part, important); - const color = this.getBorderRightColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getBorderBottom(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-bottom": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderBottomWidth(globalValue, important), - ...this.getBorderBottomStyle(globalValue, important), - ...this.getBorderBottomColor(globalValue, important) - }; - } - const properties = { - ...this.getBorderBottomWidth("initial", important), - ...this.getBorderBottomStyle("initial", important), - ...this.getBorderBottomColor("initial", important) - }; - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getBorderBottomWidth(part, important); - const style = this.getBorderBottomStyle(part, important); - const color = this.getBorderBottomColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getBorderLeft(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "border-left": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBorderLeftWidth(globalValue, important), - ...this.getBorderLeftStyle(globalValue, important), - ...this.getBorderLeftColor(globalValue, important) - }; - } - const properties = { - ...this.getBorderLeftWidth("initial", important), - ...this.getBorderLeftStyle("initial", important), - ...this.getBorderLeftColor("initial", important) - }; - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (const part of parts) { - const width = this.getBorderLeftWidth(part, important); - const style = this.getBorderLeftStyle(part, important); - const color = this.getBorderLeftColor(part, important); - if (width === null && style === null && color === null) { - return null; - } - Object.assign(properties, width, style, color); - } - return properties; - } - static getPadding(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { padding: { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getPaddingTop(globalValue, important), - ...this.getPaddingRight(globalValue, important), - ...this.getPaddingBottom(globalValue, important), - ...this.getPaddingLeft(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const top = this.getPaddingTop(parts[0], important); - const right = this.getPaddingRight(parts[1] || parts[0], important); - const bottom = this.getPaddingBottom(parts[2] || parts[0], important); - const left = this.getPaddingLeft(parts[3] || parts[1] || parts[0], important); - if (!top || !right || !bottom || !left) { - return null; - } - return { - ...top, - ...right, - ...bottom, - ...left - }; - } - static getPaddingTop(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "padding-top": { value: variable, important } }; - } - const padding = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return padding ? { "padding-top": { value: padding, important } } : null; - } - static getPaddingRight(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "padding-right": { value: variable, important } }; - } - const padding = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return padding ? { "padding-right": { value: padding, important } } : null; - } - static getPaddingBottom(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "padding-bottom": { value: variable, important } }; - } - const padding = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return padding ? { "padding-bottom": { value: padding, important } } : null; - } - static getPaddingLeft(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "padding-left": { value: variable, important } }; - } - const padding = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return padding ? { "padding-left": { value: padding, important } } : null; - } - static getMargin(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { margin: { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getMarginTop(globalValue, important), - ...this.getMarginRight(globalValue, important), - ...this.getMarginBottom(globalValue, important), - ...this.getMarginLeft(globalValue, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const top = this.getMarginTop(parts[0], important); - const right = this.getMarginRight(parts[1] || parts[0], important); - const bottom = this.getMarginBottom(parts[2] || parts[0], important); - const left = this.getMarginLeft(parts[3] || parts[1] || parts[0], important); - if (!top || !right || !bottom || !left) { - return null; - } - return { - ...top, - ...right, - ...bottom, - ...left - }; - } - static getMarginTop(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "margin-top": { value: variable, important } }; - } - const margin = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getAutoMeasurement(value); - return margin ? { "margin-top": { value: margin, important } } : null; - } - static getMarginRight(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "margin-right": { value: variable, important } }; - } - const margin = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getAutoMeasurement(value); - return margin ? { "margin-right": { value: margin, important } } : null; - } - static getMarginBottom(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "margin-bottom": { value: variable, important } }; - } - const margin = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getAutoMeasurement(value); - return margin ? { "margin-bottom": { value: margin, important } } : null; - } - static getMarginLeft(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "margin-left": { value: variable, important } }; - } - const margin = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getAutoMeasurement(value); - return margin ? { "margin-left": { value: margin, important } } : null; - } - static getFlex(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { flex: { value: variable, important } }; - } - const lowerValue = value.trim().toLowerCase(); - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getFlexGrow(globalValue, important), - ...this.getFlexShrink(globalValue, important), - ...this.getFlexBasis(globalValue, important) - }; - } - switch (lowerValue) { - case "none": - return { - ...this.getFlexGrow("0", important), - ...this.getFlexShrink("0", important), - ...this.getFlexBasis("auto", important) - }; - case "auto": - return { - ...this.getFlexGrow("1", important), - ...this.getFlexShrink("1", important), - ...this.getFlexBasis("auto", important) - }; - } - const measurement = CSSStyleDeclarationValueParser.getContentMeasurement(lowerValue); - if (measurement) { - return { - ...this.getFlexGrow("1", important), - ...this.getFlexShrink("1", important), - ...this.getFlexBasis(measurement, important) - }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - const flexGrow = this.getFlexGrow(parts[0], important); - const flexShrink = this.getFlexShrink(parts[1] || "1", important); - const flexBasis = this.getFlexBasis(parts[2] || "0%", important); - if (!flexGrow || !flexShrink || !flexBasis) { - return null; - } - return { - ...flexGrow, - ...flexShrink, - ...flexBasis - }; - } - static getFlexBasis(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "flex-basis": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FLEX_BASIS.includes(lowerValue)) { - return { "flex-basis": { value: lowerValue, important } }; - } - const measurement = CSSStyleDeclarationValueParser.getContentMeasurement(lowerValue); - return measurement ? { "flex-basis": { value: measurement, important } } : null; - } - static getFlexShrink(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "flex-shrink": { value: variable, important } }; - } - const parsedValue = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getFloat(value); - return parsedValue ? { "flex-shrink": { value: parsedValue, important } } : null; - } - static getFlexGrow(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "flex-grow": { value: variable, important } }; - } - const parsedValue = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getFloat(value); - return parsedValue ? { "flex-grow": { value: parsedValue, important } } : null; - } - static getBackground(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { background: { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBackgroundImage(globalValue, important), - ...this.getBackgroundPosition(globalValue, important), - ...this.getBackgroundSize(globalValue, important), - ...this.getBackgroundRepeat(globalValue, important), - ...this.getBackgroundAttachment(globalValue, important), - ...this.getBackgroundOrigin(globalValue, important), - ...this.getBackgroundClip(globalValue, important), - ...this.getBackgroundColor(globalValue, important) - }; - } - const properties = { - ...this.getBackgroundImage("initial", important), - ...this.getBackgroundPosition("initial", important), - ...this.getBackgroundSize("initial", important), - ...this.getBackgroundRepeat("initial", important), - ...this.getBackgroundAttachment("initial", important), - ...this.getBackgroundOrigin("initial", important), - ...this.getBackgroundClip("initial", important), - ...this.getBackgroundColor("initial", important) - }; - const parts = CSSStyleDeclarationValueUtility.splitBySpace(value.replace(/\s+\/\s+/g, "/")); - const backgroundPositions = []; - for (const part of parts) { - if (!part.startsWith("url") && part.includes("/")) { - const [position, size] = part.split("/"); - const backgroundPositionX = this.getBackgroundPositionX(position, important); - const backgroundPositionY = this.getBackgroundPositionY(position, important); - const backgroundSize = this.getBackgroundSize(size, important); - if (!backgroundPositionX && !backgroundPositionY || !backgroundSize) { - return null; - } - if (backgroundPositionY) { - backgroundPositions.push(backgroundPositionY["background-position-y"].value); - } else if (backgroundPositionX) { - backgroundPositions.push(backgroundPositionX["background-position-x"].value); - } - Object.assign(properties, backgroundSize); - } else { - const backgroundImage = this.getBackgroundImage(part, important); - const backgroundRepeat = this.getBackgroundRepeat(part, important); - const backgroundAttachment = this.getBackgroundAttachment(part, important); - const backgroundPositionX = this.getBackgroundPositionX(part, important); - const backgroundPositionY = this.getBackgroundPositionY(part, important); - const backgroundColor = this.getBackgroundColor(part, important); - const backgroundOrigin = this.getBackgroundOrigin(part, important); - const backgroundClip = this.getBackgroundClip(part, important); - if (!backgroundImage && !backgroundRepeat && !backgroundAttachment && !backgroundPositionX && !backgroundPositionY && !backgroundColor && !backgroundOrigin && !backgroundClip) { - return null; - } - if (backgroundPositionX) { - backgroundPositions.push(backgroundPositionX["background-position-x"].value); - } else if (backgroundPositionY) { - backgroundPositions.push(backgroundPositionY["background-position-y"].value); - } - Object.assign(properties, backgroundImage, backgroundRepeat, backgroundAttachment, backgroundColor, backgroundOrigin, backgroundClip); - } - } - if (backgroundPositions.length) { - Object.assign(properties, this.getBackgroundPosition(backgroundPositions.join(" "), important)); - } - return properties; - } - static getBackgroundSize(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-size": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { "background-size": { value: lowerValue, important } }; - } - const imageParts = lowerValue.split(SPLIT_COMMA_SEPARATED_WITH_PARANTHESES_REGEXP); - const parsed = []; - for (const imagePart of imageParts) { - const parts = imagePart.trim().split(" "); - if (parts.length !== 1 && parts.length !== 2) { - return null; - } - if (parts.length === 1) { - if (parts[0] !== "cover" && parts[0] !== "contain" && !CSSStyleDeclarationValueParser.getAutoMeasurement(parts[0])) { - return null; - } - parsed.push(parts[0]); - } else { - if (!CSSStyleDeclarationValueParser.getAutoMeasurement(parts[0]) || !CSSStyleDeclarationValueParser.getAutoMeasurement(parts[1])) { - return null; - } - parsed.push(`${parts[0]} ${parts[1]}`); - } - } - if (parsed.length === 1) { - return { "background-size": { value: parsed.join(", "), important } }; - } - return null; - } - static getBackgroundOrigin(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-origin": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BACKGROUND_ORIGIN.includes(lowerValue)) { - return { "background-origin": { value: lowerValue, important } }; - } - return null; - } - static getBackgroundClip(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-clip": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BACKGROUND_CLIP.includes(lowerValue)) { - return { "background-clip": { value: lowerValue, important } }; - } - return null; - } - static getBackgroundRepeat(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-repeat": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BACKGROUND_REPEAT.includes(lowerValue)) { - return { "background-repeat": { value: lowerValue, important } }; - } - return null; - } - static getBackgroundAttachment(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-attachment": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || BACKGROUND_ATTACHMENT.includes(lowerValue)) { - return { "background-attachment": { value: lowerValue, important } }; - } - return null; - } - static getBackgroundPosition(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-position": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { - ...this.getBackgroundPositionX(globalValue, important), - ...this.getBackgroundPositionY(globalValue, important) - }; - } - const imageParts = value.split(SPLIT_COMMA_SEPARATED_WITH_PARANTHESES_REGEXP); - let x = ""; - let y = ""; - for (const imagePart of imageParts) { - const parts = imagePart.trim().split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (x) { - x += ","; - y += ","; - } - switch (parts.length) { - case 1: - if (parts[0] === "top" || parts[0] === "bottom") { - x += "center"; - y += parts[0]; - } else if (parts[0] === "left" || parts[0] === "right") { - x += parts[0]; - y += "center"; - } else if (parts[0] === "center") { - x += "center"; - y += "center"; - } - break; - case 2: - x += parts[0] === "top" || parts[0] === "bottom" ? parts[1] : parts[0]; - y += parts[0] === "top" || parts[0] === "bottom" ? parts[0] : parts[1]; - break; - case 3: - if (parts[0] === "top" || parts[0] === "bottom" || parts[1] === "left" || parts[1] === "right" || parts[2] === "left" || parts[2] === "right") { - if (CSSStyleDeclarationValueParser.getMeasurement(parts[1])) { - x += parts[2]; - y += `${parts[0]} ${parts[1]}`; - } else { - x += `${parts[1]} ${parts[2]}`; - y += parts[0]; - } - } else { - if (CSSStyleDeclarationValueParser.getMeasurement(parts[1])) { - x += `${parts[0]} ${parts[1]}`; - y += parts[2]; - } else { - x += parts[0]; - y += `${parts[1]} ${parts[2]}`; - } - } - break; - case 4: - x += parts[0] === "top" || parts[0] === "bottom" || parts[1] === "top" || parts[1] === "bottom" ? `${parts[2]} ${parts[3]}` : `${parts[0]} ${parts[1]}`; - y += parts[0] === "top" || parts[0] === "bottom" || parts[1] === "top" || parts[1] === "bottom" ? `${parts[0]} ${parts[1]}` : `${parts[2]} ${parts[3]}`; - break; - default: - return null; - } - } - const xValue = this.getBackgroundPositionX(x, important); - const yValue = this.getBackgroundPositionY(y, important); - if (xValue && yValue) { - return { - ...xValue, - ...yValue - }; - } - return null; - } - static getBackgroundPositionX(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-position-x": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { "background-position-x": { value: lowerValue, important } }; - } - const imageParts = lowerValue.split(SPLIT_COMMA_SEPARATED_WITH_PARANTHESES_REGEXP); - let parsedValue = ""; - for (const imagePart of imageParts) { - const parts = imagePart.trim().split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parsedValue) { - parsedValue += ","; - } - for (const part of parts) { - const measurement = CSSStyleDeclarationValueParser.getMeasurement(part); - if (!measurement && part !== "left" && part !== "right" && part !== "center") { - return null; - } - if (parsedValue) { - parsedValue += " "; - } - parsedValue += measurement || part; - } - } - return { "background-position-x": { value: parsedValue, important } }; - } - static getBackgroundPositionY(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-position-y": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { "background-position-y": { value: lowerValue, important } }; - } - const imageParts = lowerValue.split(SPLIT_COMMA_SEPARATED_WITH_PARANTHESES_REGEXP); - let parsedValue = ""; - for (const imagePart of imageParts) { - const parts = imagePart.trim().split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parsedValue) { - parsedValue += ","; - } - for (const part of parts) { - const measurement = CSSStyleDeclarationValueParser.getMeasurement(part); - if (!measurement && part !== "top" && part !== "bottom" && part !== "center") { - return null; - } - if (parsedValue) { - parsedValue += " "; - } - parsedValue += measurement || part; - } - } - return { "background-position-y": { value: parsedValue, important } }; - } - static getBackgroundColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { - ["background-color"]: { important, value: color } - } : null; - } - static getBackgroundImage(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "background-image": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "none") { - return { "background-image": { value: lowerValue, important } }; - } - const parts = CSSStyleDeclarationValueUtility.splitByComma(value); - const parsed = []; - for (const part of parts) { - const parsedValue = CSSStyleDeclarationValueParser.getURL(part.trim()) || CSSStyleDeclarationValueParser.getGradient(part.trim()); - if (!parsedValue) { - return null; - } - parsed.push(parsedValue); - } - if (parsed.length) { - return { "background-image": { value: parsed.join(", "), important } }; - } - return null; - } - static getColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { color: { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { color: { important, value: color } } : null; - } - static getFloodColor(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "flood-color": { value: variable, important } }; - } - const color = CSSStyleDeclarationValueParser.getGlobal(value) || CSSStyleDeclarationValueParser.getColor(value); - return color ? { "flood-color": { important, value: color } } : null; - } - static getFont(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { font: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { - ...this.getFontStyle(lowerValue, important), - ...this.getFontVariant(lowerValue, important), - ...this.getFontWeight(lowerValue, important), - ...this.getFontStretch(lowerValue, important), - ...this.getFontSize(lowerValue, important), - ...this.getLineHeight(lowerValue, important), - ...this.getFontFamily(lowerValue, important) - }; - } - if (SYSTEM_FONT.includes(lowerValue)) { - return { font: { value: lowerValue, important } }; - } - const properties = { - ...this.getFontStyle("normal", important), - ...this.getFontVariant("normal", important), - ...this.getFontWeight("normal", important), - ...this.getFontStretch("normal", important), - ...this.getLineHeight("normal", important) - }; - const parts = value.replace(/\s*\/\s*/g, "/").split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - for (let i = 0, max = parts.length;i < max; i++) { - const part = parts[i]; - if (part.includes("/")) { - const [size, height] = part.split("/"); - const fontSize = this.getFontSize(size, important); - const lineHeight = this.getLineHeight(height, important); - if (!fontSize || !lineHeight) { - return null; - } - Object.assign(properties, fontSize, lineHeight); - } else { - const fontStyle = this.getFontStyle(part, important); - const fontVariant = this.getFontVariant(part, important); - const fontWeight = this.getFontWeight(part, important); - const fontSize = this.getFontSize(part, important); - const fontStretch = this.getFontStretch(part, important); - if (fontStyle) { - Object.assign(properties, fontStyle); - } else if (fontVariant) { - Object.assign(properties, fontVariant); - } else if (fontWeight) { - Object.assign(properties, fontWeight); - } else if (fontSize) { - Object.assign(properties, fontSize); - } else if (fontStretch) { - Object.assign(properties, fontStretch); - } else { - const fontFamilyValue = parts.slice(i).join(" "); - const fontFamily = this.getFontFamily(fontFamilyValue, important); - if (!fontFamily) { - return null; - } - Object.assign(properties, fontFamily); - break; - } - } - } - return properties; - } - static getFontStyle(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-style": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_STYLE.includes(lowerValue)) { - return { "font-style": { value: lowerValue, important } }; - } - const parts = value.split(SPLIT_SPACE_SEPARATED_WITH_PARANTHESES_REGEXP); - if (parts.length === 2 && parts[0] === "oblique") { - const degree = CSSStyleDeclarationValueParser.getDegree(parts[1]); - return degree ? { "font-style": { value: lowerValue, important } } : null; - } - return null; - } - static getFontVariant(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-variant": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - return CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "normal" || lowerValue === "small-caps" ? { "font-variant": { value: lowerValue, important } } : null; - } - static getFontStretch(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-stretch": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_STRETCH.includes(lowerValue)) { - return { "font-stretch": { value: lowerValue, important } }; - } - const percentage = CSSStyleDeclarationValueParser.getPercentage(value); - return percentage ? { "font-stretch": { value: percentage, important } } : null; - } - static getFontWeight(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-weight": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_WEIGHT.includes(lowerValue)) { - return { "font-weight": { value: lowerValue, important } }; - } - const integer = CSSStyleDeclarationValueParser.getInteger(value); - return integer ? { "font-weight": { value: integer, important } } : null; - } - static getFontSize(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-size": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || FONT_SIZE.includes(lowerValue)) { - return { "font-size": { value: lowerValue, important } }; - } - const measurement = CSSStyleDeclarationValueParser.getMeasurement(value); - return measurement ? { "font-size": { value: measurement, important } } : null; - } - static getLineHeight(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "line-height": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue) || lowerValue === "normal") { - return { "line-height": { value: lowerValue, important } }; - } - const lineHeight = CSSStyleDeclarationValueParser.getFloat(value) || CSSStyleDeclarationValueParser.getMeasurement(value); - return lineHeight ? { "line-height": { value: lineHeight, important } } : null; - } - static getFontFamily(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "font-family": { value: variable, important } }; - } - const globalValue = CSSStyleDeclarationValueParser.getGlobal(value); - if (globalValue) { - return { "font-family": { value: globalValue, important } }; - } - const parts = value.split(","); - let parsedValue = ""; - let endWithApostroph = false; - for (let i = 0, max = parts.length;i < max; i++) { - let trimmedPart = parts[i].trim().replace(/'/g, '"'); - if (!trimmedPart) { - return null; - } - if (trimmedPart.includes(" ")) { - const apostrophCount = (trimmedPart.match(/"/g) || []).length; - if ((trimmedPart[0] !== '"' || i !== 0) && apostrophCount !== 2 && apostrophCount !== 0) { - return null; - } - if (trimmedPart[0] === '"' && trimmedPart[trimmedPart.length - 1] !== '"') { - endWithApostroph = true; - } else if (trimmedPart[0] !== '"' && trimmedPart[trimmedPart.length - 1] !== '"') { - trimmedPart = `"${trimmedPart}"`; - } - } else { - trimmedPart = trimmedPart.replace(/"/g, ""); - } - if (i > 0) { - parsedValue += ", "; - } - parsedValue += trimmedPart; - } - if (endWithApostroph) { - parsedValue += '"'; - } - if (!parsedValue) { - return null; - } - return { - "font-family": { - important, - value: parsedValue - } - }; - } - static getTextTransform(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "text-transform": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = CSSStyleDeclarationValueParser.getGlobal(lowerValue) || TEXT_TRANSFORM.includes(lowerValue) && lowerValue; - if (parsedValue) { - return { - "text-transform": { value: parsedValue, important } - }; - } - return null; - } - static getVisibility(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { visibility: { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - const parsedValue = CSSStyleDeclarationValueParser.getGlobal(lowerValue) || VISIBILITY.includes(lowerValue) && lowerValue; - if (parsedValue) { - return { - visibility: { value: parsedValue, important } - }; - } - return null; - } - static getAspectRatio(value, important) { - const variable = CSSStyleDeclarationValueParser.getVariable(value); - if (variable) { - return { "aspect-ratio": { value: variable, important } }; - } - const lowerValue = value.toLowerCase(); - if (CSSStyleDeclarationValueParser.getGlobal(lowerValue)) { - return { "aspect-ratio": { value: lowerValue, important } }; - } - let parsedValue = value; - const hasAuto = parsedValue.includes("auto"); - if (hasAuto) { - parsedValue = parsedValue.replace("auto", ""); - } - parsedValue = parsedValue.replace(WHITE_SPACE_GLOBAL_REGEXP, ""); - if (!parsedValue) { - return { "aspect-ratio": { value: "auto", important } }; - } - const aspectRatio = parsedValue.split("/"); - if (aspectRatio.length > 3) { - return null; - } - const width = Number(aspectRatio[0]); - const height = aspectRatio[1] ? Number(aspectRatio[1]) : 1; - if (isNaN(width) || isNaN(height)) { - return null; - } - if (hasAuto) { - return { "aspect-ratio": { value: `auto ${width} / ${height}`, important } }; - } - return { "aspect-ratio": { value: `${width} / ${height}`, important } }; - } -} - -// node_modules/happy-dom/lib/css/declaration/property-manager/CSSStyleDeclarationPropertyGetParser.js -class CSSStyleDeclarationPropertyGetParser { - static getMargin(properties) { - return this.getPaddingLikeProperty(["margin-top", "margin-right", "margin-bottom", "margin-left"], properties); - } - static getPadding(properties) { - return this.getPaddingLikeProperty(["padding-top", "padding-right", "padding-bottom", "padding-left"], properties); - } - static getOutline(properties) { - if (!properties["outline-color"]?.value || !properties["outline-style"]?.value || !properties["outline-width"]?.value) { - return null; - } - const important = properties["outline-color"].important && properties["outline-style"].important && properties["outline-width"].important; - if (CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["outline-width"].value) && properties["outline-width"].value === properties["outline-style"].value && properties["outline-width"].value === properties["outline-color"].value) { - return { - important, - value: properties["outline-width"].value - }; - } - const values = []; - if (!CSSStyleDeclarationValueParser.getInitial(properties["outline-color"]?.value)) { - values.push(properties["outline-color"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["outline-style"]?.value)) { - values.push(properties["outline-style"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["outline-width"].value)) { - values.push(properties["outline-width"].value); - } - return { - important, - value: values.join(" ") - }; - } - static getBorder(properties) { - if (!properties["border-top-width"]?.value || properties["border-top-width"]?.value !== properties["border-right-width"]?.value || properties["border-top-width"]?.value !== properties["border-bottom-width"]?.value || properties["border-top-width"]?.value !== properties["border-left-width"]?.value || !properties["border-top-style"]?.value || properties["border-top-style"]?.value !== properties["border-right-style"]?.value || properties["border-top-style"]?.value !== properties["border-bottom-style"]?.value || properties["border-top-style"]?.value !== properties["border-left-style"]?.value || !properties["border-top-color"]?.value || properties["border-top-color"]?.value !== properties["border-right-color"]?.value || properties["border-top-color"]?.value !== properties["border-bottom-color"]?.value || properties["border-top-color"]?.value !== properties["border-left-color"]?.value || !properties["border-image-source"]?.value || !properties["border-image-slice"]?.value || !properties["border-image-width"]?.value || !properties["border-image-outset"]?.value || !properties["border-image-repeat"]?.value) { - return null; - } - const important = properties["border-top-width"].important && properties["border-right-width"].important && properties["border-bottom-width"].important && properties["border-left-width"].important && properties["border-top-style"].important && properties["border-right-style"].important && properties["border-bottom-style"].important && properties["border-left-style"].important && properties["border-top-color"].important && properties["border-right-color"].important && properties["border-bottom-color"].important && properties["border-left-color"].important && properties["border-image-source"].important && properties["border-image-slice"].important && properties["border-image-width"].important && properties["border-image-outset"].important && properties["border-image-repeat"].important; - if (CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-top-width"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-top-style"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-top-color"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-image-source"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-image-slice"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-image-width"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-image-outset"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["border-image-repeat"].value)) { - if (properties["border-top-width"].value !== properties["border-top-style"].value || properties["border-top-width"].value !== properties["border-top-color"].value || properties["border-top-width"].value !== properties["border-image-source"].value || properties["border-top-width"].value !== properties["border-image-slice"].value || properties["border-top-width"].value !== properties["border-image-width"].value || properties["border-top-width"].value !== properties["border-image-outset"].value || properties["border-top-width"].value !== properties["border-image-repeat"].value) { - return null; - } - return { - important, - value: properties["border-top-width"].value - }; - } - const values = []; - if (!CSSStyleDeclarationValueParser.getInitial(properties["border-top-width"].value)) { - values.push(properties["border-top-width"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["border-top-style"].value)) { - values.push(properties["border-top-style"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["border-top-color"].value)) { - values.push(properties["border-top-color"].value); - } - return { - important, - value: values.join(" ") - }; - } - static getBorderTop(properties) { - return this.getBorderTopRightBottomLeft("top", properties); - } - static getBorderRight(properties) { - return this.getBorderTopRightBottomLeft("right", properties); - } - static getBorderBottom(properties) { - return this.getBorderTopRightBottomLeft("bottom", properties); - } - static getBorderLeft(properties) { - return this.getBorderTopRightBottomLeft("left", properties); - } - static getBorderColor(properties) { - return this.getPaddingLikeProperty(["border-top-color", "border-right-color", "border-bottom-color", "border-left-color"], properties); - } - static getBorderWidth(properties) { - return this.getPaddingLikeProperty(["border-top-width", "border-right-width", "border-bottom-width", "border-left-width"], properties); - } - static getBorderStyle(properties) { - return this.getPaddingLikeProperty(["border-top-style", "border-right-style", "border-bottom-style", "border-left-style"], properties); - } - static getBorderRadius(properties) { - return this.getPaddingLikeProperty([ - "border-top-left-radius", - "border-top-right-radius", - "border-bottom-right-radius", - "border-bottom-left-radius" - ], properties); - } - static getBorderImage(properties) { - if (!properties["border-image-source"]?.value || !properties["border-image-slice"]?.value || !properties["border-image-width"]?.value || !properties["border-image-outset"]?.value || !properties["border-image-repeat"]?.value) { - return null; - } - const important = properties["border-image-source"].important && properties["border-image-slice"].important && properties["border-image-width"].important && properties["border-image-outset"].important && properties["border-image-repeat"].important; - if (CSSStyleDeclarationValueParser.getGlobal(properties["border-image-source"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["border-image-slice"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["border-image-width"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["border-image-outset"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["border-image-repeat"].value)) { - if (properties["border-image-source"].value !== properties["border-image-slice"].value || properties["border-image-source"].value !== properties["border-image-width"].value || properties["border-image-source"].value !== properties["border-image-outset"].value || properties["border-image-source"].value !== properties["border-image-repeat"].value) { - return null; - } - return { - important, - value: properties["border-image-source"].value - }; - } - return { - important, - value: `${properties["border-image-source"].value} ${properties["border-image-slice"].value} / ${properties["border-image-width"].value} / ${properties["border-image-outset"].value} ${properties["border-image-repeat"].value}` - }; - } - static getBackground(properties) { - if (!properties["background-image"]?.value || !properties["background-repeat"]?.value || !properties["background-attachment"]?.value || !properties["background-position-x"]?.value || !properties["background-position-y"]?.value || !properties["background-color"]?.value || !properties["background-size"]?.value || !properties["background-origin"]?.value || !properties["background-clip"]?.value) { - return null; - } - const important = properties["background-image"].important && properties["background-repeat"].important && properties["background-attachment"].important && properties["background-position-x"].important && properties["background-position-y"].important && properties["background-color"].important && properties["background-size"].important && properties["background-origin"].important && properties["background-clip"].important; - if (CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-image"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-repeat"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-attachment"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-position-x"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-position-y"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-color"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-size"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-origin"].value) || CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties["background-clip"].value)) { - if (properties["background-image"].value !== properties["background-repeat"].value || properties["background-image"].value !== properties["background-attachment"].value || properties["background-image"].value !== properties["background-position-x"].value || properties["background-image"].value !== properties["background-position-y"].value || properties["background-image"].value !== properties["background-color"].value || properties["background-image"].value !== properties["background-size"].value || properties["background-image"].value !== properties["background-origin"].value || properties["background-image"].value !== properties["background-clip"].value) { - return null; - } - return { - important, - value: properties["background-image"].value - }; - } - const values = []; - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-image"].value)) { - values.push(properties["background-image"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-position-x"].value) && !CSSStyleDeclarationValueParser.getInitial(properties["background-position-y"].value) && !CSSStyleDeclarationValueParser.getInitial(properties["background-size"].value)) { - values.push(`${properties["background-position-x"].value} ${properties["background-position-y"].value} / ${properties["background-size"].value}`); - } else if (!CSSStyleDeclarationValueParser.getInitial(properties["background-position-x"].value) && !CSSStyleDeclarationValueParser.getInitial(properties["background-position-y"].value)) { - values.push(`${properties["background-position-x"].value} ${properties["background-position-y"].value}`); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-repeat"].value)) { - values.push(properties["background-repeat"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-attachment"].value)) { - values.push(properties["background-attachment"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-origin"].value)) { - values.push(properties["background-origin"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-clip"].value)) { - values.push(properties["background-clip"].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties["background-color"].value)) { - values.push(properties["background-color"].value); - } - return { - important, - value: values.join(" ") - }; - } - static getBackgroundPosition(properties) { - if (!properties["background-position-x"]?.value || !properties["background-position-y"]?.value) { - return null; - } - const important = properties["background-position-x"].important && properties["background-position-y"].important; - if (CSSStyleDeclarationValueParser.getGlobal(properties["background-position-x"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["background-position-y"].value)) { - if (properties["background-position-x"].value !== properties["background-position-y"].value) { - return null; - } - return { - important, - value: properties["background-position-x"].value - }; - } - const positionX = properties["background-position-x"].value.replace(/ *, */g, ",").split(","); - const positionY = properties["background-position-y"].value.replace(/ *, */g, ",").split(","); - const parts = []; - for (let i = 0;i < positionX.length; i++) { - parts.push(`${positionX[i]} ${positionY[i]}`); - } - return { - important, - value: parts.join(", ") - }; - } - static getFlex(properties) { - if (!properties["flex-grow"]?.value || !properties["flex-shrink"]?.value || !properties["flex-basis"]?.value) { - return null; - } - const important = properties["flex-grow"].important && properties["flex-shrink"].important && properties["flex-basis"].important; - if (CSSStyleDeclarationValueParser.getGlobal(properties["flex-grow"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["flex-shrink"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["flex-basis"].value)) { - if (properties["flex-grow"].value !== properties["flex-shrink"].value || properties["flex-grow"].value !== properties["flex-basis"].value) { - return null; - } - return { - important, - value: properties["flex-grow"].value - }; - } - return { - important, - value: `${properties["flex-grow"].value} ${properties["flex-shrink"].value} ${properties["flex-basis"].value}` - }; - } - static getFont(properties) { - if (!properties["font-size"]?.value || !properties["font-family"]?.value || !properties["font-weight"]?.value || !properties["font-style"]?.value || !properties["font-variant"]?.value || !properties["font-stretch"]?.value || !properties["line-height"]?.value) { - return null; - } - const important = properties["font-size"].important && properties["font-family"].important && properties["font-weight"].important && properties["font-style"].important && properties["font-variant"].important && properties["font-stretch"].important && properties["line-height"].important; - if (CSSStyleDeclarationValueParser.getGlobal(properties["font-size"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["font-family"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["font-weight"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["font-style"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["font-variant"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["font-stretch"].value) || CSSStyleDeclarationValueParser.getGlobal(properties["line-height"].value)) { - if (properties["font-size"].value !== properties["font-family"].value || properties["font-size"].value !== properties["font-weight"].value || properties["font-size"].value !== properties["font-style"].value || properties["font-size"].value !== properties["font-variant"].value || properties["font-size"].value !== properties["font-stretch"].value || properties["font-size"].value !== properties["line-height"].value) { - return null; - } - return { - important, - value: properties["font-size"].value - }; - } - const values = []; - if (properties["font-style"].value !== "normal") { - values.push(properties["font-style"].value); - } - if (properties["font-variant"].value !== "normal") { - values.push(properties["font-variant"].value); - } - if (properties["font-weight"].value !== "normal") { - values.push(properties["font-weight"].value); - } - if (properties["font-stretch"].value !== "normal") { - values.push(properties["font-stretch"].value); - } - if (properties["line-height"].value !== "normal") { - values.push(`${properties["font-size"].value} / ${properties["line-height"].value}`); - } else { - values.push(properties["font-size"].value); - } - values.push(properties["font-family"].value); - return { - important, - value: values.join(" ") - }; - } - static getBorderTopRightBottomLeft(position, properties) { - if (!properties[`border-${position}-width`]?.value || !properties[`border-${position}-style`]?.value || !properties[`border-${position}-color`]?.value) { - return null; - } - const important = properties[`border-${position}-width`].important && properties[`border-${position}-style`].important && properties[`border-${position}-color`].important; - if (CSSStyleDeclarationValueParser.getGlobalExceptInitial(properties[`border-${position}-width`].value) && properties[`border-${position}-width`].value === properties[`border-${position}-style`].value && properties[`border-${position}-width`].value === properties[`border-${position}-color`].value) { - return { - important, - value: properties[`border-${position}-width`].value - }; - } - const values = []; - if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-width`].value)) { - values.push(properties[`border-${position}-width`].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-style`]?.value)) { - values.push(properties[`border-${position}-style`].value); - } - if (!CSSStyleDeclarationValueParser.getInitial(properties[`border-${position}-color`]?.value)) { - values.push(properties[`border-${position}-color`].value); - } - return { - important, - value: values.join(" ") - }; - } - static getPaddingLikeProperty(propertyNames, properties) { - if (!properties[propertyNames[0]]?.value || !properties[propertyNames[1]]?.value || !properties[propertyNames[2]]?.value || !properties[propertyNames[3]]?.value) { - return null; - } - const important = properties[propertyNames[0]].important && properties[propertyNames[1]].important && properties[propertyNames[2]].important && properties[propertyNames[3]].important; - if (CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[0]].value) || CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[1]].value) || CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[2]].value) || CSSStyleDeclarationValueParser.getGlobal(properties[propertyNames[3]].value)) { - if (properties[propertyNames[0]].value !== properties[propertyNames[1]].value || properties[propertyNames[0]].value !== properties[propertyNames[2]].value || properties[propertyNames[0]].value !== properties[propertyNames[3]].value) { - return null; - } - return { - important, - value: properties[propertyNames[0]].value - }; - } - const values = [properties[propertyNames[0]].value]; - if (properties[propertyNames[1]].value !== properties[propertyNames[0]].value || properties[propertyNames[2]].value !== properties[propertyNames[0]].value || properties[propertyNames[3]].value !== properties[propertyNames[1]].value) { - values.push(properties[propertyNames[1]].value); - } - if (properties[propertyNames[2]].value !== properties[propertyNames[0]].value || properties[propertyNames[3]].value !== properties[propertyNames[1]].value) { - values.push(properties[propertyNames[2]].value); - } - if (properties[propertyNames[3]].value !== properties[propertyNames[1]].value) { - values.push(properties[propertyNames[3]].value); - } - return { - important, - value: values.join(" ") - }; - } -} - -// node_modules/happy-dom/lib/css/declaration/css-parser/CSSStyleDeclarationCSSParser.js -var SPLIT_RULES_REGEXP = /\s*([^:;]+?)\s*:\s*((?:[^(;]*?(?:\([^)]*\))?)*?)\s*(!important)?\s*(?:$|;)/g; - -class CSSStyleDeclarationCSSParser { - static parse(cssText) { - const properties = {}; - const rules = []; - const regexp = new RegExp(SPLIT_RULES_REGEXP); - let match; - while (match = regexp.exec(cssText)) { - const name = (match[1] ?? "").trim(); - const value = (match[2] ?? "").trim(); - const important = match[3] ? true : false; - if (name && value) { - if (name.startsWith("--")) { - properties[name] = value; - } - rules.push({ name, value, important }); - } - } - return { rules, properties }; - } -} - -// node_modules/happy-dom/lib/css/declaration/property-manager/CSSStyleDeclarationPropertyManager.js -var TO_STRING_SHORTHAND_PROPERTIES = [ - ["margin"], - ["padding"], - ["border", ["border-width", "border-style", "border-color", "border-image"]], - ["border-radius"], - ["background", "background-position"], - ["font"] -]; - -class CSSStyleDeclarationPropertyManager { - properties = {}; - definedPropertyNames = {}; - constructor(options) { - if (options?.cssText) { - const { rules } = CSSStyleDeclarationCSSParser.parse(options.cssText); - for (const rule of rules) { - if (rule.important || !this.get(rule.name)?.important) { - this.set(rule.name, rule.value, rule.important); - } - } - } - } - get(name) { - if (this.properties[name]) { - return this.properties[name]; - } - switch (name) { - case "margin": - return CSSStyleDeclarationPropertyGetParser.getMargin(this.properties); - case "padding": - return CSSStyleDeclarationPropertyGetParser.getPadding(this.properties); - case "border": - return CSSStyleDeclarationPropertyGetParser.getBorder(this.properties); - case "border-top": - return CSSStyleDeclarationPropertyGetParser.getBorderTop(this.properties); - case "border-right": - return CSSStyleDeclarationPropertyGetParser.getBorderRight(this.properties); - case "border-bottom": - return CSSStyleDeclarationPropertyGetParser.getBorderBottom(this.properties); - case "border-left": - return CSSStyleDeclarationPropertyGetParser.getBorderLeft(this.properties); - case "border-color": - return CSSStyleDeclarationPropertyGetParser.getBorderColor(this.properties); - case "border-style": - return CSSStyleDeclarationPropertyGetParser.getBorderStyle(this.properties); - case "border-width": - return CSSStyleDeclarationPropertyGetParser.getBorderWidth(this.properties); - case "border-radius": - return CSSStyleDeclarationPropertyGetParser.getBorderRadius(this.properties); - case "border-image": - return CSSStyleDeclarationPropertyGetParser.getBorderImage(this.properties); - case "outline": - return CSSStyleDeclarationPropertyGetParser.getOutline(this.properties); - case "background": - return CSSStyleDeclarationPropertyGetParser.getBackground(this.properties); - case "background-position": - return CSSStyleDeclarationPropertyGetParser.getBackgroundPosition(this.properties); - case "flex": - return CSSStyleDeclarationPropertyGetParser.getFlex(this.properties); - case "font": - return CSSStyleDeclarationPropertyGetParser.getFont(this.properties); - } - return this.properties[name] || null; - } - remove(name) { - delete this.properties[name]; - delete this.definedPropertyNames[name]; - switch (name) { - case "border": - delete this.properties["border-top-width"]; - delete this.properties["border-right-width"]; - delete this.properties["border-bottom-width"]; - delete this.properties["border-left-width"]; - delete this.properties["border-top-style"]; - delete this.properties["border-right-style"]; - delete this.properties["border-bottom-style"]; - delete this.properties["border-left-style"]; - delete this.properties["border-top-color"]; - delete this.properties["border-right-color"]; - delete this.properties["border-bottom-color"]; - delete this.properties["border-left-color"]; - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-top": - delete this.properties["border-top-width"]; - delete this.properties["border-top-style"]; - delete this.properties["border-top-color"]; - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-right": - delete this.properties["border-right-width"]; - delete this.properties["border-right-style"]; - delete this.properties["border-right-color"]; - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-bottom": - delete this.properties["border-bottom-width"]; - delete this.properties["border-bottom-style"]; - delete this.properties["border-bottom-color"]; - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-left": - delete this.properties["border-left-width"]; - delete this.properties["border-left-style"]; - delete this.properties["border-left-color"]; - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-width": - delete this.properties["border-top-width"]; - delete this.properties["border-right-width"]; - delete this.properties["border-bottom-width"]; - delete this.properties["border-left-width"]; - break; - case "border-style": - delete this.properties["border-top-style"]; - delete this.properties["border-right-style"]; - delete this.properties["border-bottom-style"]; - delete this.properties["border-left-style"]; - break; - case "border-color": - delete this.properties["border-top-color"]; - delete this.properties["border-right-color"]; - delete this.properties["border-bottom-color"]; - delete this.properties["border-left-color"]; - break; - case "border-image": - delete this.properties["border-image-source"]; - delete this.properties["border-image-slice"]; - delete this.properties["border-image-width"]; - delete this.properties["border-image-outset"]; - delete this.properties["border-image-repeat"]; - break; - case "border-radius": - delete this.properties["border-top-left-radius"]; - delete this.properties["border-top-right-radius"]; - delete this.properties["border-bottom-right-radius"]; - delete this.properties["border-bottom-left-radius"]; - break; - case "outline": - delete this.properties["outline-color"]; - delete this.properties["outline-style"]; - delete this.properties["outline-width"]; - break; - case "background": - delete this.properties["background-color"]; - delete this.properties["background-image"]; - delete this.properties["background-repeat"]; - delete this.properties["background-attachment"]; - delete this.properties["background-position-x"]; - delete this.properties["background-position-y"]; - delete this.properties["background-size"]; - delete this.properties["background-origin"]; - delete this.properties["background-clip"]; - break; - case "background-position": - delete this.properties["background-position-x"]; - delete this.properties["background-position-y"]; - break; - case "flex": - delete this.properties["flex-grow"]; - delete this.properties["flex-shrink"]; - delete this.properties["flex-basis"]; - break; - case "font": - delete this.properties["font-style"]; - delete this.properties["font-variant"]; - delete this.properties["font-weight"]; - delete this.properties["font-stretch"]; - delete this.properties["font-size"]; - delete this.properties["line-height"]; - delete this.properties["font-family"]; - break; - case "padding": - delete this.properties["padding-top"]; - delete this.properties["padding-right"]; - delete this.properties["padding-bottom"]; - delete this.properties["padding-left"]; - break; - case "margin": - delete this.properties["margin-top"]; - delete this.properties["margin-right"]; - delete this.properties["margin-bottom"]; - delete this.properties["margin-left"]; - break; - } - } - set(name, value, important) { - if (value === null) { - this.remove(name); - return; - } - let properties = null; - switch (name) { - case "border": - properties = CSSStyleDeclarationPropertySetParser.getBorder(value, important); - break; - case "border-top": - properties = CSSStyleDeclarationPropertySetParser.getBorderTop(value, important); - break; - case "border-right": - properties = CSSStyleDeclarationPropertySetParser.getBorderRight(value, important); - break; - case "border-bottom": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottom(value, important); - break; - case "border-left": - properties = CSSStyleDeclarationPropertySetParser.getBorderLeft(value, important); - break; - case "border-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderWidth(value, important); - break; - case "border-style": - properties = CSSStyleDeclarationPropertySetParser.getBorderStyle(value, important); - break; - case "border-color": - properties = CSSStyleDeclarationPropertySetParser.getBorderColor(value, important); - break; - case "border-image": - properties = CSSStyleDeclarationPropertySetParser.getBorderImage(value, important); - break; - case "border-image-source": - properties = CSSStyleDeclarationPropertySetParser.getBorderImageSource(value, important); - break; - case "border-image-slice": - properties = CSSStyleDeclarationPropertySetParser.getBorderImageSlice(value, important); - break; - case "border-image-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderImageWidth(value, important); - break; - case "border-image-outset": - properties = CSSStyleDeclarationPropertySetParser.getBorderImageOutset(value, important); - break; - case "border-image-repeat": - properties = CSSStyleDeclarationPropertySetParser.getBorderImageRepeat(value, important); - break; - case "border-top-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderTopWidth(value, important); - break; - case "border-right-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderRightWidth(value, important); - break; - case "border-bottom-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottomWidth(value, important); - break; - case "border-left-width": - properties = CSSStyleDeclarationPropertySetParser.getBorderLeftWidth(value, important); - break; - case "border-top-color": - properties = CSSStyleDeclarationPropertySetParser.getBorderTopColor(value, important); - break; - case "border-right-color": - properties = CSSStyleDeclarationPropertySetParser.getBorderRightColor(value, important); - break; - case "border-bottom-color": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottomColor(value, important); - break; - case "border-left-color": - properties = CSSStyleDeclarationPropertySetParser.getBorderLeftColor(value, important); - break; - case "border-top-style": - properties = CSSStyleDeclarationPropertySetParser.getBorderTopStyle(value, important); - break; - case "border-right-style": - properties = CSSStyleDeclarationPropertySetParser.getBorderRightStyle(value, important); - break; - case "border-bottom-style": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottomStyle(value, important); - break; - case "border-left-style": - properties = CSSStyleDeclarationPropertySetParser.getBorderLeftStyle(value, important); - break; - case "border-radius": - properties = CSSStyleDeclarationPropertySetParser.getBorderRadius(value, important); - break; - case "border-top-left-radius": - properties = CSSStyleDeclarationPropertySetParser.getBorderTopLeftRadius(value, important); - break; - case "border-top-right-radius": - properties = CSSStyleDeclarationPropertySetParser.getBorderTopRightRadius(value, important); - break; - case "border-bottom-right-radius": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottomRightRadius(value, important); - break; - case "border-bottom-left-radius": - properties = CSSStyleDeclarationPropertySetParser.getBorderBottomLeftRadius(value, important); - break; - case "border-collapse": - properties = CSSStyleDeclarationPropertySetParser.getBorderCollapse(value, important); - break; - case "outline": - properties = CSSStyleDeclarationPropertySetParser.getOutline(value, important); - break; - case "outline-width": - properties = CSSStyleDeclarationPropertySetParser.getOutlineWidth(value, important); - break; - case "outline-style": - properties = CSSStyleDeclarationPropertySetParser.getOutlineStyle(value, important); - break; - case "outline-color": - properties = CSSStyleDeclarationPropertySetParser.getOutlineColor(value, important); - break; - case "letter-spacing": - properties = CSSStyleDeclarationPropertySetParser.getLetterSpacing(value, important); - break; - case "word-spacing": - properties = CSSStyleDeclarationPropertySetParser.getWordSpacing(value, important); - break; - case "clear": - properties = CSSStyleDeclarationPropertySetParser.getClear(value, important); - break; - case "clip": - properties = CSSStyleDeclarationPropertySetParser.getClip(value, important); - break; - case "css-float": - properties = CSSStyleDeclarationPropertySetParser.getCSSFloat(value, important); - break; - case "float": - properties = CSSStyleDeclarationPropertySetParser.getFloat(value, important); - break; - case "display": - properties = CSSStyleDeclarationPropertySetParser.getDisplay(value, important); - break; - case "direction": - properties = CSSStyleDeclarationPropertySetParser.getDirection(value, important); - break; - case "flex": - properties = CSSStyleDeclarationPropertySetParser.getFlex(value, important); - break; - case "flex-shrink": - properties = CSSStyleDeclarationPropertySetParser.getFlexShrink(value, important); - break; - case "flex-grow": - properties = CSSStyleDeclarationPropertySetParser.getFlexGrow(value, important); - break; - case "flex-basis": - properties = CSSStyleDeclarationPropertySetParser.getFlexBasis(value, important); - break; - case "padding": - properties = CSSStyleDeclarationPropertySetParser.getPadding(value, important); - break; - case "padding-top": - properties = CSSStyleDeclarationPropertySetParser.getPaddingTop(value, important); - break; - case "padding-right": - properties = CSSStyleDeclarationPropertySetParser.getPaddingRight(value, important); - break; - case "padding-bottom": - properties = CSSStyleDeclarationPropertySetParser.getPaddingBottom(value, important); - break; - case "padding-left": - properties = CSSStyleDeclarationPropertySetParser.getPaddingLeft(value, important); - break; - case "margin": - properties = CSSStyleDeclarationPropertySetParser.getMargin(value, important); - break; - case "margin-top": - properties = CSSStyleDeclarationPropertySetParser.getMarginTop(value, important); - break; - case "margin-right": - properties = CSSStyleDeclarationPropertySetParser.getMarginRight(value, important); - break; - case "margin-bottom": - properties = CSSStyleDeclarationPropertySetParser.getMarginBottom(value, important); - break; - case "margin-left": - properties = CSSStyleDeclarationPropertySetParser.getMarginLeft(value, important); - break; - case "background": - properties = CSSStyleDeclarationPropertySetParser.getBackground(value, important); - break; - case "background-image": - properties = CSSStyleDeclarationPropertySetParser.getBackgroundImage(value, important); - break; - case "background-color": - properties = CSSStyleDeclarationPropertySetParser.getBackgroundColor(value, important); - break; - case "background-repeat": - properties = CSSStyleDeclarationPropertySetParser.getBackgroundRepeat(value, important); - break; - case "background-attachment": - properties = CSSStyleDeclarationPropertySetParser.getBackgroundAttachment(value, important); - break; - case "background-position": - properties = CSSStyleDeclarationPropertySetParser.getBackgroundPosition(value, important); - break; - case "width": - properties = CSSStyleDeclarationPropertySetParser.getWidth(value, important); - break; - case "height": - properties = CSSStyleDeclarationPropertySetParser.getHeight(value, important); - break; - case "top": - properties = CSSStyleDeclarationPropertySetParser.getTop(value, important); - break; - case "right": - properties = CSSStyleDeclarationPropertySetParser.getRight(value, important); - break; - case "bottom": - properties = CSSStyleDeclarationPropertySetParser.getBottom(value, important); - break; - case "left": - properties = CSSStyleDeclarationPropertySetParser.getLeft(value, important); - break; - case "font": - properties = CSSStyleDeclarationPropertySetParser.getFont(value, important); - break; - case "font-style": - properties = CSSStyleDeclarationPropertySetParser.getFontStyle(value, important); - break; - case "font-variant": - properties = CSSStyleDeclarationPropertySetParser.getFontVariant(value, important); - break; - case "font-weight": - properties = CSSStyleDeclarationPropertySetParser.getFontWeight(value, important); - break; - case "font-stretch": - properties = CSSStyleDeclarationPropertySetParser.getFontStretch(value, important); - break; - case "font-size": - properties = CSSStyleDeclarationPropertySetParser.getFontSize(value, important); - break; - case "line-height": - properties = CSSStyleDeclarationPropertySetParser.getLineHeight(value, important); - break; - case "text-indent": - properties = CSSStyleDeclarationPropertySetParser.getTextIndent(value, important); - break; - case "font-family": - properties = CSSStyleDeclarationPropertySetParser.getFontFamily(value, important); - break; - case "color": - properties = CSSStyleDeclarationPropertySetParser.getColor(value, important); - break; - case "flood-color": - properties = CSSStyleDeclarationPropertySetParser.getFloodColor(value, important); - break; - case "text-transform": - properties = CSSStyleDeclarationPropertySetParser.getTextTransform(value, important); - break; - case "visibility": - properties = CSSStyleDeclarationPropertySetParser.getVisibility(value, important); - break; - case "aspect-ratio": - properties = CSSStyleDeclarationPropertySetParser.getAspectRatio(value, important); - break; - default: - const trimmedValue = value.trim(); - if (trimmedValue) { - const globalValue = CSSStyleDeclarationValueParser.getGlobal(trimmedValue); - properties = { - [name]: { value: globalValue || trimmedValue, important } - }; - } - break; - } - if (properties !== null && Object.keys(properties).length > 0) { - this.definedPropertyNames[name] = true; - Object.assign(this.properties, properties); - } - } - clone() { - const _class = this.constructor; - const clone = new _class; - clone.properties = JSON.parse(JSON.stringify(this.properties)); - clone.definedPropertyNames = Object.assign({}, this.definedPropertyNames); - return clone; - } - size() { - return Object.keys(this.properties).length; - } - item(index) { - return Object.keys(this.properties)[index] || ""; - } - toString() { - const result = []; - const clone = this.clone(); - const properties = {}; - for (const shorthandPropertyGroup of TO_STRING_SHORTHAND_PROPERTIES) { - for (const shorthandProperty of shorthandPropertyGroup) { - if (Array.isArray(shorthandProperty)) { - let isMatch = false; - for (const childShorthandProperty of shorthandProperty) { - const property = clone.get(childShorthandProperty); - if (property) { - properties[childShorthandProperty] = property; - clone.remove(childShorthandProperty); - isMatch = true; - } - } - if (isMatch) { - break; - } - } else { - const property = clone.get(shorthandProperty); - if (property) { - properties[shorthandProperty] = property; - clone.remove(shorthandProperty); - break; - } - } - } - } - for (const name of Object.keys(clone.properties)) { - properties[name] = clone.get(name); - } - for (const definedPropertyName of Object.keys(this.definedPropertyNames)) { - const property = properties[definedPropertyName]; - if (property) { - result.push(`${definedPropertyName}: ${property.value}${property.important ? " !important" : ""};`); - delete properties[definedPropertyName]; - } - } - for (const propertyName of Object.keys(properties)) { - const property = properties[propertyName]; - if (property) { - result.push(`${propertyName}: ${property.value}${property.important ? " !important" : ""};`); - } - } - return result.join(" "); - } -} - -// node_modules/happy-dom/lib/css/declaration/computed-style/config/CSSStyleDeclarationElementDefaultCSS.js -var CSSStyleDeclarationElementDefaultCSS_default = { - default: "display: inline;", - A: "", - ABBR: "", - ADDRESS: "display: block;", - AREA: "", - ARTICLE: "display: block;", - ASIDE: "display: block;", - AUDIO: "display: none;", - B: "", - BASE: "display: none;", - BDI: "", - BDO: "", - BLOCKQUAOTE: "", - BODY: "display: block;", - TEMPLATE: "display: none;", - FORM: "display: block;", - INPUT: "display: inline-block;", - TEXTAREA: "display: inline-block;", - SCRIPT: "display: none;", - IMG: "", - LINK: "display: none;", - STYLE: "display: none;", - LABEL: "", - SLOT: "display: contents;", - SVG: "", - CIRCLE: "", - ELLIPSE: "", - LINE: "", - PATH: "", - POLYGON: "", - POLYLINE: "", - RECT: "", - STOP: "", - USE: "", - META: "display: none;", - BLOCKQUOTE: "display: block;", - BR: "", - BUTTON: "display: inline-block;", - CANVAS: "", - CAPTION: "display: table-caption;", - CITE: "", - CODE: "", - COL: "display: table-column;", - COLGROUP: "display: table-column-group;", - DATA: "", - DATALIST: "display: none;", - DD: "display: block;", - DEL: "", - DETAILS: "display: block;", - DFN: "", - DIALOG: { - default: "display: none;", - open: "display: block;" - }, - DIV: "display: block;", - DL: "display: block;", - DT: "display: block;", - EM: "", - EMBED: "", - FIELDSET: "display: block;", - FIGCAPTION: "display: block;", - FIGURE: "display: block;", - FOOTER: "display: block;", - H1: "display: block;", - H2: "display: block;", - H3: "display: block;", - H4: "display: block;", - H5: "display: block;", - H6: "display: block;", - HEAD: "display: none;", - HEADER: "display: block;", - HGROUP: "display: block;", - HR: "display: block;", - HTML: 'display: block;direction: ltr;font: 16px "Times New Roman";', - I: "", - IFRAME: "", - INS: "", - KBD: "", - LEGEND: "display: block;", - LI: "display: list-item;", - MAIN: "display: block;", - MAP: "", - MARK: "", - MATH: "", - MENU: "display: block;", - MENUITEM: "", - METER: "display: inline-block;", - NAV: "display: block;", - NOSCRIPT: "", - OBJECT: "", - OL: "display: block;", - OPTGROUP: "display: block;", - OPTION: "display: block;", - OUTPUT: "unicode-bidi: isolate;", - P: "display: block;", - PARAM: "display: none;", - PICTURE: "", - PRE: "display: block;", - PROGRESS: "display: inline-block;", - Q: "", - RB: "", - RP: "display: none;", - RT: "", - RTC: "", - RUBY: "", - S: "", - SAMP: "", - SECTION: "display: block;", - SELECT: "display: inline-block;", - SMALL: "", - SOURCE: "", - SPAN: "", - STRONG: "", - SUB: "", - SUMMARY: "display: block;", - SUP: "", - TABLE: "display: table;", - TBODY: "display: table-row-group;", - TD: "display: table-cell;", - TFOOT: "display: table-footer-group;", - TH: "display: table-cell;", - THEAD: "display: table-header-group;", - TIME: "", - TITLE: "display: none;", - TR: "display: table-row;", - TRACK: "", - U: "", - UL: "display: block;", - VAR: "", - VIDEO: "", - WBR: "" -}; - -// node_modules/happy-dom/lib/css/declaration/computed-style/config/CSSStyleDeclarationElementInheritedProperties.js -var CSSStyleDeclarationElementInheritedProperties_default = { - "border-collapse": true, - "border-spacing": true, - "caption-side": true, - color: true, - cursor: true, - direction: true, - "empty-cells": true, - "font-family": true, - "font-size": true, - "font-style": true, - "font-variant": true, - "font-weight": true, - "font-size-adjust": true, - "font-stretch": true, - font: true, - "letter-spacing": true, - "line-height": true, - "list-style-image": true, - "list-style-position": true, - "list-style-type": true, - "list-style": true, - orphans: true, - quotes: true, - "tab-size": true, - "text-align": true, - "text-align-last": true, - "text-decoration-color": true, - "text-indent": true, - "text-justify": true, - "text-shadow": true, - "text-transform": true, - visibility: true, - "white-space": true, - widows: true, - "word-break": true, - "word-spacing": true, - "word-wrap": true -}; - -// node_modules/happy-dom/lib/css/declaration/computed-style/config/CSSStyleDeclarationElementMeasurementProperties.js -var CSSStyleDeclarationElementMeasurementProperties_default = [ - "background-position-x", - "background-position-y", - "background-size", - "border-image-outset", - "border-top-width", - "border-right-width", - "border-bottom-width", - "border-left-width", - "border-top-left-radius", - "border-top-right-radius", - "border-bottom-right-radius", - "border-bottom-left-radius", - "border-image-width", - "clip", - "font-size", - "padding-top", - "padding-right", - "padding-bottom", - "padding-left", - "margin-top", - "margin-right", - "margin-bottom", - "margin-left", - "width", - "height", - "min-width", - "min-height", - "max-width", - "max-height", - "top", - "right", - "bottom", - "left", - "outline-width", - "outline-offset", - "letter-spacing", - "word-spacing", - "text-indent", - "line-height" -]; - -// node_modules/happy-dom/lib/utilities/ClassMethodBinder.js -class ClassMethodBinder { - target; - classes; - cache = new Map; - constructor(target, classes) { - this.target = target; - this.classes = classes; - } - bind(name) { - if (this.cache.has(name) || name === Symbol.iterator || name === "constructor") { - return; - } - this.cache.set(name, true); - const target = this.target; - if (!(name in target)) { - return; - } - for (const _class of this.classes) { - const descriptor = Object.getOwnPropertyDescriptor(_class.prototype, name); - if (descriptor) { - if (typeof descriptor.value === "function") { - if (descriptor.value.toString().startsWith("class ")) { - return; - } - Object.defineProperty(target, name, { - ...descriptor, - value: descriptor.value.bind(target) - }); - } else if (descriptor.get !== undefined) { - Object.defineProperty(target, name, { - ...descriptor, - get: descriptor.get?.bind(target), - set: descriptor.set?.bind(target) - }); - } - return; - } - } - } - preventBinding(name) { - this.cache.set(name, true); - } -} - -// node_modules/happy-dom/lib/nodes/node/NodeList.js -class NodeList { - [items]; - [proxy]; - constructor(illegalConstructorSymbol, items2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[items] = items2; - const methodBinder = new ClassMethodBinder(this, this.constructor !== NodeList ? [this.constructor, NodeList] : [NodeList]); - const proxy2 = new Proxy(this, { - get: (target, property) => { - if (property === "length") { - return items2.length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - if (property === "") { - return; - } - const index = Number(property); - if (!isNaN(index)) { - return items2[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys() { - return Object.keys(items2); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < items2.length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - if (!isNaN(index) && items2[index]) { - return { - value: items2[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - this[proxy] = proxy2; - return proxy2; - } - get length() { - return this[items].length; - } - get [Symbol.toStringTag]() { - return "NodeList"; - } - toLocaleString() { - return "[object NodeList]"; - } - toString() { - return "[object NodeList]"; - } - item(index) { - const nodes = this[items]; - return index >= 0 && nodes[index] ? nodes[index] : null; - } - [Symbol.iterator]() { - const items2 = this[items]; - return items2[Symbol.iterator](); - } - values() { - return this[items].values(); - } - entries() { - return this[items].entries(); - } - forEach(callback, thisArg) { - const items2 = this[items]; - const proxy2 = this[proxy] ?? this; - for (let i = 0, max = items2.length;i < max; i++) { - const item = items2[i]; - callback.call(thisArg ?? item[window], item, i, proxy2); - } - } - keys() { - return this[items].keys(); - } -} -var NodeList_default = NodeList; - -// node_modules/happy-dom/lib/query-selector/SelectorCombinatorEnum.js -var SelectorCombinatorEnum; -(function(SelectorCombinatorEnum) { - SelectorCombinatorEnum["none"] = "none"; - SelectorCombinatorEnum["descendant"] = "descendant"; - SelectorCombinatorEnum["child"] = "child"; - SelectorCombinatorEnum["adjacentSibling"] = "adjacentSibling"; - SelectorCombinatorEnum["subsequentSibling"] = "subsequentSibling"; -})(SelectorCombinatorEnum || (SelectorCombinatorEnum = {})); -var SelectorCombinatorEnum_default = SelectorCombinatorEnum; - -// node_modules/happy-dom/lib/query-selector/SelectorItem.js -class SelectorItem { - tagName; - id; - classNames; - attributes; - pseudos; - isPseudoElement; - combinator; - constructor(options) { - this.tagName = options?.tagName || null; - this.id = options?.id || null; - this.classNames = options?.classNames || null; - this.attributes = options?.attributes || null; - this.pseudos = options?.pseudos || null; - this.isPseudoElement = options?.isPseudoElement || false; - this.combinator = options?.combinator || SelectorCombinatorEnum_default.none; - } - match(scope, element, ignoreErrors) { - let priorityWeight = 0; - if (this.isPseudoElement) { - return null; - } - if (this.tagName) { - if (this.tagName !== "*" && this.tagName !== element[tagName].toUpperCase()) { - return null; - } - priorityWeight += 1; - } - if (this.id) { - if (this.id !== element.id) { - return null; - } - priorityWeight += 100; - } - if (this.classNames) { - const result = this.matchClass(element); - if (!result) { - return null; - } - priorityWeight += result.priorityWeight; - } - if (this.attributes) { - const result = this.matchAttributes(element); - if (!result) { - return null; - } - priorityWeight += result.priorityWeight; - } - if (this.pseudos) { - const result = this.matchPseudo(scope, element, ignoreErrors); - if (!result) { - return null; - } - priorityWeight += result.priorityWeight; - } - return { priorityWeight }; - } - matchPseudo(scope, element, ignoreErrors) { - const parent = element[parentNode]; - const parentChildren = element[parentNode] ? element[parentNode][elementArray] : []; - if (!this.pseudos) { - return { priorityWeight: 0 }; - } - let priorityWeight = 0; - for (const pseudo of this.pseudos) { - switch (pseudo.name) { - case "not": - case "nth-child": - case "nth-of-type": - case "nth-last-child": - case "nth-last-of-type": - case "is": - case "where": - if (!pseudo.arguments) { - if (ignoreErrors) { - return null; - } - throw new element[window].DOMException(`Failed to execute 'matches' on '${element.constructor.name}': '${this.getSelectorString()}' is not a valid selector.`); - } - break; - } - if (!parent) { - switch (pseudo.name) { - case "first-child": - case "last-child": - case "only-child": - case "first-of-type": - case "last-of-type": - case "only-of-type": - case "nth-child": - case "nth-of-type": - case "nth-last-child": - case "nth-last-of-type": - return null; - } - } - const selectorMatch = this.matchPseudoItem(scope, element, parentChildren, pseudo, ignoreErrors); - if (!selectorMatch) { - return null; - } - priorityWeight += selectorMatch.priorityWeight; - } - return { priorityWeight }; - } - matchPseudoItem(scope, element, parentChildren, pseudo, ignoreErrors) { - const root = this.getRootElement(scope); - switch (pseudo.name) { - case "first-child": - return parentChildren[0] === element ? { priorityWeight: 10 } : null; - case "last-child": - return parentChildren.length && parentChildren[parentChildren.length - 1] === element ? { priorityWeight: 10 } : null; - case "only-child": - return parentChildren.length === 1 && parentChildren[0] === element ? { priorityWeight: 10 } : null; - case "first-of-type": - for (const child of parentChildren) { - if (child[tagName] === element[tagName]) { - return child === element ? { priorityWeight: 10 } : null; - } - } - return null; - case "last-of-type": - for (let i = parentChildren.length - 1;i >= 0; i--) { - const child = parentChildren[i]; - if (child[tagName] === element[tagName]) { - return child === element ? { priorityWeight: 10 } : null; - } - } - return null; - case "only-of-type": - let isFound = false; - for (const child of parentChildren) { - if (child[tagName] === element[tagName]) { - if (isFound || child !== element) { - return null; - } - isFound = true; - } - } - return isFound ? { priorityWeight: 10 } : null; - case "checked": - return element[tagName] === "INPUT" && element.checked ? { priorityWeight: 10 } : null; - case "disabled": - return "disabled" in element && element.hasAttribute("disabled") ? { priorityWeight: 10 } : null; - case "empty": - return !element[elementArray].length ? { priorityWeight: 10 } : null; - case "root": - return root && element === root ? { priorityWeight: 10 } : null; - case "not": - for (const selectorItem of pseudo.selectorItems) { - if (selectorItem.match(scope, element)) { - return null; - } - } - return { priorityWeight: 10 }; - case "nth-child": - let nthChildIndex = -1; - if (pseudo.selectorItems?.[0] && !pseudo.selectorItems[0].match(scope, element)) { - return null; - } - for (let i = 0, max = parentChildren.length;i < max; i++) { - if (!pseudo.selectorItems?.[0] || pseudo.selectorItems[0].match(scope, parentChildren[i])) { - nthChildIndex++; - } - if (parentChildren[i] === element) { - return nthChildIndex !== -1 && pseudo.nthFunction(nthChildIndex + 1) ? { priorityWeight: 10 } : null; - } - } - return null; - case "nth-of-type": - let nthOfTypeIndex = -1; - for (let i = 0, max = parentChildren.length;i < max; i++) { - if (parentChildren[i][tagName] === element[tagName]) { - nthOfTypeIndex++; - } - if (parentChildren[i] === element) { - return nthOfTypeIndex !== -1 && pseudo.nthFunction(nthOfTypeIndex + 1) ? { priorityWeight: 10 } : null; - } - } - return null; - case "nth-last-child": - let nthLastChildIndex = -1; - if (pseudo.selectorItems?.[0] && !pseudo.selectorItems[0].match(scope, element)) { - return null; - } - for (let i = parentChildren.length - 1;i >= 0; i--) { - if (!pseudo.selectorItems?.[0] || pseudo.selectorItems[0].match(scope, parentChildren[i])) { - nthLastChildIndex++; - } - if (parentChildren[i] === element) { - return nthLastChildIndex !== -1 && pseudo.nthFunction(nthLastChildIndex + 1) ? { priorityWeight: 10 } : null; - } - } - return null; - case "nth-last-of-type": - let nthLastOfTypeIndex = -1; - for (let i = parentChildren.length - 1;i >= 0; i--) { - if (parentChildren[i][tagName] === element[tagName]) { - nthLastOfTypeIndex++; - } - if (parentChildren[i] === element) { - return nthLastOfTypeIndex !== -1 && pseudo.nthFunction(nthLastOfTypeIndex + 1) ? { priorityWeight: 10 } : null; - } - } - return null; - case "target": - const hash = element[ownerDocument].location.hash; - if (!hash) { - return null; - } - return element.isConnected && element.id === hash.slice(1) ? { priorityWeight: 10 } : null; - case "is": - let priorityWeightForIs = 0; - if (!pseudo.selectorItems) { - return null; - } - for (const selectorItem of pseudo.selectorItems) { - const match = selectorItem.match(scope, element); - if (match && priorityWeightForIs < match.priorityWeight) { - priorityWeightForIs = match.priorityWeight; - } - } - return priorityWeightForIs ? { priorityWeight: priorityWeightForIs } : null; - case "where": - if (!pseudo.selectorItems) { - return null; - } - for (const selectorItem of pseudo.selectorItems) { - if (selectorItem.match(scope, element)) { - return { priorityWeight: 0 }; - } - } - return null; - case "has": - let priorityWeightForHas = 0; - if (pseudo.arguments && pseudo.selectorItems) { - if (pseudo.arguments[0] === "+") { - const nextSibling = element.nextElementSibling; - if (!nextSibling) { - return null; - } - for (const selectorItem of pseudo.selectorItems) { - const match = selectorItem.match(scope, nextSibling); - if (match && priorityWeightForHas < match.priorityWeight) { - priorityWeightForHas = match.priorityWeight; - } - } - } else if (pseudo.arguments[0] === ">") { - for (const selectorItem of pseudo.selectorItems) { - for (const child of element[elementArray]) { - const match = selectorItem.match(scope, child); - if (match && priorityWeightForHas < match.priorityWeight) { - priorityWeightForHas = match.priorityWeight; - break; - } - } - } - } else { - for (const selectorItem of pseudo.selectorItems) { - const match = this.matchChildOfElement(scope, selectorItem, element, ignoreErrors); - if (match && priorityWeightForHas < match.priorityWeight) { - priorityWeightForHas = match.priorityWeight; - } - } - } - } - return priorityWeightForHas ? { priorityWeight: priorityWeightForHas } : null; - case "focus": - case "focus-visible": - return element[ownerDocument].activeElement === element ? { priorityWeight: 10 } : null; - case "scope": - return scope && scope === element ? { priorityWeight: 10 } : null; - default: - return null; - } - } - matchAttributes(element) { - if (!this.attributes) { - return null; - } - let priorityWeight = 0; - for (const attribute of this.attributes) { - const elementAttribute = element[attributes].getNamedItem(attribute.name); - if (!elementAttribute) { - return null; - } - priorityWeight += 10; - if (attribute.value !== null && (elementAttribute[value] === null || attribute.regExp && !attribute.regExp.test(elementAttribute[value]) || !attribute.regExp && attribute.value !== elementAttribute[value])) { - return null; - } - } - return { priorityWeight }; - } - matchClass(element) { - if (!this.classNames) { - return null; - } - let priorityWeight = 0; - for (const className of this.classNames) { - if (!element.classList.contains(className)) { - return null; - } - priorityWeight += 10; - } - return { priorityWeight }; - } - matchChildOfElement(scope, selectorItem, element, ignoreErrors) { - for (const child of element[elementArray]) { - const match = selectorItem.match(scope, child, ignoreErrors); - if (match) { - return match; - } - const childMatch = this.matchChildOfElement(scope, selectorItem, child, ignoreErrors); - if (childMatch) { - return childMatch; - } - } - return null; - } - getSelectorString() { - return `${this.tagName ? this.tagName.toLowerCase() : ""}${this.id ? `#${this.id}` : ""}${this.classNames ? `.${this.classNames.join(".")}` : ""}${this.attributes ? this.attributes.map((attribute) => `[${attribute.name}${attribute.value ? `${attribute.operator || ""}="${attribute.value}"` : ""}]`).join("") : ""}${this.pseudos ? this.pseudos.map((pseudo) => `:${pseudo.name}${pseudo.arguments ? `(${pseudo.arguments})` : ""}`).join("") : ""}`; - } - getRootElement(scope) { - return scope?.[ownerDocument]?.documentElement || scope?.[window].document?.documentElement || null; - } -} - -// node_modules/happy-dom/lib/query-selector/SelectorParser.js -var SELECTOR_GROUP_REGEXP = /(\s*[\s,+>~]\s*)|([\[\]\(\)"'])/g; -var SELECTOR_REGEXP = /(\*)|([a-zA-Z0-9\u00A0-\uFFFF-]+)|#(([a-zA-Z0-9\u00A0-\uFFFF_-]|\\.)+)|\.(([a-zA-Z0-9\u00A0-\uFFFF_-]|\\.)+)|\[(([a-zA-Z0-9-_]|\\.)+)\]|\[(([a-zA-Z0-9-_]|\\.)+)\s*([~|^$*]{0,1})\s*=\s*("([^"]*)"|'([^']*)')\s*(s|i){0,1}\]|\[(([a-zA-Z0-9-_]|\\.)+)\s*([~|^$*]{0,1})\s*=\s*(([a-zA-Z0-9\u00A0-\uFFFF_\u00A4\u00A3-]|\\.)+)\]|:([a-zA-Z-]+)\s*\(.+\)|:([a-zA-Z-]+)|::([a-zA-Z-]+)/g; -var SELECTOR_PSEUDO_REGEXP = /:([a-zA-Z-]+)|([()])/g; -var ESCAPED_CHARACTER_REGEXP = /\\/g; -var CSS_UNESCAPE_REGEXP = /\\([0-9a-fA-F]{1,6})\s?|\\(.)/g; -var ATTRIBUTE_ESCAPE_REGEXP = /[.*+?^${}()|[\]\\]/g; -var NTH_FUNCTION = { - odd: (n) => (n + 1) % 2 === 0, - even: (n) => (n + 1) % 2 !== 0, - alwaysFalse: () => false -}; -var SPACE_REGEXP = / /g; - -class SelectorParser { - window; - scope; - ignoreErrors; - constructor(options) { - this.window = options.window; - this.scope = options.scope; - this.ignoreErrors = options.ignoreErrors ?? false; - } - getSelectorItem(selector) { - return this.getSelectorGroups(selector)[0][0]; - } - getSelectorGroups(selector) { - selector = selector.trim(); - const cached = this.window[querySelectorCache].get(selector); - if (cached) { - return cached; - } - const groups = this.getSelectorGroupsUncached(selector); - this.window[querySelectorCache].set(selector, groups); - return groups; - } - getInvalidSelectorError(selector) { - const name = this.scope.nodeType === NodeTypeEnum_default.documentNode ? "Document" : "Element"; - return new this.window.DOMException(`Failed to execute 'querySelectorAll' on '${name}': '${selector}' is not a valid selector.`); - } - getSelectorGroupsUncached(selector) { - let currentGroup = []; - const groups = [currentGroup]; - const regExp = new RegExp(SELECTOR_GROUP_REGEXP); - const depth = { - parentheses: 0, - brackets: 0, - doubleApostrophe: 0, - singleApostrophe: 0 - }; - let match = null; - let lastIndex = 0; - let selectorItem = null; - let combinator = SelectorCombinatorEnum_default.none; - while (match = regExp.exec(selector)) { - if (match[1]) { - if (depth.parentheses === 0 && depth.brackets === 0 && depth.singleApostrophe === 0 && depth.doubleApostrophe === 0) { - const childSelector = selector.substring(lastIndex, match.index).trim(); - switch (match[1].trim()) { - case ",": - selectorItem = this.getSelectorGroupItem(childSelector, combinator); - if (!selectorItem) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - currentGroup.push(selectorItem); - currentGroup = []; - groups.push(currentGroup); - combinator = SelectorCombinatorEnum_default.none; - break; - case ">": - selectorItem = this.getSelectorGroupItem(childSelector, combinator); - if (!selectorItem) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - currentGroup.push(selectorItem); - combinator = SelectorCombinatorEnum_default.child; - break; - case "+": - selectorItem = this.getSelectorGroupItem(childSelector, combinator); - if (!selectorItem) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - currentGroup.push(selectorItem); - combinator = SelectorCombinatorEnum_default.adjacentSibling; - break; - case "~": - selectorItem = this.getSelectorGroupItem(childSelector, combinator); - if (!selectorItem) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - currentGroup.push(selectorItem); - combinator = SelectorCombinatorEnum_default.subsequentSibling; - break; - case "": - selectorItem = this.getSelectorGroupItem(childSelector, combinator); - if (!selectorItem) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - currentGroup.push(selectorItem); - combinator = SelectorCombinatorEnum_default.descendant; - break; - } - lastIndex = regExp.lastIndex; - } - } else { - switch (match[2]) { - case "(": - if (depth.singleApostrophe === 0 && depth.doubleApostrophe === 0) { - depth.parentheses++; - } - break; - case ")": - if (depth.singleApostrophe === 0 && depth.doubleApostrophe === 0) { - depth.parentheses--; - } - break; - case "[": - if (depth.singleApostrophe === 0 && depth.doubleApostrophe === 0) { - depth.brackets++; - } - break; - case "]": - if (depth.singleApostrophe === 0 && depth.doubleApostrophe === 0) { - depth.brackets--; - } - break; - case '"': - if (depth.singleApostrophe === 0) { - depth.doubleApostrophe = depth.doubleApostrophe === 1 ? 0 : 1; - } - break; - case "'": - if (depth.doubleApostrophe === 0) { - depth.singleApostrophe = depth.singleApostrophe === 1 ? 0 : 1; - } - break; - } - } - } - selectorItem = this.getSelectorGroupItem(selector.substring(lastIndex), combinator); - if (!selectorItem || depth.parentheses !== 0 || depth.brackets !== 0 || depth.singleApostrophe !== 0 || depth.doubleApostrophe !== 0) { - if (this.ignoreErrors) { - return []; - } - throw this.getInvalidSelectorError(selector); - } - if (combinator === SelectorCombinatorEnum_default.none && currentGroup.length > 0) { - groups.push([selectorItem]); - } else { - currentGroup.push(selectorItem); - } - return groups; - } - getSelectorGroupItem(selector, combinator) { - selector = selector.trim(); - if (!selector) { - return null; - } - if (selector === "*") { - return new SelectorItem({ tagName: "*", combinator }); - } - const regexp = new RegExp(SELECTOR_REGEXP); - const selectorItem = new SelectorItem({ - combinator - }); - let match; - let lastIndex = 0; - while (match = regexp.exec(selector)) { - if (selector.substring(lastIndex, match.index).trim() !== "") { - return null; - } - if (match[1]) { - selectorItem.tagName = "*"; - } else if (match[2]) { - selectorItem.tagName = match[2].toUpperCase(); - } else if (match[3]) { - selectorItem.id = match[3].replace(ESCAPED_CHARACTER_REGEXP, ""); - } else if (match[5]) { - selectorItem.classNames = selectorItem.classNames || []; - selectorItem.classNames.push(match[5].replace(ESCAPED_CHARACTER_REGEXP, "")); - } else if (match[7]) { - selectorItem.attributes = selectorItem.attributes || []; - selectorItem.attributes.push({ - name: match[7].replace(ESCAPED_CHARACTER_REGEXP, ""), - operator: null, - value: null, - modifier: null, - regExp: null - }); - } else if (match[9] && (match[13] !== undefined || match[14] !== undefined)) { - const value = match[13] ?? match[14]; - const unescapedValue = SelectorParser.cssUnescape(value); - selectorItem.attributes = selectorItem.attributes || []; - selectorItem.attributes.push({ - name: match[9].replace(ESCAPED_CHARACTER_REGEXP, ""), - operator: match[11] || null, - value: unescapedValue, - modifier: match[15] || null, - regExp: this.getAttributeRegExp({ - operator: match[11], - value: unescapedValue, - modifier: match[15] - }) - }); - } else if (match[16] && match[19] !== undefined) { - const unescapedValue = SelectorParser.cssUnescape(match[19]); - selectorItem.attributes = selectorItem.attributes || []; - selectorItem.attributes.push({ - name: match[16].replace(ESCAPED_CHARACTER_REGEXP, ""), - operator: match[18] || null, - value: unescapedValue, - modifier: null, - regExp: this.getAttributeRegExp({ operator: match[18], value: unescapedValue }) - }); - } else if (match[21]) { - const pseudoRegExp = new RegExp(SELECTOR_PSEUDO_REGEXP); - let pseudoMatch = null; - let name = null; - let depth = 0; - let pseudoStartIndex = -1; - while (pseudoMatch = pseudoRegExp.exec(match[0])) { - if (pseudoMatch[1]) { - if (depth === 0) { - name = pseudoMatch[1]; - } - } else if (pseudoMatch[2]) { - if (pseudoMatch[2] === "(") { - if (depth === 0) { - pseudoStartIndex = pseudoRegExp.lastIndex; - } - depth++; - } else if (pseudoMatch[2] === ")") { - depth--; - if (depth < 0) { - return null; - } - if (depth === 0) { - if (pseudoStartIndex === -1 || !name) { - return null; - } - selectorItem.pseudos = selectorItem.pseudos || []; - selectorItem.pseudos.push(this.getPseudo(name, match[0].substring(pseudoStartIndex, pseudoMatch.index))); - name = null; - pseudoStartIndex = -1; - } - } - } - } - } else if (match[22]) { - selectorItem.pseudos = selectorItem.pseudos || []; - selectorItem.pseudos.push(this.getPseudo(match[22], null)); - } else if (match[23]) { - selectorItem.isPseudoElement = true; - } - lastIndex = regexp.lastIndex; - } - if (lastIndex < selector.length) { - return null; - } - return selectorItem; - } - getAttributeRegExp(attribute) { - const modifier = attribute.modifier === "i" ? "i" : ""; - if (!attribute.operator || !attribute.value) { - return null; - } - const escapedValue = attribute.value.replace(ATTRIBUTE_ESCAPE_REGEXP, "\\$&"); - switch (attribute.operator) { - case "~": - return new RegExp(`(^|\\s)${escapedValue}(\\s|$)`, modifier); - case "|": - return new RegExp(`^${escapedValue}[- ]|^${escapedValue}$`, modifier); - case "^": - return new RegExp(`^${escapedValue}`, modifier); - case "$": - return new RegExp(`${escapedValue}$`, modifier); - case "*": - return new RegExp(`${escapedValue}`, modifier); - default: - return null; - } - } - getPseudo(name, args) { - const lowerName = name.toLowerCase(); - if (args) { - args = args.trim(); - } - if (!args) { - return { name: lowerName, arguments: null, selectorItems: null, nthFunction: null }; - } - switch (lowerName) { - case "nth-last-child": - case "nth-child": - const nthOfIndex = args.indexOf(" of "); - const nthFunction = nthOfIndex !== -1 ? args.substring(0, nthOfIndex) : args; - const selectorItem = nthOfIndex !== -1 ? this.getSelectorItem(args.substring(nthOfIndex + 4).trim()) : null; - return { - name: lowerName, - arguments: args, - selectorItems: selectorItem ? [selectorItem] : null, - nthFunction: this.getPseudoNthFunction(nthFunction) - }; - case "nth-of-type": - case "nth-last-of-type": - return { - name: lowerName, - arguments: args, - selectorItems: null, - nthFunction: this.getPseudoNthFunction(args) - }; - case "not": - const notSelectorItems = []; - for (const group of this.getSelectorGroups(args)) { - if (group[0]) { - notSelectorItems.push(group[0]); - } - } - return { - name: lowerName, - arguments: args, - selectorItems: notSelectorItems, - nthFunction: null - }; - case "is": - case "where": - const selectorItems = []; - for (const group of this.getSelectorGroups(args)) { - if (group[0]) { - selectorItems.push(group[0]); - } - } - return { - name: lowerName, - arguments: args, - selectorItems, - nthFunction: null - }; - case "has": - const hasSelectorItems = []; - if (!args.includes(":has(")) { - let newArgs = args; - if (args[0] === "+") { - newArgs = args.replace("+", ""); - } else if (args[0] === ">") { - newArgs = args.replace(">", ""); - } - for (const group of this.getSelectorGroups(newArgs)) { - if (group[0]) { - hasSelectorItems.push(group[0]); - } - } - } - return { - name: lowerName, - arguments: args || "", - selectorItems: hasSelectorItems, - nthFunction: null - }; - case "scope": - case "root": - default: - return { name: lowerName, arguments: args, selectorItems: null, nthFunction: null }; - } - } - getPseudoNthFunction(args) { - if (!args) { - return null; - } - if (args === "odd") { - return NTH_FUNCTION.odd; - } else if (args === "even") { - return NTH_FUNCTION.even; - } - const parts = args.replace(SPACE_REGEXP, "").split("n"); - let partA = parseInt(parts[0], 10) || 0; - if (parts[0] == "-") { - partA = -1; - } - if (parts.length === 1) { - return (n) => n == partA; - } - let partB = parseInt(parts[1], 10) || 0; - if (parts[0] == "+") { - partB = 1; - } - if (partA >= 1 || partA <= -1) { - if (partA >= 1) { - if (Math.abs(partA) === 1) { - return (n) => n > partB - 1; - } - return (n) => n > partB - 1 && (n + -1 * partB) % partA === 0; - } - if (Math.abs(partA) === 1) { - return (n) => n < partB + 1; - } - return (n) => n < partB + 1 && (n + -1 * partB) % partA === 0; - } - if (parts[0]) { - return (n) => n === partB; - } - return (n) => n > partB - 1; - } - static cssUnescape(value) { - return value.replace(CSS_UNESCAPE_REGEXP, (_match, hex, char) => { - if (hex) { - return String.fromCodePoint(parseInt(hex, 16)); - } - return char; - }); - } -} - -// node_modules/happy-dom/lib/query-selector/QuerySelector.js -var INVALID_SELECTOR_REGEXP = /^[.#\[]?\d|[.#]$/; - -class QuerySelector { - static querySelectorAll(node, selector) { - const window2 = node[window]; - if (selector === "") { - throw new window2.DOMException(`Failed to execute 'querySelectorAll' on '${node.constructor.name}': The provided selector is empty.`); - } - if (typeof selector === "function") { - throw new window2.DOMException(`Failed to execute 'querySelectorAll' on '${node.constructor.name}': '${selector}' is not a valid selector.`); - } - if (typeof selector === "symbol") { - throw new window2.TypeError(`Failed to execute 'querySelectorAll' on '${node.constructor.name}': Cannot convert a Symbol value to a string`); - } - selector = String(selector); - if (INVALID_SELECTOR_REGEXP.test(selector)) { - throw new window2.DOMException(`Failed to execute 'querySelectorAll' on '${node.constructor.name}': '${selector}' is not a valid selector.`); - } - const cache2 = node[cache].querySelectorAll; - const cachedResult = cache2.get(selector); - if (cachedResult) { - if (cachedResult.result !== null) { - const result = cachedResult.result.deref(); - if (result) { - return result; - } - } - cache2.delete(selector); - } - const scope = node[nodeType] === NodeTypeEnum_default.documentNode ? node.documentElement : node; - const groups = new SelectorParser({ window: window2, scope }).getSelectorGroups(selector); - const items = []; - const nodeList = new NodeList_default(illegalConstructor, items); - const matchesMap = new Map; - const matchedPositions = []; - const cachedItem = { - result: new WeakRef(nodeList) - }; - node[cache].querySelectorAll.set(selector, cachedItem); - if (node[isConnected]) { - (node[ownerDocument] || node)[affectsCache].push(cachedItem); - } - for (const selectorItems of groups) { - const rootElement = node[nodeType] === NodeTypeEnum_default.elementNode ? node : null; - const children = node[nodeType] === NodeTypeEnum_default.elementNode ? [node] : node[elementArray]; - const matches = this.findAll({ scope, rootElement, children, selectorItems, cachedItem }); - for (const match of matches) { - if (!matchesMap.has(match.documentPosition)) { - matchesMap.set(match.documentPosition, match.element); - matchedPositions.push(match.documentPosition); - } - } - } - const keys = matchedPositions.sort(); - for (let i = 0, max = keys.length;i < max; i++) { - items.push(matchesMap.get(keys[i])); - } - return nodeList; - } - static querySelector(node, selector) { - const window2 = node[window]; - if (selector === "") { - throw new window2.DOMException(`Failed to execute 'querySelector' on '${node.constructor.name}': The provided selector is empty.`); - } - if (typeof selector === "function") { - throw new window2.DOMException(`Failed to execute 'querySelector' on '${node.constructor.name}': '${selector}' is not a valid selector.`); - } - if (typeof selector === "symbol") { - throw new window2.TypeError(`Failed to execute 'querySelector' on '${node.constructor.name}': Cannot convert a Symbol value to a string`); - } - selector = String(selector); - if (INVALID_SELECTOR_REGEXP.test(selector)) { - throw new window2.DOMException(`Failed to execute 'querySelector' on '${node.constructor.name}': '${selector}' is not a valid selector.`); - } - const cachedResult = node[cache].querySelector.get(selector); - if (cachedResult) { - if (cachedResult.result !== null) { - if (!cachedResult.result.element) { - return null; - } - const result = cachedResult.result.element.deref(); - if (result) { - return result; - } - } - node[cache].querySelector.delete(selector); - } - const cachedItem = { - result: { element: null } - }; - node[cache].querySelector.set(selector, cachedItem); - if (node[isConnected]) { - (node[ownerDocument] || node)[affectsCache].push(cachedItem); - } - let bestMatch = null; - const matchesMap = new Map; - const scope = node[nodeType] === NodeTypeEnum_default.documentNode ? node.documentElement : node; - for (const selectorItems of new SelectorParser({ window: window2, scope }).getSelectorGroups(selector)) { - const rootElement = node[nodeType] === NodeTypeEnum_default.elementNode ? node : null; - const children = node[nodeType] === NodeTypeEnum_default.elementNode ? [node] : node[elementArray]; - const match = this.findFirst({ scope, rootElement, children, selectorItems, cachedItem }); - if (match && !matchesMap.has(match.documentPosition)) { - matchesMap.set(match.documentPosition, true); - if (!bestMatch || match.documentPosition < bestMatch.documentPosition) { - bestMatch = match; - } - } - } - const element = bestMatch?.element || null; - cachedItem.result = { element: element ? new WeakRef(element) : null }; - return element; - } - static matches(element, selector, options) { - const ignoreErrors = options?.ignoreErrors; - const window2 = element[window]; - if (selector === "*") { - return { - priorityWeight: 1 - }; - } - if (selector === "") { - if (ignoreErrors) { - return null; - } - throw new window2.DOMException(`Failed to execute 'matches' on '${element.constructor.name}': The provided selector is empty.`); - } - if (typeof selector === "function") { - if (ignoreErrors) { - return null; - } - throw new window2.DOMException(`Failed to execute 'matches' on '${element.constructor.name}': '${selector}' is not a valid selector.`); - } - if (typeof selector === "symbol") { - if (ignoreErrors) { - return null; - } - throw new window2.TypeError(`Cannot convert a Symbol value to a string`); - } - selector = String(selector); - if (INVALID_SELECTOR_REGEXP.test(selector)) { - if (ignoreErrors) { - return null; - } - throw new window2.DOMException(`Failed to execute 'matches' on '${element.constructor.name}': '${selector}' is not a valid selector.`); - } - const cachedResult = element[cache].matches.get(selector); - if (cachedResult) { - if (cachedResult.result !== null) { - return cachedResult.result.match; - } - element[cache].matches.delete(selector); - } - const cachedItem = { - result: { match: null } - }; - element[cache].matches.set(selector, cachedItem); - if (element[isConnected]) { - (element[ownerDocument] || element)[affectsCache].push(cachedItem); - } - const scopeOrElement = options?.scope || element; - const scope = scopeOrElement[nodeType] === NodeTypeEnum_default.documentNode ? scopeOrElement.documentElement : scopeOrElement; - for (const items of new SelectorParser({ - ignoreErrors: options?.ignoreErrors, - window: window2, - scope - }).getSelectorGroups(selector)) { - const result = this.matchSelector({ - scope, - element, - selectorItems: items.slice().reverse(), - cachedItem, - ignoreErrors - }); - if (result) { - cachedItem.result.match = result; - return result; - } - } - return null; - } - static matchSelector(options, previousSelectorItem = null, priorityWeight = 0) { - const { scope, element, selectorItems, cachedItem, ignoreErrors } = options; - const selectorItem = selectorItems[0]; - if (!selectorItem) { - return null; - } - const result = selectorItem.match(scope, element, ignoreErrors); - if (result) { - if (selectorItems.length === 1) { - return { - priorityWeight: priorityWeight + result.priorityWeight - }; - } - switch (selectorItem.combinator) { - case SelectorCombinatorEnum_default.adjacentSibling: - const previousElementSibling = element.previousElementSibling; - if (previousElementSibling) { - previousElementSibling[affectsCache].push(cachedItem); - const match = this.matchSelector({ - scope, - element: previousElementSibling, - selectorItems: selectorItems.slice(1), - cachedItem, - ignoreErrors - }, selectorItem, priorityWeight + result.priorityWeight); - if (match) { - return match; - } - } - break; - case SelectorCombinatorEnum_default.none: - case SelectorCombinatorEnum_default.child: - case SelectorCombinatorEnum_default.descendant: - const parentElement = element.parentElement; - if (parentElement) { - parentElement[affectsCache].push(cachedItem); - const match = this.matchSelector({ - scope, - element: parentElement, - selectorItems: selectorItems.slice(1), - cachedItem, - ignoreErrors - }, selectorItem, priorityWeight + result.priorityWeight); - if (match) { - return match; - } - } - break; - case SelectorCombinatorEnum_default.subsequentSibling: - const siblingParentElement = element.parentElement; - if (siblingParentElement) { - const siblings = siblingParentElement[elementArray]; - const index = siblings.indexOf(element); - siblingParentElement[affectsCache].push(cachedItem); - for (let i = index - 1;i >= 0; i--) { - const sibling = siblings[i]; - sibling[affectsCache].push(cachedItem); - const match = this.matchSelector({ - scope, - element: sibling, - selectorItems: selectorItems.slice(1), - cachedItem, - ignoreErrors - }, selectorItem, priorityWeight + result.priorityWeight); - if (match) { - return match; - } - } - } - break; - } - } - if (previousSelectorItem?.combinator === SelectorCombinatorEnum_default.none || previousSelectorItem?.combinator === SelectorCombinatorEnum_default.descendant) { - const parentElement = element.parentElement; - if (parentElement) { - return this.matchSelector({ - scope, - element: parentElement, - selectorItems, - cachedItem, - ignoreErrors - }, previousSelectorItem, priorityWeight); - } - } - return null; - } - static findAll(options, documentPosition) { - const { scope, rootElement, children, selectorItems, cachedItem } = options; - const selectorItem = selectorItems[0]; - const nextSelectorItem = selectorItems[1]; - let matched = []; - if (!selectorItem) { - return []; - } - for (let i = 0, max = children.length;i < max; i++) { - const child = children[i]; - const childrenOfChild = child[elementArray]; - const position = (documentPosition ? documentPosition + ">" : "") + String.fromCharCode(i); - child[affectsCache].push(cachedItem); - if (selectorItem.match(scope, child)) { - if (!nextSelectorItem) { - if (rootElement !== child) { - matched.push({ - documentPosition: position, - element: child - }); - } - } else { - switch (nextSelectorItem.combinator) { - case SelectorCombinatorEnum_default.adjacentSibling: - const nextElementSibling = child.nextElementSibling; - if (nextElementSibling) { - matched = matched.concat(this.findAll({ - scope, - rootElement, - children: [nextElementSibling], - selectorItems: selectorItems.slice(1), - cachedItem - }, position)); - } - break; - case SelectorCombinatorEnum_default.none: - case SelectorCombinatorEnum_default.descendant: - case SelectorCombinatorEnum_default.child: - matched = matched.concat(this.findAll({ - scope, - rootElement, - children: childrenOfChild, - selectorItems: selectorItems.slice(1), - cachedItem - }, position)); - break; - case SelectorCombinatorEnum_default.subsequentSibling: - const index = children.indexOf(child); - for (let j = index + 1;j < children.length; j++) { - const sibling = children[j]; - matched = matched.concat(this.findAll({ - scope, - rootElement, - children: [sibling], - selectorItems: selectorItems.slice(1), - cachedItem - }, position)); - } - break; - } - } - } - if ((selectorItem.combinator === SelectorCombinatorEnum_default.none || selectorItem.combinator === SelectorCombinatorEnum_default.descendant) && childrenOfChild.length) { - matched = matched.concat(this.findAll({ - scope, - rootElement, - children: childrenOfChild, - selectorItems, - cachedItem - }, position)); - } - } - return matched; - } - static findFirst(options, documentPosition) { - const { scope, rootElement, children, selectorItems, cachedItem } = options; - const selectorItem = selectorItems[0]; - const nextSelectorItem = selectorItems[1]; - if (!selectorItem) { - return null; - } - for (let i = 0, max = children.length;i < max; i++) { - const child = children[i]; - const childrenOfChild = child[elementArray]; - const position = (documentPosition ? documentPosition + ">" : "") + String.fromCharCode(i); - child[affectsCache].push(cachedItem); - if (selectorItem.match(scope, child)) { - if (!nextSelectorItem) { - if (rootElement !== child) { - return { documentPosition: position, element: child }; - } - } else { - switch (nextSelectorItem.combinator) { - case SelectorCombinatorEnum_default.adjacentSibling: - const nextElementSibling = child.nextElementSibling; - if (nextElementSibling) { - const match = this.findFirst({ - scope, - rootElement, - children: [nextElementSibling], - selectorItems: selectorItems.slice(1), - cachedItem - }, position); - if (match) { - return match; - } - } - break; - case SelectorCombinatorEnum_default.none: - case SelectorCombinatorEnum_default.descendant: - case SelectorCombinatorEnum_default.child: - const match = this.findFirst({ - scope, - rootElement, - children: childrenOfChild, - selectorItems: selectorItems.slice(1), - cachedItem - }, position); - if (match) { - return match; - } - break; - case SelectorCombinatorEnum_default.subsequentSibling: - const index = children.indexOf(child); - for (let i = index + 1;i < children.length; i++) { - const sibling = children[i]; - const match = this.findFirst({ - scope, - rootElement, - children: [sibling], - selectorItems: selectorItems.slice(1), - cachedItem - }, position); - if (match) { - return match; - } - } - break; - } - } - } - if ((selectorItem.combinator === SelectorCombinatorEnum_default.none || selectorItem.combinator === SelectorCombinatorEnum_default.descendant) && childrenOfChild.length) { - const match = this.findFirst({ - scope, - rootElement, - children: childrenOfChild, - selectorItems, - cachedItem - }, position); - if (match) { - return match; - } - } - } - return null; - } -} - -// node_modules/happy-dom/lib/css/declaration/measurement-converter/CSSMeasurementConverter.js -class CSSMeasurementConverter { - static toPixels(options) { - const value = parseFloat(options.value); - const unit = options.value.replace(value.toString(), ""); - if (isNaN(value)) { - return null; - } - switch (unit) { - case "px": - return value; - case "rem": - return this.round(value * parseFloat(options.rootFontSize)); - case "em": - return this.round(value * parseFloat(options.parentFontSize)); - case "vw": - return this.round(value * options.window.innerWidth / 100); - case "vh": - return this.round(value * options.window.innerHeight / 100); - case "%": - return options.parentSize !== undefined && options.parentSize !== null ? this.round(value * parseFloat(options.parentSize) / 100) : null; - case "vmin": - return this.round(value * Math.min(options.window.innerWidth, options.window.innerHeight) / 100); - case "vmax": - return value * Math.max(options.window.innerWidth, options.window.innerHeight) / 100; - case "cm": - return this.round(value * 37.7812); - case "mm": - return this.round(value * 3.7781); - case "in": - return this.round(value * 96); - case "pt": - return this.round(value * 1.3281); - case "pc": - return this.round(value * 16); - case "Q": - return this.round(value * 0.945); - default: - return null; - } - } - static round(value) { - return Math.round(value * 1e4) / 1e4; - } -} - -// node_modules/happy-dom/lib/event/events/MediaQueryListEvent.js -class MediaQueryListEvent extends Event { - matches; - media; - constructor(type, eventInit = null) { - super(type, eventInit); - this.matches = eventInit?.matches ?? false; - this.media = eventInit?.media ?? ""; - } -} - -// node_modules/happy-dom/lib/match-media/MediaQueryTypeEnum.js -var MediaQueryTypeEnum; -(function(MediaQueryTypeEnum) { - MediaQueryTypeEnum["all"] = "all"; - MediaQueryTypeEnum["print"] = "print"; - MediaQueryTypeEnum["screen"] = "screen"; -})(MediaQueryTypeEnum || (MediaQueryTypeEnum = {})); -var MediaQueryTypeEnum_default = MediaQueryTypeEnum; - -// node_modules/happy-dom/lib/match-media/MediaQueryItem.js -class MediaQueryItem { - mediaTypes; - not; - rules; - ranges; - rootFontSize = null; - window; - constructor(options) { - this.window = options.window; - this.rootFontSize = options.rootFontSize || null; - this.mediaTypes = options.mediaTypes || []; - this.not = options.not || false; - this.rules = options.rules || []; - this.ranges = options.ranges || []; - } - toString() { - return `${this.not ? "not " : ""}${this.mediaTypes.join(", ")}${(this.not || this.mediaTypes.length > 0) && !!this.ranges.length ? " and " : ""}${this.ranges.map((range) => `(${range.before ? `${range.before.value} ${range.before.operator} ` : ""}${range.type}${range.after ? ` ${range.after.operator} ${range.after.value}` : ""})`).join(" and ")}${(this.not || this.mediaTypes.length > 0) && !!this.rules.length ? " and " : ""}${this.rules.map((rule) => rule.value ? `(${rule.name}: ${rule.value})` : `(${rule.name})`).join(" and ")}`; - } - matches() { - return this.not ? !this.matchesAll() : this.matchesAll(); - } - matchesAll() { - if (!!this.mediaTypes.length) { - let isMediaTypeMatch = false; - for (const mediaType of this.mediaTypes) { - if (this.matchesMediaType(mediaType)) { - isMediaTypeMatch = true; - break; - } - } - if (!isMediaTypeMatch) { - return false; - } - } - for (const rule of this.rules) { - if (!this.matchesRule(rule)) { - return false; - } - } - for (const range of this.ranges) { - if (!this.matchesRange(range)) { - return false; - } - } - return true; - } - matchesMediaType(mediaType) { - if (mediaType === MediaQueryTypeEnum_default.all) { - return true; - } - return mediaType === new WindowBrowserContext(this.window).getSettings()?.device.mediaType; - } - matchesRange(range) { - const windowSize = range.type === "width" ? this.window.innerWidth : this.window.innerHeight; - if (range.before) { - const beforeValue = this.toPixels(range.before.value); - if (beforeValue === null) { - return false; - } - switch (range.before.operator) { - case "<": - if (beforeValue >= windowSize) { - return false; - } - break; - case "<=": - if (beforeValue > windowSize) { - return false; - } - break; - case ">": - if (beforeValue <= windowSize) { - return false; - } - break; - case ">=": - if (beforeValue < windowSize) { - return false; - } - break; - } - } - if (range.after) { - const afterValue = this.toPixels(range.after.value); - if (afterValue === null) { - return false; - } - switch (range.after.operator) { - case "<": - if (windowSize >= afterValue) { - return false; - } - break; - case "<=": - if (windowSize > afterValue) { - return false; - } - break; - case ">": - if (windowSize <= afterValue) { - return false; - } - break; - case ">=": - if (windowSize < afterValue) { - return false; - } - break; - } - } - return true; - } - matchesRule(rule) { - const settings = new WindowBrowserContext(this.window).getSettings(); - if (!settings) { - return false; - } - if (!rule.value) { - switch (rule.name) { - case "min-width": - case "max-width": - case "min-height": - case "max-height": - case "width": - case "height": - case "orientation": - case "prefers-color-scheme": - case "hover": - case "any-hover": - case "any-pointer": - case "pointer": - case "display-mode": - case "min-aspect-ratio": - case "max-aspect-ratio": - case "aspect-ratio": - return true; - case "prefers-reduced-motion": - return settings.device.prefersReducedMotion === "reduce"; - case "forced-colors": - return settings.device.forcedColors === "active"; - } - return false; - } - switch (rule.name) { - case "min-width": - const minWidth = this.toPixels(rule.value); - return minWidth !== null && this.window.innerWidth >= minWidth; - case "max-width": - const maxWidth = this.toPixels(rule.value); - return maxWidth !== null && this.window.innerWidth <= maxWidth; - case "min-height": - const minHeight = this.toPixels(rule.value); - return minHeight !== null && this.window.innerHeight >= minHeight; - case "max-height": - const maxHeight = this.toPixels(rule.value); - return maxHeight !== null && this.window.innerHeight <= maxHeight; - case "width": - const width = this.toPixels(rule.value); - return width !== null && this.window.innerWidth === width; - case "height": - const height = this.toPixels(rule.value); - return height !== null && this.window.innerHeight === height; - case "orientation": - return rule.value === "landscape" ? this.window.innerWidth > this.window.innerHeight : this.window.innerWidth < this.window.innerHeight; - case "prefers-color-scheme": - return rule.value === settings.device.prefersColorScheme; - case "prefers-reduced-motion": - return rule.value === settings.device.prefersReducedMotion; - case "forced-colors": - return (rule.value === "none" || rule.value === "active") && rule.value === settings.device.forcedColors; - case "any-hover": - case "hover": - if (rule.value === "none") { - return this.window.navigator.maxTouchPoints > 0; - } - if (rule.value === "hover") { - return this.window.navigator.maxTouchPoints === 0; - } - return false; - case "any-pointer": - case "pointer": - if (rule.value === "none") { - return false; - } - if (rule.value === "coarse") { - return this.window.navigator.maxTouchPoints > 0; - } - if (rule.value === "fine") { - return this.window.navigator.maxTouchPoints === 0; - } - return false; - case "display-mode": - return rule.value === "browser"; - case "min-aspect-ratio": - case "max-aspect-ratio": - case "aspect-ratio": - const aspectRatio = rule.value.split("/"); - const aspectRatioWidth = parseInt(aspectRatio[0], 10); - const aspectRatioHeight = parseInt(aspectRatio[1], 10); - if (isNaN(aspectRatioWidth) || isNaN(aspectRatioHeight)) { - return false; - } - switch (rule.name) { - case "min-aspect-ratio": - return aspectRatioWidth / aspectRatioHeight <= this.window.innerWidth / this.window.innerHeight; - case "max-aspect-ratio": - return aspectRatioWidth / aspectRatioHeight >= this.window.innerWidth / this.window.innerHeight; - case "aspect-ratio": - return aspectRatioWidth / aspectRatioHeight === this.window.innerWidth / this.window.innerHeight; - } - } - return false; - } - toPixels(value) { - if (!new WindowBrowserContext(this.window).getSettings()?.disableComputedStyleRendering && value.endsWith("em")) { - this.rootFontSize = this.rootFontSize || parseFloat(this.window.getComputedStyle(this.window.document.documentElement).fontSize); - return CSSMeasurementConverter.toPixels({ - window: this.window, - value, - rootFontSize: this.rootFontSize, - parentFontSize: this.rootFontSize - }); - } - return CSSMeasurementConverter.toPixels({ - window: this.window, - value, - rootFontSize: 16, - parentFontSize: 16 - }); - } -} - -// node_modules/happy-dom/lib/match-media/MediaQueryParser.js -var MEDIA_QUERY_REGEXP = /(not|only|all|screen|print)|\(([^\)]+)(\)){0,1}|(,)| +(or|and) +/g; -var IS_RESOLUTION_REGEXP = /[<>]/; -var RESOLUTION_REGEXP = /(?:([0-9]+[a-z]+) *(<|<=|>|>=)){0,1} *(width|height) *(?:(<|<=|>|>=) *([0-9]+[a-z]+)){0,1}/; - -class MediaQueryParser { - static parse(options) { - let currentMediaQueryItem = new MediaQueryItem({ - window: options.window, - rootFontSize: options.rootFontSize - }); - const mediaQueryItems = [currentMediaQueryItem]; - const regexp = new RegExp(MEDIA_QUERY_REGEXP); - let match = null; - while (match = regexp.exec(options.mediaQuery.toLowerCase())) { - if (match[4] === "," || match[5] === "or") { - currentMediaQueryItem = new MediaQueryItem({ - window: options.window, - rootFontSize: options.rootFontSize - }); - mediaQueryItems.push(currentMediaQueryItem); - } else if (match[1] === "all" || match[1] === "screen" || match[1] === "print") { - currentMediaQueryItem.mediaTypes.push(match[1]); - } else if (match[1] === "not") { - currentMediaQueryItem.not = true; - } else if (match[2]) { - const resolutionMatch = IS_RESOLUTION_REGEXP.test(match[2]) ? match[2].match(RESOLUTION_REGEXP) : null; - if (resolutionMatch && (resolutionMatch[1] || resolutionMatch[5])) { - currentMediaQueryItem.ranges.push({ - before: resolutionMatch[1] ? { - value: resolutionMatch[1], - operator: resolutionMatch[2] - } : null, - type: resolutionMatch[3], - after: resolutionMatch[5] ? { - value: resolutionMatch[5], - operator: resolutionMatch[4] - } : null - }); - } else { - const [name, value] = match[2].split(":"); - const trimmedValue = value ? value.trim() : null; - if (!trimmedValue && !match[3]) { - return [ - new MediaQueryItem({ - window: options.window, - rootFontSize: options.rootFontSize, - not: true, - mediaTypes: [MediaQueryTypeEnum_default.all] - }) - ]; - } - currentMediaQueryItem.rules.push({ - name: name.trim(), - value: trimmedValue - }); - } - } - } - return mediaQueryItems; - } -} - -// node_modules/happy-dom/lib/match-media/MediaQueryList.js -class MediaQueryList extends EventTarget { - onchange = null; - #window; - #items = null; - #media; - #rootFontSize = null; - constructor(options) { - super(); - this.#window = options.window; - this.#media = options.media; - this.#rootFontSize = options.rootFontSize || null; - } - get media() { - this.#items = this.#items || MediaQueryParser.parse({ - window: this.#window, - mediaQuery: this.#media, - rootFontSize: this.#rootFontSize - }); - return this.#items.map((item) => item.toString()).join(", "); - } - get matches() { - this.#items = this.#items || MediaQueryParser.parse({ - window: this.#window, - mediaQuery: this.#media, - rootFontSize: this.#rootFontSize - }); - for (const item of this.#items) { - if (!item.matches()) { - return false; - } - } - return true; - } - addListener(callback) { - this.addEventListener("change", callback); - } - removeListener(callback) { - this.removeEventListener("change", callback); - } - addEventListener(type, listener) { - super.addEventListener(type, listener); - if (type === "change") { - let matchesState = false; - const resizeListener = () => { - const matches = this.matches; - if (matches !== matchesState) { - matchesState = matches; - this.dispatchEvent(new MediaQueryListEvent("change", { matches, media: this.media })); - } - }; - listener[windowResizeListener] = resizeListener; - this.#window.addEventListener("resize", resizeListener); - } - } - removeEventListener(type, listener) { - super.removeEventListener(type, listener); - if (type === "change" && listener[windowResizeListener]) { - this.#window.removeEventListener("resize", listener[windowResizeListener]); - } - } -} - -// node_modules/happy-dom/lib/css/rules/CSSGroupingRule.js -class CSSGroupingRule extends CSSRule { - [cssRules] = []; - get cssRules() { - return this[cssRules]; - } - insertRule(rule, index) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'insertRule' on '${this.constructor.name}': 1 argument required, but only 0 present.`); - } - const rules = this[cssParser].parseFromString(rule); - if (rules.length === 0 || rules.length > 1) { - throw new this[window].DOMException(`Failed to execute 'insertRule' on '${this.constructor.name}': Failed to parse the rule '${rule}'.`, DOMExceptionNameEnum_default.syntaxError); - } - if (index !== undefined) { - index = Number(index); - if (isNaN(index) || index > this.cssRules.length) { - throw new this[window].DOMException(`Failed to execute 'insertRule' on '${this.constructor.name}': The index provided (${index}) is larger than the maximum index (${this.cssRules.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - this.cssRules.splice(index, 0, rules[0]); - return index; - } - const newIndex = this.cssRules.length; - this.cssRules.unshift(rules[0]); - return newIndex; - } - deleteRule(index) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'deleteRule' on '${this.constructor.name}': 1 argument required, but only 0 present.`); - } - index = Number(index); - if (isNaN(index) || index < 0 || index >= this.cssRules.length) { - throw new this[window].DOMException(`Failed to execute 'deleteRule' on '${this.constructor.name}': the index (${index}) is greater than the length of the rule list.`, DOMExceptionNameEnum_default.indexSizeError); - } - this.cssRules.splice(index, 1); - } -} - -// node_modules/happy-dom/lib/css/rules/CSSScopeRule.js -class CSSScopeRule extends CSSGroupingRule { - [start] = ""; - [end] = ""; - [rulePrefix] = ""; - get type() { - return CSSRuleTypeEnum_default.containerRule; - } - get cssText() { - let cssText = ""; - for (const cssRule of this[cssRules]) { - cssText += ` - ` + cssRule.cssText; - } - cssText += ` -`; - return `@${this[rulePrefix]}scope${this[start] ? ` (${this[start]})` : ""}${this[end] ? ` to (${this[end]})` : ""} {${cssText}}`; - } - get start() { - return this[start]; - } - get end() { - return this[end]; - } -} - -// node_modules/happy-dom/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.js -var CSS_MEASUREMENT_REGEXP = /[0-9.]+(px|rem|em|vw|vh|%|vmin|vmax|cm|mm|in|pt|pc|Q)/g; -var HOST_REGEXP = /:host\s*\(([^)]+)\)|:host-context\s*\(([^)]+)\)/; -var SINGLE_CSS_VARIABLE_REGEXP = /var\( *(--[^), ]+)\)/; -var CSS_VARIABLE_REGEXP2 = /var\( *(--[^), ]+), *([^), ]+)\)/; - -class CSSStyleDeclarationComputedStyle { - element; - constructor(element) { - this.element = element; - } - getComputedStyle() { - const documentElements = []; - const parentElements = []; - let styleAndElement = { - element: this.element, - cssTexts: [] - }; - let shadowRootElements = []; - let customElements = []; - if (!this.element[isConnected]) { - return new CSSStyleDeclarationPropertyManager; - } - const cacheResult = this.element[cache].computedStyle; - if (cacheResult?.result) { - const result = cacheResult.result.deref(); - if (result) { - return result; - } - } - while (styleAndElement.element) { - if (styleAndElement.element[nodeType] === NodeTypeEnum_default.elementNode) { - const rootNode = styleAndElement.element.getRootNode(); - if (rootNode[nodeType] === NodeTypeEnum_default.documentNode) { - documentElements.unshift(styleAndElement); - } else { - shadowRootElements.unshift(styleAndElement); - } - if (styleAndElement.element.shadowRoot) { - customElements.push(styleAndElement); - } - parentElements.unshift(styleAndElement); - } - if (styleAndElement.element === this.element[ownerDocument]) { - const styleSheets = this.getStyleSheets(this.element[ownerDocument]); - for (const styleSheet of styleSheets) { - this.parseCSSRules({ - elements: documentElements, - cssRules: styleSheet.cssRules - }); - } - for (const customElement of customElements) { - const styleSheets = this.getStyleSheets(customElement.element.shadowRoot); - for (const styleSheet of styleSheets) { - this.parseCSSRules({ - elements: [], - cssRules: styleSheet.cssRules, - hostElement: customElement - }); - } - } - styleAndElement = { element: null, cssTexts: [] }; - } else if (styleAndElement.element[nodeType] === NodeTypeEnum_default.documentFragmentNode && styleAndElement.element.host) { - const shadowRoot = styleAndElement.element; - const styleSheets = this.getStyleSheets(shadowRoot); - styleAndElement = { - element: shadowRoot.host, - cssTexts: [] - }; - for (const styleSheet of styleSheets) { - this.parseCSSRules({ - elements: shadowRootElements, - cssRules: styleSheet.cssRules, - hostElement: styleAndElement - }); - } - for (const customElement of customElements) { - const styleSheets = this.getStyleSheets(customElement.element.shadowRoot); - for (const styleSheet of styleSheets) { - this.parseCSSRules({ - elements: [], - cssRules: styleSheet.cssRules, - hostElement: customElement - }); - } - } - customElements = []; - shadowRootElements = []; - } else { - styleAndElement = { - element: styleAndElement.element[parentNode], - cssTexts: [] - }; - } - } - const targetElement = parentElements[parentElements.length - 1]; - const propertyManager = new CSSStyleDeclarationPropertyManager; - const cssProperties = {}; - let rootFontSize = 16; - let parentFontSize = 16; - for (const parentElement of parentElements) { - parentElement.cssTexts.sort((a, b) => a.priorityWeight - b.priorityWeight); - const defaultCSS = CSSStyleDeclarationElementDefaultCSS_default[parentElement.element[tagName]]; - let elementCSSText = ""; - if (defaultCSS) { - if (typeof defaultCSS === "string") { - elementCSSText += defaultCSS; - } else { - for (const key of Object.keys(defaultCSS)) { - if (key === "default" || !!parentElement.element[key]) { - elementCSSText += defaultCSS[key]; - } - } - } - } - for (const cssText of parentElement.cssTexts) { - elementCSSText += cssText.cssText; - } - const elementStyleAttribute = parentElement.element.getAttribute("style"); - if (elementStyleAttribute) { - elementCSSText += elementStyleAttribute; - } - const rulesAndProperties = CSSStyleDeclarationCSSParser.parse(elementCSSText); - const rules = rulesAndProperties.rules; - Object.assign(cssProperties, rulesAndProperties.properties); - for (const { name, value, important } of rules) { - if (CSSStyleDeclarationElementInheritedProperties_default[name] || parentElement === targetElement) { - const parsedValue = this.parseCSSVariablesInValue(value.trim(), cssProperties); - if (parsedValue && (!propertyManager.get(name)?.important || important)) { - propertyManager.set(name, parsedValue, important); - if (name === "font" || name === "font-size") { - const fontSize = propertyManager.properties["font-size"]; - if (fontSize !== null) { - const parsedValue = this.parseMeasurementsInValue({ - value: fontSize.value, - rootFontSize, - parentFontSize, - parentSize: parentFontSize - }); - if (parentElement.element[tagName] === "HTML") { - rootFontSize = parsedValue; - } else if (parentElement !== targetElement) { - parentFontSize = parsedValue; - } - } - } - } - } - } - } - for (const name of CSSStyleDeclarationElementMeasurementProperties_default) { - const property = propertyManager.properties[name]; - if (property) { - property.value = this.parseMeasurementsInValue({ - value: property.value, - rootFontSize, - parentFontSize, - parentSize: name === "font-size" ? parentFontSize : null - }); - } - } - const cachedResult = { - result: new WeakRef(propertyManager) - }; - this.element[cache].computedStyle = cachedResult; - this.element[ownerDocument][affectsComputedStyleCache].push(cachedResult); - return propertyManager; - } - getStyleSheets(root) { - if (!root) { - return []; - } - const styleElements = root.querySelectorAll('style,link[rel="stylesheet"]'); - let styleSheets = []; - for (const styleElement of styleElements) { - const sheet = styleElement.sheet; - if (sheet) { - styleSheets.push(sheet); - } - } - if (root.adoptedStyleSheets) { - styleSheets = styleSheets.concat(root.adoptedStyleSheets); - } - return styleSheets; - } - parseCSSRules(options) { - if (!options.hostElement && !options.elements.length) { - return; - } - const window2 = this.element[window]; - for (const rule of options.cssRules) { - if (rule.type === CSSRuleTypeEnum_default.styleRule) { - const selectorText = rule.selectorText; - if (selectorText) { - if (selectorText[0] === ":" && selectorText.startsWith(":host")) { - if (options.hostElement) { - let isTargetHost = true; - if (selectorText !== ":host") { - const selectorMatch = selectorText.match(HOST_REGEXP); - if (selectorMatch) { - const match = QuerySelector.matches(options.hostElement.element, selectorMatch[1] || selectorMatch[2], { - ignoreErrors: true, - scope: options.scopeElement?.element - }); - if (match) { - const hostContextSelectorText = selectorText?.replace(HOST_REGEXP, "").trim(); - if (hostContextSelectorText && hostContextSelectorText[0] !== ":") { - isTargetHost = false; - for (const element of options.elements) { - const match = QuerySelector.matches(element.element, hostContextSelectorText, { - ignoreErrors: true, - scope: options.scopeElement?.element - }); - if (match) { - element.cssTexts.push({ - cssText: rule[cssText], - priorityWeight: 10 + match.priorityWeight - }); - } - } - } - } else { - isTargetHost = false; - } - } - } - if (isTargetHost) { - options.hostElement.cssTexts.push({ - cssText: rule[cssText], - priorityWeight: 10 - }); - } - } - } else { - for (const element of options.elements) { - const match = QuerySelector.matches(element.element, selectorText, { - ignoreErrors: true, - scope: options.scopeElement?.element - }); - if (match) { - element.cssTexts.push({ - cssText: rule[cssText], - priorityWeight: match.priorityWeight - }); - } - } - } - } - } else if (rule.type === CSSRuleTypeEnum_default.mediaRule && new MediaQueryList({ - window: window2, - media: rule.conditionText, - rootFontSize: this.element[tagName] === "HTML" ? 16 : null - }).matches) { - this.parseCSSRules({ - elements: options.elements, - cssRules: rule.cssRules, - hostElement: options.hostElement, - scopeElement: options.scopeElement - }); - } else if (rule.type === CSSRuleTypeEnum_default.supportsRule) { - if (window2.CSS.supports(rule.conditionText)) { - this.parseCSSRules({ - elements: options.elements, - cssRules: rule.cssRules, - hostElement: options.hostElement, - scopeElement: options.scopeElement - }); - } - } else if (rule.type === CSSRuleTypeEnum_default.containerRule) { - if (rule instanceof CSSScopeRule) { - const scopedElements = []; - let scope = null; - for (const element of options.elements) { - if (scope) { - if (rule[end]) { - const match = QuerySelector.matches(element.element, rule[end], { - ignoreErrors: true, - scope: scope.element - }); - if (match) { - break; - } - } - scopedElements.push(element); - } else { - const match = QuerySelector.matches(element.element, rule[start] || ":root", { - ignoreErrors: true - }); - if (match) { - scope = element; - scopedElements.push(element); - } - } - } - if (scopedElements.length) { - this.parseCSSRules({ - elements: scopedElements, - cssRules: rule.cssRules, - hostElement: options.hostElement, - scopeElement: scope - }); - } - } - } - } - } - parseCSSVariablesInValue(value, cssVariables) { - let newValue = value; - let match; - while ((match = newValue.match(SINGLE_CSS_VARIABLE_REGEXP)) != null) { - newValue = newValue.replace(match[0], cssVariables[match[1]] || ""); - } - while ((match = newValue.match(CSS_VARIABLE_REGEXP2)) !== null) { - newValue = newValue.replace(match[0], cssVariables[match[1]] || match[2]); - } - return newValue; - } - parseMeasurementsInValue(options) { - if (new WindowBrowserContext(this.element[window]).getSettings()?.disableComputedStyleRendering) { - return options.value; - } - const regexp = new RegExp(CSS_MEASUREMENT_REGEXP); - let newValue = options.value; - let match; - while ((match = regexp.exec(options.value)) !== null) { - if (match[1] !== "px") { - const valueInPixels = CSSMeasurementConverter.toPixels({ - window: this.element[window], - value: match[0], - rootFontSize: options.rootFontSize, - parentFontSize: options.parentFontSize, - parentSize: options.parentSize - }); - if (valueInPixels !== null) { - newValue = newValue.replace(match[0], valueInPixels + "px"); - } - } - } - return newValue; - } -} - -// node_modules/happy-dom/lib/css/declaration/CSSStyleDeclaration.js -class CSSStyleDeclaration { - parentRule = null; - [window]; - #element; - #computed; - #cache = { - attributeValue: null, - propertyManager: null - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this.#element = options?.element || null; - this.#computed = options?.element ? !!options?.computed : false; - } - get 0() { - return this.item(0) || undefined; - } - get 1() { - return this.item(1) || undefined; - } - get 2() { - return this.item(2) || undefined; - } - get 3() { - return this.item(3) || undefined; - } - get 4() { - return this.item(4) || undefined; - } - get 5() { - return this.item(5) || undefined; - } - get 6() { - return this.item(6) || undefined; - } - get 7() { - return this.item(7) || undefined; - } - get 8() { - return this.item(8) || undefined; - } - get 9() { - return this.item(9) || undefined; - } - get 10() { - return this.item(10) || undefined; - } - get 11() { - return this.item(11) || undefined; - } - get 12() { - return this.item(12) || undefined; - } - get 13() { - return this.item(13) || undefined; - } - get 14() { - return this.item(14) || undefined; - } - get 15() { - return this.item(15) || undefined; - } - get 16() { - return this.item(16) || undefined; - } - get 17() { - return this.item(17) || undefined; - } - get 18() { - return this.item(18) || undefined; - } - get 19() { - return this.item(19) || undefined; - } - get 20() { - return this.item(20) || undefined; - } - get 21() { - return this.item(21) || undefined; - } - get 22() { - return this.item(22) || undefined; - } - get 23() { - return this.item(23) || undefined; - } - get 24() { - return this.item(24) || undefined; - } - get 25() { - return this.item(25) || undefined; - } - get 26() { - return this.item(26) || undefined; - } - get 27() { - return this.item(27) || undefined; - } - get 28() { - return this.item(28) || undefined; - } - get 29() { - return this.item(29) || undefined; - } - get 30() { - return this.item(30) || undefined; - } - get 31() { - return this.item(31) || undefined; - } - get 32() { - return this.item(32) || undefined; - } - get 33() { - return this.item(33) || undefined; - } - get 34() { - return this.item(34) || undefined; - } - get 35() { - return this.item(35) || undefined; - } - get 36() { - return this.item(36) || undefined; - } - get 37() { - return this.item(37) || undefined; - } - get 38() { - return this.item(38) || undefined; - } - get 39() { - return this.item(39) || undefined; - } - get 40() { - return this.item(40) || undefined; - } - get 41() { - return this.item(41) || undefined; - } - get 42() { - return this.item(42) || undefined; - } - get 43() { - return this.item(43) || undefined; - } - get 44() { - return this.item(44) || undefined; - } - get 45() { - return this.item(45) || undefined; - } - get 46() { - return this.item(46) || undefined; - } - get 47() { - return this.item(47) || undefined; - } - get 48() { - return this.item(48) || undefined; - } - get 49() { - return this.item(49) || undefined; - } - get 50() { - return this.item(50) || undefined; - } - get 51() { - return this.item(51) || undefined; - } - get 52() { - return this.item(52) || undefined; - } - get 53() { - return this.item(53) || undefined; - } - get 54() { - return this.item(54) || undefined; - } - get 55() { - return this.item(55) || undefined; - } - get 56() { - return this.item(56) || undefined; - } - get 57() { - return this.item(57) || undefined; - } - get 58() { - return this.item(58) || undefined; - } - get 59() { - return this.item(59) || undefined; - } - get 60() { - return this.item(60) || undefined; - } - get 61() { - return this.item(61) || undefined; - } - get 62() { - return this.item(62) || undefined; - } - get 63() { - return this.item(63) || undefined; - } - get 64() { - return this.item(64) || undefined; - } - get 65() { - return this.item(65) || undefined; - } - get 66() { - return this.item(66) || undefined; - } - get 67() { - return this.item(67) || undefined; - } - get 68() { - return this.item(68) || undefined; - } - get 69() { - return this.item(69) || undefined; - } - get 70() { - return this.item(70) || undefined; - } - get 71() { - return this.item(71) || undefined; - } - get 72() { - return this.item(72) || undefined; - } - get 73() { - return this.item(73) || undefined; - } - get 74() { - return this.item(74) || undefined; - } - get 75() { - return this.item(75) || undefined; - } - get 76() { - return this.item(76) || undefined; - } - get 77() { - return this.item(77) || undefined; - } - get 78() { - return this.item(78) || undefined; - } - get 79() { - return this.item(79) || undefined; - } - get 80() { - return this.item(80) || undefined; - } - get 81() { - return this.item(81) || undefined; - } - get 82() { - return this.item(82) || undefined; - } - get 83() { - return this.item(83) || undefined; - } - get 84() { - return this.item(84) || undefined; - } - get 85() { - return this.item(85) || undefined; - } - get 86() { - return this.item(86) || undefined; - } - get 87() { - return this.item(87) || undefined; - } - get 88() { - return this.item(88) || undefined; - } - get 89() { - return this.item(89) || undefined; - } - get 90() { - return this.item(90) || undefined; - } - get 91() { - return this.item(91) || undefined; - } - get 92() { - return this.item(92) || undefined; - } - get 93() { - return this.item(93) || undefined; - } - get 94() { - return this.item(94) || undefined; - } - get 95() { - return this.item(95) || undefined; - } - get 96() { - return this.item(96) || undefined; - } - get 97() { - return this.item(97) || undefined; - } - get 98() { - return this.item(98) || undefined; - } - get 99() { - return this.item(99) || undefined; - } - get 100() { - return this.item(100) || undefined; - } - get 101() { - return this.item(101) || undefined; - } - get 102() { - return this.item(102) || undefined; - } - get 103() { - return this.item(103) || undefined; - } - get 104() { - return this.item(104) || undefined; - } - get 105() { - return this.item(105) || undefined; - } - get 106() { - return this.item(106) || undefined; - } - get 107() { - return this.item(107) || undefined; - } - get 108() { - return this.item(108) || undefined; - } - get 109() { - return this.item(109) || undefined; - } - get 110() { - return this.item(110) || undefined; - } - get 111() { - return this.item(111) || undefined; - } - get 112() { - return this.item(112) || undefined; - } - get 113() { - return this.item(113) || undefined; - } - get 114() { - return this.item(114) || undefined; - } - get 115() { - return this.item(115) || undefined; - } - get 116() { - return this.item(116) || undefined; - } - get 117() { - return this.item(117) || undefined; - } - get 118() { - return this.item(118) || undefined; - } - get 119() { - return this.item(119) || undefined; - } - get 120() { - return this.item(120) || undefined; - } - get 121() { - return this.item(121) || undefined; - } - get 122() { - return this.item(122) || undefined; - } - get 123() { - return this.item(123) || undefined; - } - get 124() { - return this.item(124) || undefined; - } - get 125() { - return this.item(125) || undefined; - } - get 126() { - return this.item(126) || undefined; - } - get 127() { - return this.item(127) || undefined; - } - get 128() { - return this.item(128) || undefined; - } - get 129() { - return this.item(129) || undefined; - } - get 130() { - return this.item(130) || undefined; - } - get 131() { - return this.item(131) || undefined; - } - get 132() { - return this.item(132) || undefined; - } - get 133() { - return this.item(133) || undefined; - } - get 134() { - return this.item(134) || undefined; - } - get 135() { - return this.item(135) || undefined; - } - get 136() { - return this.item(136) || undefined; - } - get 137() { - return this.item(137) || undefined; - } - get 138() { - return this.item(138) || undefined; - } - get 139() { - return this.item(139) || undefined; - } - get 140() { - return this.item(140) || undefined; - } - get 141() { - return this.item(141) || undefined; - } - get 142() { - return this.item(142) || undefined; - } - get 143() { - return this.item(143) || undefined; - } - get 144() { - return this.item(144) || undefined; - } - get 145() { - return this.item(145) || undefined; - } - get 146() { - return this.item(146) || undefined; - } - get 147() { - return this.item(147) || undefined; - } - get 148() { - return this.item(148) || undefined; - } - get 149() { - return this.item(149) || undefined; - } - get 150() { - return this.item(150) || undefined; - } - get 151() { - return this.item(151) || undefined; - } - get 152() { - return this.item(152) || undefined; - } - get 153() { - return this.item(153) || undefined; - } - get 154() { - return this.item(154) || undefined; - } - get 155() { - return this.item(155) || undefined; - } - get 156() { - return this.item(156) || undefined; - } - get 157() { - return this.item(157) || undefined; - } - get 158() { - return this.item(158) || undefined; - } - get 159() { - return this.item(159) || undefined; - } - get 160() { - return this.item(160) || undefined; - } - get 161() { - return this.item(161) || undefined; - } - get 162() { - return this.item(162) || undefined; - } - get 163() { - return this.item(163) || undefined; - } - get 164() { - return this.item(164) || undefined; - } - get 165() { - return this.item(165) || undefined; - } - get 166() { - return this.item(166) || undefined; - } - get 167() { - return this.item(167) || undefined; - } - get 168() { - return this.item(168) || undefined; - } - get 169() { - return this.item(169) || undefined; - } - get 170() { - return this.item(170) || undefined; - } - get 171() { - return this.item(171) || undefined; - } - get 172() { - return this.item(172) || undefined; - } - get 173() { - return this.item(173) || undefined; - } - get 174() { - return this.item(174) || undefined; - } - get 175() { - return this.item(175) || undefined; - } - get 176() { - return this.item(176) || undefined; - } - get 177() { - return this.item(177) || undefined; - } - get 178() { - return this.item(178) || undefined; - } - get 179() { - return this.item(179) || undefined; - } - get 180() { - return this.item(180) || undefined; - } - get 181() { - return this.item(181) || undefined; - } - get 182() { - return this.item(182) || undefined; - } - get 183() { - return this.item(183) || undefined; - } - get 184() { - return this.item(184) || undefined; - } - get 185() { - return this.item(185) || undefined; - } - get 186() { - return this.item(186) || undefined; - } - get 187() { - return this.item(187) || undefined; - } - get 188() { - return this.item(188) || undefined; - } - get 189() { - return this.item(189) || undefined; - } - get 190() { - return this.item(190) || undefined; - } - get 191() { - return this.item(191) || undefined; - } - get 192() { - return this.item(192) || undefined; - } - get 193() { - return this.item(193) || undefined; - } - get 194() { - return this.item(194) || undefined; - } - get 195() { - return this.item(195) || undefined; - } - get 196() { - return this.item(196) || undefined; - } - get 197() { - return this.item(197) || undefined; - } - get 198() { - return this.item(198) || undefined; - } - get 199() { - return this.item(199) || undefined; - } - get 200() { - return this.item(200) || undefined; - } - get 201() { - return this.item(201) || undefined; - } - get 202() { - return this.item(202) || undefined; - } - get 203() { - return this.item(203) || undefined; - } - get 204() { - return this.item(204) || undefined; - } - get 205() { - return this.item(205) || undefined; - } - get 206() { - return this.item(206) || undefined; - } - get 207() { - return this.item(207) || undefined; - } - get 208() { - return this.item(208) || undefined; - } - get 209() { - return this.item(209) || undefined; - } - get 210() { - return this.item(210) || undefined; - } - get 211() { - return this.item(211) || undefined; - } - get 212() { - return this.item(212) || undefined; - } - get 213() { - return this.item(213) || undefined; - } - get 214() { - return this.item(214) || undefined; - } - get 215() { - return this.item(215) || undefined; - } - get 216() { - return this.item(216) || undefined; - } - get 217() { - return this.item(217) || undefined; - } - get 218() { - return this.item(218) || undefined; - } - get 219() { - return this.item(219) || undefined; - } - get 220() { - return this.item(220) || undefined; - } - get 221() { - return this.item(221) || undefined; - } - get 222() { - return this.item(222) || undefined; - } - get 223() { - return this.item(223) || undefined; - } - get 224() { - return this.item(224) || undefined; - } - get 225() { - return this.item(225) || undefined; - } - get 226() { - return this.item(226) || undefined; - } - get 227() { - return this.item(227) || undefined; - } - get 228() { - return this.item(228) || undefined; - } - get 229() { - return this.item(229) || undefined; - } - get 230() { - return this.item(230) || undefined; - } - get 231() { - return this.item(231) || undefined; - } - get 232() { - return this.item(232) || undefined; - } - get 233() { - return this.item(233) || undefined; - } - get 234() { - return this.item(234) || undefined; - } - get 235() { - return this.item(235) || undefined; - } - get 236() { - return this.item(236) || undefined; - } - get 237() { - return this.item(237) || undefined; - } - get 238() { - return this.item(238) || undefined; - } - get 239() { - return this.item(239) || undefined; - } - get 240() { - return this.item(240) || undefined; - } - get 241() { - return this.item(241) || undefined; - } - get 242() { - return this.item(242) || undefined; - } - get 243() { - return this.item(243) || undefined; - } - get 244() { - return this.item(244) || undefined; - } - get 245() { - return this.item(245) || undefined; - } - get 246() { - return this.item(246) || undefined; - } - get 247() { - return this.item(247) || undefined; - } - get 248() { - return this.item(248) || undefined; - } - get 249() { - return this.item(249) || undefined; - } - get 250() { - return this.item(250) || undefined; - } - get 251() { - return this.item(251) || undefined; - } - get 252() { - return this.item(252) || undefined; - } - get 253() { - return this.item(253) || undefined; - } - get 254() { - return this.item(254) || undefined; - } - get 255() { - return this.item(255) || undefined; - } - get 256() { - return this.item(256) || undefined; - } - get 257() { - return this.item(257) || undefined; - } - get 258() { - return this.item(258) || undefined; - } - get 259() { - return this.item(259) || undefined; - } - get 260() { - return this.item(260) || undefined; - } - get 261() { - return this.item(261) || undefined; - } - get 262() { - return this.item(262) || undefined; - } - get 263() { - return this.item(263) || undefined; - } - get 264() { - return this.item(264) || undefined; - } - get 265() { - return this.item(265) || undefined; - } - get 266() { - return this.item(266) || undefined; - } - get 267() { - return this.item(267) || undefined; - } - get 268() { - return this.item(268) || undefined; - } - get 269() { - return this.item(269) || undefined; - } - get 270() { - return this.item(270) || undefined; - } - get 271() { - return this.item(271) || undefined; - } - get 272() { - return this.item(272) || undefined; - } - get 273() { - return this.item(273) || undefined; - } - get 274() { - return this.item(274) || undefined; - } - get 275() { - return this.item(275) || undefined; - } - get 276() { - return this.item(276) || undefined; - } - get 277() { - return this.item(277) || undefined; - } - get 278() { - return this.item(278) || undefined; - } - get 279() { - return this.item(279) || undefined; - } - get 280() { - return this.item(280) || undefined; - } - get 281() { - return this.item(281) || undefined; - } - get 282() { - return this.item(282) || undefined; - } - get 283() { - return this.item(283) || undefined; - } - get 284() { - return this.item(284) || undefined; - } - get 285() { - return this.item(285) || undefined; - } - get 286() { - return this.item(286) || undefined; - } - get 287() { - return this.item(287) || undefined; - } - get 288() { - return this.item(288) || undefined; - } - get 289() { - return this.item(289) || undefined; - } - get 290() { - return this.item(290) || undefined; - } - get 291() { - return this.item(291) || undefined; - } - get 292() { - return this.item(292) || undefined; - } - get 293() { - return this.item(293) || undefined; - } - get 294() { - return this.item(294) || undefined; - } - get 295() { - return this.item(295) || undefined; - } - get 296() { - return this.item(296) || undefined; - } - get 297() { - return this.item(297) || undefined; - } - get 298() { - return this.item(298) || undefined; - } - get 299() { - return this.item(299) || undefined; - } - get 300() { - return this.item(300) || undefined; - } - get 301() { - return this.item(301) || undefined; - } - get 302() { - return this.item(302) || undefined; - } - get 303() { - return this.item(303) || undefined; - } - get 304() { - return this.item(304) || undefined; - } - get 305() { - return this.item(305) || undefined; - } - get 306() { - return this.item(306) || undefined; - } - get 307() { - return this.item(307) || undefined; - } - get 308() { - return this.item(308) || undefined; - } - get 309() { - return this.item(309) || undefined; - } - get 310() { - return this.item(310) || undefined; - } - get 311() { - return this.item(311) || undefined; - } - get 312() { - return this.item(312) || undefined; - } - get 313() { - return this.item(313) || undefined; - } - get 314() { - return this.item(314) || undefined; - } - get 315() { - return this.item(315) || undefined; - } - get 316() { - return this.item(316) || undefined; - } - get 317() { - return this.item(317) || undefined; - } - get 318() { - return this.item(318) || undefined; - } - get 319() { - return this.item(319) || undefined; - } - get 320() { - return this.item(320) || undefined; - } - get 321() { - return this.item(321) || undefined; - } - get 322() { - return this.item(322) || undefined; - } - get 323() { - return this.item(323) || undefined; - } - get 324() { - return this.item(324) || undefined; - } - get 325() { - return this.item(325) || undefined; - } - get 326() { - return this.item(326) || undefined; - } - get 327() { - return this.item(327) || undefined; - } - get 328() { - return this.item(328) || undefined; - } - get 329() { - return this.item(329) || undefined; - } - get 330() { - return this.item(330) || undefined; - } - get 331() { - return this.item(331) || undefined; - } - get 332() { - return this.item(332) || undefined; - } - get 333() { - return this.item(333) || undefined; - } - get 334() { - return this.item(334) || undefined; - } - get 335() { - return this.item(335) || undefined; - } - get 336() { - return this.item(336) || undefined; - } - get 337() { - return this.item(337) || undefined; - } - get 338() { - return this.item(338) || undefined; - } - get 339() { - return this.item(339) || undefined; - } - get 340() { - return this.item(340) || undefined; - } - get 341() { - return this.item(341) || undefined; - } - get 342() { - return this.item(342) || undefined; - } - get 343() { - return this.item(343) || undefined; - } - get 344() { - return this.item(344) || undefined; - } - get 345() { - return this.item(345) || undefined; - } - get 346() { - return this.item(346) || undefined; - } - get 347() { - return this.item(347) || undefined; - } - get 348() { - return this.item(348) || undefined; - } - get 349() { - return this.item(349) || undefined; - } - get 350() { - return this.item(350) || undefined; - } - get 351() { - return this.item(351) || undefined; - } - get 352() { - return this.item(352) || undefined; - } - get 353() { - return this.item(353) || undefined; - } - get 354() { - return this.item(354) || undefined; - } - get 355() { - return this.item(355) || undefined; - } - get 356() { - return this.item(356) || undefined; - } - get 357() { - return this.item(357) || undefined; - } - get 358() { - return this.item(358) || undefined; - } - get 359() { - return this.item(359) || undefined; - } - get 360() { - return this.item(360) || undefined; - } - get 361() { - return this.item(361) || undefined; - } - get 362() { - return this.item(362) || undefined; - } - get 363() { - return this.item(363) || undefined; - } - get 364() { - return this.item(364) || undefined; - } - get 365() { - return this.item(365) || undefined; - } - get 366() { - return this.item(366) || undefined; - } - get 367() { - return this.item(367) || undefined; - } - get 368() { - return this.item(368) || undefined; - } - get 369() { - return this.item(369) || undefined; - } - get 370() { - return this.item(370) || undefined; - } - get 371() { - return this.item(371) || undefined; - } - get 372() { - return this.item(372) || undefined; - } - get 373() { - return this.item(373) || undefined; - } - get 374() { - return this.item(374) || undefined; - } - get 375() { - return this.item(375) || undefined; - } - get 376() { - return this.item(376) || undefined; - } - get 377() { - return this.item(377) || undefined; - } - get 378() { - return this.item(378) || undefined; - } - get 379() { - return this.item(379) || undefined; - } - get 380() { - return this.item(380) || undefined; - } - get 381() { - return this.item(381) || undefined; - } - get 382() { - return this.item(382) || undefined; - } - get 383() { - return this.item(383) || undefined; - } - get 384() { - return this.item(384) || undefined; - } - get 385() { - return this.item(385) || undefined; - } - get 386() { - return this.item(386) || undefined; - } - get 387() { - return this.item(387) || undefined; - } - get 388() { - return this.item(388) || undefined; - } - get 389() { - return this.item(389) || undefined; - } - get 390() { - return this.item(390) || undefined; - } - get 391() { - return this.item(391) || undefined; - } - get 392() { - return this.item(392) || undefined; - } - get 393() { - return this.item(393) || undefined; - } - get accentColor() { - return this.getPropertyValue("accent-color"); - } - set accentColor(value) { - this.setProperty("accent-color", value); - } - get appRegion() { - return this.getPropertyValue("app-region"); - } - set appRegion(value) { - this.setProperty("app-region", value); - } - get alignContent() { - return this.getPropertyValue("align-content"); - } - set alignContent(value) { - this.setProperty("align-content", value); - } - get alignItems() { - return this.getPropertyValue("align-items"); - } - set alignItems(value) { - this.setProperty("align-items", value); - } - get alignSelf() { - return this.getPropertyValue("align-self"); - } - set alignSelf(value) { - this.setProperty("align-self", value); - } - get alignmentBaseline() { - return this.getPropertyValue("alignment-baseline"); - } - set alignmentBaseline(value) { - this.setProperty("alignment-baseline", value); - } - get all() { - return this.getPropertyValue("all"); - } - set all(value) { - this.setProperty("all", value); - } - get animation() { - return this.getPropertyValue("animation"); - } - set animation(value) { - this.setProperty("animation", value); - } - get animationDelay() { - return this.getPropertyValue("animation-delay"); - } - set animationDelay(value) { - this.setProperty("animation-delay", value); - } - get animationDirection() { - return this.getPropertyValue("animation-direction"); - } - set animationDirection(value) { - this.setProperty("animation-direction", value); - } - get animationDuration() { - return this.getPropertyValue("animation-duration"); - } - set animationDuration(value) { - this.setProperty("animation-duration", value); - } - get animationFillMode() { - return this.getPropertyValue("animation-fill-mode"); - } - set animationFillMode(value) { - this.setProperty("animation-fill-mode", value); - } - get animationIterationCount() { - return this.getPropertyValue("animation-iteration-count"); - } - set animationIterationCount(value) { - this.setProperty("animation-iteration-count", value); - } - get animationName() { - return this.getPropertyValue("animation-name"); - } - set animationName(value) { - this.setProperty("animation-name", value); - } - get animationPlayState() { - return this.getPropertyValue("animation-play-state"); - } - set animationPlayState(value) { - this.setProperty("animation-play-state", value); - } - get animationTimingFunction() { - return this.getPropertyValue("animation-timing-function"); - } - set animationTimingFunction(value) { - this.setProperty("animation-timing-function", value); - } - get appearance() { - return this.getPropertyValue("appearance"); - } - set appearance(value) { - this.setProperty("appearance", value); - } - get backdropFilter() { - return this.getPropertyValue("backdrop-filter"); - } - set backdropFilter(value) { - this.setProperty("backdrop-filter", value); - } - get backfaceVisibility() { - return this.getPropertyValue("backface-visibility"); - } - set backfaceVisibility(value) { - this.setProperty("backface-visibility", value); - } - get background() { - return this.getPropertyValue("background"); - } - set background(value) { - this.setProperty("background", value); - } - get backgroundAttachment() { - return this.getPropertyValue("background-attachment"); - } - set backgroundAttachment(value) { - this.setProperty("background-attachment", value); - } - get backgroundBlendMode() { - return this.getPropertyValue("background-blend-mode"); - } - set backgroundBlendMode(value) { - this.setProperty("background-blend-mode", value); - } - get backgroundClip() { - return this.getPropertyValue("background-clip"); - } - set backgroundClip(value) { - this.setProperty("background-clip", value); - } - get backgroundColor() { - return this.getPropertyValue("background-color"); - } - set backgroundColor(value) { - this.setProperty("background-color", value); - } - get backgroundImage() { - return this.getPropertyValue("background-image"); - } - set backgroundImage(value) { - this.setProperty("background-image", value); - } - get backgroundOrigin() { - return this.getPropertyValue("background-origin"); - } - set backgroundOrigin(value) { - this.setProperty("background-origin", value); - } - get backgroundPosition() { - return this.getPropertyValue("background-position"); - } - set backgroundPosition(value) { - this.setProperty("background-position", value); - } - get backgroundPositionX() { - return this.getPropertyValue("background-position-x"); - } - set backgroundPositionX(value) { - this.setProperty("background-position-x", value); - } - get backgroundPositionY() { - return this.getPropertyValue("background-position-y"); - } - set backgroundPositionY(value) { - this.setProperty("background-position-y", value); - } - get backgroundRepeat() { - return this.getPropertyValue("background-repeat"); - } - set backgroundRepeat(value) { - this.setProperty("background-repeat", value); - } - get backgroundRepeatX() { - return this.getPropertyValue("background-repeat-x"); - } - set backgroundRepeatX(value) { - this.setProperty("background-repeat-x", value); - } - get backgroundRepeatY() { - return this.getPropertyValue("background-repeat-y"); - } - set backgroundRepeatY(value) { - this.setProperty("background-repeat-y", value); - } - get backgroundSize() { - return this.getPropertyValue("background-size"); - } - set backgroundSize(value) { - this.setProperty("background-size", value); - } - get baselineShift() { - return this.getPropertyValue("baseline-shift"); - } - set baselineShift(value) { - this.setProperty("baseline-shift", value); - } - get blockSize() { - return this.getPropertyValue("block-size"); - } - set blockSize(value) { - this.setProperty("block-size", value); - } - get border() { - return this.getPropertyValue("border"); - } - set border(value) { - this.setProperty("border", value); - } - get borderBlockEnd() { - return this.getPropertyValue("border-block-end"); - } - set borderBlockEnd(value) { - this.setProperty("border-block-end", value); - } - get borderBlockEndColor() { - return this.getPropertyValue("border-block-end-color"); - } - set borderBlockEndColor(value) { - this.setProperty("border-block-end-color", value); - } - get borderBlockEndStyle() { - return this.getPropertyValue("border-block-end-style"); - } - set borderBlockEndStyle(value) { - this.setProperty("border-block-end-style", value); - } - get borderBlockEndWidth() { - return this.getPropertyValue("border-block-end-width"); - } - set borderBlockEndWidth(value) { - this.setProperty("border-block-end-width", value); - } - get borderBlockStart() { - return this.getPropertyValue("border-block-start"); - } - set borderBlockStart(value) { - this.setProperty("border-block-start", value); - } - get borderBlockStartColor() { - return this.getPropertyValue("border-block-start-color"); - } - set borderBlockStartColor(value) { - this.setProperty("border-block-start-color", value); - } - get borderBlockStartStyle() { - return this.getPropertyValue("border-block-start-style"); - } - set borderBlockStartStyle(value) { - this.setProperty("border-block-start-style", value); - } - get borderBlockStartWidth() { - return this.getPropertyValue("border-block-start-width"); - } - set borderBlockStartWidth(value) { - this.setProperty("border-block-start-width", value); - } - get borderBottom() { - return this.getPropertyValue("border-bottom"); - } - set borderBottom(value) { - this.setProperty("border-bottom", value); - } - get borderBottomColor() { - return this.getPropertyValue("border-bottom-color"); - } - set borderBottomColor(value) { - this.setProperty("border-bottom-color", value); - } - get borderBottomLeftRadius() { - return this.getPropertyValue("border-bottom-left-radius"); - } - set borderBottomLeftRadius(value) { - this.setProperty("border-bottom-left-radius", value); - } - get borderBottomRightRadius() { - return this.getPropertyValue("border-bottom-right-radius"); - } - set borderBottomRightRadius(value) { - this.setProperty("border-bottom-right-radius", value); - } - get borderBottomStyle() { - return this.getPropertyValue("border-bottom-style"); - } - set borderBottomStyle(value) { - this.setProperty("border-bottom-style", value); - } - get borderBottomWidth() { - return this.getPropertyValue("border-bottom-width"); - } - set borderBottomWidth(value) { - this.setProperty("border-bottom-width", value); - } - get borderCollapse() { - return this.getPropertyValue("border-collapse"); - } - set borderCollapse(value) { - this.setProperty("border-collapse", value); - } - get borderColor() { - return this.getPropertyValue("border-color"); - } - set borderColor(value) { - this.setProperty("border-color", value); - } - get borderImage() { - return this.getPropertyValue("border-image"); - } - set borderImage(value) { - this.setProperty("border-image", value); - } - get borderImageOutset() { - return this.getPropertyValue("border-image-outset"); - } - set borderImageOutset(value) { - this.setProperty("border-image-outset", value); - } - get borderImageRepeat() { - return this.getPropertyValue("border-image-repeat"); - } - set borderImageRepeat(value) { - this.setProperty("border-image-repeat", value); - } - get borderImageSlice() { - return this.getPropertyValue("border-image-slice"); - } - set borderImageSlice(value) { - this.setProperty("border-image-slice", value); - } - get borderImageSource() { - return this.getPropertyValue("border-image-source"); - } - set borderImageSource(value) { - this.setProperty("border-image-source", value); - } - get borderImageWidth() { - return this.getPropertyValue("border-image-width"); - } - set borderImageWidth(value) { - this.setProperty("border-image-width", value); - } - get borderInlineEnd() { - return this.getPropertyValue("border-inline-end"); - } - set borderInlineEnd(value) { - this.setProperty("border-inline-end", value); - } - get borderInlineEndColor() { - return this.getPropertyValue("border-inline-end-color"); - } - set borderInlineEndColor(value) { - this.setProperty("border-inline-end-color", value); - } - get borderInlineEndStyle() { - return this.getPropertyValue("border-inline-end-style"); - } - set borderInlineEndStyle(value) { - this.setProperty("border-inline-end-style", value); - } - get borderInlineEndWidth() { - return this.getPropertyValue("border-inline-end-width"); - } - set borderInlineEndWidth(value) { - this.setProperty("border-inline-end-width", value); - } - get borderInlineStart() { - return this.getPropertyValue("border-inline-start"); - } - set borderInlineStart(value) { - this.setProperty("border-inline-start", value); - } - get borderInlineStartColor() { - return this.getPropertyValue("border-inline-start-color"); - } - set borderInlineStartColor(value) { - this.setProperty("border-inline-start-color", value); - } - get borderInlineStartStyle() { - return this.getPropertyValue("border-inline-start-style"); - } - set borderInlineStartStyle(value) { - this.setProperty("border-inline-start-style", value); - } - get borderInlineStartWidth() { - return this.getPropertyValue("border-inline-start-width"); - } - set borderInlineStartWidth(value) { - this.setProperty("border-inline-start-width", value); - } - get borderLeft() { - return this.getPropertyValue("border-left"); - } - set borderLeft(value) { - this.setProperty("border-left", value); - } - get borderLeftColor() { - return this.getPropertyValue("border-left-color"); - } - set borderLeftColor(value) { - this.setProperty("border-left-color", value); - } - get borderLeftStyle() { - return this.getPropertyValue("border-left-style"); - } - set borderLeftStyle(value) { - this.setProperty("border-left-style", value); - } - get borderLeftWidth() { - return this.getPropertyValue("border-left-width"); - } - set borderLeftWidth(value) { - this.setProperty("border-left-width", value); - } - get borderRadius() { - return this.getPropertyValue("border-radius"); - } - set borderRadius(value) { - this.setProperty("border-radius", value); - } - get borderRight() { - return this.getPropertyValue("border-right"); - } - set borderRight(value) { - this.setProperty("border-right", value); - } - get borderRightColor() { - return this.getPropertyValue("border-right-color"); - } - set borderRightColor(value) { - this.setProperty("border-right-color", value); - } - get borderRightStyle() { - return this.getPropertyValue("border-right-style"); - } - set borderRightStyle(value) { - this.setProperty("border-right-style", value); - } - get borderRightWidth() { - return this.getPropertyValue("border-right-width"); - } - set borderRightWidth(value) { - this.setProperty("border-right-width", value); - } - get borderSpacing() { - return this.getPropertyValue("border-spacing"); - } - set borderSpacing(value) { - this.setProperty("border-spacing", value); - } - get borderStyle() { - return this.getPropertyValue("border-style"); - } - set borderStyle(value) { - this.setProperty("border-style", value); - } - get borderTop() { - return this.getPropertyValue("border-top"); - } - set borderTop(value) { - this.setProperty("border-top", value); - } - get borderTopColor() { - return this.getPropertyValue("border-top-color"); - } - set borderTopColor(value) { - this.setProperty("border-top-color", value); - } - get borderTopLeftRadius() { - return this.getPropertyValue("border-top-left-radius"); - } - set borderTopLeftRadius(value) { - this.setProperty("border-top-left-radius", value); - } - get borderTopRightRadius() { - return this.getPropertyValue("border-top-right-radius"); - } - set borderTopRightRadius(value) { - this.setProperty("border-top-right-radius", value); - } - get borderTopStyle() { - return this.getPropertyValue("border-top-style"); - } - set borderTopStyle(value) { - this.setProperty("border-top-style", value); - } - get borderTopWidth() { - return this.getPropertyValue("border-top-width"); - } - set borderTopWidth(value) { - this.setProperty("border-top-width", value); - } - get borderWidth() { - return this.getPropertyValue("border-width"); - } - set borderWidth(value) { - this.setProperty("border-width", value); - } - get borderEndEndRadius() { - return this.getPropertyValue("border-end-end-radius"); - } - set borderEndEndRadius(value) { - this.setProperty("border-end-end-radius", value); - } - get borderEndStartRadius() { - return this.getPropertyValue("border-end-start-radius"); - } - set borderEndStartRadius(value) { - this.setProperty("border-end-start-radius", value); - } - get borderStartEndRadius() { - return this.getPropertyValue("border-start-end-radius"); - } - set borderStartEndRadius(value) { - this.setProperty("border-start-end-radius", value); - } - get borderStartStartRadius() { - return this.getPropertyValue("border-start-start-radius"); - } - set borderStartStartRadius(value) { - this.setProperty("border-start-start-radius", value); - } - get bottom() { - return this.getPropertyValue("bottom"); - } - set bottom(value) { - this.setProperty("bottom", value); - } - get boxShadow() { - return this.getPropertyValue("box-shadow"); - } - set boxShadow(value) { - this.setProperty("box-shadow", value); - } - get boxSizing() { - return this.getPropertyValue("box-sizing"); - } - set boxSizing(value) { - this.setProperty("box-sizing", value); - } - get breakAfter() { - return this.getPropertyValue("break-after"); - } - set breakAfter(value) { - this.setProperty("break-after", value); - } - get breakBefore() { - return this.getPropertyValue("break-before"); - } - set breakBefore(value) { - this.setProperty("break-before", value); - } - get breakInside() { - return this.getPropertyValue("break-inside"); - } - set breakInside(value) { - this.setProperty("break-inside", value); - } - get bufferedRendering() { - return this.getPropertyValue("buffered-rendering"); - } - set bufferedRendering(value) { - this.setProperty("buffered-rendering", value); - } - get captionSide() { - return this.getPropertyValue("caption-side"); - } - set captionSide(value) { - this.setProperty("caption-side", value); - } - get caretColor() { - return this.getPropertyValue("caret-color"); - } - set caretColor(value) { - this.setProperty("caret-color", value); - } - get clear() { - return this.getPropertyValue("clear"); - } - set clear(value) { - this.setProperty("clear", value); - } - get clip() { - return this.getPropertyValue("clip"); - } - set clip(value) { - this.setProperty("clip", value); - } - get clipPath() { - return this.getPropertyValue("clip-path"); - } - set clipPath(value) { - this.setProperty("clip-path", value); - } - get clipRule() { - return this.getPropertyValue("clip-rule"); - } - set clipRule(value) { - this.setProperty("clip-rule", value); - } - get color() { - return this.getPropertyValue("color"); - } - set color(value) { - this.setProperty("color", value); - } - get colorInterpolation() { - return this.getPropertyValue("color-interpolation"); - } - set colorInterpolation(value) { - this.setProperty("color-interpolation", value); - } - get colorInterpolationFilters() { - return this.getPropertyValue("color-interpolation-filters"); - } - set colorInterpolationFilters(value) { - this.setProperty("color-interpolation-filters", value); - } - get colorRendering() { - return this.getPropertyValue("color-rendering"); - } - set colorRendering(value) { - this.setProperty("color-rendering", value); - } - get colorScheme() { - return this.getPropertyValue("color-scheme"); - } - set colorScheme(value) { - this.setProperty("color-scheme", value); - } - get columnCount() { - return this.getPropertyValue("column-count"); - } - set columnCount(value) { - this.setProperty("column-count", value); - } - get columnFill() { - return this.getPropertyValue("column-fill"); - } - set columnFill(value) { - this.setProperty("column-fill", value); - } - get columnGap() { - return this.getPropertyValue("column-gap"); - } - set columnGap(value) { - this.setProperty("column-gap", value); - } - get columnRule() { - return this.getPropertyValue("column-rule"); - } - set columnRule(value) { - this.setProperty("column-rule", value); - } - get columnRuleColor() { - return this.getPropertyValue("column-rule-color"); - } - set columnRuleColor(value) { - this.setProperty("column-rule-color", value); - } - get columnRuleStyle() { - return this.getPropertyValue("column-rule-style"); - } - set columnRuleStyle(value) { - this.setProperty("column-rule-style", value); - } - get columnRuleWidth() { - return this.getPropertyValue("column-rule-width"); - } - set columnRuleWidth(value) { - this.setProperty("column-rule-width", value); - } - get columnSpan() { - return this.getPropertyValue("column-span"); - } - set columnSpan(value) { - this.setProperty("column-span", value); - } - get columnWidth() { - return this.getPropertyValue("column-width"); - } - set columnWidth(value) { - this.setProperty("column-width", value); - } - get columns() { - return this.getPropertyValue("columns"); - } - set columns(value) { - this.setProperty("columns", value); - } - get contain() { - return this.getPropertyValue("contain"); - } - set contain(value) { - this.setProperty("contain", value); - } - get containIntrinsicSize() { - return this.getPropertyValue("contain-intrinsic-size"); - } - set containIntrinsicSize(value) { - this.setProperty("contain-intrinsic-size", value); - } - get content() { - return this.getPropertyValue("content"); - } - set content(value) { - this.setProperty("content", value); - } - get contentVisibility() { - return this.getPropertyValue("content-visibility"); - } - set contentVisibility(value) { - this.setProperty("content-visibility", value); - } - get counterIncrement() { - return this.getPropertyValue("counter-increment"); - } - set counterIncrement(value) { - this.setProperty("counter-increment", value); - } - get counterReset() { - return this.getPropertyValue("counter-reset"); - } - set counterReset(value) { - this.setProperty("counter-reset", value); - } - get counterSet() { - return this.getPropertyValue("counter-set"); - } - set counterSet(value) { - this.setProperty("counter-set", value); - } - get containIntrinsicBlockSize() { - return this.getPropertyValue("contain-intrinsic-block-size"); - } - set containIntrinsicBlockSize(value) { - this.setProperty("contain-intrinsic-block-size", value); - } - get containIntrinsicHeight() { - return this.getPropertyValue("contain-intrinsic-height"); - } - set containIntrinsicHeight(value) { - this.setProperty("contain-intrinsic-height", value); - } - get containIntrinsicInlineSize() { - return this.getPropertyValue("contain-intrinsic-inline-size"); - } - set containIntrinsicInlineSize(value) { - this.setProperty("contain-intrinsic-inline-size", value); - } - get containIntrinsicWidth() { - return this.getPropertyValue("contain-intrinsic-width"); - } - set containIntrinsicWidth(value) { - this.setProperty("contain-intrinsic-width", value); - } - get cssFloat() { - return this.getPropertyValue("css-float"); - } - set cssFloat(value) { - this.setProperty("css-float", value); - } - get cursor() { - return this.getPropertyValue("cursor"); - } - set cursor(value) { - this.setProperty("cursor", value); - } - get cx() { - return this.getPropertyValue("cx"); - } - set cx(value) { - this.setProperty("cx", value); - } - get cy() { - return this.getPropertyValue("cy"); - } - set cy(value) { - this.setProperty("cy", value); - } - get d() { - return this.getPropertyValue("d"); - } - set d(value) { - this.setProperty("d", value); - } - get direction() { - return this.getPropertyValue("direction"); - } - set direction(value) { - this.setProperty("direction", value); - } - get display() { - return this.getPropertyValue("display"); - } - set display(value) { - this.setProperty("display", value); - } - get dominantBaseline() { - return this.getPropertyValue("dominant-baseline"); - } - set dominantBaseline(value) { - this.setProperty("dominant-baseline", value); - } - get emptyCells() { - return this.getPropertyValue("empty-cells"); - } - set emptyCells(value) { - this.setProperty("empty-cells", value); - } - get fill() { - return this.getPropertyValue("fill"); - } - set fill(value) { - this.setProperty("fill", value); - } - get fillOpacity() { - return this.getPropertyValue("fill-opacity"); - } - set fillOpacity(value) { - this.setProperty("fill-opacity", value); - } - get fillRule() { - return this.getPropertyValue("fill-rule"); - } - set fillRule(value) { - this.setProperty("fill-rule", value); - } - get filter() { - return this.getPropertyValue("filter"); - } - set filter(value) { - this.setProperty("filter", value); - } - get flex() { - return this.getPropertyValue("flex"); - } - set flex(value) { - this.setProperty("flex", value); - } - get flexBasis() { - return this.getPropertyValue("flex-basis"); - } - set flexBasis(value) { - this.setProperty("flex-basis", value); - } - get flexDirection() { - return this.getPropertyValue("flex-direction"); - } - set flexDirection(value) { - this.setProperty("flex-direction", value); - } - get flexFlow() { - return this.getPropertyValue("flex-flow"); - } - set flexFlow(value) { - this.setProperty("flex-flow", value); - } - get flexGrow() { - return this.getPropertyValue("flex-grow"); - } - set flexGrow(value) { - this.setProperty("flex-grow", value); - } - get flexShrink() { - return this.getPropertyValue("flex-shrink"); - } - set flexShrink(value) { - this.setProperty("flex-shrink", value); - } - get flexWrap() { - return this.getPropertyValue("flex-wrap"); - } - set flexWrap(value) { - this.setProperty("flex-wrap", value); - } - get float() { - return this.getPropertyValue("float"); - } - set float(value) { - this.setProperty("float", value); - } - get floodColor() { - return this.getPropertyValue("flood-color"); - } - set floodColor(value) { - this.setProperty("flood-color", value); - } - get floodOpacity() { - return this.getPropertyValue("flood-opacity"); - } - set floodOpacity(value) { - this.setProperty("flood-opacity", value); - } - get font() { - return this.getPropertyValue("font"); - } - set font(value) { - this.setProperty("font", value); - } - get fontDisplay() { - return this.getPropertyValue("font-display"); - } - set fontDisplay(value) { - this.setProperty("font-display", value); - } - get fontFamily() { - return this.getPropertyValue("font-family"); - } - set fontFamily(value) { - this.setProperty("font-family", value); - } - get fontFeatureSettings() { - return this.getPropertyValue("font-feature-settings"); - } - set fontFeatureSettings(value) { - this.setProperty("font-feature-settings", value); - } - get fontKerning() { - return this.getPropertyValue("font-kerning"); - } - set fontKerning(value) { - this.setProperty("font-kerning", value); - } - get fontOpticalSizing() { - return this.getPropertyValue("font-optical-sizing"); - } - set fontOpticalSizing(value) { - this.setProperty("font-optical-sizing", value); - } - get fontSize() { - return this.getPropertyValue("font-size"); - } - set fontSize(value) { - this.setProperty("font-size", value); - } - get fontStretch() { - return this.getPropertyValue("font-stretch"); - } - set fontStretch(value) { - this.setProperty("font-stretch", value); - } - get fontStyle() { - return this.getPropertyValue("font-style"); - } - set fontStyle(value) { - this.setProperty("font-style", value); - } - get fontVariant() { - return this.getPropertyValue("font-variant"); - } - set fontVariant(value) { - this.setProperty("font-variant", value); - } - get fontVariantCaps() { - return this.getPropertyValue("font-variant-caps"); - } - set fontVariantCaps(value) { - this.setProperty("font-variant-caps", value); - } - get fontVariantEastAsian() { - return this.getPropertyValue("font-variant-east-asian"); - } - set fontVariantEastAsian(value) { - this.setProperty("font-variant-east-asian", value); - } - get fontVariantLigatures() { - return this.getPropertyValue("font-variant-ligatures"); - } - set fontVariantLigatures(value) { - this.setProperty("font-variant-ligatures", value); - } - get fontVariantNumeric() { - return this.getPropertyValue("font-variant-numeric"); - } - set fontVariantNumeric(value) { - this.setProperty("font-variant-numeric", value); - } - get fontVariationSettings() { - return this.getPropertyValue("font-variation-settings"); - } - set fontVariationSettings(value) { - this.setProperty("font-variation-settings", value); - } - get fontPalette() { - return this.getPropertyValue("font-palette"); - } - set fontPalette(value) { - this.setProperty("font-palette", value); - } - get fontSynthesisSmallCaps() { - return this.getPropertyValue("font-synthesis-small-caps"); - } - set fontSynthesisSmallCaps(value) { - this.setProperty("font-synthesis-small-caps", value); - } - get fontSynthesisStyle() { - return this.getPropertyValue("font-synthesis-style"); - } - set fontSynthesisStyle(value) { - this.setProperty("font-synthesis-style", value); - } - get fontSynthesisWeight() { - return this.getPropertyValue("font-synthesis-weight"); - } - set fontSynthesisWeight(value) { - this.setProperty("font-synthesis-weight", value); - } - get fontWeight() { - return this.getPropertyValue("font-weight"); - } - set fontWeight(value) { - this.setProperty("font-weight", value); - } - get gap() { - return this.getPropertyValue("gap"); - } - set gap(value) { - this.setProperty("gap", value); - } - get grid() { - return this.getPropertyValue("grid"); - } - set grid(value) { - this.setProperty("grid", value); - } - get gridArea() { - return this.getPropertyValue("grid-area"); - } - set gridArea(value) { - this.setProperty("grid-area", value); - } - get gridAutoColumns() { - return this.getPropertyValue("grid-auto-columns"); - } - set gridAutoColumns(value) { - this.setProperty("grid-auto-columns", value); - } - get gridAutoFlow() { - return this.getPropertyValue("grid-auto-flow"); - } - set gridAutoFlow(value) { - this.setProperty("grid-auto-flow", value); - } - get gridAutoRows() { - return this.getPropertyValue("grid-auto-rows"); - } - set gridAutoRows(value) { - this.setProperty("grid-auto-rows", value); - } - get gridColumn() { - return this.getPropertyValue("grid-column"); - } - set gridColumn(value) { - this.setProperty("grid-column", value); - } - get gridColumnEnd() { - return this.getPropertyValue("grid-column-end"); - } - set gridColumnEnd(value) { - this.setProperty("grid-column-end", value); - } - get gridColumnGap() { - return this.getPropertyValue("grid-column-gap"); - } - set gridColumnGap(value) { - this.setProperty("grid-column-gap", value); - } - get gridColumnStart() { - return this.getPropertyValue("grid-column-start"); - } - set gridColumnStart(value) { - this.setProperty("grid-column-start", value); - } - get gridGap() { - return this.getPropertyValue("grid-gap"); - } - set gridGap(value) { - this.setProperty("grid-gap", value); - } - get gridRow() { - return this.getPropertyValue("grid-row"); - } - set gridRow(value) { - this.setProperty("grid-row", value); - } - get gridRowEnd() { - return this.getPropertyValue("grid-row-end"); - } - set gridRowEnd(value) { - this.setProperty("grid-row-end", value); - } - get gridRowGap() { - return this.getPropertyValue("grid-row-gap"); - } - set gridRowGap(value) { - this.setProperty("grid-row-gap", value); - } - get gridRowStart() { - return this.getPropertyValue("grid-row-start"); - } - set gridRowStart(value) { - this.setProperty("grid-row-start", value); - } - get gridTemplate() { - return this.getPropertyValue("grid-template"); - } - set gridTemplate(value) { - this.setProperty("grid-template", value); - } - get gridTemplateAreas() { - return this.getPropertyValue("grid-template-areas"); - } - set gridTemplateAreas(value) { - this.setProperty("grid-template-areas", value); - } - get gridTemplateColumns() { - return this.getPropertyValue("grid-template-columns"); - } - set gridTemplateColumns(value) { - this.setProperty("grid-template-columns", value); - } - get gridTemplateRows() { - return this.getPropertyValue("grid-template-rows"); - } - set gridTemplateRows(value) { - this.setProperty("grid-template-rows", value); - } - get height() { - return this.getPropertyValue("height"); - } - set height(value) { - this.setProperty("height", value); - } - get hyphens() { - return this.getPropertyValue("hyphens"); - } - set hyphens(value) { - this.setProperty("hyphens", value); - } - get imageOrientation() { - return this.getPropertyValue("image-orientation"); - } - set imageOrientation(value) { - this.setProperty("image-orientation", value); - } - get imageRendering() { - return this.getPropertyValue("image-rendering"); - } - set imageRendering(value) { - this.setProperty("image-rendering", value); - } - get inherits() { - return this.getPropertyValue("inherits"); - } - set inherits(value) { - this.setProperty("inherits", value); - } - get initialValue() { - return this.getPropertyValue("initial-value"); - } - set initialValue(value) { - this.setProperty("initial-value", value); - } - get inlineSize() { - return this.getPropertyValue("inline-size"); - } - set inlineSize(value) { - this.setProperty("inline-size", value); - } - get isolation() { - return this.getPropertyValue("isolation"); - } - set isolation(value) { - this.setProperty("isolation", value); - } - get insetBlockEnd() { - return this.getPropertyValue("inset-block-end"); - } - set insetBlockEnd(value) { - this.setProperty("inset-block-end", value); - } - get insetBlockStart() { - return this.getPropertyValue("inset-block-start"); - } - set insetBlockStart(value) { - this.setProperty("inset-block-start", value); - } - get insetInlineEnd() { - return this.getPropertyValue("inset-inline-end"); - } - set insetInlineEnd(value) { - this.setProperty("inset-inline-end", value); - } - get insetInlineStart() { - return this.getPropertyValue("inset-inline-start"); - } - set insetInlineStart(value) { - this.setProperty("inset-inline-start", value); - } - get justifyContent() { - return this.getPropertyValue("justify-content"); - } - set justifyContent(value) { - this.setProperty("justify-content", value); - } - get justifyItems() { - return this.getPropertyValue("justify-items"); - } - set justifyItems(value) { - this.setProperty("justify-items", value); - } - get justifySelf() { - return this.getPropertyValue("justify-self"); - } - set justifySelf(value) { - this.setProperty("justify-self", value); - } - get left() { - return this.getPropertyValue("left"); - } - set left(value) { - this.setProperty("left", value); - } - get letterSpacing() { - return this.getPropertyValue("letter-spacing"); - } - set letterSpacing(value) { - this.setProperty("letter-spacing", value); - } - get lightingColor() { - return this.getPropertyValue("lighting-color"); - } - set lightingColor(value) { - this.setProperty("lighting-color", value); - } - get lineBreak() { - return this.getPropertyValue("line-break"); - } - set lineBreak(value) { - this.setProperty("line-break", value); - } - get lineHeight() { - return this.getPropertyValue("line-height"); - } - set lineHeight(value) { - this.setProperty("line-height", value); - } - get listStyle() { - return this.getPropertyValue("list-style"); - } - set listStyle(value) { - this.setProperty("list-style", value); - } - get listStyleImage() { - return this.getPropertyValue("list-style-image"); - } - set listStyleImage(value) { - this.setProperty("list-style-image", value); - } - get listStylePosition() { - return this.getPropertyValue("list-style-position"); - } - set listStylePosition(value) { - this.setProperty("list-style-position", value); - } - get listStyleType() { - return this.getPropertyValue("list-style-type"); - } - set listStyleType(value) { - this.setProperty("list-style-type", value); - } - get margin() { - return this.getPropertyValue("margin"); - } - set margin(value) { - this.setProperty("margin", value); - } - get marginBlockEnd() { - return this.getPropertyValue("margin-block-end"); - } - set marginBlockEnd(value) { - this.setProperty("margin-block-end", value); - } - get marginBlockStart() { - return this.getPropertyValue("margin-block-start"); - } - set marginBlockStart(value) { - this.setProperty("margin-block-start", value); - } - get marginBottom() { - return this.getPropertyValue("margin-bottom"); - } - set marginBottom(value) { - this.setProperty("margin-bottom", value); - } - get marginInlineEnd() { - return this.getPropertyValue("margin-inline-end"); - } - set marginInlineEnd(value) { - this.setProperty("margin-inline-end", value); - } - get marginInlineStart() { - return this.getPropertyValue("margin-inline-start"); - } - set marginInlineStart(value) { - this.setProperty("margin-inline-start", value); - } - get marginLeft() { - return this.getPropertyValue("margin-left"); - } - set marginLeft(value) { - this.setProperty("margin-left", value); - } - get marginRight() { - return this.getPropertyValue("margin-right"); - } - set marginRight(value) { - this.setProperty("margin-right", value); - } - get marginTop() { - return this.getPropertyValue("margin-top"); - } - set marginTop(value) { - this.setProperty("margin-top", value); - } - get marker() { - return this.getPropertyValue("marker"); - } - set marker(value) { - this.setProperty("marker", value); - } - get markerEnd() { - return this.getPropertyValue("marker-end"); - } - set markerEnd(value) { - this.setProperty("marker-end", value); - } - get markerMid() { - return this.getPropertyValue("marker-mid"); - } - set markerMid(value) { - this.setProperty("marker-mid", value); - } - get markerStart() { - return this.getPropertyValue("marker-start"); - } - set markerStart(value) { - this.setProperty("marker-start", value); - } - get mask() { - return this.getPropertyValue("mask"); - } - set mask(value) { - this.setProperty("mask", value); - } - get maskType() { - return this.getPropertyValue("mask-type"); - } - set maskType(value) { - this.setProperty("mask-type", value); - } - get maxBlockSize() { - return this.getPropertyValue("max-block-size"); - } - set maxBlockSize(value) { - this.setProperty("max-block-size", value); - } - get maxHeight() { - return this.getPropertyValue("max-height"); - } - set maxHeight(value) { - this.setProperty("max-height", value); - } - get maxInlineSize() { - return this.getPropertyValue("max-inline-size"); - } - set maxInlineSize(value) { - this.setProperty("max-inline-size", value); - } - get maxWidth() { - return this.getPropertyValue("max-width"); - } - set maxWidth(value) { - this.setProperty("max-width", value); - } - get maxZoom() { - return this.getPropertyValue("max-zoom"); - } - set maxZoom(value) { - this.setProperty("max-zoom", value); - } - get minBlockSize() { - return this.getPropertyValue("min-block-size"); - } - set minBlockSize(value) { - this.setProperty("min-block-size", value); - } - get minHeight() { - return this.getPropertyValue("min-height"); - } - set minHeight(value) { - this.setProperty("min-height", value); - } - get minInlineSize() { - return this.getPropertyValue("min-inline-size"); - } - set minInlineSize(value) { - this.setProperty("min-inline-size", value); - } - get minWidth() { - return this.getPropertyValue("min-width"); - } - set minWidth(value) { - this.setProperty("min-width", value); - } - get minZoom() { - return this.getPropertyValue("min-zoom"); - } - set minZoom(value) { - this.setProperty("min-zoom", value); - } - get mixBlendMode() { - return this.getPropertyValue("mix-blend-mode"); - } - set mixBlendMode(value) { - this.setProperty("mix-blend-mode", value); - } - get objectFit() { - return this.getPropertyValue("object-fit"); - } - set objectFit(value) { - this.setProperty("object-fit", value); - } - get objectPosition() { - return this.getPropertyValue("object-position"); - } - set objectPosition(value) { - this.setProperty("object-position", value); - } - get offset() { - return this.getPropertyValue("offset"); - } - set offset(value) { - this.setProperty("offset", value); - } - get offsetDistance() { - return this.getPropertyValue("offset-distance"); - } - set offsetDistance(value) { - this.setProperty("offset-distance", value); - } - get offsetPath() { - return this.getPropertyValue("offset-path"); - } - set offsetPath(value) { - this.setProperty("offset-path", value); - } - get offsetRotate() { - return this.getPropertyValue("offset-rotate"); - } - set offsetRotate(value) { - this.setProperty("offset-rotate", value); - } - get opacity() { - return this.getPropertyValue("opacity"); - } - set opacity(value) { - this.setProperty("opacity", value); - } - get order() { - return this.getPropertyValue("order"); - } - set order(value) { - this.setProperty("order", value); - } - get orientation() { - return this.getPropertyValue("orientation"); - } - set orientation(value) { - this.setProperty("orientation", value); - } - get orphans() { - return this.getPropertyValue("orphans"); - } - set orphans(value) { - this.setProperty("orphans", value); - } - get outline() { - return this.getPropertyValue("outline"); - } - set outline(value) { - this.setProperty("outline", value); - } - get outlineColor() { - return this.getPropertyValue("outline-color"); - } - set outlineColor(value) { - this.setProperty("outline-color", value); - } - get outlineOffset() { - return this.getPropertyValue("outline-offset"); - } - set outlineOffset(value) { - this.setProperty("outline-offset", value); - } - get outlineStyle() { - return this.getPropertyValue("outline-style"); - } - set outlineStyle(value) { - this.setProperty("outline-style", value); - } - get outlineWidth() { - return this.getPropertyValue("outline-width"); - } - set outlineWidth(value) { - this.setProperty("outline-width", value); - } - get overflow() { - return this.getPropertyValue("overflow"); - } - set overflow(value) { - this.setProperty("overflow", value); - } - get overflowAnchor() { - return this.getPropertyValue("overflow-anchor"); - } - set overflowAnchor(value) { - this.setProperty("overflow-anchor", value); - } - get overflowWrap() { - return this.getPropertyValue("overflow-wrap"); - } - set overflowWrap(value) { - this.setProperty("overflow-wrap", value); - } - get overflowX() { - return this.getPropertyValue("overflow-x"); - } - set overflowX(value) { - this.setProperty("overflow-x", value); - } - get overflowY() { - return this.getPropertyValue("overflow-y"); - } - set overflowY(value) { - this.setProperty("overflow-y", value); - } - get overscrollBehavior() { - return this.getPropertyValue("overscroll-behavior"); - } - set overscrollBehavior(value) { - this.setProperty("overscroll-behavior", value); - } - get overscrollBehaviorBlock() { - return this.getPropertyValue("overscroll-behavior-block"); - } - set overscrollBehaviorBlock(value) { - this.setProperty("overscroll-behavior-block", value); - } - get overscrollBehaviorInline() { - return this.getPropertyValue("overscroll-behavior-inline"); - } - set overscrollBehaviorInline(value) { - this.setProperty("overscroll-behavior-inline", value); - } - get overscrollBehaviorX() { - return this.getPropertyValue("overscroll-behavior-x"); - } - set overscrollBehaviorX(value) { - this.setProperty("overscroll-behavior-x", value); - } - get overscrollBehaviorY() { - return this.getPropertyValue("overscroll-behavior-y"); - } - set overscrollBehaviorY(value) { - this.setProperty("overscroll-behavior-y", value); - } - get overflowClipMargin() { - return this.getPropertyValue("overflow-clip-margin"); - } - set overflowClipMargin(value) { - this.setProperty("overflow-clip-margin", value); - } - get padding() { - return this.getPropertyValue("padding"); - } - set padding(value) { - this.setProperty("padding", value); - } - get paddingBlockEnd() { - return this.getPropertyValue("padding-block-end"); - } - set paddingBlockEnd(value) { - this.setProperty("padding-block-end", value); - } - get paddingBlockStart() { - return this.getPropertyValue("padding-block-start"); - } - set paddingBlockStart(value) { - this.setProperty("padding-block-start", value); - } - get paddingBottom() { - return this.getPropertyValue("padding-bottom"); - } - set paddingBottom(value) { - this.setProperty("padding-bottom", value); - } - get paddingInlineEnd() { - return this.getPropertyValue("padding-inline-end"); - } - set paddingInlineEnd(value) { - this.setProperty("padding-inline-end", value); - } - get paddingInlineStart() { - return this.getPropertyValue("padding-inline-start"); - } - set paddingInlineStart(value) { - this.setProperty("padding-inline-start", value); - } - get paddingLeft() { - return this.getPropertyValue("padding-left"); - } - set paddingLeft(value) { - this.setProperty("padding-left", value); - } - get paddingRight() { - return this.getPropertyValue("padding-right"); - } - set paddingRight(value) { - this.setProperty("padding-right", value); - } - get paddingTop() { - return this.getPropertyValue("padding-top"); - } - set paddingTop(value) { - this.setProperty("padding-top", value); - } - get page() { - return this.getPropertyValue("page"); - } - set page(value) { - this.setProperty("page", value); - } - get pageBreakAfter() { - return this.getPropertyValue("page-break-after"); - } - set pageBreakAfter(value) { - this.setProperty("page-break-after", value); - } - get pageBreakBefore() { - return this.getPropertyValue("page-break-before"); - } - set pageBreakBefore(value) { - this.setProperty("page-break-before", value); - } - get pageBreakInside() { - return this.getPropertyValue("page-break-inside"); - } - set pageBreakInside(value) { - this.setProperty("page-break-inside", value); - } - get pageOrientation() { - return this.getPropertyValue("page-orientation"); - } - set pageOrientation(value) { - this.setProperty("page-orientation", value); - } - get paintOrder() { - return this.getPropertyValue("paint-order"); - } - set paintOrder(value) { - this.setProperty("paint-order", value); - } - get perspective() { - return this.getPropertyValue("perspective"); - } - set perspective(value) { - this.setProperty("perspective", value); - } - get perspectiveOrigin() { - return this.getPropertyValue("perspective-origin"); - } - set perspectiveOrigin(value) { - this.setProperty("perspective-origin", value); - } - get placeContent() { - return this.getPropertyValue("place-content"); - } - set placeContent(value) { - this.setProperty("place-content", value); - } - get placeItems() { - return this.getPropertyValue("place-items"); - } - set placeItems(value) { - this.setProperty("place-items", value); - } - get placeSelf() { - return this.getPropertyValue("place-self"); - } - set placeSelf(value) { - this.setProperty("place-self", value); - } - get pointerEvents() { - return this.getPropertyValue("pointer-events"); - } - set pointerEvents(value) { - this.setProperty("pointer-events", value); - } - get position() { - return this.getPropertyValue("position"); - } - set position(value) { - this.setProperty("position", value); - } - get quotes() { - return this.getPropertyValue("quotes"); - } - set quotes(value) { - this.setProperty("quotes", value); - } - get r() { - return this.getPropertyValue("r"); - } - set r(value) { - this.setProperty("r", value); - } - get resize() { - return this.getPropertyValue("resize"); - } - set resize(value) { - this.setProperty("resize", value); - } - get right() { - return this.getPropertyValue("right"); - } - set right(value) { - this.setProperty("right", value); - } - get rowGap() { - return this.getPropertyValue("row-gap"); - } - set rowGap(value) { - this.setProperty("row-gap", value); - } - get rubyPosition() { - return this.getPropertyValue("ruby-position"); - } - set rubyPosition(value) { - this.setProperty("ruby-position", value); - } - get rx() { - return this.getPropertyValue("rx"); - } - set rx(value) { - this.setProperty("rx", value); - } - get ry() { - return this.getPropertyValue("ry"); - } - set ry(value) { - this.setProperty("ry", value); - } - get scrollBehavior() { - return this.getPropertyValue("scroll-behavior"); - } - set scrollBehavior(value) { - this.setProperty("scroll-behavior", value); - } - get scrollMargin() { - return this.getPropertyValue("scroll-margin"); - } - set scrollMargin(value) { - this.setProperty("scroll-margin", value); - } - get scrollMarginBlock() { - return this.getPropertyValue("scroll-margin-block"); - } - set scrollMarginBlock(value) { - this.setProperty("scroll-margin-block", value); - } - get scrollMarginBlockEnd() { - return this.getPropertyValue("scroll-margin-block-end"); - } - set scrollMarginBlockEnd(value) { - this.setProperty("scroll-margin-block-end", value); - } - get scrollMarginBlockStart() { - return this.getPropertyValue("scroll-margin-block-start"); - } - set scrollMarginBlockStart(value) { - this.setProperty("scroll-margin-block-start", value); - } - get scrollMarginBottom() { - return this.getPropertyValue("scroll-margin-bottom"); - } - set scrollMarginBottom(value) { - this.setProperty("scroll-margin-bottom", value); - } - get scrollMarginInline() { - return this.getPropertyValue("scroll-margin-inline"); - } - set scrollMarginInline(value) { - this.setProperty("scroll-margin-inline", value); - } - get scrollMarginInlineEnd() { - return this.getPropertyValue("scroll-margin-inline-end"); - } - set scrollMarginInlineEnd(value) { - this.setProperty("scroll-margin-inline-end", value); - } - get scrollMarginInlineStart() { - return this.getPropertyValue("scroll-margin-inline-start"); - } - set scrollMarginInlineStart(value) { - this.setProperty("scroll-margin-inline-start", value); - } - get scrollMarginLeft() { - return this.getPropertyValue("scroll-margin-left"); - } - set scrollMarginLeft(value) { - this.setProperty("scroll-margin-left", value); - } - get scrollMarginRight() { - return this.getPropertyValue("scroll-margin-right"); - } - set scrollMarginRight(value) { - this.setProperty("scroll-margin-right", value); - } - get scrollMarginTop() { - return this.getPropertyValue("scroll-margin-top"); - } - set scrollMarginTop(value) { - this.setProperty("scroll-margin-top", value); - } - get scrollPadding() { - return this.getPropertyValue("scroll-padding"); - } - set scrollPadding(value) { - this.setProperty("scroll-padding", value); - } - get scrollPaddingBlock() { - return this.getPropertyValue("scroll-padding-block"); - } - set scrollPaddingBlock(value) { - this.setProperty("scroll-padding-block", value); - } - get scrollPaddingBlockEnd() { - return this.getPropertyValue("scroll-padding-block-end"); - } - set scrollPaddingBlockEnd(value) { - this.setProperty("scroll-padding-block-end", value); - } - get scrollPaddingBlockStart() { - return this.getPropertyValue("scroll-padding-block-start"); - } - set scrollPaddingBlockStart(value) { - this.setProperty("scroll-padding-block-start", value); - } - get scrollPaddingBottom() { - return this.getPropertyValue("scroll-padding-bottom"); - } - set scrollPaddingBottom(value) { - this.setProperty("scroll-padding-bottom", value); - } - get scrollPaddingInline() { - return this.getPropertyValue("scroll-padding-inline"); - } - set scrollPaddingInline(value) { - this.setProperty("scroll-padding-inline", value); - } - get scrollPaddingInlineEnd() { - return this.getPropertyValue("scroll-padding-inline-end"); - } - set scrollPaddingInlineEnd(value) { - this.setProperty("scroll-padding-inline-end", value); - } - get scrollPaddingInlineStart() { - return this.getPropertyValue("scroll-padding-inline-start"); - } - set scrollPaddingInlineStart(value) { - this.setProperty("scroll-padding-inline-start", value); - } - get scrollPaddingLeft() { - return this.getPropertyValue("scroll-padding-left"); - } - set scrollPaddingLeft(value) { - this.setProperty("scroll-padding-left", value); - } - get scrollPaddingRight() { - return this.getPropertyValue("scroll-padding-right"); - } - set scrollPaddingRight(value) { - this.setProperty("scroll-padding-right", value); - } - get scrollPaddingTop() { - return this.getPropertyValue("scroll-padding-top"); - } - set scrollPaddingTop(value) { - this.setProperty("scroll-padding-top", value); - } - get scrollSnapAlign() { - return this.getPropertyValue("scroll-snap-align"); - } - set scrollSnapAlign(value) { - this.setProperty("scroll-snap-align", value); - } - get scrollSnapStop() { - return this.getPropertyValue("scroll-snap-stop"); - } - set scrollSnapStop(value) { - this.setProperty("scroll-snap-stop", value); - } - get scrollSnapType() { - return this.getPropertyValue("scroll-snap-type"); - } - set scrollSnapType(value) { - this.setProperty("scroll-snap-type", value); - } - get shapeImageThreshold() { - return this.getPropertyValue("shape-image-threshold"); - } - set shapeImageThreshold(value) { - this.setProperty("shape-image-threshold", value); - } - get shapeMargin() { - return this.getPropertyValue("shape-margin"); - } - set shapeMargin(value) { - this.setProperty("shape-margin", value); - } - get shapeOutside() { - return this.getPropertyValue("shape-outside"); - } - set shapeOutside(value) { - this.setProperty("shape-outside", value); - } - get shapeRendering() { - return this.getPropertyValue("shape-rendering"); - } - set shapeRendering(value) { - this.setProperty("shape-rendering", value); - } - get size() { - return this.getPropertyValue("size"); - } - set size(value) { - this.setProperty("size", value); - } - get speak() { - return this.getPropertyValue("speak"); - } - set speak(value) { - this.setProperty("speak", value); - } - get src() { - return this.getPropertyValue("src"); - } - set src(value) { - this.setProperty("src", value); - } - get stopColor() { - return this.getPropertyValue("stop-color"); - } - set stopColor(value) { - this.setProperty("stop-color", value); - } - get stopOpacity() { - return this.getPropertyValue("stop-opacity"); - } - set stopOpacity(value) { - this.setProperty("stop-opacity", value); - } - get stroke() { - return this.getPropertyValue("stroke"); - } - set stroke(value) { - this.setProperty("stroke", value); - } - get strokeDasharray() { - return this.getPropertyValue("stroke-dasharray"); - } - set strokeDasharray(value) { - this.setProperty("stroke-dasharray", value); - } - get strokeDashoffset() { - return this.getPropertyValue("stroke-dashoffset"); - } - set strokeDashoffset(value) { - this.setProperty("stroke-dashoffset", value); - } - get strokeLinecap() { - return this.getPropertyValue("stroke-linecap"); - } - set strokeLinecap(value) { - this.setProperty("stroke-linecap", value); - } - get strokeLinejoin() { - return this.getPropertyValue("stroke-linejoin"); - } - set strokeLinejoin(value) { - this.setProperty("stroke-linejoin", value); - } - get strokeMiterlimit() { - return this.getPropertyValue("stroke-miterlimit"); - } - set strokeMiterlimit(value) { - this.setProperty("stroke-miterlimit", value); - } - get strokeOpacity() { - return this.getPropertyValue("stroke-opacity"); - } - set strokeOpacity(value) { - this.setProperty("stroke-opacity", value); - } - get strokeWidth() { - return this.getPropertyValue("stroke-width"); - } - set strokeWidth(value) { - this.setProperty("stroke-width", value); - } - get syntax() { - return this.getPropertyValue("syntax"); - } - set syntax(value) { - this.setProperty("syntax", value); - } - get scrollbarGutter() { - return this.getPropertyValue("scrollbar-gutter"); - } - set scrollbarGutter(value) { - this.setProperty("scrollbar-gutter", value); - } - get tabSize() { - return this.getPropertyValue("tab-size"); - } - set tabSize(value) { - this.setProperty("tab-size", value); - } - get tableLayout() { - return this.getPropertyValue("table-layout"); - } - set tableLayout(value) { - this.setProperty("table-layout", value); - } - get textAlign() { - return this.getPropertyValue("text-align"); - } - set textAlign(value) { - this.setProperty("text-align", value); - } - get textAlignLast() { - return this.getPropertyValue("text-align-last"); - } - set textAlignLast(value) { - this.setProperty("text-align-last", value); - } - get textAnchor() { - return this.getPropertyValue("text-anchor"); - } - set textAnchor(value) { - this.setProperty("text-anchor", value); - } - get textCombineUpright() { - return this.getPropertyValue("text-combine-upright"); - } - set textCombineUpright(value) { - this.setProperty("text-combine-upright", value); - } - get textDecoration() { - return this.getPropertyValue("text-decoration"); - } - set textDecoration(value) { - this.setProperty("text-decoration", value); - } - get textDecorationColor() { - return this.getPropertyValue("text-decoration-color"); - } - set textDecorationColor(value) { - this.setProperty("text-decoration-color", value); - } - get textDecorationLine() { - return this.getPropertyValue("text-decoration-line"); - } - set textDecorationLine(value) { - this.setProperty("text-decoration-line", value); - } - get textDecorationSkipInk() { - return this.getPropertyValue("text-decoration-skip-ink"); - } - set textDecorationSkipInk(value) { - this.setProperty("text-decoration-skip-ink", value); - } - get textDecorationStyle() { - return this.getPropertyValue("text-decoration-style"); - } - set textDecorationStyle(value) { - this.setProperty("text-decoration-style", value); - } - get textIndent() { - return this.getPropertyValue("text-indent"); - } - set textIndent(value) { - this.setProperty("text-indent", value); - } - get textOrientation() { - return this.getPropertyValue("text-orientation"); - } - set textOrientation(value) { - this.setProperty("text-orientation", value); - } - get textOverflow() { - return this.getPropertyValue("text-overflow"); - } - set textOverflow(value) { - this.setProperty("text-overflow", value); - } - get textRendering() { - return this.getPropertyValue("text-rendering"); - } - set textRendering(value) { - this.setProperty("text-rendering", value); - } - get textShadow() { - return this.getPropertyValue("text-shadow"); - } - set textShadow(value) { - this.setProperty("text-shadow", value); - } - get textSizeAdjust() { - return this.getPropertyValue("text-size-adjust"); - } - set textSizeAdjust(value) { - this.setProperty("text-size-adjust", value); - } - get textTransform() { - return this.getPropertyValue("text-transform"); - } - set textTransform(value) { - this.setProperty("text-transform", value); - } - get textUnderlinePosition() { - return this.getPropertyValue("text-underline-position"); - } - set textUnderlinePosition(value) { - this.setProperty("text-underline-position", value); - } - get top() { - return this.getPropertyValue("top"); - } - set top(value) { - this.setProperty("top", value); - } - get touchAction() { - return this.getPropertyValue("touch-action"); - } - set touchAction(value) { - this.setProperty("touch-action", value); - } - get transform() { - return this.getPropertyValue("transform"); - } - set transform(value) { - this.setProperty("transform", value); - } - get transformBox() { - return this.getPropertyValue("transform-box"); - } - set transformBox(value) { - this.setProperty("transform-box", value); - } - get transformOrigin() { - return this.getPropertyValue("transform-origin"); - } - set transformOrigin(value) { - this.setProperty("transform-origin", value); - } - get transformStyle() { - return this.getPropertyValue("transform-style"); - } - set transformStyle(value) { - this.setProperty("transform-style", value); - } - get transition() { - return this.getPropertyValue("transition"); - } - set transition(value) { - this.setProperty("transition", value); - } - get transitionDelay() { - return this.getPropertyValue("transition-delay"); - } - set transitionDelay(value) { - this.setProperty("transition-delay", value); - } - get transitionDuration() { - return this.getPropertyValue("transition-duration"); - } - set transitionDuration(value) { - this.setProperty("transition-duration", value); - } - get transitionProperty() { - return this.getPropertyValue("transition-property"); - } - set transitionProperty(value) { - this.setProperty("transition-property", value); - } - get transitionTimingFunction() { - return this.getPropertyValue("transition-timing-function"); - } - set transitionTimingFunction(value) { - this.setProperty("transition-timing-function", value); - } - get textEmphasisColor() { - return this.getPropertyValue("text-emphasis-color"); - } - set textEmphasisColor(value) { - this.setProperty("text-emphasis-color", value); - } - get textEmphasisPosition() { - return this.getPropertyValue("text-emphasis-position"); - } - set textEmphasisPosition(value) { - this.setProperty("text-emphasis-position", value); - } - get textEmphasisStyle() { - return this.getPropertyValue("text-emphasis-style"); - } - set textEmphasisStyle(value) { - this.setProperty("text-emphasis-style", value); - } - get unicodeBidi() { - return this.getPropertyValue("unicode-bidi"); - } - set unicodeBidi(value) { - this.setProperty("unicode-bidi", value); - } - get unicodeRange() { - return this.getPropertyValue("unicode-range"); - } - set unicodeRange(value) { - this.setProperty("unicode-range", value); - } - get userSelect() { - return this.getPropertyValue("user-select"); - } - set userSelect(value) { - this.setProperty("user-select", value); - } - get userZoom() { - return this.getPropertyValue("user-zoom"); - } - set userZoom(value) { - this.setProperty("user-zoom", value); - } - get vectorEffect() { - return this.getPropertyValue("vector-effect"); - } - set vectorEffect(value) { - this.setProperty("vector-effect", value); - } - get verticalAlign() { - return this.getPropertyValue("vertical-align"); - } - set verticalAlign(value) { - this.setProperty("vertical-align", value); - } - get visibility() { - return this.getPropertyValue("visibility"); - } - set visibility(value) { - this.setProperty("visibility", value); - } - get whiteSpace() { - return this.getPropertyValue("white-space"); - } - set whiteSpace(value) { - this.setProperty("white-space", value); - } - get widows() { - return this.getPropertyValue("widows"); - } - set widows(value) { - this.setProperty("widows", value); - } - get width() { - return this.getPropertyValue("width"); - } - set width(value) { - this.setProperty("width", value); - } - get willChange() { - return this.getPropertyValue("will-change"); - } - set willChange(value) { - this.setProperty("will-change", value); - } - get wordBreak() { - return this.getPropertyValue("word-break"); - } - set wordBreak(value) { - this.setProperty("word-break", value); - } - get wordSpacing() { - return this.getPropertyValue("word-spacing"); - } - set wordSpacing(value) { - this.setProperty("word-spacing", value); - } - get wordWrap() { - return this.getPropertyValue("word-wrap"); - } - set wordWrap(value) { - this.setProperty("word-wrap", value); - } - get writingMode() { - return this.getPropertyValue("writing-mode"); - } - set writingMode(value) { - this.setProperty("writing-mode", value); - } - get x() { - return this.getPropertyValue("x"); - } - set x(value) { - this.setProperty("x", value); - } - get y() { - return this.getPropertyValue("y"); - } - set y(value) { - this.setProperty("y", value); - } - get zIndex() { - return this.getPropertyValue("z-index"); - } - set zIndex(value) { - this.setProperty("z-index", value); - } - get zoom() { - return this.getPropertyValue("zoom"); - } - set zoom(value) { - this.setProperty("zoom", value); - } - get containerType() { - return this.getPropertyValue("container-type"); - } - set containerType(value) { - this.setProperty("container-type", value); - } - get containerName() { - return this.getPropertyValue("container-name"); - } - set containerName(value) { - this.setProperty("container-name", value); - } - get aspectRatio() { - return this.getPropertyValue("aspect-ratio"); - } - set aspectRatio(value) { - this.setProperty("aspect-ratio", value); - } - get length() { - return this.#getPropertyManager().size(); - } - get cssText() { - if (this.#element && this.#computed) { - return ""; - } - return this.#getPropertyManager().toString(); - } - set cssText(cssText) { - if (this.#computed) { - throw new this[window].DOMException(`Failed to execute 'cssText' on 'CSSStyleDeclaration': These styles are computed, and the properties are therefore read-only.`, DOMExceptionNameEnum_default.domException); - } - if (this.#element) { - this.#cache.propertyManager = new CSSStyleDeclarationPropertyManager({ cssText }); - this.#cache.attributeValue = cssText; - this.#element.setAttribute("style", this.#cache.propertyManager.toString()); - } else { - this.#cache.propertyManager = new CSSStyleDeclarationPropertyManager({ cssText }); - } - } - item(index) { - return this.#getPropertyManager().item(index); - } - setProperty(name, value, priority) { - if (this.#computed) { - throw new this[window].DOMException(`Failed to execute 'setProperty' on 'CSSStyleDeclaration': These styles are computed, and therefore the '${name}' property is read-only.`, DOMExceptionNameEnum_default.domException); - } - if (priority !== "" && priority !== undefined && priority !== "important") { - return; - } - const stringValue = String(value).trim(); - const propertyManager = this.#getPropertyManager(); - if (stringValue) { - propertyManager.set(name, stringValue, !!priority); - } else { - propertyManager.remove(name); - } - if (this.#element) { - this.#cache.attributeValue = propertyManager.toString(); - if (this.#cache.attributeValue) { - this.#element.setAttribute("style", this.#cache.attributeValue); - } else { - this.#element.removeAttribute("style"); - } - } - } - removeProperty(name) { - if (this.#computed) { - throw new this[window].DOMException(`Failed to execute 'removeProperty' on 'CSSStyleDeclaration': These styles are computed, and therefore the '${name}' property is read-only.`, DOMExceptionNameEnum_default.domException); - } - const propertyManager = this.#getPropertyManager(); - propertyManager.remove(name); - if (this.#element) { - this.#cache.attributeValue = propertyManager.toString(); - if (this.#cache.attributeValue) { - this.#element.setAttribute("style", this.#cache.attributeValue); - } else { - this.#element.removeAttribute("style"); - } - } - } - getPropertyValue(name) { - return this.#getPropertyManager().get(name)?.value || ""; - } - getPropertyPriority(name) { - return this.#getPropertyManager().get(name)?.important ? "important" : ""; - } - #getPropertyManager() { - const element = this.#element; - const cache = this.#cache; - if (!element) { - if (!cache.propertyManager) { - cache.propertyManager = new CSSStyleDeclarationPropertyManager; - } - return cache.propertyManager; - } - if (this.#computed) { - return new CSSStyleDeclarationComputedStyle(element).getComputedStyle(); - } - const attributeValue = element.getAttribute("style") || ""; - if (cache.attributeValue !== attributeValue) { - cache.propertyManager = new CSSStyleDeclarationPropertyManager({ cssText: attributeValue }); - } - return cache.propertyManager; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSConditionRule.js -class CSSConditionRule extends CSSGroupingRule { - [conditionText] = ""; - get conditionText() { - return this[conditionText]; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSContainerRule.js -class CSSContainerRule extends CSSConditionRule { - [type] = CSSRuleTypeEnum_default.containerRule; - [rulePrefix] = ""; - get type() { - return CSSRuleTypeEnum_default.containerRule; - } - get cssText() { - let cssText = ""; - for (const cssRule of this[cssRules]) { - cssText += ` - ` + cssRule.cssText; - } - cssText += ` -`; - return `@${this[rulePrefix]}container ${this[conditionText]} {${cssText}}`; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSFontFaceRule.js -class CSSFontFaceRule extends CSSRule { - [cssText] = ""; - #style = null; - get type() { - return CSSRuleTypeEnum_default.fontFaceRule; - } - get cssText() { - return `@font-face { ${this.style.cssText} }`; - } - get style() { - if (!this.#style) { - this.#style = new CSSStyleDeclaration(illegalConstructor, this[window]); - this.#style.parentRule = this; - this.#style.cssText = this[cssText]; - } - return this.#style; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSKeyframeRule.js -class CSSKeyframeRule extends CSSRule { - [keyText] = ""; - [cssText] = ""; - #style = null; - get type() { - return CSSRuleTypeEnum_default.keyframeRule; - } - get cssText() { - return `${this[keyText]} { ${this.style.cssText} }`; - } - get style() { - if (!this.#style) { - this.#style = new CSSStyleDeclaration(illegalConstructor, this[window]); - this.#style.parentRule = this; - this.#style.cssText = this[cssText]; - } - return this.#style; - } - get keyText() { - return this[keyText]; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSKeyframesRule.js -var CSS_RULE_REGEXP = /^(from|to|[0-9]{1,3}%)\s*{([^}]*)}$/; - -class CSSKeyframesRule extends CSSRule { - [cssRules] = []; - [name] = ""; - [rulePrefix] = ""; - get type() { - return CSSRuleTypeEnum_default.keyframesRule; - } - get cssText() { - let cssText = ""; - for (const cssRule of this[cssRules]) { - cssText += ` - ` + cssRule.cssText; - } - cssText += ` -`; - return `@${this[rulePrefix]}keyframes ${this[name]} { ${cssText}}`; - } - get cssRules() { - return this[cssRules]; - } - get name() { - return this[name]; - } - get length() { - return this[cssRules].length; - } - appendRule(rule) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'appendRule' on 'CSSKeyframesRule': 1 argument required, but only 0 present.`); - } - const match = String(rule).trim().match(CSS_RULE_REGEXP); - if (!match) { - throw new this[window].DOMException(`Invalid or unexpected token`, DOMExceptionNameEnum_default.syntaxError); - } - const cssRule = new CSSKeyframeRule(illegalConstructor, this[window], this[cssParser]); - let keyText2 = match[1].trim(); - if (keyText2 === "from") { - keyText2 = "0%"; - } else if (keyText2 === "to") { - keyText2 = "100%"; - } - cssRule[parentRule] = this; - cssRule[keyText] = keyText2; - cssRule[cssText] = match[2].trim(); - this[cssRules].push(cssRule); - } - deleteRule(rule) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'deleteRule' on 'CSSKeyframesRule': 1 argument required, but only 0 present.`); - } - for (let i = 0, max = this[cssRules].length;i < max; i++) { - if (this[cssRules][i][keyText] === rule) { - this[cssRules].splice(i, 1); - return; - } - } - } - findRule(rule) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'findRule' on 'CSSKeyframesRule': 1 argument required, but only 0 present.`); - } - for (let i = 0, max = this[cssRules].length;i < max; i++) { - if (this[cssRules][i][keyText] === rule) { - return this[cssRules][i]; - } - } - return null; - } -} - -// node_modules/happy-dom/lib/css/MediaList.js -var MEDIUM_REGEXP = /\s*,\s*/; - -class MediaList { - [cssRule]; - constructor(illegalConstructorSymbol, cssRule2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[cssRule] = cssRule2; - const methodBinder = new ClassMethodBinder(this, [MediaList]); - return new Proxy(this, { - get: (target, property) => { - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (property in target || typeof property === "symbol") { - target[property] = newValue; - return true; - } - return true; - }, - deleteProperty(target, property) { - if (property in target || typeof property === "symbol") { - delete target[property]; - return true; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (typeof property === "symbol") { - return false; - } - if (property in target) { - return true; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get mediaText() { - return this[cssRule][conditionText]; - } - set mediaText(mediaText) { - this[cssRule][conditionText] = mediaText === null ? "" : String(mediaText).split(MEDIUM_REGEXP).join(", "); - } - item(index) { - const items = this[getItemList](); - return items[Number(index)] || null; - } - appendMedium(medium) { - const items = this[getItemList](); - if (items.indexOf(medium) === -1) { - items.push(medium); - this[cssRule][conditionText] = items.join(", "); - } - } - deleteMedium(medium) { - const items = this[getItemList](); - const index = items.indexOf(medium); - if (index !== -1) { - items.splice(index, 1); - this[cssRule][conditionText] = items.join(", "); - } - } - [getItemList]() { - const text = this[cssRule][conditionText].trim(); - const media = text ? this[cssRule][conditionText].split(MEDIUM_REGEXP) : []; - return media; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSMediaRule.js -class CSSMediaRule extends CSSConditionRule { - [media] = new MediaList(illegalConstructor, this); - get type() { - return CSSRuleTypeEnum_default.mediaRule; - } - get cssText() { - let cssText = ""; - for (const cssRule of this[cssRules]) { - cssText += ` - ` + cssRule.cssText; - } - cssText += cssText ? ` -` : " "; - return `@media ${this.conditionText} {${cssText}}`; - } - get media() { - return this[media]; - } - get conditionText() { - return this.media.mediaText; - } -} - -// node_modules/happy-dom/lib/css/style-property-map/CSSKeywordValue.js -class CSSKeywordValue { - #value; - constructor(value) { - this.#value = value; - } - get value() { - return this.#value; - } - set value(value) { - this.#value = value; - } -} - -// node_modules/happy-dom/lib/css/style-property-map/CSSStyleValue.js -class CSSStyleValue { - #style; - #property; - constructor(illegalConstructorSymbol, style, property) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this.#style = style; - this.#property = property; - } - toString() { - return this.#style.getPropertyValue(this.#property); - } -} - -// node_modules/happy-dom/lib/css/style-property-map/StylePropertyMapReadOnly.js -class StylePropertyMapReadOnly { - [style]; - constructor(illegalConstructorSymbol, style2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[style] = style2; - } - get size() { - return this[style].length; - } - [Symbol.iterator]() { - return this.entries(); - } - entries() { - const length = this[style].length; - const array = new Array(length); - for (let i = 0;i < length; i++) { - const property = this[style][i]; - array[i] = [ - property, - [new CSSKeywordValue(this[style].getPropertyValue(property))] - ]; - } - return array.values(); - } - values() { - const length = this[style].length; - const array = new Array(length); - for (let i = 0;i < length; i++) { - const property = this[style][i]; - array[i] = [new CSSKeywordValue(this[style].getPropertyValue(property))]; - } - return array.values(); - } - keys() { - const length = this[style].length; - const array = new Array(length); - for (let i = 0;i < length; i++) { - array[i] = this[style][i]; - } - return array.values(); - } - get(property) { - return new CSSStyleValue(illegalConstructor, this[style], property); - } - getAll(property) { - return [ - new CSSStyleValue(illegalConstructor, this[style], property) - ]; - } - has(property) { - return !!this[style].getPropertyValue(property); - } -} - -// node_modules/happy-dom/lib/css/style-property-map/StylePropertyMap.js -class StylePropertyMap extends StylePropertyMapReadOnly { - append(property, value) { - this[style].setProperty(property, value); - } - clear() { - this[style].cssText = ""; - } - delete(property) { - this[style].removeProperty(property); - } - set(property, value) { - this[style].setProperty(property, value); - } -} - -// node_modules/happy-dom/lib/css/rules/CSSStyleRule.js -class CSSStyleRule extends CSSGroupingRule { - [styleMap] = null; - [selectorText] = ""; - [cssText] = ""; - #style = null; - get type() { - return CSSRuleTypeEnum_default.styleRule; - } - get cssText() { - return `${this[selectorText]} { ${this.style.cssText} }`; - } - get styleMap() { - if (!this[styleMap]) { - this[styleMap] = new StylePropertyMap(illegalConstructor, this.style); - } - return this[styleMap]; - } - get selectorText() { - return this[selectorText]; - } - get style() { - if (!this.#style) { - this.#style = new CSSStyleDeclaration(illegalConstructor, this[window]); - this.#style.parentRule = this; - this.#style.cssText = this[cssText]; - } - return this.#style; - } -} - -// node_modules/happy-dom/lib/css/rules/CSSSupportsRule.js -class CSSSupportsRule extends CSSConditionRule { - [type] = CSSRuleTypeEnum_default.supportsRule; - [rulePrefix] = ""; - get type() { - return CSSRuleTypeEnum_default.supportsRule; - } - get cssText() { - let cssText = ""; - for (const cssRule of this[cssRules]) { - cssText += ` - ` + cssRule.cssText; - } - cssText += ` -`; - return `@${this[rulePrefix]}supports ${this.conditionText} {${cssText}}`; - } -} - -// node_modules/happy-dom/lib/config/NamespaceURI.js -var NamespaceURI_default = { - html: "http://www.w3.org/1999/xhtml", - svg: "http://www.w3.org/2000/svg", - mathML: "http://www.w3.org/1998/Math/MathML", - xml: "http://www.w3.org/XML/1998/namespace", - xlink: "http://www.w3.org/1999/xlink", - xmlns: "http://www.w3.org/2000/xmlns/" -}; - -// node_modules/happy-dom/lib/utilities/StringUtility.js -var ASCII_LOWER_CASE_CACHE = new Map; -var ASCII_UPPER_CASE_CACHE = new Map; -var ASCII_UPPER_CASE_REGEXP = /[A-Z]/g; -var ASCII_LOWER_CASE_REGEXP = /[a-z]/g; - -class StringUtility { - static asciiLowerCase(text) { - const cached = ASCII_LOWER_CASE_CACHE.get(text); - if (cached) { - return cached; - } - const newText = text.replace(ASCII_UPPER_CASE_REGEXP, (char) => String.fromCharCode(char.charCodeAt(0) + 32)); - ASCII_LOWER_CASE_CACHE.set(text, newText); - return newText; - } - static asciiUpperCase(text) { - const cached = ASCII_UPPER_CASE_CACHE.get(text); - if (cached) { - return cached; - } - const newText = text.replace(ASCII_LOWER_CASE_REGEXP, (char) => String.fromCharCode(char.charCodeAt(0) - 32)); - ASCII_UPPER_CASE_CACHE.set(text, newText); - return newText; - } -} - -// node_modules/happy-dom/lib/custom-element/CustomElementUtility.js -var PCEN_CHAR = "[-_.]|[0-9]|[a-z]|\xB7|[\xC0-\xD6]|[\xD8-\xF6]" + "|[\xF8-\u037D]|[\u037F-\u1FFF]" + "|[\u200C-\u200D]|[\u203F-\u2040]|[\u2070-\u218F]" + "|[\u2C00-\u2FEF]|[\u3001-\uD7FF]" + "|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|[\uD800\uDC00-\uDB7F\uDFFF]"; -var PCEN_REGEXP = new RegExp(`^[a-z](${PCEN_CHAR})*-(${PCEN_CHAR})*$`, "u"); -var RESERVED_NAMES = [ - "annotation-xml", - "color-profile", - "font-face", - "font-face-src", - "font-face-uri", - "font-face-format", - "font-face-name", - "missing-glyph" -]; - -class CustomElementUtility { - static isValidCustomElementName(name) { - return PCEN_REGEXP.test(name) && !RESERVED_NAMES.includes(name); - } -} - -// node_modules/happy-dom/lib/custom-element/CustomElementRegistry.js -class CustomElementRegistry { - [registry] = new Map; - [classRegistry] = new Map; - [callbacks] = new Map; - [destroyed] = false; - #window; - constructor(window) { - if (!window) { - throw new TypeError("Illegal constructor"); - } - this.#window = window; - } - define(name, elementClass, options) { - if (this[destroyed]) { - return; - } - if (!CustomElementUtility.isValidCustomElementName(name)) { - throw new this.#window.DOMException(`Failed to execute 'define' on 'CustomElementRegistry': "${name}" is not a valid custom element name`); - } - if (this[registry].has(name)) { - throw new this.#window.DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`); - } - if (this[classRegistry].has(elementClass)) { - throw new this.#window.DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry"); - } - const tagName2 = StringUtility.asciiUpperCase(name); - elementClass.prototype[window] = this.#window; - elementClass.prototype[ownerDocument] = this.#window.document; - elementClass.prototype[tagName] = tagName2; - elementClass.prototype[localName] = name; - elementClass.prototype[namespaceURI] = NamespaceURI_default.html; - const observedAttributes = new Set; - const elementObservervedAttributes = elementClass.observedAttributes; - if (Array.isArray(elementObservervedAttributes)) { - for (const attribute of elementObservervedAttributes) { - observedAttributes.add(String(attribute).toLowerCase()); - } - } - this[registry].set(name, { - elementClass, - extends: options && options.extends ? options.extends.toLowerCase() : null, - observedAttributes, - lifecycleCallbacks: { - connectedCallback: elementClass.prototype.connectedCallback, - disconnectedCallback: elementClass.prototype.disconnectedCallback, - attributeChangedCallback: elementClass.prototype.attributeChangedCallback - } - }); - this[classRegistry].set(elementClass, name); - const callbacks2 = this[callbacks].get(name); - if (callbacks2) { - this[callbacks].delete(name); - for (const callback of callbacks2) { - callback(); - } - } - } - get(name) { - return this[registry].get(name)?.elementClass; - } - upgrade(_root) {} - whenDefined(name) { - if (this[destroyed]) { - return Promise.reject(new this.#window.DOMException(`Failed to execute 'whenDefined' on 'CustomElementRegistry': The custom element registry has been destroyed.`)); - } - if (!CustomElementUtility.isValidCustomElementName(name)) { - return Promise.reject(new this.#window.DOMException(`Failed to execute 'whenDefined' on 'CustomElementRegistry': Invalid custom element name: "${name}"`)); - } - if (this.get(name)) { - return Promise.resolve(); - } - return new Promise((resolve) => { - const callbacks2 = this[callbacks].get(name); - if (callbacks2) { - callbacks2.push(resolve); - } else { - this[callbacks].set(name, [resolve]); - } - }); - } - getName(elementClass) { - return this[classRegistry].get(elementClass) || null; - } - [destroy]() { - this[destroyed] = true; - for (const definition of this[registry].values()) { - definition.elementClass.prototype[window] = null; - definition.elementClass.prototype[ownerDocument] = null; - definition.elementClass.prototype[tagName] = null; - definition.elementClass.prototype[localName] = null; - definition.elementClass.prototype[namespaceURI] = null; - } - this[registry] = new Map; - this[classRegistry] = new Map; - this[callbacks] = new Map; - } -} - -// node_modules/happy-dom/lib/event/DataTransferItem.js -class DataTransferItem { - kind; - type; - #item = null; - constructor(item, type = "") { - this.kind = typeof item === "string" ? "string" : "file"; - this.type = this.kind === "string" ? type : item.type; - this.#item = item; - } - getAsFile() { - if (this.kind === "string") { - return null; - } - return this.#item; - } - getAsString(callback) { - if (this.kind === "file") { - callback(""); - } - callback(this.#item); - } -} - -// node_modules/happy-dom/lib/file/File.js -class File extends Blob { - lastModified; - name; - constructor(bits, name, options) { - if (arguments.length < 2) { - throw new TypeError("Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present."); - } - super(bits, options); - this.name = name; - this.lastModified = options && options.lastModified ? options.lastModified : Date.now(); - } -} - -// node_modules/happy-dom/lib/event/DataTransferItemList.js -class DataTransferItemList extends Array { - add(item, type) { - if (item instanceof File) { - this.push(new DataTransferItem(item)); - return; - } - if (!type) { - throw new TypeError(`Failed to execute 'add' on 'DataTransferItemList': parameter 1 is not of type 'File'.`); - } - this.push(new DataTransferItem(item, type)); - } - remove(index) { - this.splice(index, 1); - } - clear() { - while (this.length) { - this.pop(); - } - } -} - -// node_modules/happy-dom/lib/event/DataTransfer.js -class DataTransfer { - dropEffect = "none"; - effectAllowed = "none"; - items = new DataTransferItemList; - get files() { - const files = []; - for (const item of this.items) { - if (item.kind === "file") { - const file = item.getAsFile(); - if (file) { - files.push(file); - } - } - } - return files; - } - get types() { - return this.items.map((item) => item.type); - } - clearData() { - this.items.clear(); - } - setData(format, data) { - for (let i = 0, max = this.items.length;i < max; i++) { - if (this.items[i].type === format) { - this.items[i] = new DataTransferItem(data, format); - return; - } - } - this.items.add(data, format); - } - getData(format) { - const normalizedFormat = this.#normalizeFormat(format); - for (let i = 0, max = this.items.length;i < max; i++) { - const itemFormat = this.#normalizeFormat(this.items[i].type); - if (itemFormat === normalizedFormat) { - let data = ""; - this.items[i].getAsString((s) => data = s); - return data; - } - } - return ""; - } - #normalizeFormat(format) { - const lowercaseFormat = format.toLowerCase(); - if (lowercaseFormat === "text") { - return "text/plain"; - } - if (lowercaseFormat === "url") { - return "text/uri-list"; - } - return lowercaseFormat; - } - setDragImage() { - throw new Error("Not implemented."); - } -} - -// node_modules/happy-dom/lib/event/Touch.js -class Touch { - identifier; - target; - clientX; - clientY; - screenX; - screenY; - pageX; - pageY; - radiusX; - radiusY; - rotationAngle; - force; - constructor(touchInit) { - this.identifier = touchInit.identifier; - this.target = touchInit.target; - this.clientX = touchInit.clientX ?? 0; - this.clientY = touchInit.clientY ?? 0; - this.screenX = touchInit.screenX ?? 0; - this.screenY = touchInit.screenY ?? 0; - this.pageX = touchInit.pageX ?? 0; - this.pageY = touchInit.pageY ?? 0; - this.radiusX = touchInit.radiusX ?? 0; - this.radiusY = touchInit.radiusY ?? 0; - this.rotationAngle = touchInit.rotationAngle ?? 0; - this.force = touchInit.force ?? 0; - } -} - -// node_modules/happy-dom/lib/event/UIEvent.js -class UIEvent extends Event { - static NONE = 0; - static CAPTURING_PHASE = 1; - static AT_TARGET = 2; - static BUBBLING_PHASE = 3; - detail; - layerX = 0; - layerY = 0; - pageX = 0; - pageY = 0; - view; - constructor(type, eventInit = null) { - super(type, eventInit); - this.detail = eventInit?.detail ?? 0; - this.view = eventInit?.view ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/AnimationEvent.js -class AnimationEvent extends Event { - animationName; - elapsedTime; - pseudoElement; - constructor(type, eventInit = null) { - super(type, eventInit); - this.animationName = eventInit?.animationName ?? ""; - this.elapsedTime = eventInit?.elapsedTime ?? 0; - this.pseudoElement = eventInit?.pseudoElement ?? ""; - } -} - -// node_modules/happy-dom/lib/event/events/ClipboardEvent.js -class ClipboardEvent extends Event { - clipboardData; - constructor(type, eventInit = null) { - super(type, eventInit); - this.clipboardData = eventInit?.clipboardData ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/CustomEvent.js -class CustomEvent extends Event { - [detail]; - constructor(type, eventInit = null) { - super(type, eventInit); - this[detail] = eventInit?.detail ?? null; - } - get detail() { - return this[detail]; - } - initCustomEvent(type2, bubbles2 = false, cancelable2 = false, detail2 = null) { - this[type] = type2; - this[bubbles] = bubbles2; - this[cancelable] = cancelable2; - this[detail] = detail2; - } -} - -// node_modules/happy-dom/lib/event/events/ErrorEvent.js -class ErrorEvent extends UIEvent { - message; - filename; - lineno; - colno; - error; - constructor(type, eventInit = null) { - super(type, eventInit); - this.message = eventInit?.message ?? ""; - this.filename = eventInit?.filename ?? ""; - this.lineno = eventInit?.lineno ?? 0; - this.colno = eventInit?.colno ?? 0; - this.error = eventInit?.error ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/FocusEvent.js -class FocusEvent extends UIEvent { - relatedTarget; - constructor(type, eventInit = null) { - super(type, eventInit); - this.relatedTarget = eventInit?.relatedTarget ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/HashChangeEvent.js -class HashChangeEvent extends Event { - newURL; - oldURL; - constructor(type, eventInit = null) { - super(type, eventInit); - this.newURL = eventInit?.newURL ?? ""; - this.oldURL = eventInit?.oldURL ?? ""; - } -} - -// node_modules/happy-dom/lib/event/events/InputEvent.js -class InputEvent extends UIEvent { - data; - dataTransfer; - inputType; - isComposing; - constructor(type, eventInit = null) { - super(type, eventInit); - this.data = eventInit?.data ?? ""; - this.dataTransfer = eventInit?.dataTransfer ?? null; - this.inputType = eventInit?.inputType ?? ""; - this.isComposing = eventInit?.isComposing ?? false; - } -} - -// node_modules/happy-dom/lib/event/events/KeyboardEvent.js -class KeyboardEvent extends UIEvent { - static DOM_KEY_LOCATION_STANDARD = 0; - static DOM_KEY_LOCATION_LEFT = 1; - static DOM_KEY_LOCATION_RIGHT = 2; - static DOM_KEY_LOCATION_NUMPAD = 3; - altKey; - code; - ctrlKey; - isComposing; - key; - location; - metaKey; - repeat; - shiftKey; - keyCode; - which; - constructor(type, eventInit = null) { - super(type, eventInit); - this.altKey = eventInit?.altKey ?? false; - this.code = eventInit?.code ?? ""; - this.ctrlKey = eventInit?.ctrlKey ?? false; - this.isComposing = eventInit?.isComposing ?? false; - this.key = eventInit?.key ?? ""; - this.location = eventInit?.location ?? 0; - this.metaKey = eventInit?.metaKey ?? false; - this.repeat = eventInit?.repeat ?? false; - this.shiftKey = eventInit?.shiftKey ?? false; - this.keyCode = eventInit?.keyCode ?? 0; - this.which = eventInit?.which ?? eventInit?.keyCode ?? 0; - } - getModifierState(key) { - if (arguments.length < 1) { - throw new TypeError("Failed to execute 'getModifierState' on 'KeyboardEvent': 1 argument required, but only 0 present."); - } - switch (String(key).toLowerCase()) { - case "alt": - case "altgraph": - return this.altKey; - case "control": - return this.ctrlKey; - case "meta": - return this.metaKey; - case "shift": - return this.shiftKey; - default: - return false; - } - } -} - -// node_modules/happy-dom/lib/event/events/MessageEvent.js -class MessageEvent extends Event { - data; - origin; - lastEventId; - source; - ports; - constructor(type, eventInit = null) { - super(type, eventInit); - this.data = eventInit?.data ?? null; - this.origin = eventInit?.origin ?? ""; - this.lastEventId = eventInit?.lastEventId ?? ""; - this.source = eventInit?.source ?? null; - this.ports = eventInit?.ports ?? []; - } -} - -// node_modules/happy-dom/lib/event/events/MouseEvent.js -class MouseEvent extends UIEvent { - altKey; - button; - buttons; - clientX; - clientY; - ctrlKey; - metaKey; - movementX; - movementY; - offsetX; - offsetY; - region; - relatedTarget; - screenX; - screenY; - shiftKey; - constructor(type, eventInit = null) { - super(type, eventInit); - this.altKey = eventInit?.altKey ?? false; - this.button = eventInit?.button ?? 0; - this.buttons = eventInit?.buttons ?? 0; - this.clientX = eventInit?.clientX ?? 0; - this.clientY = eventInit?.clientY ?? 0; - this.ctrlKey = eventInit?.ctrlKey ?? false; - this.metaKey = eventInit?.metaKey ?? false; - this.movementX = eventInit?.movementX ?? 0; - this.movementY = eventInit?.movementY ?? 0; - this.offsetX = eventInit?.offsetX ?? 0; - this.offsetY = eventInit?.offsetY ?? 0; - this.region = eventInit?.region ?? ""; - this.relatedTarget = eventInit?.relatedTarget ?? null; - this.screenX = eventInit?.screenX ?? 0; - this.screenY = eventInit?.screenY ?? 0; - this.shiftKey = eventInit?.shiftKey ?? false; - } -} - -// node_modules/happy-dom/lib/event/events/PointerEvent.js -class PointerEvent extends MouseEvent { - pointerId; - width; - height; - pressure; - tangentialPressure; - tiltX; - tiltY; - twist; - altitudeAngle; - azimuthAngle; - pointerType; - isPrimary; - coalescedEvents; - predictedEvents; - constructor(type, eventInit = null) { - super(type, eventInit); - this.pointerId = eventInit?.pointerId ?? 0; - this.width = eventInit?.width ?? 1; - this.height = eventInit?.height ?? 1; - this.pressure = eventInit?.pressure ?? 0; - this.tangentialPressure = eventInit?.tangentialPressure ?? 0; - this.tiltX = eventInit?.tiltX ?? 0; - this.tiltY = eventInit?.tiltY ?? 0; - this.twist = eventInit?.twist ?? 0; - this.altitudeAngle = eventInit?.altitudeAngle ?? 0; - this.azimuthAngle = eventInit?.azimuthAngle ?? 0; - this.pointerType = eventInit?.pointerType ?? ""; - this.isPrimary = eventInit?.isPrimary ?? false; - this.coalescedEvents = eventInit?.coalescedEvents ?? []; - this.predictedEvents = eventInit?.predictedEvents ?? []; - } - getCoalescedEvents = () => this.coalescedEvents; - getPredictedEvents = () => this.predictedEvents; -} - -// node_modules/happy-dom/lib/event/events/ProgressEvent.js -class ProgressEvent extends Event { - lengthComputable; - loaded; - total; - constructor(type, eventInit = null) { - super(type); - this.lengthComputable = eventInit?.lengthComputable ?? false; - this.loaded = eventInit?.loaded ?? 0; - this.total = eventInit?.total ?? 0; - } -} - -// node_modules/happy-dom/lib/event/events/StorageEvent.js -class StorageEvent extends Event { - key; - oldValue; - newValue; - url; - storageArea; - constructor(type, eventInit = null) { - super(type); - this.key = eventInit?.key ?? null; - this.oldValue = eventInit?.oldValue ?? null; - this.newValue = eventInit?.newValue ?? null; - this.url = eventInit?.url ?? ""; - this.storageArea = eventInit?.storageArea ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/SubmitEvent.js -class SubmitEvent extends Event { - submitter; - constructor(type, eventInit = null) { - super(type, eventInit); - this.submitter = eventInit?.submitter ?? null; - } -} - -// node_modules/happy-dom/lib/event/events/TouchEvent.js -class TouchEvent extends UIEvent { - altKey; - changedTouches; - ctrlKey; - metaKey; - shiftKey; - targetTouches; - touches; - constructor(type, eventInit = null) { - super(type, eventInit); - this.altKey = eventInit?.altKey ?? false; - this.changedTouches = eventInit?.changedTouches ?? []; - this.ctrlKey = eventInit?.ctrlKey ?? false; - this.metaKey = eventInit?.metaKey ?? false; - this.shiftKey = eventInit?.shiftKey ?? false; - this.targetTouches = eventInit?.targetTouches ?? []; - this.touches = eventInit?.touches ?? []; - } -} - -// node_modules/happy-dom/lib/event/events/WheelEvent.js -class WheelEvent extends UIEvent { - static DOM_DELTA_PIXEL = 0; - static DOM_DELTA_LINE = 1; - static DOM_DELTA_PAGE = 2; - deltaX; - deltaY; - deltaZ; - deltaMode; - constructor(type, eventInit = null) { - super(type, eventInit); - this.deltaX = eventInit?.deltaX ?? 0; - this.deltaY = eventInit?.deltaY ?? 0; - this.deltaZ = eventInit?.deltaZ ?? 0; - this.deltaMode = eventInit?.deltaMode ?? 0; - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchRequestReferrerUtility.js -import { isIP } from "net"; -var REQUEST_REFERRER_UNSUPPORTED_PROTOCOL_REGEXP = /^(about|blob|data):$/; -var REFERRER_POLICIES = [ - "", - "no-referrer", - "no-referrer-when-downgrade", - "same-origin", - "origin", - "strict-origin", - "origin-when-cross-origin", - "strict-origin-when-cross-origin", - "unsafe-url" -]; - -class FetchRequestReferrerUtility { - static prepareRequest(originURL, request) { - if (!request.referrerPolicy) { - request[referrerPolicy] = "strict-origin-when-cross-origin"; - } - if (request.referrer && request.referrer !== "no-referrer") { - request[referrer] = this.getSentReferrer(originURL, request); - } else { - request[referrer] = "no-referrer"; - } - } - static getInitialReferrer(window, referrer) { - if (referrer === "" || referrer === "no-referrer" || referrer === "client") { - return referrer; - } else if (referrer) { - const referrerURL = referrer instanceof URL2 ? referrer : new URL2(referrer, window.location.href); - return referrerURL.origin === window.location.origin ? referrerURL : "client"; - } - return "client"; - } - static getReferrerPolicyFromHeader(headers) { - const referrerPolicyHeader = headers.get("Referrer-Policy"); - if (!referrerPolicyHeader) { - return ""; - } - const policyTokens = referrerPolicyHeader.split(/[,\s]+/); - let policy = ""; - for (const token of policyTokens) { - if (token && REFERRER_POLICIES.includes(token)) { - policy = token; - } - } - return policy; - } - static getSentReferrer(originURL, request) { - if (request.referrer === "about:client" && originURL.origin === "null") { - return "no-referrer"; - } - const requestURL = new URL2(request.url); - const referrerURL = request.referrer === "about:client" ? new URL2(originURL.href) : new URL2(request.referrer); - if (REQUEST_REFERRER_UNSUPPORTED_PROTOCOL_REGEXP.test(referrerURL.protocol)) { - return "no-referrer"; - } - referrerURL.username = ""; - referrerURL.password = ""; - referrerURL.hash = ""; - switch (request.referrerPolicy) { - case "no-referrer": - return "no-referrer"; - case "origin": - return new URL2(referrerURL.origin); - case "unsafe-url": - return referrerURL; - case "strict-origin": - if (this.isURLPotentiallyTrustWorthy(referrerURL) && !this.isURLPotentiallyTrustWorthy(requestURL)) { - return "no-referrer"; - } - return new URL2(referrerURL.origin); - case "strict-origin-when-cross-origin": - if (referrerURL.origin === requestURL.origin) { - return referrerURL; - } - if (this.isURLPotentiallyTrustWorthy(referrerURL) && !this.isURLPotentiallyTrustWorthy(requestURL)) { - return "no-referrer"; - } - return new URL2(referrerURL.origin); - case "same-origin": - if (referrerURL.origin === requestURL.origin) { - return referrerURL; - } - return "no-referrer"; - case "origin-when-cross-origin": - if (referrerURL.origin === requestURL.origin) { - return referrerURL; - } - return new URL2(referrerURL.origin); - case "no-referrer-when-downgrade": - if (this.isURLPotentiallyTrustWorthy(referrerURL) && !this.isURLPotentiallyTrustWorthy(requestURL)) { - return "no-referrer"; - } - return referrerURL; - } - return "no-referrer"; - } - static isURLPotentiallyTrustWorthy(url) { - if (/^about:(blank|srcdoc)$/.test(url.href)) { - return true; - } - if (url.protocol === "data:") { - return true; - } - if (/^(blob|filesystem):$/.test(url.protocol)) { - return true; - } - return this.isOriginPotentiallyTrustWorthy(url); - } - static isOriginPotentiallyTrustWorthy(url) { - if (/^(http|ws)s:$/.test(url.protocol)) { - return true; - } - const hostIp = url.host.replace(/(^\[)|(]$)/g, ""); - const hostIPVersion = isIP(hostIp); - if (hostIPVersion === 4 && /^127\./.test(hostIp)) { - return true; - } - if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) { - return true; - } - if (url.host === "localhost" || url.host.endsWith(".localhost")) { - return false; - } - if (url.protocol === "file:") { - return true; - } - return false; - } -} - -// node_modules/happy-dom/lib/fetch/Fetch.js -import HTTP from "http"; -import HTTPS from "https"; -import Zlib from "zlib"; -import { URL as URL6 } from "url"; -import FS2 from "fs"; -import Path3 from "path"; -import Stream2 from "stream"; - -// node_modules/happy-dom/lib/fetch/data-uri/DataURIParser.js -class DataURIParser { - static parse(uri) { - if (!/^data:/i.test(uri)) { - throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")'); - } - uri = uri.replace(/\r?\n/g, ""); - const firstComma = uri.indexOf(","); - if (firstComma === -1 || firstComma <= 4) { - throw new TypeError("malformed data: URI"); - } - const meta = uri.substring(5, firstComma).split(";"); - let charset = ""; - let base64 = false; - let type = meta[0] || "text/plain"; - for (let i = 1;i < meta.length; i++) { - if (meta[i] === "base64") { - base64 = true; - } else if (meta[i]) { - type += `;${meta[i]}`; - if (meta[i].indexOf("charset=") === 0) { - charset = meta[i].substring(8); - } - } - } - if (!meta[0] && !charset.length) { - type += ";charset=US-ASCII"; - charset = "US-ASCII"; - } - const encoding = base64 ? "base64" : "ascii"; - const data = unescape(uri.substring(firstComma + 1)); - const buffer = Buffer.from(data, encoding); - return { - type, - charset, - buffer - }; - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchCORSUtility.js -import { URL as URL3 } from "url"; - -class FetchCORSUtility { - static isCORS(originURL, targetURL) { - originURL = typeof originURL === "string" ? new URL3(originURL) : originURL; - targetURL = typeof targetURL === "string" ? new URL3(targetURL) : targetURL; - if (targetURL.protocol === "about:" || targetURL.protocol === "javascript:") { - return false; - } - return originURL.origin !== targetURL.origin; - } -} - -// node_modules/happy-dom/lib/fetch/Request.js -import { URL as URL5 } from "url"; - -// node_modules/happy-dom/lib/fetch/multipart/MultipartFormDataParser.js -import { ReadableStream as ReadableStream2 } from "stream/web"; - -// node_modules/happy-dom/lib/fetch/multipart/MultipartReader.js -var MultipartParserStateEnum; -(function(MultipartParserStateEnum) { - MultipartParserStateEnum[MultipartParserStateEnum["boundary"] = 0] = "boundary"; - MultipartParserStateEnum[MultipartParserStateEnum["headerStart"] = 2] = "headerStart"; - MultipartParserStateEnum[MultipartParserStateEnum["header"] = 3] = "header"; - MultipartParserStateEnum[MultipartParserStateEnum["data"] = 5] = "data"; -})(MultipartParserStateEnum || (MultipartParserStateEnum = {})); -var CHARACTER_CODE = { - lf: 10, - cr: 13 -}; - -class MultipartReader { - formData; - boundary; - boundaryIndex = 0; - state = MultipartParserStateEnum.boundary; - data = { - contentDisposition: null, - value: [], - contentType: null, - header: "" - }; - constructor(window, boundary) { - const boundaryHeader = `--${boundary}`; - this.boundary = new Uint8Array(boundaryHeader.length); - this.formData = new window.FormData; - for (let i = 0, max = boundaryHeader.length;i < max; i++) { - this.boundary[i] = boundaryHeader.charCodeAt(i); - } - } - write(data) { - let char; - let nextChar; - for (let i = 0, max = data.length;i < max; i++) { - char = data[i]; - nextChar = data[i + 1]; - switch (this.state) { - case MultipartParserStateEnum.boundary: - if (char === this.boundary[this.boundaryIndex]) { - this.boundaryIndex++; - } else { - this.boundaryIndex = 0; - } - if (this.boundaryIndex === this.boundary.length) { - this.state = MultipartParserStateEnum.headerStart; - this.boundaryIndex = 0; - } - break; - case MultipartParserStateEnum.headerStart: - if (nextChar !== CHARACTER_CODE.cr && nextChar !== CHARACTER_CODE.lf) { - this.data.header = ""; - this.state = data[i - 2] === CHARACTER_CODE.lf ? MultipartParserStateEnum.data : MultipartParserStateEnum.header; - } - break; - case MultipartParserStateEnum.header: - if (char === CHARACTER_CODE.cr) { - if (this.data.header) { - const headerParts = this.data.header.split(":"); - if (headerParts.length > 1) { - const headerName = headerParts[0].toLowerCase(); - const headerValue = headerParts[1].trim(); - switch (headerName) { - case "content-disposition": - this.data.contentDisposition = this.getContentDisposition(headerValue); - break; - case "content-type": - this.data.contentType = headerValue; - break; - } - } - } - this.state = MultipartParserStateEnum.headerStart; - } else { - this.data.header += String.fromCharCode(char); - } - break; - case MultipartParserStateEnum.data: - if (char === this.boundary[this.boundaryIndex]) { - this.boundaryIndex++; - } else { - this.boundaryIndex = 0; - } - if (this.boundaryIndex === this.boundary.length) { - this.state = MultipartParserStateEnum.headerStart; - if (this.data.value.length) { - this.appendFormData(this.data.contentDisposition.name, Buffer.from(this.data.value.slice(0, -(this.boundary.length + 1))), this.data.contentDisposition.filename, this.data.contentType); - this.data.value = []; - this.data.contentDisposition = null; - this.data.contentType = null; - } - this.boundaryIndex = 0; - } else { - this.data.value.push(char); - } - break; - } - } - } - end() { - if (this.data.contentDisposition && this.data.value.length) { - this.appendFormData(this.data.contentDisposition.name, Buffer.from(this.data.value.slice(0, -2)), this.data.contentDisposition.filename, this.data.contentType); - } - return this.formData; - } - appendFormData(key, value, filename, type) { - if (!value.length) { - return; - } - if (filename) { - this.formData.append(key, new File([value], filename, { - type - })); - } else { - this.formData.append(key, value.toString()); - } - } - getContentDisposition(headerValue) { - const regex = /([a-z]+) *= *"([^"]+)"/g; - const contentDisposition = {}; - let match; - while (match = regex.exec(headerValue)) { - contentDisposition[match[1]] = match[2]; - } - return contentDisposition; - } -} - -// node_modules/happy-dom/lib/fetch/multipart/MultipartFormDataParser.js -import { Buffer as Buffer3 } from "buffer"; - -// node_modules/happy-dom/lib/fetch/ReadableStreamWrapper.js -class ReadableStreamWrapper { - #read; - #readableStream = null; - constructor(read) { - this.#read = read; - } - get readableStream() { - if (!this.#readableStream) { - this.#readableStream = this.#read(); - } - return this.#readableStream; - } -} - -// node_modules/happy-dom/lib/fetch/multipart/MultipartFormDataParser.js -class MultipartFormDataParser { - static async streamToFormData(window, requestOrResponse, contentType) { - if (!/multipart/i.test(contentType)) { - throw new window.DOMException(`Failed to build FormData object: The "content-type" header isn't of type "multipart/form-data".`, DOMExceptionNameEnum_default.invalidStateError); - } - const body = requestOrResponse.body; - if (!body) { - throw new window.DOMException("Failed to build FormData object: The response body is null.", DOMExceptionNameEnum_default.invalidStateError); - } - const match = contentType.match(/boundary=(?:"([^"]+)"|([^;]+))/i); - if (!match) { - throw new window.DOMException(`Failed to build FormData object: The "content-type" header doesn't contain any multipart boundary.`, DOMExceptionNameEnum_default.invalidStateError); - } - const bodyReader = body.getReader(); - const reader = new MultipartReader(window, match[1] || match[2]); - const chunks = []; - let buffer; - const bytes = 0; - let readResult = await bodyReader.read(); - while (!readResult.done) { - if (requestOrResponse[error]) { - throw requestOrResponse[error]; - } - if (requestOrResponse[aborted]) { - throw new window.DOMException("Failed to read response body: The stream was aborted.", DOMExceptionNameEnum_default.abortError); - } - reader.write(readResult.value); - readResult = await bodyReader.read(); - } - try { - buffer = typeof chunks[0] === "string" ? Buffer3.from(chunks.join("")) : Buffer3.concat(chunks, bytes); - } catch (error) { - throw new window.DOMException(`Could not create Buffer from response body. Error: ${error.message}.`, DOMExceptionNameEnum_default.invalidStateError); - } - return { - formData: reader.end(), - buffer - }; - } - static formDataToStream(formData) { - const boundary = "----HappyDOMFormDataBoundary" + Math.random().toString(36); - const chunks = []; - const prefix = `--${boundary}\r -Content-Disposition: form-data; name="`; - for (const [name, value] of formData) { - if (typeof value === "string") { - chunks.push(Buffer3.from(`${prefix}${this.escapeName(name)}"\r -\r -${value.replace(/\r(?!\n)|(? new ReadableStream2({ - start(controller) { - controller.enqueue(buffer2); - controller.close(); - } - })) - }; - } - static escapeName(name, filename = false) { - return (filename ? name : name.replace(/\r?\n|\r/g, `\r -`)).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"); - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchBodyUtility.js -import { ReadableStream as ReadableStream3 } from "stream/web"; -import { URLSearchParams as URLSearchParams2 } from "url"; - -// node_modules/happy-dom/lib/form-data/FormData.js -class FormData { - #entries = []; - constructor(form, submitter) { - if (!form) { - return; - } - if (submitter) { - const formProxy = form[proxy] ? form[proxy] : form; - if (submitter.form !== formProxy) { - throw new this[window].DOMException("The specified element is not owned by this form element", DOMExceptionNameEnum_default.notFoundError); - } - const isSubmitButton = submitter[tagName] === "INPUT" && (submitter.type === "submit" || submitter.type === "image") || submitter[tagName] === "BUTTON" && submitter.type === "submit"; - if (!isSubmitButton) { - throw new this[window].TypeError("The specified element is not a submit button"); - } - } - const items = form[getFormControlItems](); - for (const item of items) { - const name = item.name; - if (name) { - switch (item[tagName]) { - case "INPUT": - if (item.disabled) { - break; - } - switch (item.type) { - case "file": - if (item[files].length === 0) { - this.append(name, new File([], "", { type: "application/octet-stream" })); - } else { - for (const file of item[files]) { - this.append(name, file); - } - } - break; - case "checkbox": - case "radio": - if (item.checked) { - this.append(name, item.value); - } - break; - case "submit": - case "reset": - case "button": - if (item === submitter && item.value) { - this.append(name, item.value); - } - break; - default: - this.append(name, item.value); - break; - } - break; - case "BUTTON": - if (item === submitter && item.value) { - this.append(name, item.value); - } - break; - case "TEXTAREA": - case "SELECT": - this.append(name, item.value); - break; - } - } - } - } - forEach(callback, thisArg) { - for (const entry of this.#entries) { - callback.call(thisArg, entry.value, entry.name, this); - } - } - append(name, value, filename) { - if (filename && !(value instanceof Blob)) { - throw new this[window].TypeError('Failed to execute "append" on "FormData": parameter 2 is not of type "Blob".'); - } - this.#entries.push({ - name, - value: this.#parseValue(value, filename) - }); - } - delete(name) { - const newEntries = []; - for (const entry of this.#entries) { - if (entry.name !== name) { - newEntries.push(entry); - } - } - this.#entries = newEntries; - } - get(name) { - for (const entry of this.#entries) { - if (entry.name === name) { - return entry.value; - } - } - return null; - } - getAll(name) { - const values = []; - for (const entry of this.#entries) { - if (entry.name === name) { - values.push(entry.value); - } - } - return values; - } - has(name) { - for (const entry of this.#entries) { - if (entry.name === name) { - return true; - } - } - return false; - } - set(name, value, filename) { - for (const entry of this.#entries) { - if (entry.name === name) { - entry.value = this.#parseValue(value, filename); - return; - } - } - this.append(name, value); - } - *keys() { - for (const entry of this.#entries) { - yield entry.name; - } - } - *values() { - for (const entry of this.#entries) { - yield entry.value; - } - } - *entries() { - for (const entry of this.#entries) { - yield [entry.name, entry.value]; - } - } - *[Symbol.iterator]() { - for (const entry of this.#entries) { - yield [entry.name, entry.value]; - } - } - #parseValue(value, filename) { - if (value instanceof File) { - if (filename) { - const file = new File([], filename, { type: value.type, lastModified: value.lastModified }); - file[buffer] = value[buffer]; - return file; - } - return value; - } - if (value instanceof Blob) { - const file = new File([], "blob", { type: value.type }); - file[buffer] = value[buffer]; - return file; - } - return String(value); - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchBodyUtility.js -import { Buffer as Buffer4 } from "buffer"; -import Stream from "stream"; -class FetchBodyUtility { - static getBodyStream(body) { - if (body === null || body === undefined) { - return { stream: null, buffer: null, contentType: null, contentLength: null }; - } else if (body instanceof URLSearchParams2) { - const buffer2 = Buffer4.from(body.toString()); - return { - buffer: buffer2, - stream: this.getReadableStream(buffer2), - contentType: "application/x-www-form-urlencoded;charset=UTF-8", - contentLength: buffer2.length - }; - } else if (body instanceof Blob) { - const buffer2 = body[buffer]; - return { - buffer: buffer2, - stream: this.getReadableStream(buffer2), - contentType: body.type, - contentLength: body.size - }; - } else if (Buffer4.isBuffer(body)) { - return { - buffer: body, - stream: this.getReadableStream(body), - contentType: null, - contentLength: body.length - }; - } else if (body instanceof ArrayBuffer) { - const buffer2 = Buffer4.from(body); - return { - buffer: buffer2, - stream: this.getReadableStream(buffer2), - contentType: null, - contentLength: body.byteLength - }; - } else if (ArrayBuffer.isView(body)) { - const buffer2 = Buffer4.from(body.buffer, body.byteOffset, body.byteLength); - return { - buffer: buffer2, - stream: this.getReadableStream(buffer2), - contentType: null, - contentLength: body.byteLength - }; - } else if (body instanceof ReadableStream3) { - return { - buffer: null, - stream: new ReadableStreamWrapper(() => body), - contentType: null, - contentLength: null - }; - } else if (body instanceof FormData) { - return MultipartFormDataParser.formDataToStream(body); - } - const buffer2 = Buffer4.from(String(body)); - return { - buffer: buffer2, - stream: this.getReadableStream(buffer2), - contentType: "text/plain;charset=UTF-8", - contentLength: buffer2.length - }; - } - static cloneBodyStream(window, requestOrResponse) { - if (requestOrResponse.bodyUsed) { - throw new window.DOMException(`Failed to clone body stream of request: Request body is already used.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (requestOrResponse.body === null || requestOrResponse.body === undefined) { - return null; - } - if (requestOrResponse[buffer]) { - return this.getReadableStream(requestOrResponse[buffer]).readableStream; - } - if (requestOrResponse.body[nodeStream]) { - const stream1 = new Stream.PassThrough; - const stream2 = new Stream.PassThrough; - requestOrResponse.body[nodeStream].pipe(stream1); - requestOrResponse.body[nodeStream].pipe(stream2); - requestOrResponse[body] = new ReadableStreamWrapper(() => this.nodeToWebStream(stream1)); - return this.nodeToWebStream(stream2); - } - const [stream1, stream2] = requestOrResponse.body.tee(); - requestOrResponse[body] = new ReadableStreamWrapper(() => stream1); - return stream2; - } - static async consumeBodyStream(window, requestOrResponse) { - const body = requestOrResponse.body; - if (body === null || !(body instanceof ReadableStream3)) { - return Buffer4.alloc(0); - } - if (requestOrResponse[error]) { - throw requestOrResponse[error]; - } - const reader = body.getReader(); - const chunks = []; - let bytes = 0; - try { - let readResult = await reader.read(); - while (!readResult.done) { - if (requestOrResponse[error]) { - throw requestOrResponse[error]; - } - if (requestOrResponse[aborted]) { - throw new window.DOMException("Failed to read response body: The stream was aborted.", DOMExceptionNameEnum_default.abortError); - } - const chunk = readResult.value; - bytes += chunk.length; - chunks.push(chunk); - readResult = await reader.read(); - } - } catch (error) { - if (error instanceof DOMException) { - throw error; - } - throw new window.DOMException(`Failed to read response body. Error: ${error.message}.`, DOMExceptionNameEnum_default.encodingError); - } - try { - if (typeof chunks[0] === "string") { - return Buffer4.from(chunks.join("")); - } - return Buffer4.concat(chunks, bytes); - } catch (error) { - throw new window.DOMException(`Could not create Buffer from response body. Error: ${error.message}.`, DOMExceptionNameEnum_default.invalidStateError); - } - } - static nodeToWebStream(nodeStream2) { - const readableStream = new ReadableStream3({ - start(controller) { - nodeStream2.on("data", (chunk) => { - controller.enqueue(chunk); - }); - nodeStream2.on("end", () => { - controller.close(); - }); - nodeStream2.on("error", (err) => { - controller.error(err); - }); - } - }); - readableStream[nodeStream] = nodeStream2; - return readableStream; - } - static getReadableStream(value) { - return new ReadableStreamWrapper(() => new ReadableStream3({ - start(controller) { - controller.enqueue(value); - controller.close(); - } - })); - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchRequestValidationUtility.js -var VALID_REFERRER_POLICIES = [ - "", - "no-referrer", - "no-referrer-when-downgrade", - "same-origin", - "origin", - "strict-origin", - "origin-when-cross-origin", - "strict-origin-when-cross-origin", - "unsafe-url" -]; -var VALID_REDIRECTS = ["error", "manual", "follow"]; -var SUPPORTED_SCHEMAS = ["data:", "http:", "https:"]; -var FORBIDDEN_REQUEST_METHODS = ["TRACE", "TRACK", "CONNECT"]; -var REQUEST_METHOD_REGEXP = /^[A-Z]+$/; - -class FetchRequestValidationUtility { - static validateMethod(request) { - if (!request.method || FORBIDDEN_REQUEST_METHODS.includes(request.method)) { - throw new DOMException(`'${request.method || ""}' is not a valid HTTP method.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (!REQUEST_METHOD_REGEXP.test(request.method)) { - throw new DOMException(`'${request.method}' HTTP method is unsupported.`, DOMExceptionNameEnum_default.invalidStateError); - } - } - static validateBody(request) { - if (request.body && (request.method === "GET" || request.method === "HEAD")) { - throw new DOMException(`Request with GET/HEAD method cannot have body.`, DOMExceptionNameEnum_default.invalidStateError); - } - } - static validateURL(url) { - if (url.username !== "" || url.password !== "") { - throw new DOMException(`${url} is an url with embedded credentials.`, DOMExceptionNameEnum_default.notSupportedError); - } - } - static validateReferrerPolicy(referrerPolicy) { - if (!VALID_REFERRER_POLICIES.includes(referrerPolicy)) { - throw new DOMException(`Invalid referrer policy "${referrerPolicy}".`, DOMExceptionNameEnum_default.syntaxError); - } - } - static validateRedirect(redirect) { - if (!VALID_REDIRECTS.includes(redirect)) { - throw new DOMException(`Invalid redirect "${redirect}".`, DOMExceptionNameEnum_default.syntaxError); - } - } - static validateSchema(request) { - if (!SUPPORTED_SCHEMAS.includes(request[url].protocol)) { - throw new DOMException(`Failed to fetch from "${request.url}": URL scheme "${request[url].protocol.replace(/:$/, "")}" is not supported.`, DOMExceptionNameEnum_default.notSupportedError); - } - } -} - -// node_modules/happy-dom/lib/cookie/urilities/CookieStringUtility.js -class CookieStringUtility { - static stringToCookie(originURL, cookieString) { - const parts = cookieString.split(";"); - const part = parts.shift(); - if (!part) { - return null; - } - const index = part.indexOf("="); - const key = index !== -1 ? part.slice(0, index).trim() : part.trim(); - const value = index !== -1 ? part.slice(index + 1).trim() : null; - const cookie = Object.assign({}, DefaultCookie_default, { - key, - value, - originURL - }); - if (!cookie.key) { - return null; - } - for (const part of parts) { - const index = part.indexOf("="); - const key = index !== -1 ? part.slice(0, index).trim().toLowerCase() : part.trim().toLowerCase(); - const value = index !== -1 ? part.slice(index + 1).trim() : ""; - switch (key) { - case "expires": - cookie.expires = new Date(value); - break; - case "max-age": - cookie.expires = new Date(parseInt(value, 10) * 1000 + Date.now()); - break; - case "domain": - cookie.domain = value; - break; - case "path": - cookie.path = value[0] === "/" ? value : `/${value}`; - break; - case "httponly": - cookie.httpOnly = true; - break; - case "secure": - cookie.secure = true; - break; - case "samesite": - switch (value.toLowerCase()) { - case "strict": - cookie.sameSite = CookieSameSiteEnum_default.strict; - break; - case "lax": - cookie.sameSite = CookieSameSiteEnum_default.lax; - break; - case "none": - cookie.sameSite = CookieSameSiteEnum_default.none; - } - break; - } - } - const lowerKey = cookie.key.toLowerCase(); - if (lowerKey.startsWith("__secure-") && !cookie.secure) { - return null; - } - if (lowerKey.startsWith("__host-") && (!cookie.secure || cookie.path !== "/" || cookie.domain)) { - return null; - } - return cookie; - } - static cookiesToString(cookies) { - const cookieString = []; - for (const cookie of cookies) { - if (cookie.value !== null) { - cookieString.push(`${cookie.key}=${cookie.value}`); - } else { - cookieString.push(cookie.key); - } - } - return cookieString.join("; "); - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchRequestHeaderUtility.js -import { URL as URL4 } from "url"; -var FORBIDDEN_HEADER_NAMES = [ - "accept-charset", - "accept-encoding", - "access-control-request-headers", - "access-control-request-method", - "connection", - "content-length", - "content-transfer-encoding", - "cookie", - "cookie2", - "date", - "dnt", - "expect", - "host", - "keep-alive", - "origin", - "referer", - "te", - "trailer", - "transfer-encoding", - "upgrade", - "via" -]; - -class FetchRequestHeaderUtility { - static removeForbiddenHeaders(headers) { - for (const key of Object.keys(headers[entries])) { - if (FORBIDDEN_HEADER_NAMES.includes(key) || key.startsWith("proxy-") || key.startsWith("sec-")) { - delete headers[entries][key]; - } - } - } - static isHeaderForbidden(name) { - return FORBIDDEN_HEADER_NAMES.includes(name.toLowerCase()); - } - static getRequestHeaders(options) { - const headers = new options.window.Headers(options.baseHeaders); - options.request.headers.forEach((value, key) => { - headers.set(key, value); - }); - const originURL = new URL4(options.window.location.href); - const isCORS = FetchCORSUtility.isCORS(originURL, options.request[url]); - headers.set("Accept-Encoding", "gzip, deflate, br"); - headers.set("Connection", "close"); - if (!headers.has("User-Agent")) { - headers.set("User-Agent", options.window.navigator.userAgent); - } - if (options.request[referrer] instanceof URL4) { - headers.set("Referer", options.request[referrer].href); - } - if (options.request.credentials === "include" || options.request.credentials === "same-origin" && !isCORS) { - const cookies = options.browserFrame.page.context.cookieContainer.getCookies(options.request[url], false); - if (cookies.length > 0) { - headers.set("Cookie", CookieStringUtility.cookiesToString(cookies)); - } - } else { - headers.delete("Cookie"); - headers.delete("Cookie2"); - } - if (!headers.has("Accept")) { - headers.set("Accept", "*/*"); - } - if (!headers.has("Content-Length") && options.request[contentLength] !== null) { - headers.set("Content-Length", String(options.request[contentLength])); - } - if (!headers.has("Content-Type") && options.request[contentType]) { - headers.set("Content-Type", options.request[contentType]); - } - if (isCORS) { - headers.set("Origin", originURL.origin); - } - const httpRequestHeaders = {}; - for (const header of Object.values(headers[entries])) { - httpRequestHeaders[header.name] = header.value.join(", "); - } - return httpRequestHeaders; - } -} - -// node_modules/happy-dom/lib/fetch/Request.js -class Request { - [method]; - [body]; - [mode] = "cors"; - [headers]; - [redirect]; - [referrerPolicy]; - [signal]; - [bodyUsed] = false; - [credentials]; - [aborted] = false; - [error] = null; - [contentLength] = null; - [contentType] = null; - [referrer] = "client"; - [url]; - [bodyBuffer]; - constructor(input, init) { - const window2 = this[window]; - if (!window2) { - throw new TypeError(`Failed to construct 'Request': 'Request' was constructed outside a Window context.`); - } - if (typeof input !== `string` && !input) { - throw new window2.TypeError(`Failed to construct 'Request': 1 argument required, only 0 present.`); - } - this[method] = (init?.method || input.method || "GET").toUpperCase(); - if (init?.mode) { - switch (init.mode) { - case "navigate": - case "websocket": - throw new window2.DOMException(`Failed to construct 'Request': Cannot construct a Request with a RequestInit whose mode member is set as '${init.mode}'.`, DOMExceptionNameEnum_default.securityError); - case "same-origin": - case "no-cors": - case "cors": - this[mode] = init.mode; - break; - default: - throw new window2.DOMException(`Failed to construct 'Request': The provided value '${init.mode}' is not a valid enum value of type RequestMode.`, DOMExceptionNameEnum_default.syntaxError); - } - } else if (input instanceof Request) { - this[mode] = input.mode; - } - const { stream, buffer, contentType: contentType2, contentLength: contentLength2 } = FetchBodyUtility.getBodyStream(input instanceof Request && (input[bodyBuffer] || input.body) ? input[bodyBuffer] || FetchBodyUtility.cloneBodyStream(window2, input) : init?.body ?? null); - this[bodyBuffer] = buffer; - this[body] = stream; - this[credentials] = init?.credentials || input.credentials || "same-origin"; - this[headers] = new this[window].Headers(init?.headers || input.headers || {}); - FetchRequestHeaderUtility.removeForbiddenHeaders(this.headers); - if (contentLength2) { - this[contentLength] = contentLength2; - } else if (!this.body && (this.method === "POST" || this.method === "PUT")) { - this[contentLength] = 0; - } - if (contentType2) { - if (!this.headers.has("Content-Type")) { - this.headers.set("Content-Type", contentType2); - } - this[contentType] = contentType2; - } else if (input instanceof Request && input[contentType]) { - this[contentType] = input[contentType]; - } - this[redirect] = init?.redirect || input.redirect || "follow"; - this[referrerPolicy] = (init?.referrerPolicy || input.referrerPolicy || "").toLowerCase(); - this[signal] = init?.signal || input.signal || new window2.AbortSignal; - this[referrer] = FetchRequestReferrerUtility.getInitialReferrer(window2, init?.referrer !== null && init?.referrer !== undefined ? init?.referrer : input.referrer); - if (input instanceof URL5) { - this[url] = input; - } else { - try { - if (input instanceof Request && input.url) { - this[url] = new URL5(input.url, window2.location.href); - } else { - this[url] = new URL5(input, window2.location.href); - } - } catch (error2) { - throw new window2.DOMException(`Failed to construct 'Request': Invalid URL "${input}" on document location '${window2.location}'.${window2.location.origin === "null" ? " Relative URLs are not permitted on current document location." : ""}`, DOMExceptionNameEnum_default.notSupportedError); - } - } - FetchRequestValidationUtility.validateMethod(this); - FetchRequestValidationUtility.validateBody(this); - FetchRequestValidationUtility.validateURL(this[url]); - FetchRequestValidationUtility.validateReferrerPolicy(this.referrerPolicy); - FetchRequestValidationUtility.validateRedirect(this.redirect); - } - get method() { - return this[method]; - } - get body() { - return this[body]?.readableStream || null; - } - get mode() { - return this[mode]; - } - get headers() { - return this[headers]; - } - get redirect() { - return this[redirect]; - } - get referrerPolicy() { - return this[referrerPolicy]; - } - get signal() { - return this[signal]; - } - get bodyUsed() { - return this[bodyUsed]; - } - get credentials() { - return this[credentials]; - } - get referrer() { - if (!this[referrer] || this[referrer] === "no-referrer") { - return ""; - } - if (this[referrer] === "client") { - return "about:client"; - } - return this[referrer].toString(); - } - get url() { - return this[url].href; - } - get [Symbol.toStringTag]() { - return "Request"; - } - async arrayBuffer() { - const window2 = this[window]; - if (this[bodyUsed]) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const asyncTaskManager = new WindowBrowserContext(window2).getAsyncTaskManager(); - this[bodyUsed] = true; - const taskID = asyncTaskManager.startTask(() => { - this[aborted] = true; - this.signal[abort](); - }); - let buffer; - try { - buffer = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager.endTask(taskID); - throw error2; - } - asyncTaskManager.endTask(taskID); - return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength); - } - async blob() { - const type = this.headers.get("Content-Type") || ""; - const buffer = await this.arrayBuffer(); - return new Blob([buffer], { type }); - } - async buffer() { - const window2 = this[window]; - if (this[bodyUsed]) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const asyncTaskManager = new WindowBrowserContext(window2).getAsyncTaskManager(); - this[bodyUsed] = true; - const taskID = asyncTaskManager.startTask(() => { - this[aborted] = true; - this.signal[abort](); - }); - let buffer; - try { - buffer = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager.endTask(taskID); - throw error2; - } - asyncTaskManager.endTask(taskID); - return buffer; - } - async text() { - const window2 = this[window]; - if (this[bodyUsed]) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const asyncTaskManager = new WindowBrowserContext(window2).getAsyncTaskManager(); - this[bodyUsed] = true; - const taskID = asyncTaskManager.startTask(() => { - this[aborted] = true; - this.signal[abort](); - }); - let buffer; - try { - buffer = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager.endTask(taskID); - throw error2; - } - asyncTaskManager.endTask(taskID); - return new TextDecoder().decode(buffer); - } - async json() { - const text = await this.text(); - return JSON.parse(text); - } - async formData() { - const window2 = this[window]; - const asyncTaskManager = new WindowBrowserContext(window2).getAsyncTaskManager(); - const contentType2 = this.headers.get("Content-Type") ?? this[contentType]; - if (this.body && contentType2 && /multipart/i.test(contentType2)) { - if (this[bodyUsed]) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - this[bodyUsed] = true; - const taskID = asyncTaskManager.startTask(() => { - this[aborted] = true; - this.signal[abort](); - }); - let formData; - try { - const result = await MultipartFormDataParser.streamToFormData(window2, this, contentType2); - formData = result.formData; - } catch (error2) { - asyncTaskManager.endTask(taskID); - throw error2; - } - asyncTaskManager.endTask(taskID); - return formData; - } - if (contentType2?.startsWith("application/x-www-form-urlencoded")) { - const parameters = new URLSearchParams(await this.text()); - const formData = new window2.FormData; - for (const [key, value] of parameters) { - formData.append(key, value); - } - return formData; - } - throw new window2.DOMException(`Failed to construct FormData object: The "content-type" header is neither "application/x-www-form-urlencoded" nor "multipart/form-data".`, DOMExceptionNameEnum_default.invalidStateError); - } - clone() { - return new this[window].Request(this); - } -} - -// node_modules/happy-dom/lib/fetch/Response.js -import { URLSearchParams as URLSearchParams3 } from "url"; -import { Buffer as Buffer5 } from "buffer"; -var REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308]; - -class Response { - bodyUsed = false; - redirected = false; - type = "basic"; - url = ""; - status; - statusText; - ok; - headers; - [cachedResponse] = null; - [buffer] = null; - [virtualServerFile] = null; - [aborted] = false; - [error] = null; - [body] = null; - constructor(body2, init) { - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - this.status = init?.status !== undefined ? init.status : 200; - this.statusText = init?.statusText || ""; - this.ok = this.status >= 200 && this.status < 300; - this.headers = new this[window].Headers(init?.headers); - this.headers.delete("Set-Cookie"); - this.headers.delete("Set-Cookie2"); - if (body2) { - const { stream, buffer: buffer2, contentType } = FetchBodyUtility.getBodyStream(body2); - this[body] = stream; - if (buffer2) { - this[buffer] = buffer2; - } - if (contentType && !this.headers.has("Content-Type")) { - this.headers.set("Content-Type", contentType); - } - } - } - get [Symbol.toStringTag]() { - return "Response"; - } - get body() { - return this[body]?.readableStream || null; - } - async arrayBuffer() { - const window2 = this[window]; - if (this.bodyUsed) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return new ArrayBuffer(0); - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - this.bodyUsed = true; - let buffer2 = this[buffer]; - if (!buffer2) { - const taskID = asyncTaskManager2.startTask(() => { - this[aborted] = true; - }); - try { - buffer2 = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager2.endTask(taskID); - throw error2; - } - asyncTaskManager2.endTask(taskID); - } - this.#storeBodyInCache(buffer2); - return buffer2.buffer.slice(buffer2.byteOffset, buffer2.byteOffset + buffer2.byteLength); - } - async blob() { - const type = this.headers.get("Content-Type") || ""; - const buffer2 = await this.arrayBuffer(); - return new Blob([buffer2], { type }); - } - async buffer() { - const window2 = this[window]; - if (this.bodyUsed) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return Buffer5.alloc(0); - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - this.bodyUsed = true; - let buffer2 = this[buffer]; - if (!buffer2) { - const taskID = asyncTaskManager2.startTask(() => { - this[aborted] = true; - }); - try { - buffer2 = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager2.endTask(taskID); - throw error2; - } - asyncTaskManager2.endTask(taskID); - } - this.#storeBodyInCache(buffer2); - return buffer2; - } - async text() { - const window2 = this[window]; - if (this.bodyUsed) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return ""; - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - this.bodyUsed = true; - let buffer2 = this[buffer]; - if (!buffer2) { - const taskID = asyncTaskManager2.startTask(() => { - this[aborted] = true; - }); - try { - buffer2 = await FetchBodyUtility.consumeBodyStream(window2, this); - } catch (error2) { - asyncTaskManager2.endTask(taskID); - throw error2; - } - asyncTaskManager2.endTask(taskID); - } - this.#storeBodyInCache(buffer2); - return new TextDecoder().decode(buffer2); - } - async json() { - const text = await this.text(); - return JSON.parse(text); - } - async formData() { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return new window2.FormData; - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - const contentType = this.headers.get("Content-Type"); - if (contentType && this.body && /multipart/i.test(contentType)) { - if (this.bodyUsed) { - throw new window2.DOMException(`Body has already been used for "${this.url}".`, DOMExceptionNameEnum_default.invalidStateError); - } - this.bodyUsed = true; - const taskID = browserFrame[asyncTaskManager].startTask(() => { - this[aborted] = true; - }); - let formData; - let buffer2; - try { - const result = await MultipartFormDataParser.streamToFormData(window2, this, contentType); - formData = result.formData; - buffer2 = result.buffer; - } catch (error2) { - asyncTaskManager2.endTask(taskID); - throw error2; - } - this.#storeBodyInCache(buffer2); - asyncTaskManager2.endTask(taskID); - return formData; - } - if (contentType?.startsWith("application/x-www-form-urlencoded")) { - const parameters = new URLSearchParams3(await this.text()); - const formData = new window2.FormData; - for (const [key, value] of parameters) { - formData.append(key, value); - } - return formData; - } - throw new window2.DOMException(`Failed to build FormData object: The "content-type" header is neither "application/x-www-form-urlencoded" nor "multipart/form-data".`, DOMExceptionNameEnum_default.invalidStateError); - } - clone() { - const window2 = this[window]; - const body2 = FetchBodyUtility.cloneBodyStream(window2, this); - const response = new window2.Response(body2, { - status: this.status, - statusText: this.statusText, - headers: this.headers - }); - response[cachedResponse] = this[cachedResponse]; - response[buffer] = this[buffer]; - response.ok = this.ok; - response.redirected = this.redirected; - response.type = this.type; - response.url = this.url; - return response; - } - #storeBodyInCache(buffer2) { - this[buffer] = buffer2; - if (this[cachedResponse]?.response?.waitingForBody) { - this[cachedResponse].response.body = buffer2; - this[cachedResponse].response.waitingForBody = false; - } - } - static redirect(url, status = 302) { - const window2 = this[window]; - if (!REDIRECT_STATUS_CODES.includes(status)) { - throw new window2.DOMException("Failed to create redirect response: Invalid redirect status code.", DOMExceptionNameEnum_default.invalidStateError); - } - return new window2.Response(null, { - headers: { - location: new URL2(url).toString() - }, - status - }); - } - static error() { - const response = new this[window].Response(null, { status: 0, statusText: "" }); - response.type = "error"; - return response; - } - static json(data, init) { - const window2 = this[window]; - const body2 = JSON.stringify(data); - if (body2 === undefined) { - throw new window2.TypeError("data is not JSON serializable"); - } - const headers = new window2.Headers(init && init.headers); - if (!headers.has("Content-Type")) { - headers.set("Content-Type", "application/json"); - } - return new window2.Response(body2, { - status: 200, - ...init, - headers - }); - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchResponseRedirectUtility.js -var REDIRECT_STATUS_CODES2 = [301, 302, 303, 307, 308]; -var MAX_REDIRECT_COUNT = 20; - -class FetchResponseRedirectUtility { - static isRedirect(statusCode) { - return REDIRECT_STATUS_CODES2.includes(statusCode); - } - static isMaxRedirectsReached(redirectCount) { - return redirectCount >= MAX_REDIRECT_COUNT; - } -} - -// node_modules/happy-dom/lib/fetch/utilities/FetchResponseHeaderUtility.js -class FetchResponseHeaderUtility { - static parseResponseHeaders(options) { - const headers = new options.browserFrame.window.Headers; - let key = null; - for (const header of options.rawHeaders) { - if (!key) { - key = header; - } else { - const lowerName = key.toLowerCase(); - if (lowerName === "set-cookie" || lowerName === "set-cookie2") { - const cookie = CookieStringUtility.stringToCookie(options.requestURL, header); - if (cookie) { - options.browserFrame.page.context.cookieContainer.addCookies([cookie]); - } - } else { - headers.append(key, header); - } - key = null; - } - } - return headers; - } -} - -// node_modules/happy-dom/lib/fetch/certificate/FetchHTTPSCertificate.js -var FetchHTTPSCertificate_default = { - cert: `-----BEGIN CERTIFICATE----- -MIIDYzCCAkugAwIBAgIUJRKB/H66hpet1VfUlm0CiXqePA4wDQYJKoZIhvcNAQEL -BQAwQTELMAkGA1UEBhMCU0UxDjAMBgNVBAgMBVNrYW5lMQ4wDAYDVQQHDAVNYWxt -bzESMBAGA1UECgwJSGFwcHkgRE9NMB4XDTIyMTAxMTIyMDM0OVoXDTMyMTAwODIy -MDM0OVowQTELMAkGA1UEBhMCU0UxDjAMBgNVBAgMBVNrYW5lMQ4wDAYDVQQHDAVN -YWxtbzESMBAGA1UECgwJSGFwcHkgRE9NMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEAqerQSQEg/SxVxRiwlItithr5e5EMZo1nsqt/xOxagbmpW3IEmt0j -bpbH7iEF4DDEo7KAOwUCOwVWeFxRoag8lG2ax48wrgjlCna45XDn0Xeg1ARajL04 -gs46HZ0VrzIloVGfln0zgt/Vum5BNqs9Oc5fQoBmoP3cAn3dn4ZVcP0AKthtcyPl -q2DuNRN0PV0D2RtMSiAy9l1Ko6N5x+sAeClDyOL+sTDLngZBVeZyOKt9Id15S8Zt -XtA6VMgHnnF3jChn7pag77rsd/y5iANAVNZYqRl+Eg7xaDcsvbgH46UBOrBcB39Q -tTh5Mtjoxep5e3ZDFG+kQ1HUE+iz5O5n0wIDAQABo1MwUTAdBgNVHQ4EFgQU69s9 -YSobG/m2SN4L/7zTaF7iDbwwHwYDVR0jBBgwFoAU69s9YSobG/m2SN4L/7zTaF7i -DbwwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAi/WUXx2oal8L -YnPlIuKfh49n/K18wXSYG//oFYwxfVxqpYH8hUiXVm/GUcXCxS++hUkaKLqXmH9q -MKJiCrZr3vS+2nsBKopkICu/TLdROl0sAI9lByfnEbfSAzjxe1IWJdK8NdY0y5m5 -9pEr/URVIAp/CxrneyASb4q0Jg5To3FR7vYc+2X6wZn0MundKMg6Dp9/A37jiF3l -Tt/EJp299YZcsUzh+LnRuggRjnoOVu1aLcLFlaUiwZfy9m8mLG6B/mdW/qNzNMh9 -Oqvg1zfGdpz/4D/2UUUBn6pq1vbsoAaF3OesoA3mfDcegDf/H9woJlpT0Wql+e68 -Y3FblSokcA== ------END CERTIFICATE-----`, - key: `-----BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCp6tBJASD9LFXF -GLCUi2K2Gvl7kQxmjWeyq3/E7FqBualbcgSa3SNulsfuIQXgMMSjsoA7BQI7BVZ4 -XFGhqDyUbZrHjzCuCOUKdrjlcOfRd6DUBFqMvTiCzjodnRWvMiWhUZ+WfTOC39W6 -bkE2qz05zl9CgGag/dwCfd2fhlVw/QAq2G1zI+WrYO41E3Q9XQPZG0xKIDL2XUqj -o3nH6wB4KUPI4v6xMMueBkFV5nI4q30h3XlLxm1e0DpUyAeecXeMKGfulqDvuux3 -/LmIA0BU1lipGX4SDvFoNyy9uAfjpQE6sFwHf1C1OHky2OjF6nl7dkMUb6RDUdQT -6LPk7mfTAgMBAAECggEAKkwTkTjAt4UjzK56tl+EMQTB+ep/hb/JgoaChci4Nva6 -m9LkJpDJ0yuhlTuPNOGu8XjrxsVWas7HWarRf0Zb3i7yip6wZYI9Ub+AA015x4DZ -/i0fRU2NFbK0cM67qSL4jxG8gj+kZP3HPGNZxHwX/53JxMolwgmvjMc8NgvAlSFd -NnV9h4xtbhUh1NGS5zmP3iU2rwnE8JrIEzwy6axLom7nekAgkdcbAr0UoBs8gcgH -aYNhU4Gz3tGcZZ0IXAfT/bJIH1Ko8AGv4pssWc3BXcmmNdm/+kzvHIxEIV7Qegmo -XG1ZyZCyD/0b4/3e8ySDBEDqwR+HeyTW2isWG2agAQKBgQDp44aTwr3dkIXY30xv -FPfUOipg/B49dWnffYJ9MWc1FT9ijNPAngWSk0EIiEQIazICcUBI4Yji6/KeyqLJ -GdLpDi1CkKqtyh73mjELinYp3EUQgEa77aQogGa2+nMOVfu+O5CtloUrv/A18jX3 -+VEyaEASK0fWmnSI0OdlxQHIAQKBgQC5+xOls2F3MlKASvWRLlnW1wHqlDTtVoYg -5Nh8syZH4Ci2UH8tON3A5/7SWNM0t1cgV6Cw4zW8Z2spgIT/W0iYYrQ4hHL1xdCu -+CxL1km4Gy8Uwpsd+KdFahFqF/XTmLzW0HXLxWSK0fTwmdV0SFrKF3MXfTCU2AeZ -jJoMFb6P0wKBgQC3Odw6s0vkYAzLGhuZxfZkVvDOK5RRF0NKpttr0iEFL9EJFkPo -2KKK8jr3QTDy229BBJGUxsJi6u6VwS8HlehpVQbV59kd7oKV/EBBx0XMg1fDlopT -PNbmN7i/zbIG4AsoOyebJZjL7kBzMn1e9vzKHWtcEHXlw/hZGja8vjooAQKBgAeg -xK2HLfg1mCyq5meN/yFQsENu0LzrT5UJzddPgcJw7zqLEqxIKNBAs7Ls8by3yFsL -PQwERa/0jfCl1M6kb9XQNpQa2pw6ANUsWKTDpUJn2wZ+9N3F1RaDwzMWyH5lRVmK -M0qoTfdjpSg5Jwgd75taWt4bxGJWeflSSv8z5R0BAoGAWL8c527AbeBvx2tOYKkD -2TFranvANNcoMrbeviZSkkGvMNDP3p8b6juJwXOIeWNr8q4vFgCzLmq6d1/9gYm2 -3XJwwyD0LKlqzkBrrKU47qrnmMosUrIRlrAzd3HbShOptxc6Iz2apSaUDKGKXkaw -gl5OpEjeliU7Mus0BVS858g= ------END PRIVATE KEY-----` -}; - -// node_modules/happy-dom/lib/fetch/Fetch.js -import { Buffer as Buffer6 } from "buffer"; - -// node_modules/happy-dom/lib/fetch/utilities/VirtualServerUtility.js -import Path2 from "path"; -var NOT_FOUND_HTML = "Happy DOM Virtual Server - 404 Not Found

Happy DOM Virtual Server - 404 Not Found

"; - -class VirtualServerUtility { - static getFilepath(window, requestURL) { - const browserSettings = new WindowBrowserContext(window).getSettings(); - if (!browserSettings || !browserSettings.fetch.virtualServers && !browserSettings.module.resolveNodeModules) { - return null; - } - if (browserSettings.fetch.virtualServers) { - for (const virtualServer of browserSettings.fetch.virtualServers) { - let baseURL = null; - if (typeof virtualServer.url === "string") { - const url = new URL(virtualServer.url[virtualServer.url.length - 1] === "/" ? virtualServer.url.slice(0, -1) : virtualServer.url, window.location.origin !== "null" ? window.location.origin : undefined); - if (requestURL.startsWith(url.href)) { - baseURL = url; - } - } else if (virtualServer.url instanceof RegExp) { - const match = requestURL.match(virtualServer.url); - if (match) { - baseURL = new URL(match[0][match[0].length - 1] === "/" ? match[0].slice(0, -1) : match[0], window.location.origin); - } - } - if (baseURL) { - const path = requestURL.slice(baseURL.href.length).split("?")[0].split("#")[0]; - return Path2.join(Path2.resolve(virtualServer.directory), path.replaceAll("/", Path2.sep)); - } - } - } - if (browserSettings.module.resolveNodeModules) { - const moduleUrl = browserSettings.module.resolveNodeModules.url; - const url = new URL(moduleUrl[moduleUrl.length - 1] === "/" ? moduleUrl.slice(0, -1) : moduleUrl, window.location.origin); - if (requestURL.startsWith(url.href)) { - const path = requestURL.slice(url.href.length).split("?")[0].split("#")[0]; - return Path2.join(Path2.resolve(browserSettings.module.resolveNodeModules.directory), path.replaceAll("/", Path2.sep)); - } - } - return null; - } - static getNotFoundResponse(window) { - return new window.Response(NOT_FOUND_HTML, { - status: 404, - statusText: "Not Found", - headers: { - "Content-Type": "text/html" - } - }); - } - static getNotFoundSyncResponse(window, requestURL) { - return { - status: 404, - statusText: "Not Found", - ok: false, - url: requestURL, - redirected: false, - headers: new window.Headers({ - "Content-Type": "text/html" - }), - body: Buffer.from(NOT_FOUND_HTML), - [virtualServerFile]: null - }; - } -} - -// node_modules/happy-dom/lib/fetch/preload/PreloadUtility.js -class PreloadUtility { - static getKey(options) { - return JSON.stringify({ - url: options.url, - destination: options.destination, - mode: options.mode, - credentialsMode: options.credentialsMode - }); - } -} - -// node_modules/happy-dom/lib/fetch/Fetch.js -var LAST_CHUNK = Buffer6.from(`0\r -\r -`); - -class Fetch { - reject = null; - resolve = null; - listeners = { - onSignalAbort: this.onSignalAbort.bind(this) - }; - isChunkedTransfer = false; - isProperLastChunkReceived = false; - previousChunk = null; - nodeRequest = null; - nodeResponse = null; - response = null; - responseHeaders = null; - interceptor; - requestHeaders; - request; - redirectCount = 0; - disableCache; - disableSameOriginPolicy; - disablePreload; - #browserFrame; - #window; - #unfilteredHeaders = null; - constructor(options) { - this.#browserFrame = options.browserFrame; - this.#window = options.window; - this.#unfilteredHeaders = options.unfilteredHeaders ?? null; - this.request = typeof options.url === "string" || options.url instanceof URL6 ? new options.window.Request(options.url, options.init) : options.url; - if (options.contentType) { - this.request[contentType] = options.contentType; - } - this.redirectCount = options.redirectCount ?? 0; - this.disableCache = options.disableCache ?? false; - this.disableSameOriginPolicy = options.disableSameOriginPolicy ?? this.#browserFrame.page.context.browser.settings.fetch.disableSameOriginPolicy ?? false; - this.interceptor = this.#browserFrame.page.context.browser.settings.fetch.interceptor; - this.requestHeaders = this.#browserFrame.page.context.browser.settings.fetch.requestHeaders; - this.disablePreload = options.disablePreload ?? false; - } - async send() { - if (!(this.request instanceof Request) || !(this.request[url] instanceof URL6)) { - throw new this.#window.DOMException("Unknown request object. Request object must be an instance of Request.", DOMExceptionNameEnum_default.invalidStateError); - } - FetchRequestReferrerUtility.prepareRequest(new URL6(this.#window.location.href), this.request); - if (this.requestHeaders) { - for (const header of this.requestHeaders) { - if (!header.url || (typeof header.url === "string" ? header.url.startsWith(this.request.url) : this.request.url.match(header.url))) { - for (const [key, value] of Object.entries(header.headers)) { - this.request.headers.set(key, value); - } - } - } - } - if (this.interceptor?.beforeAsyncRequest) { - const taskID = this.#browserFrame[asyncTaskManager].startTask(); - const response = await this.interceptor.beforeAsyncRequest({ - request: this.request, - window: this.#window - }); - this.#browserFrame[asyncTaskManager].endTask(taskID); - if (response instanceof Response) { - return response; - } - } - FetchRequestValidationUtility.validateSchema(this.request); - if (this.request.signal[aborted]) { - if (this.request.signal[reason] !== undefined) { - throw this.request.signal[reason]; - } - throw new this.#window.DOMException("signal is aborted without reason", DOMExceptionNameEnum_default.abortError); - } - if (this.request[url].protocol === "data:") { - const result = DataURIParser.parse(this.request.url); - this.response = new this.#window.Response(result.buffer, { - headers: { "Content-Type": result.type } - }); - const interceptedResponse = this.interceptor?.afterAsyncResponse ? await this.interceptor.afterAsyncResponse({ - window: this.#window, - response: this.response, - request: this.request - }) : undefined; - return interceptedResponse instanceof Response ? interceptedResponse : this.response; - } - if (this.request[url].protocol === "http:" && this.#window.location.protocol === "https:") { - throw new this.#window.DOMException(`Mixed Content: The page at '${this.#window.location.href}' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${this.request.url}'. This request has been blocked; the content must be served over HTTPS.`, DOMExceptionNameEnum_default.securityError); - } - if (!this.disableCache) { - const cachedResponse = await this.getCachedResponse(); - if (cachedResponse) { - return cachedResponse; - } - } - if (!this.disablePreload) { - const preloadKey = PreloadUtility.getKey({ - url: this.request.url, - destination: "fetch", - mode: this.request.mode, - credentialsMode: this.request.credentials - }); - const preloadEntry = this.#window.document[preloads].get(preloadKey); - if (preloadEntry) { - this.#window.document[preloads].delete(preloadKey); - if (preloadEntry.response) { - return preloadEntry.response; - } - const taskID = this.#browserFrame[asyncTaskManager].startTask(); - const response = await preloadEntry.onResponseAvailable(); - this.#browserFrame[asyncTaskManager].endTask(taskID); - return response; - } - } - const virtualServerResponse = await this.getVirtualServerResponse(); - if (virtualServerResponse) { - return virtualServerResponse; - } - if (!this.disableSameOriginPolicy) { - const compliesWithCrossOriginPolicy = await this.compliesWithCrossOriginPolicy(); - if (!compliesWithCrossOriginPolicy) { - this.#browserFrame.page.console.warn(`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "${this.request.url}".`); - throw new this.#window.DOMException(`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "${this.request.url}".`, DOMExceptionNameEnum_default.networkError); - } - } - return await this.sendRequest(); - } - async getCachedResponse() { - if (this.disableCache) { - return null; - } - let cachedResponse2 = this.#browserFrame.page.context.responseCache.get(this.request); - if (!cachedResponse2 || cachedResponse2.response.waitingForBody) { - return null; - } - if (cachedResponse2.state === CachedResponseStateEnum_default.stale) { - const headers = new this.#window.Headers(cachedResponse2.request.headers); - if (cachedResponse2.etag) { - headers.set("If-None-Match", cachedResponse2.etag); - } else { - if (!cachedResponse2.lastModified) { - return null; - } - headers.set("If-Modified-Since", new Date(cachedResponse2.lastModified).toUTCString()); - } - const fetch2 = new Fetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: this.request.url, - init: { headers, method: cachedResponse2.request.method }, - disableCache: true, - disableSameOriginPolicy: true - }); - if (cachedResponse2.etag || !cachedResponse2.staleWhileRevalidate) { - const validateResponse = await fetch2.send(); - const body = validateResponse.status !== 304 ? await validateResponse.buffer() : null; - cachedResponse2 = this.#browserFrame.page.context.responseCache.add(this.request, { - ...validateResponse, - body, - waitingForBody: false - }); - if (validateResponse.status !== 304) { - const response = new this.#window.Response(body, { - status: validateResponse.status, - statusText: validateResponse.statusText, - headers: validateResponse.headers - }); - response.url = validateResponse.url; - response[cachedResponse] = cachedResponse2; - return response; - } - } else { - fetch2.send().then((response) => { - response.buffer().then((body) => { - this.#browserFrame.page.context.responseCache.add(this.request, { - ...response, - body, - waitingForBody: false - }); - }); - }); - } - } - if (!cachedResponse2 || cachedResponse2.response.waitingForBody) { - return null; - } - const response = new this.#window.Response(cachedResponse2.response.body, { - status: cachedResponse2.response.status, - statusText: cachedResponse2.response.statusText, - headers: cachedResponse2.response.headers - }); - response.url = cachedResponse2.response.url; - response[cachedResponse] = cachedResponse2; - return response; - } - async getVirtualServerResponse() { - let filePath = VirtualServerUtility.getFilepath(this.#window, this.request.url); - if (!filePath) { - return null; - } - const taskID = this.#browserFrame[asyncTaskManager].startTask(); - if (this.request.method !== "GET") { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} 404 (Not Found)`); - const response = VirtualServerUtility.getNotFoundResponse(this.#window); - const interceptedResponse = this.interceptor?.afterAsyncResponse ? await this.interceptor.afterAsyncResponse({ - window: this.#window, - response: await response, - request: this.request - }) : undefined; - this.#browserFrame[asyncTaskManager].endTask(taskID); - return interceptedResponse instanceof Response ? interceptedResponse : response; - } - let buffer2; - try { - const stat = await FS2.promises.stat(filePath); - filePath = stat.isDirectory() ? Path3.join(filePath, "index.html") : filePath; - buffer2 = await FS2.promises.readFile(filePath); - } catch (error) { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} 404 (Not Found)`); - const response = VirtualServerUtility.getNotFoundResponse(this.#window); - const interceptedResponse = this.interceptor?.afterAsyncResponse ? await this.interceptor.afterAsyncResponse({ - window: this.#window, - response: await response, - request: this.request - }) : undefined; - this.#browserFrame[asyncTaskManager].endTask(taskID); - return interceptedResponse instanceof Response ? interceptedResponse : response; - } - const body = new this.#window.ReadableStream({ - start: (controller) => { - this.#window.queueMicrotask(() => { - controller.enqueue(buffer2); - controller.close(); - }); - } - }); - const response = new this.#window.Response(body); - response[buffer] = buffer2; - response[virtualServerFile] = filePath; - response.url = this.request.url; - const interceptedResponse = this.interceptor?.afterAsyncResponse ? await this.interceptor.afterAsyncResponse({ - window: this.#window, - response: await response, - request: this.request - }) : undefined; - this.#browserFrame[asyncTaskManager].endTask(taskID); - const returnResponse = interceptedResponse instanceof Response ? interceptedResponse : response; - const cacheableResponse = { - ...returnResponse, - body: buffer2, - waitingForBody: false, - virtual: true - }; - response[cachedResponse] = this.#browserFrame.page.context.responseCache.add(this.request, cacheableResponse); - return returnResponse; - } - async compliesWithCrossOriginPolicy() { - if (this.disableSameOriginPolicy || !FetchCORSUtility.isCORS(this.#window.location.href, this.request[url])) { - return true; - } - const cachedPreflightResponse = this.#browserFrame.page.context.preflightResponseCache.get(this.request); - if (cachedPreflightResponse) { - if (cachedPreflightResponse.allowOrigin !== "*" && cachedPreflightResponse.allowOrigin !== this.#window.location.origin) { - return false; - } - if (cachedPreflightResponse.allowMethods.length !== 0 && !cachedPreflightResponse.allowMethods.includes(this.request.method)) { - return false; - } - return true; - } - const requestHeaders = []; - for (const [header] of this.request.headers) { - requestHeaders.push(header.toLowerCase()); - } - const corsHeaders = new this.#window.Headers({ - "Access-Control-Request-Method": this.request.method, - Origin: this.#window.location.origin - }); - if (requestHeaders.length > 0) { - corsHeaders.set("Access-Control-Request-Headers", requestHeaders.slice().sort().join(",")); - } - const fetch2 = new Fetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: this.request.url, - init: { method: "OPTIONS" }, - disableCache: true, - disableSameOriginPolicy: true, - unfilteredHeaders: corsHeaders - }); - const response = await fetch2.send(); - if (!response.ok) { - return false; - } - const allowOrigin = response.headers.get("Access-Control-Allow-Origin"); - if (!allowOrigin) { - return false; - } - if (allowOrigin !== "*" && allowOrigin !== this.#window.location.origin) { - return false; - } - const allowMethods = []; - if (response.headers.has("Access-Control-Allow-Methods")) { - const allowMethodsHeader = response.headers.get("Access-Control-Allow-Methods"); - if (allowMethodsHeader !== "*") { - for (const method of allowMethodsHeader.split(",")) { - allowMethods.push(method.trim().toUpperCase()); - } - } - } - if (allowMethods.length !== 0 && !allowMethods.includes(this.request.method)) { - return false; - } - return true; - } - sendRequest() { - return new Promise((resolve, reject) => { - const taskID = this.#browserFrame[asyncTaskManager].startTask(() => this.onAsyncTaskManagerAbort()); - if (this.resolve) { - throw new this.#window.Error("Fetch already sent."); - } - this.resolve = async (response) => { - if (!this.disableCache && response instanceof Response && this.#browserFrame.page && this.#browserFrame.page.context) { - response[cachedResponse] = this.#browserFrame.page.context.responseCache.add(this.request, { - ...response, - headers: this.responseHeaders, - body: response[buffer], - waitingForBody: !response[buffer] && !!response.body - }); - } - const interceptedResponse = this.interceptor?.afterAsyncResponse ? await this.interceptor.afterAsyncResponse({ - window: this.#window, - response: await response, - request: this.request - }) : undefined; - this.#browserFrame[asyncTaskManager].endTask(taskID); - const returnResponse = interceptedResponse instanceof Response ? interceptedResponse : response; - if (returnResponse instanceof Response && !returnResponse.ok) { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} ${returnResponse.status} (${returnResponse.statusText})`); - } - resolve(returnResponse); - }; - this.reject = (error) => { - this.#browserFrame[asyncTaskManager].endTask(taskID); - reject(error); - }; - this.request.signal.addEventListener("abort", this.listeners.onSignalAbort); - const send = (this.request[url].protocol === "https:" ? HTTPS : HTTP).request; - this.nodeRequest = send(this.request[url].href, { - method: this.request.method, - headers: FetchRequestHeaderUtility.getRequestHeaders({ - browserFrame: this.#browserFrame, - window: this.#window, - request: this.request, - baseHeaders: this.#unfilteredHeaders - }), - agent: false, - rejectUnauthorized: !this.#browserFrame.page.context.browser.settings.fetch.disableStrictSSL, - key: this.request[url].protocol === "https:" ? FetchHTTPSCertificate_default.key : undefined, - cert: this.request[url].protocol === "https:" ? FetchHTTPSCertificate_default.cert : undefined - }); - this.nodeRequest.on("error", this.onError.bind(this)); - this.nodeRequest.on("socket", this.onSocket.bind(this)); - this.nodeRequest.on("response", this.onResponse.bind(this)); - if (this.request.body === null) { - this.nodeRequest.end(); - } else { - Stream2.pipeline(this.request.body, this.nodeRequest, (error) => { - if (error) { - this.onError(error); - } - }); - } - }); - } - onSocket(socket) { - const onSocketClose = () => { - if (this.isChunkedTransfer && !this.isProperLastChunkReceived) { - const error2 = new this.#window.DOMException("Premature close.", DOMExceptionNameEnum_default.networkError); - this.request[error] = error2; - if (this.response) { - this.response[error] = error2; - if (this.response.body && !this.response.body.locked) { - this.response.body.cancel(error2); - } - } - } - }; - const onData = (buffer) => { - this.isProperLastChunkReceived = Buffer6.compare(buffer.slice(-5), LAST_CHUNK) === 0; - if (!this.isProperLastChunkReceived && this.previousChunk) { - this.isProperLastChunkReceived = Buffer6.compare(this.previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && Buffer6.compare(buffer.slice(-2), LAST_CHUNK.slice(3)) === 0; - } - this.previousChunk = buffer; - }; - socket.prependListener("close", onSocketClose); - socket.on("data", onData); - this.nodeRequest.on("close", () => { - socket.removeListener("close", onSocketClose); - socket.removeListener("data", onData); - }); - } - onSignalAbort(event) { - this.finalizeRequest(); - this.abort(event.target?.reason); - } - onError(error) { - this.finalizeRequest(); - this.#browserFrame.page.console.error(error); - this.reject(new this.#window.DOMException(`Failed to execute "fetch()" on "Window" with URL "${this.request.url}": ${error.message}`, DOMExceptionNameEnum_default.networkError)); - } - onAsyncTaskManagerAbort() { - const error2 = new this.#window.DOMException("The operation was aborted.", DOMExceptionNameEnum_default.abortError); - this.request[aborted] = true; - this.request[error] = error2; - if (this.response) { - this.response[aborted] = true; - this.response[error] = error2; - } - if (this.listeners.onSignalAbort) { - this.request.signal.removeEventListener("abort", this.listeners.onSignalAbort); - } - if (this.nodeRequest && !this.nodeRequest.destroyed) { - this.nodeRequest.destroy(error2); - } - if (this.nodeResponse && !this.nodeResponse.destroyed) { - this.nodeResponse.destroy(error2); - } - if (this.response && this.response.body) { - if (!this.response.body.locked) { - this.response.body.cancel(error2); - } - } - } - onResponse(nodeResponse) { - this.isChunkedTransfer = nodeResponse.headers["transfer-encoding"] === "chunked" && !nodeResponse.headers["content-length"]; - this.nodeRequest.setTimeout(0); - this.responseHeaders = FetchResponseHeaderUtility.parseResponseHeaders({ - browserFrame: this.#browserFrame, - requestURL: this.request[url], - rawHeaders: nodeResponse.rawHeaders - }); - if (this.handleRedirectResponse(nodeResponse, this.responseHeaders)) { - return; - } - nodeResponse.once("end", () => this.request.signal.removeEventListener("abort", this.listeners.onSignalAbort)); - let body = Stream2.pipeline(nodeResponse, new Stream2.PassThrough, (error) => { - if (error) {} - }); - const responseOptions = { - status: nodeResponse.statusCode, - statusText: nodeResponse.statusMessage, - headers: this.responseHeaders - }; - const contentEncodingHeader = this.responseHeaders.get("Content-Encoding"); - if (this.request.method === "HEAD" || contentEncodingHeader === null || nodeResponse.statusCode === 204 || nodeResponse.statusCode === 304) { - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - return; - } - if (contentEncodingHeader === "gzip" || contentEncodingHeader === "x-gzip") { - const zlibOptions = { - flush: Zlib.constants.Z_SYNC_FLUSH, - finishFlush: Zlib.constants.Z_SYNC_FLUSH - }; - body = Stream2.pipeline(body, Zlib.createGunzip(zlibOptions), (error) => { - if (error) {} - }); - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - return; - } - if (contentEncodingHeader === "deflate" || contentEncodingHeader === "x-deflate") { - const raw = Stream2.pipeline(nodeResponse, new Stream2.PassThrough, (error) => { - if (error) {} - }); - raw.on("data", (chunk) => { - if ((chunk[0] & 15) === 8) { - body = Stream2.pipeline(body, Zlib.createInflate(), (error) => { - if (error) {} - }); - } else { - body = Stream2.pipeline(body, Zlib.createInflateRaw(), (error) => { - if (error) {} - }); - } - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - }); - raw.on("end", () => { - if (!this.response) { - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - } - }); - return; - } - if (contentEncodingHeader === "br") { - body = Stream2.pipeline(body, Zlib.createBrotliDecompress(), (error) => { - if (error) {} - }); - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - return; - } - this.response = new this.#window.Response(FetchBodyUtility.nodeToWebStream(body), responseOptions); - this.response.redirected = this.redirectCount > 0; - this.response.url = this.request.url; - this.resolve(this.response); - } - handleRedirectResponse(nodeResponse, responseHeaders) { - if (!FetchResponseRedirectUtility.isRedirect(nodeResponse.statusCode)) { - return false; - } - switch (this.request.redirect) { - case "error": - this.finalizeRequest(); - this.reject(new this.#window.DOMException(`URI requested responds with a redirect, redirect mode is set to "error": ${this.request.url}`, DOMExceptionNameEnum_default.abortError)); - return true; - case "manual": - return false; - case "follow": - const locationHeader = responseHeaders.get("Location"); - const shouldBecomeGetRequest = nodeResponse.statusCode === 303 || (nodeResponse.statusCode === 301 || nodeResponse.statusCode === 302) && this.request.method === "POST"; - let locationURL = null; - if (locationHeader !== null) { - try { - locationURL = new URL6(locationHeader, this.request.url); - } catch { - this.finalizeRequest(); - this.reject(new this.#window.DOMException(`URI requested responds with an invalid redirect URL: ${locationHeader}`, DOMExceptionNameEnum_default.uriMismatchError)); - return true; - } - } - if (locationURL === null) { - return false; - } - if (FetchResponseRedirectUtility.isMaxRedirectsReached(this.redirectCount)) { - this.finalizeRequest(); - this.reject(new this.#window.DOMException(`Maximum redirects reached at: ${this.request.url}`, DOMExceptionNameEnum_default.networkError)); - return true; - } - const headers = new this.#window.Headers(this.request.headers); - const requestInit = { - method: this.request.method, - signal: this.request.signal, - referrer: this.request.referrer, - referrerPolicy: this.request.referrerPolicy, - credentials: this.request.credentials, - headers, - body: this.request[bodyBuffer] - }; - if (this.request.credentials === "omit" || this.request.credentials === "same-origin" && FetchCORSUtility.isCORS(this.#window.location.href, locationURL)) { - headers.delete("cookie"); - headers.delete("cookie2"); - } - if (this.request.signal[aborted]) { - this.abort(this.request.signal[reason]); - return true; - } - if (shouldBecomeGetRequest) { - requestInit.method = "GET"; - requestInit.body = undefined; - headers.delete("Content-Length"); - headers.delete("Content-Type"); - } - const responseReferrerPolicy = FetchRequestReferrerUtility.getReferrerPolicyFromHeader(headers); - if (responseReferrerPolicy) { - requestInit.referrerPolicy = responseReferrerPolicy; - } - const fetch2 = new Fetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: locationURL, - init: requestInit, - redirectCount: this.redirectCount + 1, - disableSameOriginPolicy: this.disableSameOriginPolicy, - contentType: !shouldBecomeGetRequest ? this.request[contentType] : null - }); - this.finalizeRequest(); - fetch2.send().then((response) => this.resolve(response)).catch((error) => this.reject(error)); - return true; - default: - this.finalizeRequest(); - this.reject(new this.#window.DOMException(`Redirect option '${this.request.redirect}' is not a valid value of TRequestRedirect`)); - return true; - } - } - finalizeRequest() { - this.request.signal.removeEventListener("abort", this.listeners.onSignalAbort); - this.nodeRequest?.destroy(); - } - abort(reason) { - const error2 = new this.#window.DOMException("The operation was aborted." + (reason ? " " + reason.toString() : ""), DOMExceptionNameEnum_default.abortError); - this.request[aborted] = true; - this.request[error] = error2; - if (this.response) { - this.response[aborted] = true; - this.response[error] = error2; - } - if (this.nodeRequest && !this.nodeRequest.destroyed) { - this.nodeRequest.destroy(error2); - } - if (this.nodeResponse && !this.nodeResponse.destroyed) { - this.nodeResponse.destroy(error2); - } - if (this.response && this.response.body) { - if (!this.response.body.locked) { - this.response.body.cancel(error2); - } - } - if (this.reject) { - this.reject(reason !== undefined ? reason : error2); - } - } -} - -// node_modules/happy-dom/lib/history/HistoryScrollRestorationEnum.js -var HistoryScrollRestorationEnum; -(function(HistoryScrollRestorationEnum) { - HistoryScrollRestorationEnum["auto"] = "auto"; - HistoryScrollRestorationEnum["manual"] = "manual"; -})(HistoryScrollRestorationEnum || (HistoryScrollRestorationEnum = {})); -var HistoryScrollRestorationEnum_default = HistoryScrollRestorationEnum; - -// node_modules/happy-dom/lib/browser/utilities/BrowserFrameURL.js -import { URL as URL7 } from "url"; -class BrowserFrameURL { - static getRelativeURL(frame, url) { - url = url ? String(url) : "about:blank"; - if (url.startsWith("about:") || url.startsWith("javascript:")) { - return new URL7(url); - } - try { - return new URL7(url, frame.window[location].href); - } catch (e) { - return new URL7("about:blank"); - } - } -} - -// node_modules/happy-dom/lib/history/History.js -class History { - #browserFrame; - #window; - constructor(browserFrame, window) { - if (!browserFrame) { - throw new TypeError("Illegal constructor"); - } - this.#browserFrame = browserFrame; - this.#window = window; - } - get length() { - return this.#browserFrame?.[history].items.length || 0; - } - get state() { - return this.#browserFrame?.[history].currentItem.state || null; - } - get scrollRestoration() { - return this.#browserFrame?.[history].currentItem.scrollRestoration || HistoryScrollRestorationEnum_default.auto; - } - set scrollRestoration(scrollRestoration) { - switch (scrollRestoration) { - case HistoryScrollRestorationEnum_default.auto: - case HistoryScrollRestorationEnum_default.manual: - const currentItem = this.#browserFrame?.[history].currentItem; - if (currentItem) { - currentItem.scrollRestoration = scrollRestoration; - } - break; - } - } - back() { - if (!this.#window.closed) { - this.#browserFrame?.goBack(); - } - } - forward() { - if (!this.#window.closed) { - this.#browserFrame?.goForward(); - } - } - go(delta) { - if (!this.#window.closed) { - this.#browserFrame?.goSteps(delta); - } - } - pushState(state, _unused, url) { - if (!this.#browserFrame || this.#window.closed) { - return; - } - const history2 = this.#browserFrame?.[history]; - if (!history2) { - return; - } - if (arguments.length < 2) { - throw new this.#window.TypeError(`Failed to execute 'pushState' on 'History': 2 arguments required, but only ${arguments.length} present.`); - } - const location2 = this.#window[location]; - const newURL = url ? BrowserFrameURL.getRelativeURL(this.#browserFrame, url) : location2; - if (url && newURL.origin !== location2.origin) { - throw new this.#window.DOMException(`Failed to execute 'pushState' on 'History': A history state object with URL '${url.toString()}' cannot be created in a document with origin '${location2.origin}' and URL '${location2.href}'.`, DOMExceptionNameEnum_default.securityError); - } - history2.currentItem.popState = true; - history2.push({ - title: this.#window.document.title, - href: newURL.href, - state, - popState: true, - scrollRestoration: history2.currentItem.scrollRestoration, - method: history2.currentItem.method || "GET", - formData: history2.currentItem.formData || null - }); - location2[setURL](this.#browserFrame, history2.currentItem.href); - } - replaceState(state, _unused, url) { - if (!this.#browserFrame || this.#window.closed) { - return; - } - const history2 = this.#browserFrame?.[history]; - if (!history2) { - return; - } - if (arguments.length < 2) { - throw new this.#window.TypeError(`Failed to execute 'pushState' on 'History': 2 arguments required, but only ${arguments.length} present.`); - } - const location2 = this.#window[location]; - const newURL = url ? BrowserFrameURL.getRelativeURL(this.#browserFrame, url) : location2; - if (url && newURL.origin !== location2.origin) { - throw new this.#window.DOMException(`Failed to execute 'pushState' on 'History': A history state object with URL '${url.toString()}' cannot be created in a document with origin '${location2.origin}' and URL '${location2.href}'.`, DOMExceptionNameEnum_default.securityError); - } - history2.replace({ - title: this.#window.document.title, - href: newURL.href, - state, - popState: history2.currentItem.popState, - scrollRestoration: history2.currentItem.scrollRestoration, - method: history2.currentItem.method, - formData: history2.currentItem.formData - }); - if (url) { - location2[setURL](this.#browserFrame, history2.currentItem.href); - } - } - [destroy]() { - this.#browserFrame = null; - } -} - -// node_modules/happy-dom/lib/intersection-observer/IntersectionObserver.js -class IntersectionObserver { - #callback; - #options; - constructor(callback, options) { - this.#callback = callback; - this.#options = options || {}; - } - observe(_target) {} - disconnect() {} - unobserve(_target) {} - takeRecords() { - return []; - } -} - -// node_modules/happy-dom/lib/intersection-observer/IntersectionObserverEntry.js -class IntersectionObserverEntry { - boundingClientRect = null; - intersectionRatio = 0; - intersectionRect = null; - isIntersecting = false; - rootBounds = null; - target = null; - time = 0; - constructor(init) { - Object.assign(this, init); - } -} - -// node_modules/happy-dom/lib/location/Location.js -class Location { - [Symbol.toStringTag] = "Location"; - #browserFrame; - #url; - #hashChangeTimeout = null; - #hashChangeEvents = []; - constructor(browserFrame, url) { - if (!browserFrame) { - throw new TypeError("Illegal constructor"); - } - this.#browserFrame = browserFrame; - this.#url = new URL(url); - } - get hash() { - return this.#url.hash; - } - set hash(hash) { - const history2 = this.#browserFrame?.[history]; - if (!history2 || !this.#browserFrame) { - return; - } - const url = new URL(this.#url.href); - const oldHash = this.#url.hash; - url.hash = hash; - if (url.hash !== oldHash) { - history2.currentItem.popState = true; - history2.push({ - title: "", - href: url.href, - state: history2.currentItem.state, - popState: true, - scrollRestoration: HistoryScrollRestorationEnum_default.manual, - method: history2.currentItem.method, - formData: history2.currentItem.formData || null - }); - this[setURL](this.#browserFrame, url.href); - } - } - get host() { - return this.#url.host; - } - set host(host) { - const url = new URL(this.#url.href); - url.host = host; - this.href = url.href; - } - get hostname() { - return this.#url.hostname; - } - set hostname(hostname) { - const url = new URL(this.#url.href); - url.hostname = hostname; - this.href = url.href; - } - get href() { - return this.#url.href; - } - set href(url) { - if (!this.#browserFrame) { - return; - } - this.#browserFrame.goto(url).catch((error) => { - if (this.#browserFrame?.page?.console) { - this.#browserFrame.page.console.error(error); - } else { - throw error; - } - }); - } - get origin() { - return this.#url.origin; - } - get pathname() { - return this.#url.pathname; - } - set pathname(pathname) { - const url = new URL(this.#url.href); - url.pathname = pathname; - this.href = url.href; - } - get port() { - return this.#url.port; - } - set port(port) { - const url = new URL(this.#url.href); - url.port = port; - this.href = url.href; - } - get protocol() { - return this.#url.protocol; - } - set protocol(protocol) { - const url = new URL(this.#url.href); - url.protocol = protocol; - this.href = url.href; - } - get search() { - return this.#url.search; - } - set search(search) { - const url = new URL(this.#url.href); - url.search = search; - this.href = url.href; - } - replace(url) { - this.href = String(url); - } - assign(url) { - this.href = String(url); - } - reload() { - if (!this.#browserFrame) { - return; - } - this.#browserFrame.goto(this.href).catch((error) => { - if (this.#browserFrame?.page.console) { - this.#browserFrame.page.console.error(error); - } else { - throw error; - } - }); - } - [setURL](browserFrame, url) { - if (!this.#browserFrame) { - return; - } - if (this.#browserFrame !== browserFrame) { - throw new Error("Failed to set URL. Browser frame mismatch."); - } - const oldURL = this.#url.href; - const oldHash = this.#url.hash; - this.#url.href = url; - if (this.#url.hash !== oldHash) { - const newURL = this.#url.href; - this.#hashChangeEvents.push(new HashChangeEvent("hashchange", { oldURL, newURL })); - this.#browserFrame?.window?.document?.[clearCache](); - if (this.#hashChangeTimeout) { - this.#browserFrame.window?.clearTimeout(this.#hashChangeTimeout); - } - this.#hashChangeTimeout = this.#browserFrame.window?.setTimeout(() => { - const hashChangeEvents = this.#hashChangeEvents; - this.#hashChangeEvents = []; - for (const event of hashChangeEvents) { - this.#browserFrame?.window?.dispatchEvent(event); - } - }); - } - } - [destroy]() { - if (this.#hashChangeTimeout) { - this.#browserFrame?.window?.clearTimeout(this.#hashChangeTimeout); - } - this.#browserFrame = null; - } - toString() { - return this.#url.toString(); - } -} - -// node_modules/happy-dom/lib/mutation-observer/MutationRecord.js -class MutationRecord { - type; - target; - addedNodes; - removedNodes; - previousSibling; - nextSibling; - attributeName; - attributeNamespace; - oldValue; - constructor(init) { - this.type = init.type; - this.target = init.target; - this.addedNodes = init.addedNodes || []; - this.removedNodes = init.removedNodes || []; - this.previousSibling = init.previousSibling || null; - this.nextSibling = init.nextSibling || null; - this.attributeName = init.attributeName || null; - this.attributeNamespace = init.attributeNamespace || null; - this.oldValue = init.oldValue || null; - } -} - -// node_modules/happy-dom/lib/navigator/MimeType.js -class MimeType { - description; - enabledPlugin; - suffixes; - type; - constructor(description, enabledPlugin, suffixes, type) { - this.description = description; - this.enabledPlugin = enabledPlugin; - this.suffixes = suffixes; - this.type = type; - } - toString() { - return "[object MimeType]"; - } -} - -// node_modules/happy-dom/lib/navigator/MimeTypeArray.js -class MimeTypeArray { - length; - constructor(mimeTypes) { - for (let i = 0, max = mimeTypes.length;i < max; i++) { - this[i] = mimeTypes[i]; - this[mimeTypes[i].type] = mimeTypes[i]; - } - this.length = mimeTypes.length; - } - item(index) { - return this[index] || null; - } - namedItem(name) { - return this[name] || null; - } - toString() { - return "[object MimeTypeArray]"; - } -} - -// node_modules/happy-dom/lib/navigator/PluginArray.js -class PluginArray { - length; - constructor(plugins) { - for (let i = 0, max = plugins.length;i < max; i++) { - this[i] = plugins[i]; - this[plugins[i].name] = plugins[i]; - } - this.length = plugins.length; - } - item(index) { - return this[index] || null; - } - namedItem(name) { - return this[name] || null; - } - refresh() {} - toString() { - return "[object PluginArray]"; - } -} - -// node_modules/happy-dom/lib/permissions/PermissionNameEnum.js -var PermissionNameEnum; -(function(PermissionNameEnum) { - PermissionNameEnum["geolocation"] = "geolocation"; - PermissionNameEnum["notifications"] = "notifications"; - PermissionNameEnum["push"] = "push"; - PermissionNameEnum["midi"] = "midi"; - PermissionNameEnum["camera"] = "camera"; - PermissionNameEnum["microphone"] = "microphone"; - PermissionNameEnum["backgroundFetch"] = "background-fetch"; - PermissionNameEnum["backgroundSync"] = "background-sync"; - PermissionNameEnum["persistentStorage"] = "persistent-storage"; - PermissionNameEnum["ambientLightSensor"] = "ambient-light-sensor"; - PermissionNameEnum["accelerometer"] = "accelerometer"; - PermissionNameEnum["gyroscope"] = "gyroscope"; - PermissionNameEnum["magnetometer"] = "magnetometer"; - PermissionNameEnum["screenWakeLock"] = "screen-wake-lock"; - PermissionNameEnum["nfc"] = "nfc"; - PermissionNameEnum["displayCapture"] = "display-capture"; - PermissionNameEnum["accessibilityEvents"] = "accessibility-events"; - PermissionNameEnum["clipboardRead"] = "clipboard-read"; - PermissionNameEnum["clipboardWrite"] = "clipboard-write"; - PermissionNameEnum["paymentHandler"] = "payment-handler"; - PermissionNameEnum["idleDetection"] = "idle-detection"; - PermissionNameEnum["periodicBackgroundSync"] = "periodic-background-sync"; - PermissionNameEnum["systemWakeLock"] = "system-wake-lock"; - PermissionNameEnum["storageAccess"] = "storage-access"; - PermissionNameEnum["windowManagement"] = "window-management"; - PermissionNameEnum["windowPlacement"] = "window-placement"; - PermissionNameEnum["localFonts"] = "local-fonts"; - PermissionNameEnum["topLevelStorageAccess"] = "top-level-storage-access"; -})(PermissionNameEnum || (PermissionNameEnum = {})); -var PermissionNameEnum_default = PermissionNameEnum; - -// node_modules/happy-dom/lib/permissions/Permissions.js -class Permissions { - #permissionStatus = {}; - #window; - constructor(window) { - if (!window?.document) { - new TypeError("Invalid constructor"); - } - this.#window = window; - } - async query(permissionDescriptor) { - const name = permissionDescriptor?.name; - if (name && this.#permissionStatus[name]) { - return this.#permissionStatus[name]; - } - if (!Object.values(PermissionNameEnum_default).includes(name)) { - throw new Error(`Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': The provided value '${name}' is not a valid enum value of type PermissionName.`); - } - this.#permissionStatus[name] = new this.#window.PermissionStatus("granted"); - return this.#permissionStatus[name]; - } -} - -// node_modules/happy-dom/lib/navigator/Navigator.js -class Navigator { - #window; - #clipboard; - #permissions; - constructor(window) { - if (!window) { - throw new TypeError("Invalid constructor"); - } - this.#window = window; - this.#clipboard = new Clipboard(window); - this.#permissions = new Permissions(window); - } - get cookieEnabled() { - return true; - } - get credentials() { - return null; - } - get geolocation() { - return null; - } - get language() { - return "en-US"; - } - get languages() { - return ["en-US", "en"]; - } - get locks() { - return null; - } - get maxTouchPoints() { - return new WindowBrowserContext(this.#window).getSettings()?.navigator.maxTouchPoints || 0; - } - get hardwareConcurrency() { - return 8; - } - get appCodeName() { - return "Mozilla"; - } - get appName() { - return "Netscape"; - } - get appVersion() { - const userAgent = this.userAgent; - const index = userAgent.indexOf("/"); - return index > -1 ? userAgent.substring(index + 1) : ""; - } - get platform() { - const userAgent = this.userAgent; - const indexStart = userAgent.indexOf("("); - const indexEnd = userAgent.indexOf(")"); - return indexStart > -1 && indexEnd > -1 ? userAgent.substring(indexStart + 1, indexEnd) : ""; - } - get product() { - return "Gecko"; - } - get productSub() { - return "20100101"; - } - get vendor() { - return ""; - } - get vendorSub() { - return ""; - } - get userAgent() { - return new WindowBrowserContext(this.#window).getSettings()?.navigator.userAgent || ""; - } - get onLine() { - return true; - } - get permissions() { - return this.#permissions; - } - get clipboard() { - return this.#clipboard; - } - get webdriver() { - return true; - } - get doNotTrack() { - return "unspecified"; - } - get mimeTypes() { - return new MimeTypeArray([]); - } - get plugins() { - return new PluginArray([]); - } - sendBeacon(url, data) { - this.#window.fetch(url, { - method: "POST", - body: data - }); - return true; - } - toString() { - return "[object Navigator]"; - } -} - -// node_modules/happy-dom/lib/navigator/Plugin.js -class Plugin { - length = 0; - description; - filename; - name; - constructor(mimeTypes, description, filename, name) { - this.description = description; - this.filename = filename; - this.name = name; - for (let i = 0, max = mimeTypes.length;i < max; i++) { - this[i] = mimeTypes[i]; - this[mimeTypes[i].type] = mimeTypes[i]; - } - this.length = mimeTypes.length; - } - item(index) { - return this[index] || null; - } - namedItem(name) { - return this[name] || null; - } - toString() { - return "[object Plugin]"; - } -} - -// node_modules/happy-dom/lib/nodes/node/NodeDocumentPositionEnum.js -var NodeDocumentPositionEnum; -(function(NodeDocumentPositionEnum) { - NodeDocumentPositionEnum[NodeDocumentPositionEnum["disconnect"] = 1] = "disconnect"; - NodeDocumentPositionEnum[NodeDocumentPositionEnum["preceding"] = 2] = "preceding"; - NodeDocumentPositionEnum[NodeDocumentPositionEnum["following"] = 4] = "following"; - NodeDocumentPositionEnum[NodeDocumentPositionEnum["contains"] = 8] = "contains"; - NodeDocumentPositionEnum[NodeDocumentPositionEnum["containedBy"] = 16] = "containedBy"; - NodeDocumentPositionEnum[NodeDocumentPositionEnum["implementationSpecific"] = 32] = "implementationSpecific"; -})(NodeDocumentPositionEnum || (NodeDocumentPositionEnum = {})); -var NodeDocumentPositionEnum_default = NodeDocumentPositionEnum; - -// node_modules/happy-dom/lib/nodes/node/NodeUtility.js -class NodeUtility { - static isTextNode(node) { - return node?.[nodeType] === NodeTypeEnum_default.textNode; - } - static isInclusiveAncestor(ancestorNode, referenceNode, includeShadowRoots = false) { - if (ancestorNode === null || referenceNode === null) { - return false; - } - if (ancestorNode === referenceNode) { - return true; - } - if (!ancestorNode[nodeArray].length) { - return false; - } - if (includeShadowRoots && referenceNode[isConnected] !== ancestorNode[isConnected]) { - return false; - } - if (includeShadowRoots && ancestorNode === referenceNode[ownerDocument] && referenceNode[isConnected]) { - return true; - } - let parent = referenceNode[parentNode]; - while (parent) { - if (ancestorNode === parent) { - return true; - } - if (ancestorNode[parentNode] === parent[parentNode]) { - return false; - } - parent = parent[parentNode] ? parent[parentNode] : includeShadowRoots && parent.host ? parent.host : null; - } - return false; - } - static isFollowing(nodeA, nodeB) { - if (nodeA === nodeB) { - return false; - } - let current = nodeB; - while (current) { - current = this.following(current); - if (current === nodeA) { - return true; - } - } - return false; - } - static getNodeLength(node) { - switch (node[nodeType]) { - case NodeTypeEnum_default.documentTypeNode: - return 0; - case NodeTypeEnum_default.textNode: - case NodeTypeEnum_default.processingInstructionNode: - case NodeTypeEnum_default.commentNode: - return node.data.length; - default: - return node[nodeArray].length; - } - } - static following(node, root) { - const firstChild = node.firstChild; - if (firstChild) { - return firstChild; - } - let current = node; - while (current) { - if (current === root) { - return null; - } - const nextSibling = current.nextSibling; - if (nextSibling) { - return nextSibling; - } - current = current[parentNode]; - } - return null; - } - static nextDescendantNode(node) { - while (node && !node.nextSibling) { - node = node[parentNode]; - } - if (!node) { - return null; - } - return node.nextSibling; - } - static attributeListsEqual(elementA, elementB) { - const attributesA = Array.from(elementA[attributes][items].values()); - const attributesB = Array.from(elementB[attributes][items].values()); - for (const attributeA of attributesA) { - let found = false; - for (const attributeB of attributesB) { - if (attributeA[namespaceURI] === attributeB[namespaceURI] && attributeA.localName === attributeB.localName && attributeA[value] === attributeB[value]) { - found = true; - break; - } - } - if (!found) { - return false; - } - } - return true; - } - static isEqualNode(nodeA, nodeB) { - if (nodeA[nodeType] !== nodeB[nodeType]) { - return false; - } - switch (nodeA[nodeType]) { - case NodeTypeEnum_default.documentTypeNode: - const documentTypeA = nodeA; - const documentTypeB = nodeB; - if (documentTypeA.name !== documentTypeB.name || documentTypeA.publicId !== documentTypeB.publicId || documentTypeA.systemId !== documentTypeB.systemId) { - return false; - } - break; - case NodeTypeEnum_default.elementNode: - const elementA = nodeA; - const elementB = nodeB; - if (elementA[namespaceURI] !== elementB[namespaceURI] || elementA[prefix] !== elementB[prefix] || elementA[localName] !== elementB[localName] || elementA[attributes][items].size !== elementB[attributes][items].size) { - return false; - } - break; - case NodeTypeEnum_default.attributeNode: - const attributeA = nodeA; - const attributeB = nodeB; - if (attributeA[namespaceURI] !== attributeB[namespaceURI] || attributeA.localName !== attributeB.localName || attributeA[value] !== attributeB[value]) { - return false; - } - break; - case NodeTypeEnum_default.processingInstructionNode: - const processingInstructionA = nodeA; - const processingInstructionB = nodeB; - if (processingInstructionA.target !== processingInstructionB.target || processingInstructionA.data !== processingInstructionB.data) { - return false; - } - break; - case NodeTypeEnum_default.textNode: - case NodeTypeEnum_default.commentNode: - const textOrCommentA = nodeA; - const textOrCommentB = nodeB; - if (textOrCommentA.data !== textOrCommentB.data) { - return false; - } - break; - } - if (nodeA[nodeType] === NodeTypeEnum_default.elementNode && !NodeUtility.attributeListsEqual(nodeA, nodeB)) { - return false; - } - if (nodeA[nodeArray].length !== nodeB[nodeArray].length) { - return false; - } - for (let i = 0;i < nodeA[nodeArray].length; i++) { - const childNodeA = nodeA[nodeArray][i]; - const childNodeB = nodeB[nodeArray][i]; - if (!NodeUtility.isEqualNode(childNodeA, childNodeB)) { - return false; - } - } - return true; - } -} - -// node_modules/happy-dom/lib/mutation-observer/MutationTypeEnum.js -var MutationTypeEnum; -(function(MutationTypeEnum) { - MutationTypeEnum["attributes"] = "attributes"; - MutationTypeEnum["characterData"] = "characterData"; - MutationTypeEnum["childList"] = "childList"; -})(MutationTypeEnum || (MutationTypeEnum = {})); -var MutationTypeEnum_default = MutationTypeEnum; - -// node_modules/happy-dom/lib/nodes/NodeFactory.js -class NodeFactory { - static ownerDocuments = []; - static createNode(ownerDocument, nodeClass, ...args) { - if (!nodeClass.prototype[window]) { - this.ownerDocuments.push(ownerDocument); - } - return new nodeClass(...args); - } - static pullOwnerDocument() { - return this.ownerDocuments.pop() || null; - } -} - -// node_modules/happy-dom/lib/nodes/node/Node.js -class Node extends EventTarget { - static ELEMENT_NODE = NodeTypeEnum_default.elementNode; - static ATTRIBUTE_NODE = NodeTypeEnum_default.attributeNode; - static TEXT_NODE = NodeTypeEnum_default.textNode; - static CDATA_SECTION_NODE = NodeTypeEnum_default.cdataSectionNode; - static COMMENT_NODE = NodeTypeEnum_default.commentNode; - static DOCUMENT_NODE = NodeTypeEnum_default.documentNode; - static DOCUMENT_TYPE_NODE = NodeTypeEnum_default.documentTypeNode; - static DOCUMENT_FRAGMENT_NODE = NodeTypeEnum_default.documentFragmentNode; - static PROCESSING_INSTRUCTION_NODE = NodeTypeEnum_default.processingInstructionNode; - static DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum_default.containedBy; - static DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum_default.contains; - static DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum_default.disconnect; - static DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum_default.following; - static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = NodeDocumentPositionEnum_default.implementationSpecific; - static DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum_default.preceding; - [isConnected] = false; - [parentNode] = null; - [rootNode] = null; - [styleNode] = null; - [textAreaNode] = null; - [formNode] = null; - [selectNode] = null; - [mutationListeners] = []; - [nodeArray] = []; - [elementArray] = []; - [childNodes] = null; - [assignedToSlot] = null; - [cache] = { - querySelector: new Map, - querySelectorAll: new Map, - matches: new Map, - elementsByTagName: new Map, - elementsByTagNameNS: new Map, - elementByTagName: new Map, - elementById: new Map, - computedStyle: null - }; - [affectsCache] = []; - constructor() { - super(); - if (this[window]) { - this[ownerDocument] = this[window].document; - } else { - const ownerDocument2 = NodeFactory.pullOwnerDocument(); - if (!ownerDocument2) { - throw new TypeError("Illegal constructor"); - } - this[ownerDocument] = ownerDocument2; - this[window] = ownerDocument2[window]; - } - } - get [Symbol.toStringTag]() { - return this.constructor.name; - } - get isConnected() { - return this[isConnected]; - } - get ownerDocument() { - return this[ownerDocument]; - } - get parentNode() { - return this[parentNode]; - } - get nodeType() { - return this[nodeType]; - } - get childNodes() { - if (!this[childNodes]) { - this[childNodes] = new NodeList_default(illegalConstructor, this[nodeArray]); - } - return this[childNodes]; - } - get textContent() { - return ""; - } - set textContent(_textContent) {} - get nodeValue() { - return null; - } - set nodeValue(_nodeValue) {} - get nodeName() { - return ""; - } - get previousSibling() { - if (this[parentNode]) { - const nodeArray2 = this[parentNode][nodeArray]; - const index = nodeArray2.indexOf(this[proxy] || this); - if (index > 0) { - return nodeArray2[index - 1]; - } - } - return null; - } - get nextSibling() { - if (this[parentNode]) { - const nodeArray2 = this[parentNode][nodeArray]; - const index = nodeArray2.indexOf(this[proxy] || this); - if (index > -1 && index + 1 < nodeArray2.length) { - return nodeArray2[index + 1]; - } - } - return null; - } - get firstChild() { - const nodeArray2 = this[nodeArray]; - if (nodeArray2.length > 0) { - return nodeArray2[0]; - } - return null; - } - get lastChild() { - const nodeArray2 = this[nodeArray]; - if (nodeArray2.length > 0) { - return nodeArray2[nodeArray2.length - 1]; - } - return null; - } - get parentElement() { - let parent = this[parentNode]; - while (parent && parent[nodeType] !== NodeTypeEnum_default.elementNode) { - parent = parent[parentNode]; - } - return parent; - } - get baseURI() { - const base = this[ownerDocument].querySelector("base"); - if (base) { - return base.href; - } - return this[window].location.href; - } - hasChildNodes() { - return this[nodeArray].length > 0; - } - contains(otherNode) { - if (otherNode === undefined) { - return false; - } - const self = this[proxy] || this; - return NodeUtility.isInclusiveAncestor(self, otherNode); - } - getRootNode(options) { - if (this[isConnected]) { - if (this[rootNode] && !options?.composed) { - return this[rootNode]; - } - return this[ownerDocument]; - } - let root = this; - while (root[parentNode]) { - root = root[parentNode]; - } - return root; - } - cloneNode(deep = false) { - return this[cloneNode](deep); - } - appendChild(node) { - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendChild' on 'Node': 1 argument required, but only 0 present`); - } - return this[appendChild](node); - } - removeChild(node) { - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeChild' on 'Node': 1 argument required, but only 0 present`); - } - return this[removeChild](node); - } - insertBefore(newNode, referenceNode) { - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only ${arguments.length} present.`); - } - return this[insertBefore](newNode, referenceNode); - } - replaceChild(newChild, oldChild) { - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceChild' on 'Node': 2 arguments required, but only ${arguments.length} present.`); - } - return this[replaceChild](newChild, oldChild); - } - [cloneNode](deep = false) { - const clone = NodeFactory.createNode(this[ownerDocument], this.constructor); - if (clone[nodeArray].length) { - const childNodes2 = clone[nodeArray]; - while (childNodes2.length) { - clone.removeChild(childNodes2[0]); - } - } - if (deep) { - for (const childNode of this[nodeArray]) { - const childClone = childNode.cloneNode(true); - childClone[parentNode] = clone; - clone[nodeArray].push(childClone); - if (childClone[nodeType] === NodeTypeEnum_default.elementNode) { - clone[elementArray].push(childClone); - } - } - } - return clone; - } - [appendChild](node, disableValidations = false) { - if (node[proxy]) { - node = node[proxy]; - } - const self = this[proxy] || this; - if (!disableValidations) { - if (node === self) { - throw new this[window].DOMException("Failed to execute 'appendChild' on 'Node': Not possible to append a node as a child of itself."); - } - if (NodeUtility.isInclusiveAncestor(node, self, true)) { - throw new this[window].DOMException("Failed to execute 'appendChild' on 'Node': The new node is a parent of the node to insert to.", DOMExceptionNameEnum_default.domException); - } - } - if (node[nodeType] === NodeTypeEnum_default.documentFragmentNode) { - const childNodes2 = node[nodeArray]; - while (childNodes2.length) { - this.appendChild(childNodes2[0]); - } - return node; - } - if (node[parentNode]) { - node[parentNode][removeChild](node); - } - node[parentNode] = self; - node[clearCache](); - this[nodeArray].push(node); - if (node[nodeType] === NodeTypeEnum_default.elementNode) { - this[elementArray].push(node); - } - node[connectedToNode](); - for (const mutationListener of this[mutationListeners]) { - if (mutationListener.options?.subtree && mutationListener.callback.deref()) { - node[observeMutations](mutationListener); - } - } - this[reportMutation](new MutationRecord({ - target: self, - type: MutationTypeEnum_default.childList, - addedNodes: [node] - })); - return node; - } - [removeChild](node) { - if (node[proxy]) { - node = node[proxy]; - } - const index = this[nodeArray].indexOf(node); - if (index === -1) { - throw new this[window].DOMException(`Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.`); - } - const previousSibling = node.previousSibling; - const nextSibling = node.nextSibling; - node[parentNode] = null; - node[clearCache](); - this[nodeArray].splice(index, 1); - if (node[nodeType] === NodeTypeEnum_default.elementNode) { - const index = this[elementArray].indexOf(node); - if (index !== -1) { - this[elementArray].splice(index, 1); - } - } - if (node[assignedToSlot]) { - const index = node[assignedToSlot][assignedNodes].indexOf(node); - if (index !== -1) { - node[assignedToSlot][assignedNodes].splice(index, 1); - } - node[assignedToSlot] = null; - } - node[disconnectedFromNode](); - for (const mutationListener of this[mutationListeners]) { - if (mutationListener.options?.subtree && mutationListener.callback.deref()) { - node[unobserveMutations](mutationListener); - } - } - this[reportMutation](new MutationRecord({ - target: this[proxy] || this, - type: MutationTypeEnum_default.childList, - removedNodes: [node], - previousSibling, - nextSibling - })); - return node; - } - [insertBefore](newNode, referenceNode, disableValidations = false) { - if (newNode[proxy]) { - newNode = newNode[proxy]; - } - if (referenceNode && referenceNode[proxy]) { - referenceNode = referenceNode[proxy]; - } - if (newNode === referenceNode) { - return newNode; - } - const self = this[proxy] || this; - if (!disableValidations) { - if (newNode === self) { - throw new this[window].DOMException("Failed to execute 'insertBefore' on 'Node': Not possible to insert a node as a child of itself."); - } - if (NodeUtility.isInclusiveAncestor(newNode, self, true)) { - throw new this[window].DOMException("Failed to execute 'insertBefore' on 'Node': The new node is a parent of the node to insert to.", DOMExceptionNameEnum_default.domException); - } - } - if (newNode[nodeType] === NodeTypeEnum_default.documentFragmentNode) { - const childNodes2 = newNode[nodeArray]; - while (childNodes2.length > 0) { - this[insertBefore](childNodes2[0], referenceNode, true); - } - return newNode; - } - if (!referenceNode) { - this[appendChild](newNode, true); - return newNode; - } - const nodeArray2 = this[nodeArray]; - if (!nodeArray2.includes(referenceNode)) { - throw new this[window].DOMException("Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node."); - } - if (newNode[parentNode]) { - newNode[parentNode][removeChild](newNode); - } - newNode[parentNode] = self; - newNode[clearCache](); - const index = nodeArray2.indexOf(referenceNode); - if (newNode[nodeType] === NodeTypeEnum_default.elementNode) { - const elementArray2 = this[elementArray]; - if (referenceNode[nodeType] === NodeTypeEnum_default.elementNode) { - elementArray2.splice(elementArray2.indexOf(referenceNode), 0, newNode); - } else { - let isInserted = false; - for (let i = index, max = nodeArray2.length;i < max; i++) { - if (nodeArray2[i][nodeType] === NodeTypeEnum_default.elementNode) { - elementArray2.splice(elementArray2.indexOf(nodeArray2[i]), 0, newNode); - isInserted = true; - break; - } - } - if (!isInserted) { - elementArray2.push(newNode); - } - } - } - nodeArray2.splice(index, 0, newNode); - newNode[connectedToNode](); - for (const mutationListener of this[mutationListeners]) { - if (mutationListener.options?.subtree && mutationListener.callback.deref()) { - newNode[observeMutations](mutationListener); - } - } - this[reportMutation](new MutationRecord({ - target: self, - type: MutationTypeEnum_default.childList, - addedNodes: [newNode] - })); - return newNode; - } - [replaceChild](newChild, oldChild) { - this.insertBefore(newChild, oldChild); - this.removeChild(oldChild); - return oldChild; - } - isEqualNode(node) { - return NodeUtility.isEqualNode(this, node); - } - toString() { - return `[object ${this.constructor.name}]`; - } - [observeMutations](listener) { - this[mutationListeners].push(listener); - if (listener.options.subtree) { - for (const node of this[nodeArray]) { - node[observeMutations](listener); - } - } - } - [unobserveMutations](listener) { - const index = this[mutationListeners].indexOf(listener); - if (index !== -1) { - this[mutationListeners].splice(index, 1); - } - if (listener.options.subtree) { - for (const node of this[nodeArray]) { - node[unobserveMutations](listener); - } - } - } - [reportMutation](record) { - this[clearCache](); - const mutationListeners2 = this[mutationListeners]; - if (!mutationListeners2.length) { - return; - } - for (let i = 0, max = mutationListeners2.length;i < max; i++) { - const mutationListener = mutationListeners2[i]; - const callback = mutationListener.callback.deref(); - if (callback) { - switch (record.type) { - case MutationTypeEnum_default.childList: - if (mutationListener.options.childList) { - callback(record); - } - break; - case MutationTypeEnum_default.attributes: - if (mutationListener.options.attributes && (!mutationListener.options.attributeFilter || mutationListener.options.attributeFilter.includes(record.attributeName))) { - callback(record); - } - break; - case MutationTypeEnum_default.characterData: - if (mutationListener.options?.characterData) { - callback(record); - } - break; - } - } else { - mutationListeners2.splice(i, 1); - i--; - max--; - } - } - } - [clearCache]() { - const cache2 = this[cache]; - if (cache2.querySelector.size) { - for (const item of cache2.querySelector.values()) { - if (item.result) { - item.result = null; - } - } - cache2.querySelector = new Map; - } - if (cache2.querySelectorAll.size) { - for (const item of cache2.querySelectorAll.values()) { - if (item.result) { - item.result = null; - } - } - cache2.querySelectorAll = new Map; - } - if (cache2.matches.size) { - for (const item of cache2.matches.values()) { - if (item.result) { - item.result = null; - } - } - cache2.matches = new Map; - } - if (cache2.elementsByTagName.size) { - for (const item of cache2.elementsByTagName.values()) { - if (item.result) { - item.result = null; - } - } - cache2.elementsByTagName = new Map; - } - if (cache2.elementsByTagNameNS.size) { - for (const item of cache2.elementsByTagNameNS.values()) { - if (item.result) { - item.result = null; - } - } - cache2.elementsByTagNameNS = new Map; - } - if (cache2.elementByTagName.size) { - for (const item of cache2.elementByTagName.values()) { - if (item.result) { - item.result = null; - } - } - cache2.elementByTagName = new Map; - } - if (cache2.elementById.size) { - for (const item of cache2.elementById.values()) { - if (item.result) { - item.result = null; - } - } - cache2.elementById = new Map; - } - const affectsCache2 = this[affectsCache]; - if (affectsCache2.length) { - for (const item of affectsCache2) { - item.result = null; - } - this[affectsCache] = []; - } - const document = this[ownerDocument]; - if (document && document[affectsComputedStyleCache].length) { - for (const item of document[affectsComputedStyleCache]) { - item.result = null; - } - document[affectsComputedStyleCache] = []; - } - } - [connectedToNode]() { - const parentNode2 = this[parentNode]; - const parent = parentNode2 || this[host]; - let isConnected2 = false; - let isDisconnected = false; - if (!this[isConnected] && parent[isConnected]) { - this[isConnected] = true; - isConnected2 = true; - } else if (this[isConnected] && !parent[isConnected]) { - this[isConnected] = false; - isDisconnected = true; - } - this[ownerDocument] = parent[ownerDocument] || parent; - this[window] = parent[window] || parent[defaultView]; - if (parentNode2) { - if (this[nodeType] !== NodeTypeEnum_default.documentFragmentNode) { - this[rootNode] = parentNode2[rootNode]; - } - const tagName2 = this[tagName]; - if (parentNode2[styleNode] && tagName2 !== "STYLE") { - this[styleNode] = parentNode2[styleNode]; - } - if (parentNode2[textAreaNode] && tagName2 !== "TEXTAREA") { - this[textAreaNode] = parentNode2[textAreaNode]; - } - if (parentNode2[formNode] && tagName2 !== "FORM") { - this[formNode] = parentNode2[formNode]; - } - if (parentNode2[selectNode] && tagName2 !== "SELECT") { - this[selectNode] = parentNode2[selectNode]; - } - } - const childNodes2 = this[nodeArray].slice(); - for (let i = 0, max = childNodes2.length;i < max; i++) { - childNodes2[i][parentNode] = this; - childNodes2[i][connectedToNode](); - } - if (this[shadowRoot]) { - this[shadowRoot][connectedToNode](); - } - if (isConnected2) { - this[connectedToDocument](); - } else if (isDisconnected) { - this[disconnectedFromDocument](); - } - } - [disconnectedFromNode]() { - if (this[nodeType] !== NodeTypeEnum_default.documentFragmentNode) { - this[rootNode] = null; - } - const tagName2 = this[tagName]; - if (tagName2 !== "STYLE") { - this[styleNode] = null; - } - if (tagName2 !== "TEXTAREA") { - this[textAreaNode] = null; - } - if (tagName2 !== "FORM") { - this[formNode] = null; - } - if (tagName2 !== "SELECT") { - this[selectNode] = null; - } - if (this[isConnected]) { - this[isConnected] = false; - this[disconnectedFromDocument](); - } - const childNodes2 = this[nodeArray].slice(); - for (let i = 0, max = childNodes2.length;i < max; i++) { - childNodes2[i][connectedToNode](); - } - if (this[shadowRoot]) { - this[shadowRoot][disconnectedFromNode](); - } - } - [connectedToDocument]() { - if (this[shadowRoot]) { - this[shadowRoot][connectedToDocument](); - } - } - [disconnectedFromDocument]() { - if (this[ownerDocument][activeElement] === this) { - this[ownerDocument][clearCache](); - this[ownerDocument][activeElement] = null; - } - if (this[shadowRoot]) { - this[shadowRoot][disconnectedFromDocument](); - } - } - [destroy]() { - super[destroy](); - this[isConnected] = false; - for (let i = 0, max = this[nodeArray].length;i < max; i++) { - this[nodeArray][i][destroy](); - } - this[mutationListeners] = []; - this[parentNode] = null; - this[rootNode] = null; - this[styleNode] = null; - this[textAreaNode] = null; - this[formNode] = null; - this[selectNode] = null; - this[mutationListeners] = []; - this[nodeArray] = []; - this[elementArray] = []; - this[childNodes] = null; - this[assignedToSlot] = null; - this[clearCache](); - } - compareDocumentPosition(otherNode) { - if (this === otherNode) { - return 0; - } - let node1 = otherNode; - let node2 = this[proxy] || this; - let attr1 = null; - let attr2 = null; - if (node1[nodeType] === NodeTypeEnum_default.attributeNode) { - attr1 = node1; - node1 = attr1[ownerElement]; - } - if (node2[nodeType] === NodeTypeEnum_default.attributeNode) { - attr2 = node2; - node2 = attr2[ownerElement]; - if (attr1 !== null && node1 !== null && node2 === node1) { - for (const attribute of node2[attributes][items].values()) { - if (NodeUtility.isEqualNode(attribute, attr1)) { - return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING; - } - if (NodeUtility.isEqualNode(attribute, attr2)) { - return Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_FOLLOWING; - } - } - } - } - const node2Ancestors = []; - let node2Ancestor = node2; - while (node2Ancestor) { - if (node2Ancestor === node1) { - return Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING; - } - node2Ancestors.push(node2Ancestor); - node2Ancestor = node2Ancestor[parentNode]; - } - const node1Ancestors = []; - let node1Ancestor = node1; - while (node1Ancestor) { - if (node1Ancestor === node2) { - return Node.DOCUMENT_POSITION_CONTAINED_BY | Node.DOCUMENT_POSITION_FOLLOWING; - } - node1Ancestors.push(node1Ancestor); - node1Ancestor = node1Ancestor[parentNode]; - } - const reverseArrayIndex = (array, reverseIndex) => { - return array[array.length - 1 - reverseIndex]; - }; - const root = reverseArrayIndex(node2Ancestors, 0); - if (!root || root !== reverseArrayIndex(node1Ancestors, 0)) { - return Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_FOLLOWING; - } - let commonAncestorIndex = 0; - const ancestorsMinLength = Math.min(node2Ancestors.length, node1Ancestors.length); - for (let i = 0;i < ancestorsMinLength; ++i) { - const node2Ancestor = reverseArrayIndex(node2Ancestors, i); - const node1Ancestor = reverseArrayIndex(node1Ancestors, i); - if (node2Ancestor !== node1Ancestor) { - break; - } - commonAncestorIndex = i; - } - const commonAncestor = reverseArrayIndex(node2Ancestors, commonAncestorIndex); - let indexes = 0; - let node2Index = -1; - let node1Index = -1; - const node2Node = reverseArrayIndex(node2Ancestors, commonAncestorIndex + 1); - const node1Node = reverseArrayIndex(node1Ancestors, commonAncestorIndex + 1); - const computeNodeIndexes = (nodes) => { - for (const childNode of nodes) { - computeNodeIndexes(childNode[nodeArray]); - if (childNode === node2Node) { - node2Index = indexes; - } else if (childNode === node1Node) { - node1Index = indexes; - } - if (node2Index !== -1 && node1Index !== -1) { - break; - } - indexes++; - } - }; - computeNodeIndexes(commonAncestor[nodeArray]); - return node1Index < node2Index ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING; - } - normalize() { - let child = this.firstChild; - while (child) { - if (NodeUtility.isTextNode(child)) { - while (NodeUtility.isTextNode(child.nextSibling)) { - child.data += child.nextSibling.data; - child.nextSibling.remove(); - } - if (!child.data.length) { - const node = child; - child = child.nextSibling; - node.remove(); - continue; - } - } else { - child.normalize(); - } - child = child.nextSibling; - } - } - isSameNode(node) { - return this === node; - } -} -Node.prototype.ELEMENT_NODE = NodeTypeEnum_default.elementNode; -Node.prototype.ATTRIBUTE_NODE = NodeTypeEnum_default.attributeNode; -Node.prototype.TEXT_NODE = NodeTypeEnum_default.textNode; -Node.prototype.CDATA_SECTION_NODE = NodeTypeEnum_default.cdataSectionNode; -Node.prototype.COMMENT_NODE = NodeTypeEnum_default.commentNode; -Node.prototype.DOCUMENT_NODE = NodeTypeEnum_default.documentNode; -Node.prototype.DOCUMENT_TYPE_NODE = NodeTypeEnum_default.documentTypeNode; -Node.prototype.DOCUMENT_FRAGMENT_NODE = NodeTypeEnum_default.documentFragmentNode; -Node.prototype.PROCESSING_INSTRUCTION_NODE = NodeTypeEnum_default.processingInstructionNode; -Node.prototype.DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum_default.containedBy; -Node.prototype.DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum_default.contains; -Node.prototype.DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum_default.disconnect; -Node.prototype.DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum_default.following; -Node.prototype.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = NodeDocumentPositionEnum_default.implementationSpecific; -Node.prototype.DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum_default.preceding; - -// node_modules/happy-dom/lib/nodes/attr/Attr.js -class Attr extends Node { - [nodeType] = NodeTypeEnum_default.attributeNode; - [namespaceURI] = null; - [name] = null; - [localName] = null; - [prefix] = null; - [value] = null; - [specified] = true; - [ownerElement] = null; - get specified() { - return this[specified]; - } - get ownerElement() { - return this[ownerElement]; - } - get value() { - return this[value]; - } - set value(value2) { - this[value] = value2; - } - get name() { - return this[name] || ""; - } - get localName() { - return this[localName] || ""; - } - get prefix() { - return this[prefix]; - } - get textContent() { - return this[value] || ""; - } - get namespaceURI() { - return this[namespaceURI]; - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[namespaceURI] = this[namespaceURI]; - clone[name] = this[name]; - clone[localName] = this[localName]; - clone[prefix] = this[prefix]; - clone[value] = this[value]; - clone[specified] = this[specified]; - return clone; - } -} - -// node_modules/happy-dom/lib/nodes/character-data/CharacterDataUtility.js -class CharacterDataUtility { - static appendData(characterData, data) { - characterData.data += data; - } - static deleteData(characterData, offset, count) { - characterData.data = characterData.data.substring(0, offset) + characterData.data.substring(offset + count); - } - static insertData(characterData, offset, data) { - characterData.data = characterData.data.substring(0, offset) + data + characterData.data.substring(offset); - } - static replaceData(characterData, offset, count, data) { - characterData.data = characterData.data.substring(0, offset) + data + characterData.data.substring(offset + count); - } - static substringData(characterData, offset, count) { - return characterData.data.substring(offset, offset + count); - } -} - -// node_modules/happy-dom/lib/nodes/child-node/NonDocumentChildNodeUtility.js -class NonDocumentChildNodeUtility { - static previousElementSibling(childNode) { - let sibling = childNode.previousSibling; - while (sibling && sibling[nodeType] !== NodeTypeEnum_default.elementNode) { - sibling = sibling.previousSibling; - } - return sibling; - } - static nextElementSibling(childNode) { - let sibling = childNode.nextSibling; - while (sibling && sibling[nodeType] !== NodeTypeEnum_default.elementNode) { - sibling = sibling.nextSibling; - } - return sibling; - } -} - -// node_modules/happy-dom/lib/nodes/child-node/ChildNodeUtility.js -class ChildNodeUtility { - static remove(childNode) { - if (childNode[parentNode]) { - childNode[parentNode].removeChild(childNode); - } - } - static replaceWith(childNode, ...nodes) { - const parent = childNode[parentNode]; - if (!parent) { - return; - } - for (const node of nodes) { - if (node instanceof Node) { - parent.insertBefore(node, childNode); - } else { - parent.insertBefore(parent[ownerDocument].createTextNode(String(node)), childNode); - } - } - parent.removeChild(childNode); - } - static before(childNode, ...nodes) { - const parent = childNode[parentNode]; - if (!parent) { - return; - } - for (const node of nodes) { - if (node instanceof Node) { - parent.insertBefore(node, childNode); - } else { - parent.insertBefore(parent[ownerDocument].createTextNode(String(node)), childNode); - } - } - } - static after(childNode, ...nodes) { - const parent = childNode[parentNode]; - if (!parent) { - return; - } - const nextSibling = childNode.nextSibling; - for (const node of nodes) { - const insertedNode = node instanceof Node ? node : parent[ownerDocument].createTextNode(String(node)); - if (!nextSibling) { - parent.appendChild(insertedNode); - } else { - parent.insertBefore(insertedNode, nextSibling); - } - } - } -} - -// node_modules/happy-dom/lib/nodes/character-data/CharacterData.js -class CharacterData extends Node { - [data] = ""; - constructor(data2) { - super(); - this[data] = data2 !== undefined ? String(data2) : ""; - } - get length() { - return this[data].length; - } - get data() { - return this[data]; - } - set data(data2) { - const oldValue = this[data]; - this[data] = String(data2); - this[reportMutation](new MutationRecord({ - target: this, - type: MutationTypeEnum_default.characterData, - oldValue - })); - } - get textContent() { - return this[data]; - } - set textContent(textContent) { - this.data = textContent; - } - get nodeValue() { - return this[data]; - } - set nodeValue(nodeValue) { - this.textContent = nodeValue; - } - get previousElementSibling() { - return NonDocumentChildNodeUtility.previousElementSibling(this); - } - get nextElementSibling() { - return NonDocumentChildNodeUtility.nextElementSibling(this); - } - appendData(data2) { - CharacterDataUtility.appendData(this, data2); - } - deleteData(offset, count) { - CharacterDataUtility.deleteData(this, offset, count); - } - insertData(offset, data2) { - CharacterDataUtility.insertData(this, offset, data2); - } - replaceData(offset, count, data2) { - CharacterDataUtility.replaceData(this, offset, count, data2); - } - substringData(offset, count) { - return CharacterDataUtility.substringData(this, offset, count); - } - remove() { - ChildNodeUtility.remove(this); - } - replaceWith(...nodes) { - ChildNodeUtility.replaceWith(this, ...nodes); - } - before(...nodes) { - ChildNodeUtility.before(this, ...nodes); - } - after(...nodes) { - ChildNodeUtility.after(this, ...nodes); - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[data] = this[data]; - return clone; - } -} - -// node_modules/happy-dom/lib/nodes/document-type/DocumentType.js -class DocumentType extends Node { - [nodeType] = NodeTypeEnum_default.documentTypeNode; - [name] = ""; - [publicId] = ""; - [systemId] = ""; - get name() { - return this[name]; - } - get publicId() { - return this[publicId]; - } - get systemId() { - return this[systemId]; - } - get nodeName() { - return this.name; - } - toString() { - return "[object DocumentType]"; - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[name] = this[name]; - clone[publicId] = this[publicId]; - clone[systemId] = this[systemId]; - return clone; - } -} - -// node_modules/happy-dom/lib/nodes/document/DocumentReadyStateEnum.js -var DocumentReadyStateEnum; -(function(DocumentReadyStateEnum) { - DocumentReadyStateEnum["loading"] = "loading"; - DocumentReadyStateEnum["interactive"] = "interactive"; - DocumentReadyStateEnum["complete"] = "complete"; -})(DocumentReadyStateEnum || (DocumentReadyStateEnum = {})); -var DocumentReadyStateEnum_default = DocumentReadyStateEnum; - -// node_modules/happy-dom/lib/nodes/document/DocumentReadyStateManager.js -class DocumentReadyStateManager { - #asyncTaskManager; - constructor(browserFrame) { - this.#asyncTaskManager = new AsyncTaskManager(browserFrame); - } - waitUntilComplete() { - return this.#asyncTaskManager.waitUntilComplete(); - } - startTask() { - return this.#asyncTaskManager.startTask(); - } - endTask(taskID) { - this.#asyncTaskManager.endTask(taskID); - } - destroy() { - return this.#asyncTaskManager.destroy(); - } -} - -// node_modules/happy-dom/lib/dom/DOMRectReadOnly.js -class DOMRectReadOnly { - [x] = 0; - [y] = 0; - [width] = 0; - [height] = 0; - constructor(x2, y2, width2, height2) { - this[x] = x2 !== undefined && x2 !== null ? Number(x2) : 0; - this[y] = y2 !== undefined && y2 !== null ? Number(y2) : 0; - this[width] = width2 !== undefined && width2 !== null ? Number(width2) : 0; - this[height] = height2 !== undefined && height2 !== null ? Number(height2) : 0; - } - get x() { - return this[x]; - } - get y() { - return this[y]; - } - get width() { - return this[width]; - } - get height() { - return this[height]; - } - get top() { - return Math.min(this[y], this[y] + this[height]); - } - get right() { - return Math.max(this[x], this[x] + this[width]); - } - get bottom() { - return Math.max(this[y], this[y] + this[height]); - } - get left() { - return Math.min(this[x], this[x] + this[width]); - } - toJSON() { - return { - x: this.x, - y: this.y, - width: this.width, - height: this.height, - top: this.top, - right: this.right, - bottom: this.bottom, - left: this.left - }; - } - static fromRect(other) { - return new DOMRectReadOnly(other.x, other.y, other.width, other.height); - } -} - -// node_modules/happy-dom/lib/dom/DOMRect.js -class DOMRect extends DOMRectReadOnly { - set x(value) { - this[x] = value; - } - get x() { - return this[x]; - } - set y(value) { - this[y] = value; - } - get y() { - return this[y]; - } - set width(value) { - this[width] = value; - } - get width() { - return this[width]; - } - set height(value) { - this[height] = value; - } - get height() { - return this[height]; - } - static fromRect(other) { - return new DOMRect(other.x, other.y, other.width, other.height); - } -} - -// node_modules/happy-dom/lib/dom/DOMTokenList.js -var ATTRIBUTE_SPLIT_REGEXP = /[\t\f\n\r ]+/; - -class DOMTokenList { - [ownerElement]; - [attributeName]; - [cache] = { - items: [], - attributeValue: "" - }; - [supports]; - [proxy]; - constructor(illegalConstructorSymbol, ownerElement2, attributeName2, supports2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[ownerElement] = ownerElement2; - this[attributeName] = attributeName2; - this[supports] = supports2 || []; - const methodBinder = new ClassMethodBinder(this, [DOMTokenList]); - const proxy2 = new Proxy(this, { - get: (target, property) => { - if (property === "length") { - return target[getTokenList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getTokenList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getTokenList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getTokenList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getTokenList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - this[proxy] = proxy2; - return proxy2; - } - get length() { - return this[getTokenList]().length; - } - set value(value) { - this[ownerElement].setAttribute(this[attributeName], value); - } - get value() { - return this[ownerElement].getAttribute(this[attributeName]) || ""; - } - [Symbol.iterator]() { - return this[getTokenList]().values(); - } - item(index) { - const items = this[getTokenList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - replace(token, newToken) { - const list = this[getTokenList]().slice(); - const index = list.indexOf(token); - if (index === -1) { - return false; - } - list[index] = newToken; - this[ownerElement].setAttribute(this[attributeName], list.join(" ")); - return true; - } - supports(token) { - return this[supports].includes(token); - } - values() { - return this[getTokenList]().values(); - } - entries() { - return this[getTokenList]().entries(); - } - forEach(callback, thisArg) { - const thisArgValue = thisArg ?? this[ownerElement][window]; - const items = this[getTokenList](); - const proxy2 = this[proxy] ?? this; - for (let i = 0, max = items.length;i < max; i++) { - callback.call(thisArgValue, items[i], i, proxy2); - } - } - keys() { - return this[getTokenList]().keys(); - } - add(...tokens) { - const list = this[getTokenList]().slice(); - const existingTokens = new Set(list); - for (const token of tokens) { - if (!existingTokens.has(token)) { - existingTokens.add(token); - list.push(token); - } - } - this[ownerElement].setAttribute(this[attributeName], list.join(" ")); - } - remove(...tokens) { - const list = this[getTokenList](); - const tokensToRemove = new Set(tokens); - const newList = list.filter((item) => !tokensToRemove.has(item)); - this[ownerElement].setAttribute(this[attributeName], newList.join(" ")); - } - contains(className) { - return this[getTokenList]().includes(className); - } - toggle(token, force) { - let shouldAdd; - if (force !== undefined) { - shouldAdd = force; - } else { - shouldAdd = !this.contains(token); - } - if (shouldAdd) { - this.add(token); - return true; - } - this.remove(token); - return false; - } - [getTokenList]() { - const attributeValue = this[ownerElement].getAttribute(this[attributeName]) ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue) { - return cache2.items; - } - const items = []; - const trimmed = attributeValue.trim(); - if (trimmed) { - for (const item of trimmed.split(ATTRIBUTE_SPLIT_REGEXP)) { - if (!items.includes(item)) { - items.push(item); - } - } - } - cache2.attributeValue = attributeValue; - cache2.items = items; - return items; - } - toString() { - return this.value || ""; - } -} - -// node_modules/happy-dom/lib/nodes/element/HTMLCollection.js -class HTMLCollection { - [query]; - constructor(illegalConstructorSymbol, query2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[query] = query2; - const methodBinder = new ClassMethodBinder(this, this.constructor !== HTMLCollection ? [this.constructor, HTMLCollection] : [HTMLCollection]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length") { - return query2().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return query2()[index]; - } - return target.namedItem(property) || undefined; - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys() { - const keys = []; - const items = query2(); - for (let i = 0;i < items.length; i++) { - const item = items[i]; - const name = item.getAttribute("id") || item.getAttribute("name"); - keys.push(String(i)); - if (name) { - keys.push(name); - } - } - return keys; - }, - has(target, property) { - if (property in target) { - return true; - } - const items = query2(); - const index = Number(property); - if (!isNaN(index) && index >= 0 && index < items.length) { - return true; - } - property = String(property); - for (let i = 0;i < items.length; i++) { - const item = items[i]; - const name = item.getAttribute("id") || item.getAttribute("name"); - if (name && name === property) { - return true; - } - } - return false; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const items = query2(); - const index = Number(property); - if (!isNaN(index) && index >= 0 && index < items.length) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - for (let i = 0;i < items.length; i++) { - const item = items[i]; - const name = item.getAttribute("id") || item.getAttribute("name"); - if (name && name === property) { - return { - value: item, - writable: false, - enumerable: true, - configurable: true - }; - } - } - } - }); - } - get length() { - return this[query]().length; - } - get [Symbol.toStringTag]() { - return this.constructor.name; - } - toLocaleString() { - return `[object ${this.constructor.name}]`; - } - toString() { - return `[object ${this.constructor.name}]`; - } - item(index) { - const items = this[query](); - return index >= 0 && items[index] ? items[index] : null; - } - [Symbol.iterator]() { - const items = this[query](); - return items[Symbol.iterator](); - } - namedItem(name) { - const items = this[query](); - name = String(name); - for (const item of items) { - if (item.getAttribute("id") === name || item.getAttribute("name") === name) { - return item; - } - } - return null; - } -} - -// node_modules/happy-dom/lib/nodes/parent-node/ParentNodeUtility.js -class ParentNodeUtility { - static append(parentNode, ...nodes) { - for (const node of nodes) { - if (node instanceof Node) { - parentNode.appendChild(node); - } else { - parentNode.appendChild(parentNode[ownerDocument].createTextNode(String(node))); - } - } - } - static prepend(parentNode, ...nodes) { - const firstChild = parentNode.firstChild; - for (const node of nodes) { - if (node instanceof Node) { - parentNode.insertBefore(node, firstChild); - } else { - parentNode.insertBefore(parentNode[ownerDocument].createTextNode(String(node)), firstChild); - } - } - } - static replaceChildren(parentNode, ...nodes) { - const childNodes = parentNode[nodeArray]; - while (childNodes.length) { - parentNode.removeChild(childNodes[0]); - } - this.append(parentNode, ...nodes); - } - static getElementsByClassName(parentNode, className) { - return new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(parentNode, `.${className.replace(/\s+/gm, ".")}`)[items]); - } - static getElementsByTagName(parentNode, tagName2) { - const upperTagName = tagName2.toUpperCase(); - const includeAll = tagName2 === "*"; - const find = (parent, cachedResult) => { - const elements = []; - for (const element of parent[elementArray]) { - if (includeAll || element[tagName].toUpperCase() === upperTagName) { - elements.push(element); - } - element[affectsCache].push(cachedResult); - for (const foundElement of find(element, cachedResult)) { - elements.push(foundElement); - } - } - return elements; - }; - const query = () => { - const cache2 = parentNode[cache].elementsByTagName; - const cachedItems = cache2.get(tagName2); - if (cachedItems?.result) { - const items = cachedItems.result.deref(); - if (items) { - return items; - } - } - const cachedResult = { result: null }; - const items = find(parentNode, cachedResult); - cachedResult.result = new WeakRef(items); - cache2.set(tagName2, cachedResult); - return items; - }; - return new HTMLCollection(illegalConstructor, query); - } - static getElementsByTagNameNS(parentNode, namespaceURI2, tagName2) { - const formattedTagName = namespaceURI2 === NamespaceURI_default.html && parentNode[ownerDocument][contentType] === "text/html" ? tagName2.toUpperCase() : tagName2; - const includeAll = tagName2 === "*"; - const find = (parent, cachedResult) => { - const elements = []; - for (const element of parent[elementArray]) { - if ((includeAll || element[tagName] === formattedTagName) && element[namespaceURI] === namespaceURI2) { - elements.push(element); - } - element[affectsCache].push(cachedResult); - for (const foundElement of find(element, cachedResult)) { - elements.push(foundElement); - } - } - return elements; - }; - const query = () => { - const cache2 = parentNode[cache].elementsByTagNameNS; - const cachedItems = cache2.get(tagName2); - if (cachedItems?.result) { - const items = cachedItems.result.deref(); - if (items) { - return items; - } - } - const cachedResult = { result: null }; - const items = find(parentNode, cachedResult); - cachedResult.result = new WeakRef(items); - cache2.set(tagName2, cachedResult); - return items; - }; - return new HTMLCollection(illegalConstructor, query); - } - static getElementByTagName(parentNode, tagName2) { - const upperTagName = tagName2.toUpperCase(); - const find = (parent, cachedResult) => { - for (const element of parent[elementArray]) { - element[affectsCache].push(cachedResult); - if (element[tagName] === upperTagName) { - return element; - } - const foundElement = find(element, cachedResult); - if (foundElement) { - return foundElement; - } - } - return null; - }; - const cache2 = parentNode[cache].elementByTagName; - const cachedItem = cache2.get(tagName2); - if (cachedItem?.result) { - const item = cachedItem.result.deref(); - if (item) { - return item; - } - } - const cachedResult = { result: null }; - const item = find(parentNode, cachedResult); - cachedResult.result = item ? new WeakRef(item) : { deref: () => null }; - cache2.set(tagName2, cachedResult); - return item; - } - static getElementById(parentNode, id) { - id = String(id); - if (parentNode[nodeType] === Node.DOCUMENT_NODE) { - const entry = parentNode[elementIdMap].get(id); - if (entry && entry.elements.length > 0) { - return entry.elements[0]; - } - return null; - } - const find = (parent, cachedResult) => { - for (const element of parent[elementArray]) { - element[affectsCache].push(cachedResult); - if (element.getAttribute("id") === id) { - return element; - } - const foundElement = find(element, cachedResult); - if (foundElement) { - return foundElement; - } - } - return null; - }; - const cache2 = parentNode[cache].elementById; - const cachedItem = cache2.get(id); - if (cachedItem?.result) { - const item = cachedItem.result.deref(); - if (item) { - return item; - } - } - const cachedResult = { result: null }; - const item = find(parentNode, cachedResult); - cachedResult.result = item ? new WeakRef(item) : { deref: () => null }; - cache2.set(id, cachedResult); - return item; - } -} - -// node_modules/happy-dom/lib/dom/DOMRectList.js -class DOMRectList extends Array { - constructor(illegalConstructorSymbol) { - super(); - if (illegalConstructorSymbol !== 1 && illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - } - item(index) { - return this[index] ?? null; - } -} - -// node_modules/happy-dom/lib/nodes/element/NamedNodeMap.js -class NamedNodeMap { - [itemsByNamespaceURI] = new Map; - [itemsByName] = new Map; - [items] = new Map; - constructor(ownerElement2) { - this[ownerElement] = ownerElement2; - } - get length() { - return this[items].size; - } - get [Symbol.toStringTag]() { - return "NamedNodeMap"; - } - toString() { - return "[object NamedNodeMap]"; - } - [Symbol.iterator]() { - return this[items].values(); - } - item(index) { - const items2 = Array.from(this[items].values()); - return index >= 0 && items2[index] ? items2[index] : null; - } - getNamedItem(name) { - name = String(name); - if (this[ownerElement][namespaceURI] === NamespaceURI_default.html && this[ownerElement][ownerDocument][contentType] === "text/html") { - return this[itemsByName].get(StringUtility.asciiLowerCase(name))?.[0] || null; - } - return this[itemsByName].get(name)?.[0] || null; - } - getNamedItemNS(namespace, localName) { - const item = this[itemsByNamespaceURI].get(`${namespace || ""}:${localName}`); - if (item && (!item[prefix] || item[namespaceURI])) { - return item; - } - return null; - } - setNamedItem(item) { - return this[setNamedItem](item); - } - setNamedItemNS(item) { - return this[setNamedItem](item); - } - removeNamedItem(name) { - const item = this.getNamedItem(name); - if (!item) { - throw new this[ownerElement][window].DOMException(`Failed to execute 'removeNamedItem' on 'NamedNodeMap': No item with name '${name}' was found.`, DOMExceptionNameEnum_default.notFoundError); - } - this[removeNamedItem](item); - return item; - } - removeNamedItemNS(namespace, localName) { - const item = this.getNamedItemNS(namespace, localName); - if (!item) { - throw new this[ownerElement][window].DOMException(`Failed to execute 'removeNamedItemNS' on 'NamedNodeMap': No item with name '${localName}' in namespace '${namespace}' was found.`, DOMExceptionNameEnum_default.notFoundError); - } - this[removeNamedItem](item); - return item; - } - [setNamedItem](item, ignoreListeners = false) { - if (item[ownerElement] !== null && item[ownerElement] !== this[ownerElement]) { - throw new this[ownerElement][window].DOMException("The attribute is in use.", DOMExceptionNameEnum_default.inUseAttributeError); - } - item[ownerElement] = this[ownerElement]; - const replacedItem = this.getNamedItemNS(item[namespaceURI], item[localName]) || null; - const itemsByName2 = this[itemsByName].get(item[name]); - if (replacedItem === item) { - return item; - } - this[itemsByNamespaceURI].set(`${item[namespaceURI] || ""}:${item[localName]}`, item); - this[items].set(`${item[namespaceURI] || ""}:${item[name]}`, item); - if (!itemsByName2?.length) { - this[itemsByName].set(item[name], [item]); - } else { - const index = itemsByName2.indexOf(replacedItem); - if (index !== -1) { - itemsByName2.splice(index, 1); - } - itemsByName2.push(item); - } - if (!ignoreListeners) { - this[ownerElement][onSetAttribute](item, replacedItem); - } - return replacedItem; - } - [removeNamedItem](item, ignoreListeners = false) { - item[ownerElement] = null; - this[itemsByNamespaceURI].delete(`${item[namespaceURI] || ""}:${item[localName]}`); - this[items].delete(`${item[namespaceURI] || ""}:${item[name]}`); - const itemsByName2 = this[itemsByName].get(item[name]); - if (itemsByName2?.length) { - const index = itemsByName2.indexOf(item); - if (index !== -1) { - itemsByName2.splice(index, 1); - } - if (!itemsByName2.length) { - this[itemsByName].delete(item[name]); - } - } - if (!ignoreListeners) { - this[ownerElement][onRemoveAttribute](item); - } - } -} - -// node_modules/happy-dom/lib/nodes/element/NamedNodeMapProxyFactory.js -class NamedNodeMapProxyFactory { - static createProxy(namedNodeMap) { - const methodBinder = new ClassMethodBinder(this, [NamedNodeMap]); - return new Proxy(namedNodeMap, { - get: (target, property) => { - if (property === "length") { - return namedNodeMap[items].size; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target.item(index); - } - return target.getNamedItem(property) || undefined; - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys() { - const keys = Array.from(namedNodeMap[items].keys()); - for (let i = 0, max = namedNodeMap[items].size;i < max; i++) { - keys.push(String(i)); - } - return keys; - }, - has(target, property) { - if (typeof property === "symbol") { - return false; - } - if (property in target || namedNodeMap[items].has(property)) { - return true; - } - const index = Number(property); - if (!isNaN(index) && index >= 0 && index < namedNodeMap[items].size) { - return true; - } - return false; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - if (!isNaN(index)) { - if (index >= 0) { - const itemByIndex = target.item(index); - if (itemByIndex) { - return { - value: itemByIndex, - writable: false, - enumerable: true, - configurable: true - }; - } - } - return; - } - const items2 = namedNodeMap[items].get(property); - if (items2) { - return { - value: items2, - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } -} - -// node_modules/happy-dom/lib/config/HTMLElementConfigContentModelEnum.js -var HTMLElementConfigContentModelEnum; -(function(HTMLElementConfigContentModelEnum) { - HTMLElementConfigContentModelEnum["rawText"] = "rawText"; - HTMLElementConfigContentModelEnum["noSelfDescendants"] = "noSelfDescendants"; - HTMLElementConfigContentModelEnum["noFirstLevelSelfDescendants"] = "noFirstLevelSelfDescendants"; - HTMLElementConfigContentModelEnum["noForbiddenFirstLevelDescendants"] = "noForbiddenFirstLevelDescendants"; - HTMLElementConfigContentModelEnum["noDescendants"] = "noDescendants"; - HTMLElementConfigContentModelEnum["permittedDescendants"] = "permittedDescendants"; - HTMLElementConfigContentModelEnum["textOrComments"] = "textOrComments"; - HTMLElementConfigContentModelEnum["anyDescendants"] = "anyDescendants"; -})(HTMLElementConfigContentModelEnum || (HTMLElementConfigContentModelEnum = {})); -var HTMLElementConfigContentModelEnum_default = HTMLElementConfigContentModelEnum; - -// node_modules/happy-dom/lib/config/HTMLElementConfig.js -var HTMLElementConfig_default = { - a: { - className: "HTMLAnchorElement", - contentModel: HTMLElementConfigContentModelEnum_default.noSelfDescendants - }, - abbr: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - address: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - area: { - className: "HTMLAreaElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - article: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - aside: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - audio: { - className: "HTMLAudioElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - b: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - base: { - className: "HTMLBaseElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - bdi: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - bdo: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - body: { - className: "HTMLBodyElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - template: { - className: "HTMLTemplateElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - form: { - className: "HTMLFormElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - input: { - className: "HTMLInputElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - textarea: { - className: "HTMLTextAreaElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - script: { - className: "HTMLScriptElement", - contentModel: HTMLElementConfigContentModelEnum_default.rawText - }, - img: { - className: "HTMLImageElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - link: { - className: "HTMLLinkElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - style: { - className: "HTMLStyleElement", - contentModel: HTMLElementConfigContentModelEnum_default.rawText - }, - label: { - className: "HTMLLabelElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - slot: { - className: "HTMLSlotElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - meta: { - className: "HTMLMetaElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - blockquote: { - className: "HTMLQuoteElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - br: { - className: "HTMLBRElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - button: { - className: "HTMLButtonElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - canvas: { - className: "HTMLCanvasElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - caption: { - className: "HTMLTableCaptionElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["table", "tbody", "thead", "tfoot", "tr", "td", "th", "col", "colgroup"], - permittedParents: ["table"] - }, - cite: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - code: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - col: { - className: "HTMLTableColElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants, - permittedParents: ["colgroup"] - }, - colgroup: { - className: "HTMLTableColElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["col"] - }, - data: { - className: "HTMLDataElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - datalist: { - className: "HTMLDataListElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - dd: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["dt", "dd"] - }, - del: { - className: "HTMLModElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - details: { - className: "HTMLDetailsElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - dfn: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - dialog: { - className: "HTMLDialogElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - div: { - className: "HTMLDivElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - dl: { - className: "HTMLDListElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - dt: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["dt", "dd"] - }, - em: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - embed: { - className: "HTMLEmbedElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - fieldset: { - className: "HTMLFieldSetElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - figcaption: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - figure: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - footer: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - h1: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - h2: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - h3: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - h4: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - h5: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - h6: { - className: "HTMLHeadingElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - head: { - className: "HTMLHeadElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - header: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - hgroup: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - hr: { - className: "HTMLHRElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - html: { - className: "HTMLHtmlElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - i: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - iframe: { - className: "HTMLIFrameElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - ins: { - className: "HTMLModElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - kbd: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - legend: { - className: "HTMLLegendElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - li: { - className: "HTMLLIElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - main: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - map: { - className: "HTMLMapElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - mark: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - menu: { - className: "HTMLMenuElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - meter: { - className: "HTMLMeterElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - nav: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - noscript: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - object: { - className: "HTMLObjectElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - ol: { - className: "HTMLOListElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - optgroup: { - className: "HTMLOptGroupElement", - contentModel: HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants - }, - option: { - className: "HTMLOptionElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["option", "optgroup"] - }, - output: { - className: "HTMLOutputElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - p: { - className: "HTMLParagraphElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: [ - "address", - "article", - "aside", - "blockquote", - "details", - "dialog", - "div", - "dl", - "fieldset", - "figcaption", - "figure", - "footer", - "form", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "header", - "hgroup", - "hr", - "main", - "menu", - "nav", - "ol", - "p", - "pre", - "section", - "table", - "ul" - ] - }, - param: { - className: "HTMLParamElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - picture: { - className: "HTMLPictureElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - pre: { - className: "HTMLPreElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - progress: { - className: "HTMLProgressElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - q: { - className: "HTMLQuoteElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - rb: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - rp: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["rp", "rt"] - }, - rt: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["rp", "rt"] - }, - rtc: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - ruby: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - s: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - samp: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - section: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - select: { - className: "HTMLSelectElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - small: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - source: { - className: "HTMLSourceElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - span: { - className: "HTMLSpanElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - strong: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - sub: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - summary: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - sup: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - table: { - className: "HTMLTableElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["caption", "colgroup", "thead", "tfoot", "tbody"], - moveForbiddenDescendant: { exclude: [] } - }, - tbody: { - className: "HTMLTableSectionElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["tr"], - permittedParents: ["table"], - moveForbiddenDescendant: { exclude: ["caption", "colgroup", "thead", "tfoot", "tbody"] } - }, - td: { - className: "HTMLTableCellElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["td", "th", "tr", "tbody", "tfoot", "thead"], - permittedParents: ["tr"] - }, - tfoot: { - className: "HTMLTableSectionElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["tr"], - permittedParents: ["table"], - moveForbiddenDescendant: { exclude: ["caption", "colgroup", "thead", "tfoot", "tbody"] } - }, - th: { - className: "HTMLTableCellElement", - contentModel: HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants, - forbiddenDescendants: ["td", "th", "tr", "tbody", "tfoot", "thead"], - permittedParents: ["tr"] - }, - thead: { - className: "HTMLTableSectionElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["tr"], - permittedParents: ["table"], - moveForbiddenDescendant: { exclude: ["caption", "colgroup", "thead", "tfoot", "tbody"] } - }, - time: { - className: "HTMLTimeElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - title: { - className: "HTMLTitleElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - tr: { - className: "HTMLTableRowElement", - contentModel: HTMLElementConfigContentModelEnum_default.permittedDescendants, - permittedDescendants: ["td", "th"], - permittedParents: ["tbody", "tfoot", "thead"], - addPermittedParent: "tbody", - moveForbiddenDescendant: { exclude: ["caption", "colgroup", "thead", "tfoot", "tbody", "tr"] } - }, - track: { - className: "HTMLTrackElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - }, - u: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - ul: { - className: "HTMLUListElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - var: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - video: { - className: "HTMLVideoElement", - contentModel: HTMLElementConfigContentModelEnum_default.anyDescendants - }, - wbr: { - className: "HTMLElement", - contentModel: HTMLElementConfigContentModelEnum_default.noDescendants - } -}; - -// node_modules/entities/dist/esm/decode-codepoint.js -var _a; -var decodeMap = new Map([ - [0, 65533], - [128, 8364], - [130, 8218], - [131, 402], - [132, 8222], - [133, 8230], - [134, 8224], - [135, 8225], - [136, 710], - [137, 8240], - [138, 352], - [139, 8249], - [140, 338], - [142, 381], - [145, 8216], - [146, 8217], - [147, 8220], - [148, 8221], - [149, 8226], - [150, 8211], - [151, 8212], - [152, 732], - [153, 8482], - [154, 353], - [155, 8250], - [156, 339], - [158, 382], - [159, 376] -]); -var fromCodePoint = (_a = String.fromCodePoint) !== null && _a !== undefined ? _a : (codePoint) => { - let output = ""; - if (codePoint > 65535) { - codePoint -= 65536; - output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296); - codePoint = 56320 | codePoint & 1023; - } - output += String.fromCharCode(codePoint); - return output; -}; -function replaceCodePoint(codePoint) { - var _a; - if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) { - return 65533; - } - return (_a = decodeMap.get(codePoint)) !== null && _a !== undefined ? _a : codePoint; -} - -// node_modules/entities/dist/esm/internal/decode-shared.js -function decodeBase64(input) { - const binary = typeof atob === "function" ? atob(input) : typeof Buffer.from === "function" ? Buffer.from(input, "base64").toString("binary") : new Buffer(input, "base64").toString("binary"); - const evenLength = binary.length & ~1; - const out = new Uint16Array(evenLength / 2); - for (let index = 0, outIndex = 0;index < evenLength; index += 2) { - const lo = binary.charCodeAt(index); - const hi = binary.charCodeAt(index + 1); - out[outIndex++] = lo | hi << 8; - } - return out; -} - -// node_modules/entities/dist/esm/generated/decode-data-html.js -var htmlDecodeTree = /* @__PURE__ */ decodeBase64("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZABlADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcwCgLCFhAJJjcgAA4DXYBd1wAGYAAOA12Dnd5SF2ZdhiYwDyAOoAbSJwZXEAAKBOIgAHSE9hY2RlZmhpbG9yc3UXARoBHwE6AVIBVQFiAWQBZgGCAakB6QHtAfIBYwB5ACdkUABZADuAqQCpQIABY3B5ACUBKAE1AfUhdGUGYWmg0iJ0KGFsRGlmZmVyZW50aWFsRAAAoEUhbCJleXMAAKAtIQACYWVpb0EBRAFKAU0B8iFvbgxhZABpAGwAO4DHAMdAcgBjAAhhbiJpbnQAAKAwIm8AdAAKYQABZG5ZAV0BaSJsbGEAuGB0I2VyRG90ALdg8gA5AWkAp2NyImNsZQAAAkRNUFRwAXQBeQF9AW8AdAAAoJkiaSJudXMAAKCWIuwhdXMAoJUiaSJtZXMAAKCXIm8AAAFjc4cBlAFrKndpc2VDb250b3VySW50ZWdyYWwAAKAyImUjQ3VybHkAAAFEUZwBpAFvJXVibGVRdW90ZQAAoB0gdSJvdGUAAKAZIAACbG5wdbABtgHNAdgBbwBuAGWgNyIAoHQqgAFnaXQAvAHBAcUB8iJ1ZW50AKBhIm4AdAAAoC8i7yV1ckludGVncmFsAKAuIgABZnLRAdMBAKACIe8iZHVjdACgECJuLnRlckNsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbAAAoDMi7yFzcwCgLypjAHIAAOA12J7ccABDoNMiYQBwAACgTSKABURKU1phY2VmaW9zAAsCEgIVAhgCGwIsAjQCOQI9AnMCfwNvoEUh9CJyYWhkAKARKWMAeQACZGMAeQAFZGMAeQAPZIABZ3JzACECJQIoAuchZXIAoCEgcgAAoKEhaAB2AACg5CoAAWF5MAIzAvIhb24OYRRkbAB0oAciYQCUY3IAAOA12AfdAAFhZkECawIAAWNtRQJnAvIjaXRpY2FsAAJBREdUUAJUAl8CYwJjInV0ZQC0YG8AdAFZAloC2WJiJGxlQWN1dGUA3WJyImF2ZQBgYGkibGRlANxi7yFuZACgxCJmJWVyZW50aWFsRAAAoEYhcAR9AgAAAAAAAIECjgIAABoDZgAA4DXYO91EoagAhQKJAm8AdAAAoNwgcSJ1YWwAAKBQIuIhbGUAA0NETFJVVpkCqAK1Au8C/wIRA28AbgB0AG8AdQByAEkAbgB0AGUAZwByAGEA7ADEAW8AdAKvAgAAAACwAqhgbiNBcnJvdwAAoNMhAAFlb7kC0AJmAHQAgAFBUlQAwQLGAs0CciJyb3cAAKDQIekkZ2h0QXJyb3cAoNQhZQDlACsCbgBnAAABTFLWAugC5SFmdAABQVLcAuECciJyb3cAAKD4J+kkZ2h0QXJyb3cAoPon6SRnaHRBcnJvdwCg+SdpImdodAAAAUFU9gL7AnIicm93AACg0iFlAGUAAKCoInAAQQIGAwAAAAALA3Iicm93AACg0SFvJHduQXJyb3cAAKDVIWUlcnRpY2FsQmFyAACgJSJuAAADQUJMUlRhJAM2AzoDWgNxA3oDciJyb3cAAKGTIUJVLAMwA2EAcgAAoBMpcCNBcnJvdwAAoPUhciJldmUAEWPlIWZ00gJDAwAASwMAAFIDaSVnaHRWZWN0b3IAAKBQKWUkZVZlY3RvcgAAoF4p5SJjdG9yQqC9IWEAcgAAoFYpaSJnaHQA1AFiAwAAaQNlJGVWZWN0b3IAAKBfKeUiY3RvckKgwSFhAHIAAKBXKWUAZQBBoKQiciJyb3cAAKCnIXIAcgBvAPcAtAIAAWN0gwOHA3IAAOA12J/c8iFvaxBhAAhOVGFjZGZnbG1vcHFzdHV4owOlA6kDsAO/A8IDxgPNA9ID8gP9AwEEFAQeBCAEJQRHAEphSAA7gNAA0EBjAHUAdABlADuAyQDJQIABYWl5ALYDuQO+A/Ihb24aYXIAYwA7gMoAykAtZG8AdAAWYXIAAOA12AjdcgBhAHYAZQA7gMgAyEDlIm1lbnQAoAgiAAFhcNYD2QNjAHIAEmF0AHkAUwLhAwAAAADpA20lYWxsU3F1YXJlAACg+yVlJ3J5U21hbGxTcXVhcmUAAKCrJQABZ3D2A/kDbwBuABhhZgAA4DXYPN3zImlsb26VY3UAAAFhaQYEDgRsAFSgdSppImxkZQAAoEIi7CNpYnJpdW0AoMwhAAFjaRgEGwRyAACgMCFtAACgcyphAJdjbQBsADuAywDLQAABaXApBC0E8yF0cwCgAyLvJG5lbnRpYWxFAKBHIYACY2Zpb3MAPQQ/BEMEXQRyBHkAJGRyAADgNdgJ3WwibGVkAFMCTAQAAAAAVARtJWFsbFNxdWFyZQAAoPwlZSdyeVNtYWxsU3F1YXJlAACgqiVwA2UEAABpBAAAAABtBGYAAOA12D3dwSFsbACgACLyI2llcnRyZgCgMSFjAPIAcQQABkpUYWJjZGZnb3JzdIgEiwSOBJMElwSkBKcEqwStBLIE5QTqBGMAeQADZDuAPgA+QO0hbWFkoJMD3GNyImV2ZQAeYYABZWl5AJ0EoASjBOQhaWwiYXIAYwAcYRNkbwB0ACBhcgAA4DXYCt0AoNkicABmAADgNdg+3eUiYXRlcgADRUZHTFNUvwTIBM8E1QTZBOAEcSJ1YWwATKBlIuUhc3MAoNsidSRsbEVxdWFsAACgZyJyI2VhdGVyAACgoirlIXNzAKB3IuwkYW50RXF1YWwAoH4qaSJsZGUAAKBzImMAcgAA4DXYotwAoGsiAARBYWNmaW9zdfkE/QQFBQgFCwUTBSIFKwVSIkRjeQAqZAABY3QBBQQFZQBrAMdiXmDpIXJjJGFyAACgDCFsJWJlcnRTcGFjZQAAoAsh8AEYBQAAGwVmAACgDSHpJXpvbnRhbExpbmUAoAAlAAFjdCYFKAXyABIF8iFvayZhbQBwAEQBMQU5BW8AdwBuAEgAdQBtAPAAAAFxInVhbAAAoE8iAAdFSk9hY2RmZ21ub3N0dVMFVgVZBVwFYwVtBXAFcwV6BZAFtgXFBckFzQVjAHkAFWTsIWlnMmFjAHkAAWRjAHUAdABlADuAzQDNQAABaXlnBWwFcgBjADuAzgDOQBhkbwB0ADBhcgAAoBEhcgBhAHYAZQA7gMwAzEAAoREhYXB/BYsFAAFjZ4MFhQVyACphaSNuYXJ5SQAAoEghbABpAGUA8wD6AvQBlQUAAKUFZaAsIgABZ3KaBZ4F8iFhbACgKyLzI2VjdGlvbgCgwiJpI3NpYmxlAAABQ1SsBbEFbyJtbWEAAKBjIGkibWVzAACgYiCAAWdwdAC8Bb8FwwVvAG4ALmFmAADgNdhA3WEAmWNjAHIAAKAQIWkibGRlAChh6wHSBQAA1QVjAHkABmRsADuAzwDPQIACY2Zvc3UA4QXpBe0F8gX9BQABaXnlBegFcgBjADRhGWRyAADgNdgN3XAAZgAA4DXYQd3jAfcFAAD7BXIAAOA12KXc8iFjeQhk6yFjeQRkgANISmFjZm9zAAwGDwYSBhUGHQYhBiYGYwB5ACVkYwB5AAxk8CFwYZpjAAFleRkGHAbkIWlsNmEaZHIAAOA12A7dcABmAADgNdhC3WMAcgAA4DXYptyABUpUYWNlZmxtb3N0AD0GQAZDBl4GawZkB2gHcAd0B80H2gdjAHkACWQ7gDwAPECAAmNtbnByAEwGTwZSBlUGWwb1IXRlOWHiIWRhm2NnAACg6ifsI2FjZXRyZgCgEiFyAACgniGAAWFleQBkBmcGagbyIW9uPWHkIWlsO2EbZAABZnNvBjQHdAAABUFDREZSVFVWYXKABp4GpAbGBssG3AYDByEHwQIqBwABbnKEBowGZyVsZUJyYWNrZXQAAKDoJ/Ihb3cAoZAhQlKTBpcGYQByAACg5CHpJGdodEFycm93AKDGIWUjaWxpbmcAAKAII28A9QGqBgAAsgZiJWxlQnJhY2tldAAAoOYnbgDUAbcGAAC+BmUkZVZlY3RvcgAAoGEp5SJjdG9yQqDDIWEAcgAAoFkpbCJvb3IAAKAKI2kiZ2h0AAABQVbSBtcGciJyb3cAAKCUIeUiY3RvcgCgTikAAWVy4AbwBmUAAKGjIkFW5gbrBnIicm93AACgpCHlImN0b3IAoFopaSNhbmdsZQBCorIi+wYAAAAA/wZhAHIAAKDPKXEidWFsAACgtCJwAIABRFRWAAoHEQcYB+8kd25WZWN0b3IAoFEpZSRlVmVjdG9yAACgYCnlImN0b3JCoL8hYQByAACgWCnlImN0b3JCoLwhYQByAACgUilpAGcAaAB0AGEAcgByAG8A9wDMAnMAAANFRkdMU1Q/B0cHTgdUB1gHXwfxJXVhbEdyZWF0ZXIAoNoidSRsbEVxdWFsAACgZiJyI2VhdGVyAACgdiLlIXNzAKChKuwkYW50RXF1YWwAoH0qaSJsZGUAAKByInIAAOA12A/dZaDYIuYjdGFycm93AKDaIWkiZG90AD9hgAFucHcAege1B7kHZwAAAkxSbHKCB5QHmwerB+UhZnQAAUFSiAeNB3Iicm93AACg9SfpJGdodEFycm93AKD3J+kkZ2h0QXJyb3cAoPYn5SFmdAABYXLcAqEHaQBnAGgAdABhAHIAcgBvAPcA5wJpAGcAaAB0AGEAcgByAG8A9wDuAmYAAOA12EPdZQByAAABTFK/B8YHZSRmdEFycm93AACgmSHpJGdodEFycm93AKCYIYABY2h0ANMH1QfXB/IAWgYAoLAh8iFva0FhAKBqIgAEYWNlZmlvc3XpB+wH7gf/BwMICQgOCBEIcAAAoAUpeQAcZAABZGzyB/kHaSR1bVNwYWNlAACgXyBsI2ludHJmAACgMyFyAADgNdgQ3e4jdXNQbHVzAKATInAAZgAA4DXYRN1jAPIA/gecY4AESmFjZWZvc3R1ACEIJAgoCDUIgQiFCDsKQApHCmMAeQAKZGMidXRlAENhgAFhZXkALggxCDQI8iFvbkdh5CFpbEVhHWSAAWdzdwA7CGEIfQjhInRpdmWAAU1UVgBECEwIWQhlJWRpdW1TcGFjZQAAoAsgaABpAAABY25SCFMIawBTAHAAYQBjAOUASwhlAHIAeQBUAGgAaQDuAFQI9CFlZAABR0xnCHUIcgBlAGEAdABlAHIARwByAGUAYQB0AGUA8gDrBGUAcwBzAEwAZQBzAPMA2wdMImluZQAKYHIAAOA12BHdAAJCbnB0jAiRCJkInAhyImVhawAAoGAgwiZyZWFraW5nU3BhY2WgYGYAAKAVIUOq7CqzCMIIzQgAAOcIGwkAAAAAAAAtCQAAbwkAAIcJAACdCcAJGQoAADQKAAFvdbYIvAjuI2dydWVudACgYiJwIkNhcAAAoG0ibyh1YmxlVmVydGljYWxCYXIAAKAmIoABbHF4ANII1wjhCOUibWVudACgCSL1IWFsVKBgImkibGRlAADgQiI4A2kic3RzAACgBCJyI2VhdGVyAACjbyJFRkdMU1T1CPoIAgkJCQ0JFQlxInVhbAAAoHEidSRsbEVxdWFsAADgZyI4A3IjZWF0ZXIAAOBrIjgD5SFzcwCgeSLsJGFudEVxdWFsAOB+KjgDaSJsZGUAAKB1IvUhbXBEASAJJwnvI3duSHVtcADgTiI4A3EidWFsAADgTyI4A2UAAAFmczEJRgn0JFRyaWFuZ2xlQqLqIj0JAAAAAEIJYQByAADgzyk4A3EidWFsAACg7CJzAICibiJFR0xTVABRCVYJXAlhCWkJcSJ1YWwAAKBwInIjZWF0ZXIAAKB4IuUhc3MA4GoiOAPsJGFudEVxdWFsAOB9KjgDaSJsZGUAAKB0IuUic3RlZAABR0x1CX8J8iZlYXRlckdyZWF0ZXIA4KIqOAPlI3NzTGVzcwDgoSo4A/IjZWNlZGVzAKGAIkVTjwmVCXEidWFsAADgryo4A+wkYW50RXF1YWwAoOAiAAFlaaAJqQl2JmVyc2VFbGVtZW50AACgDCLnJWh0VHJpYW5nbGVCousitgkAAAAAuwlhAHIAAODQKTgDcSJ1YWwAAKDtIgABcXXDCeAJdSNhcmVTdQAAAWJwywnVCfMhZXRF4I8iOANxInVhbAAAoOIi5SJyc2V0ReCQIjgDcSJ1YWwAAKDjIoABYmNwAOYJ8AkNCvMhZXRF4IIi0iBxInVhbAAAoIgi4yJlZWRzgKGBIkVTVAD6CQAKBwpxInVhbAAA4LAqOAPsJGFudEVxdWFsAKDhImkibGRlAADgfyI4A+UicnNldEXggyLSIHEidWFsAACgiSJpImxkZQCAoUEiRUZUACIKJwouCnEidWFsAACgRCJ1JGxsRXF1YWwAAKBHImkibGRlAACgSSJlJXJ0aWNhbEJhcgAAoCQiYwByAADgNdip3GkAbABkAGUAO4DRANFAnWMAB0VhY2RmZ21vcHJzdHV2XgphCmgKcgp2CnoKgQqRCpYKqwqtCrsKyArNCuwhaWdSYWMAdQB0AGUAO4DTANNAAAFpeWwKcQpyAGMAO4DUANRAHmRiImxhYwBQYXIAAOA12BLdcgBhAHYAZQA7gNIA0kCAAWFlaQCHCooKjQpjAHIATGFnAGEAqWNjInJvbgCfY3AAZgAA4DXYRt3lI25DdXJseQABRFGeCqYKbyV1YmxlUXVvdGUAAKAcIHUib3RlAACgGCAAoFQqAAFjbLEKtQpyAADgNdiq3GEAcwBoADuA2ADYQGkAbAHACsUKZABlADuA1QDVQGUAcwAAoDcqbQBsADuA1gDWQGUAcgAAAUJQ0wrmCgABYXLXCtoKcgAAoD4gYQBjAAABZWvgCuIKAKDeI2UAdAAAoLQjYSVyZW50aGVzaXMAAKDcI4AEYWNmaGlsb3JzAP0KAwsFCwkLCwsMCxELIwtaC3IjdGlhbEQAAKACInkAH2RyAADgNdgT3WkApmOgY/Ujc01pbnVzsWAAAWlwFQsgC24AYwBhAHIAZQBwAGwAYQBuAOUACgVmAACgGSGAobsqZWlvACoLRQtJC+MiZWRlc4CheiJFU1QANAs5C0ALcSJ1YWwAAKCvKuwkYW50RXF1YWwAoHwiaSJsZGUAAKB+Im0AZQAAoDMgAAFkcE0LUQv1IWN0AKAPIm8jcnRpb24AYaA3ImwAAKAdIgABY2leC2ILcgAA4DXYq9yoYwACVWZvc2oLbwtzC3cLTwBUADuAIgAiQHIAAOA12BTdcABmAACgGiFjAHIAAOA12KzcAAZCRWFjZWZoaW9yc3WPC5MLlwupC7YL2AvbC90LhQyTDJoMowzhIXJyAKAQKUcAO4CuAK5AgAFjbnIAnQugC6ML9SF0ZVRhZwAAoOsncgB0oKAhbAAAoBYpgAFhZXkArwuyC7UL8iFvblhh5CFpbFZhIGR2oBwhZSJyc2UAAAFFVb8LzwsAAWxxwwvIC+UibWVudACgCyL1JGlsaWJyaXVtAKDLIXAmRXF1aWxpYnJpdW0AAKBvKXIAAKAcIW8AoWPnIWh0AARBQ0RGVFVWYewLCgwQDDIMNwxeDHwM9gIAAW5y8Av4C2clbGVCcmFja2V0AACg6SfyIW93AKGSIUJM/wsDDGEAcgAAoOUhZSRmdEFycm93AACgxCFlI2lsaW5nAACgCSNvAPUBFgwAAB4MYiVsZUJyYWNrZXQAAKDnJ24A1AEjDAAAKgxlJGVWZWN0b3IAAKBdKeUiY3RvckKgwiFhAHIAAKBVKWwib29yAACgCyMAAWVyOwxLDGUAAKGiIkFWQQxGDHIicm93AACgpiHlImN0b3IAoFspaSNhbmdsZQBCorMiVgwAAAAAWgxhAHIAAKDQKXEidWFsAACgtSJwAIABRFRWAGUMbAxzDO8kd25WZWN0b3IAoE8pZSRlVmVjdG9yAACgXCnlImN0b3JCoL4hYQByAACgVCnlImN0b3JCoMAhYQByAACgUykAAXB1iQyMDGYAAKAdIe4kZEltcGxpZXMAoHAp6SRnaHRhcnJvdwCg2yEAAWNongyhDHIAAKAbIQCgsSHsJGVEZWxheWVkAKD0KYAGSE9hY2ZoaW1vcXN0dQC/DMgMzAzQDOIM5gwKDQ0NFA0ZDU8NVA1YDQABQ2PDDMYMyCFjeSlkeQAoZEYiVGN5ACxkYyJ1dGUAWmEAorwqYWVpedgM2wzeDOEM8iFvbmBh5CFpbF5hcgBjAFxhIWRyAADgNdgW3e8hcnQAAkRMUlXvDPYM/QwEDW8kd25BcnJvdwAAoJMhZSRmdEFycm93AACgkCHpJGdodEFycm93AKCSIXAjQXJyb3cAAKCRIechbWGjY+EkbGxDaXJjbGUAoBgicABmAADgNdhK3XICHw0AAAAAIg10AACgGiLhIXJlgKGhJUlTVQAqDTINSg3uJXRlcnNlY3Rpb24AoJMidQAAAWJwNw1ADfMhZXRFoI8icSJ1YWwAAKCRIuUicnNldEWgkCJxInVhbAAAoJIibiJpb24AAKCUImMAcgAA4DXYrtxhAHIAAKDGIgACYmNtcF8Nag2ODZANc6DQImUAdABFoNAicSJ1YWwAAKCGIgABY2huDYkNZSJlZHMAgKF7IkVTVAB4DX0NhA1xInVhbAAAoLAq7CRhbnRFcXVhbACgfSJpImxkZQAAoH8iVABoAGEA9ADHCwCgESIAodEiZXOVDZ8NciJzZXQARaCDInEidWFsAACghyJlAHQAAKDRIoAFSFJTYWNmaGlvcnMAtQ27Db8NyA3ODdsN3w3+DRgOHQ4jDk8AUgBOADuA3gDeQMEhREUAoCIhAAFIY8MNxg1jAHkAC2R5ACZkAAFidcwNzQ0JYKRjgAFhZXkA1A3XDdoN8iFvbmRh5CFpbGJhImRyAADgNdgX3QABZWnjDe4N8gHoDQAA7Q3lImZvcmUAoDQiYQCYYwABY27yDfkNayNTcGFjZQAA4F8gCiDTInBhY2UAoAkg7CFkZYChPCJFRlQABw4MDhMOcSJ1YWwAAKBDInUkbGxFcXVhbAAAoEUiaSJsZGUAAKBIInAAZgAA4DXYS93pI3BsZURvdACg2yAAAWN0Jw4rDnIAAOA12K/c8iFva2Zh4QpFDlYOYA5qDgAAbg5yDgAAAAAAAAAAAAB5DnwOqA6zDgAADg8RDxYPGg8AAWNySA5ODnUAdABlADuA2gDaQHIAb6CfIeMhaXIAoEkpcgDjAVsOAABdDnkADmR2AGUAbGEAAWl5Yw5oDnIAYwA7gNsA20AjZGIibGFjAHBhcgAA4DXYGN1yAGEAdgBlADuA2QDZQOEhY3JqYQABZGl/Dp8OZQByAAABQlCFDpcOAAFhcokOiw5yAF9gYQBjAAABZWuRDpMOAKDfI2UAdAAAoLUjYSVyZW50aGVzaXMAAKDdI28AbgBQoMMi7CF1cwCgjiIAAWdwqw6uDm8AbgByYWYAAOA12EzdAARBREVUYWRwc78O0g7ZDuEOBQPqDvMOBw9yInJvdwDCoZEhyA4AAMwOYQByAACgEilvJHduQXJyb3cAAKDFIW8kd25BcnJvdwAAoJUhcSV1aWxpYnJpdW0AAKBuKWUAZQBBoKUiciJyb3cAAKClIW8AdwBuAGEAcgByAG8A9wAQA2UAcgAAAUxS+Q4AD2UkZnRBcnJvdwAAoJYh6SRnaHRBcnJvdwCglyFpAGyg0gNvAG4ApWPpIW5nbmFjAHIAAOA12LDcaSJsZGUAaGFtAGwAO4DcANxAgAREYmNkZWZvc3YALQ8xDzUPNw89D3IPdg97D4AP4SFzaACgqyJhAHIAAKDrKnkAEmThIXNobKCpIgCg5ioAAWVyQQ9DDwCgwSKAAWJ0eQBJD00Paw9hAHIAAKAWIGmgFiDjIWFsAAJCTFNUWA9cD18PZg9hAHIAAKAjIukhbmV8YGUkcGFyYXRvcgAAoFgnaSJsZGUAAKBAItQkaGluU3BhY2UAoAogcgAA4DXYGd1wAGYAAOA12E3dYwByAADgNdix3GQiYXNoAACgqiKAAmNlZm9zAI4PkQ+VD5kPng/pIXJjdGHkIWdlAKDAInIAAOA12BrdcABmAADgNdhO3WMAcgAA4DXYstwAAmZpb3OqD64Prw+0D3IAAOA12BvdnmNwAGYAAOA12E/dYwByAADgNdiz3IAEQUlVYWNmb3N1AMgPyw/OD9EP2A/gD+QP6Q/uD2MAeQAvZGMAeQAHZGMAeQAuZGMAdQB0AGUAO4DdAN1AAAFpedwP3w9yAGMAdmErZHIAAOA12BzdcABmAADgNdhQ3WMAcgAA4DXYtNxtAGwAeGEABEhhY2RlZm9z/g8BEAUQDRAQEB0QIBAkEGMAeQAWZGMidXRlAHlhAAFheQkQDBDyIW9ufWEXZG8AdAB7YfIBFRAAABwQbwBXAGkAZAB0AOgAVAhhAJZjcgAAoCghcABmAACgJCFjAHIAAOA12LXc4QtCEEkQTRAAAGcQbRByEAAAAAAAAAAAeRCKEJcQ8hD9EAAAGxEhETIROREAAD4RYwB1AHQAZQA7gOEA4UByImV2ZQADYYCiPiJFZGl1eQBWEFkQWxBgEGUQAOA+IjMDAKA/InIAYwA7gOIA4kB0AGUAO4C0ALRAMGRsAGkAZwA7gOYA5kByoGEgAOA12B7dcgBhAHYAZQA7gOAA4EAAAWVwfBCGEAABZnCAEIQQ8yF5bQCgNSHoAIMQaABhALFjAAFhcI0QWwAAAWNskRCTEHIAAWFnAACgPypkApwQAAAAALEQAKInImFkc3ajEKcQqRCuEG4AZAAAoFUqAKBcKmwib3BlAACgWCoAoFoqAKMgImVsbXJzersQvRDAEN0Q5RDtEACgpCllAACgICJzAGQAYaAhImEEzhDQENIQ1BDWENgQ2hDcEACgqCkAoKkpAKCqKQCgqykAoKwpAKCtKQCgrikAoK8pdAB2oB8iYgBkoL4iAKCdKQABcHTpEOwQaAAAoCIixWDhIXJyAKB8IwABZ3D1EPgQbwBuAAVhZgAA4DXYUt0Ao0giRWFlaW9wBxEJEQ0RDxESERQRAKBwKuMhaXIAoG8qAKBKImQAAKBLInMAJ2DyIW94ZaBIIvEADhFpAG4AZwA7gOUA5UCAAWN0eQAmESoRKxFyAADgNdi23CpgbQBwAGWgSCLxAPgBaQBsAGQAZQA7gOMA40BtAGwAO4DkAORAAAFjaUERRxFvAG4AaQBuAPQA6AFuAHQAAKARKgAITmFiY2RlZmlrbG5vcHJzdWQRaBGXEZ8RpxGrEdIR1hErEjASexKKEn0RThNbE3oTbwB0AACg7SoAAWNybBGJEWsAAAJjZXBzdBF4EX0RghHvIW5nAKBMInAjc2lsb24A9mNyImltZQAAoDUgaQBtAGWgPSJxAACgzSJ2AY0RkRFlAGUAAKC9ImUAZABnoAUjZQAAoAUjcgBrAHSgtSPiIXJrAKC2IwABb3mjEaYRbgDnAHcRMWTxIXVvAKAeIIACY21wcnQAtBG5Eb4RwRHFEeEhdXPloDUi5ABwInR5dgAAoLApcwDpAH0RbgBvAPUA6gCAAWFodwDLEcwRzhGyYwCgNiHlIWVuAKBsInIAAOA12B/dZwCAA2Nvc3R1dncA4xHyEQUSEhIhEiYSKRKAAWFpdQDpEesR7xHwAKMFcgBjAACg7yVwAACgwyKAAWRwdAD4EfwRABJvAHQAAKAAKuwhdXMAoAEqaSJtZXMAAKACKnECCxIAAAAADxLjIXVwAKAGKmEAcgAAoAUm8iNpYW5nbGUAAWR1GhIeEu8hd24AoL0lcAAAoLMlcCJsdXMAAKAEKmUA5QBCD+UAkg9hInJvdwAAoA0pgAFha28ANhJoEncSAAFjbjoSZRJrAIABbHN0AEESRxJNEm8jemVuZ2UAAKDrKXEAdQBhAHIA5QBcBPIjaWFuZ2xlgKG0JWRscgBYElwSYBLvIXduAKC+JeUhZnQAoMIlaSJnaHQAAKC4JWsAAKAjJLEBbRIAAHUSsgFxEgAAcxIAoJIlAKCRJTQAAKCTJWMAawAAoIglAAFlb38ShxJx4D0A5SD1IWl2AOBhIuUgdAAAoBAjAAJwdHd4kRKVEpsSnxJmAADgNdhT3XSgpSJvAG0AAKClIvQhaWUAoMgiAAZESFVWYmRobXB0dXayEsES0RLgEvcS+xIKExoTHxMjEygTNxMAAkxSbHK5ErsSvRK/EgCgVyUAoFQlAKBWJQCgUyUAolAlRFVkdckSyxLNEs8SAKBmJQCgaSUAoGQlAKBnJQACTFJsctgS2hLcEt4SAKBdJQCgWiUAoFwlAKBZJQCjUSVITFJobHLrEu0S7xLxEvMS9RIAoGwlAKBjJQCgYCUAoGslAKBiJQCgXyVvAHgAAKDJKQACTFJscgITBBMGEwgTAKBVJQCgUiUAoBAlAKAMJQCiACVEVWR1EhMUExYTGBMAoGUlAKBoJQCgLCUAoDQlaSJudXMAAKCfIuwhdXMAoJ4iaSJtZXMAAKCgIgACTFJsci8TMRMzEzUTAKBbJQCgWCUAoBglAKAUJQCjAiVITFJobHJCE0QTRhNIE0oTTBMAoGolAKBhJQCgXiUAoDwlAKAkJQCgHCUAAWV2UhNVE3YA5QD5AGIAYQByADuApgCmQAACY2Vpb2ITZhNqE24TcgAA4DXYt9xtAGkAAKBPIG0A5aA9IogRbAAAoVwAYmh0E3YTAKDFKfMhdWIAoMgnbAF+E4QTbABloCIgdAAAoCIgcAAAoU4iRWWJE4sTAKCuKvGgTyI8BeEMqRMAAN8TABQDFB8UAAAjFDQUAAAAAIUUAAAAAI0UAAAAANcU4xT3FPsUAACIFQAAlhWAAWNwcgCuE7ET1RP1IXRlB2GAoikiYWJjZHMAuxO/E8QTzhPSE24AZAAAoEQqciJjdXAAAKBJKgABYXXIE8sTcAAAoEsqcAAAoEcqbwB0AACgQCoA4CkiAP4AAWVv2RPcE3QAAKBBIO4ABAUAAmFlaXXlE+8T9RP4E/AB6hMAAO0TcwAAoE0qbwBuAA1hZABpAGwAO4DnAOdAcgBjAAlhcABzAHOgTCptAACgUCpvAHQAC2GAAWRtbgAIFA0UEhRpAGwAO4C4ALhAcCJ0eXYAAKCyKXQAAIGiADtlGBQZFKJAcgBkAG8A9ABiAXIAAOA12CDdgAFjZWkAKBQqFDIUeQBHZGMAawBtoBMn4SFyawCgEyfHY3IAAKPLJUVjZWZtcz8UQRRHFHcUfBSAFACgwykAocYCZWxGFEkUcQAAoFciZQBhAlAUAAAAAGAUciJyb3cAAAFsclYUWhTlIWZ0AKC6IWkiZ2h0AACguyGAAlJTYWNkAGgUaRRrFG8UcxSuYACgyCRzAHQAAKCbIukhcmMAoJoi4SFzaACgnSJuImludAAAoBAqaQBkAACg7yrjIWlyAKDCKfUhYnN1oGMmaQB0AACgYybsApMUmhS2FAAAwxRvAG4AZaA6APGgVCKrAG0CnxQAAAAAoxRhAHSgLABAYAChASJmbKcUqRTuABMNZQAAAW14rhSyFOUhbnQAoAEiZQDzANIB5wG6FAAAwBRkoEUibwB0AACgbSpuAPQAzAGAAWZyeQDIFMsUzhQA4DXYVN1vAOQA1wEAgakAO3MeAdMUcgAAoBchAAFhb9oU3hRyAHIAAKC1IXMAcwAAoBcnAAFjdeYU6hRyAADgNdi43AABYnDuFPIUZaDPKgCg0SploNAqAKDSKuQhb3QAoO8igANkZWxwcnZ3AAYVEBUbFSEVRBVlFYQV4SFycgABbHIMFQ4VAKA4KQCgNSlwAhYVAAAAABkVcgAAoN4iYwAAoN8i4SFycnCgtiEAoD0pgKIqImJjZG9zACsVMBU6FT4VQRVyImNhcAAAoEgqAAFhdTQVNxVwAACgRipwAACgSipvAHQAAKCNInIAAKBFKgDgKiIA/gACYWxydksVURVuFXMVcgByAG2gtyEAoDwpeQCAAWV2dwBYFWUVaRVxAHACXxUAAAAAYxVyAGUA4wAXFXUA4wAZFWUAZQAAoM4iZSJkZ2UAAKDPImUAbgA7gKQApEBlI2Fycm93AAABbHJ7FX8V5SFmdACgtiFpImdodAAAoLchZQDkAG0VAAFjaYsVkRVvAG4AaQBuAPQAkwFuAHQAAKAxImwiY3R5AACgLSOACUFIYWJjZGVmaGlqbG9yc3R1d3oAuBW7Fb8V1RXgFegV+RUKFhUWHxZUFlcWZRbFFtsW7xb7FgUXChdyAPIAtAJhAHIAAKBlKQACZ2xyc8YVyhXOFdAV5yFlcgCgICDlIXRoAKA4IfIA9QxoAHagECAAoKMiawHZFd4VYSJyb3cAAKAPKWEA4wBfAgABYXnkFecV8iFvbg9hNGQAoUYhYW/tFfQVAAFnciEC8RVyAACgyiF0InNlcQAAoHcqgAFnbG0A/xUCFgUWO4CwALBAdABhALRjcCJ0eXYAAKCxKQABaXIOFhIW8yFodACgfykA4DXYId1hAHIAAAFschsWHRYAoMMhAKDCIYACYWVnc3YAKBauAjYWOhY+Fm0AAKHEIm9zLhY0Fm4AZABzoMQi9SFpdACgZiZhIm1tYQDdY2kAbgAAoPIiAKH3AGlvQxZRFmQAZQAAgfcAO29KFksW90BuI3RpbWVzAACgxyJuAPgAUBZjAHkAUmRjAG8CXhYAAAAAYhZyAG4AAKAeI28AcAAAoA0jgAJscHR1dwBuFnEWdRaSFp4W7CFhciRgZgAA4DXYVd0AotkCZW1wc30WhBaJFo0WcQBkoFAibwB0AACgUSJpIm51cwAAoDgi7CF1cwCgFCLxInVhcmUAoKEiYgBsAGUAYgBhAHIAdwBlAGQAZwDlANcAbgCAAWFkaAClFqoWtBZyAHIAbwD3APUMbwB3AG4AYQByAHIAbwB3APMA8xVhI3Jwb29uAAABbHK8FsAWZQBmAPQAHBZpAGcAaAD0AB4WYgHJFs8WawBhAHIAbwD3AJILbwLUFgAAAADYFnIAbgAAoB8jbwBwAACgDCOAAWNvdADhFukW7BYAAXJ55RboFgDgNdi53FVkbAAAoPYp8iFvaxFhAAFkcvMW9xZvAHQAAKDxImkA5qC/JVsSAAFhaP8WAhdyAPIANQNhAPIA1wvhIm5nbGUAoKYpAAFjaQ4XEBd5AF9k5yJyYXJyAKD/JwAJRGFjZGVmZ2xtbm9wcXJzdHV4MRc4F0YXWxcyBF4XaRd5F40XrBe0F78X2RcVGCEYLRg1GEAYAAFEbzUXgRZvAPQA+BUAAWNzPBdCF3UAdABlADuA6QDpQPQhZXIAoG4qAAJhaW95TRdQF1YXWhfyIW9uG2FyAGOgViI7gOoA6kDsIW9uAKBVIk1kbwB0ABdhAAFEcmIXZhdvAHQAAKBSIgDgNdgi3XKhmipuF3QXYQB2AGUAO4DoAOhAZKCWKm8AdAAAoJgqgKGZKmlscwCAF4UXhxfuInRlcnMAoOcjAKATIWSglSpvAHQAAKCXKoABYXBzAJMXlheiF2MAcgATYXQAeQBzogUinxcAAAAAoRdlAHQAAKAFInAAMaADIDMBqRerFwCgBCAAoAUgAAFnc7AXsRdLYXAAAKACIAABZ3C4F7sXbwBuABlhZgAA4DXYVt2AAWFscwDFF8sXzxdyAHOg1SJsAACg4yl1AHMAAKBxKmkAAKG1A2x21RfYF28AbgC1Y/VjAAJjc3V24BfoF/0XEBgAAWlv5BdWF3IAYwAAoFYiaQLuFwAAAADwF+0ADQThIW50AAFnbPUX+Rd0AHIAAKCWKuUhc3MAoJUqgAFhZWkAAxgGGAoYbABzAD1gcwB0AACgXyJ2AESgYSJEAACgeCrwImFyc2wAoOUpAAFEYRkYHRhvAHQAAKBTInIAcgAAoHEpgAFjZGkAJxgqGO0XcgAAoC8hbwD0AIwCAAFhaDEYMhi3YzuA8ADwQAABbXI5GD0YbAA7gOsA60BvAACgrCCAAWNpcABGGEgYSxhsACFgcwD0ACwEAAFlb08YVxhjAHQAYQB0AGkAbwDuABoEbgBlAG4AdABpAGEAbADlADME4Ql1GAAAgRgAAIMYiBgAAAAAoRilGAAAqhgAALsYvhjRGAAA1xgnGWwAbABpAG4AZwBkAG8AdABzAGUA8QBlF3kARGRtImFsZQAAoEAmgAFpbHIAjRiRGJ0Y7CFpZwCgA/tpApcYAAAAAJoYZwAAoAD7aQBnAACgBPsA4DXYI93sIWlnAKAB++whaWcA4GYAagCAAWFsdACvGLIYthh0AACgbSZpAGcAAKAC+24AcwAAoLElbwBmAJJh8AHCGAAAxhhmAADgNdhX3QABYWvJGMwYbADsAGsEdqDUIgCg2SphI3J0aW50AACgDSoAAWFv2hgiGQABY3PeGB8ZsQPnGP0YBRkSGRUZAAAdGbID7xjyGPQY9xj5GAAA+xg7gL0AvUAAoFMhO4C8ALxAAKBVIQCgWSEAoFshswEBGQAAAxkAoFQhAKBWIbQCCxkOGQAAAAAQGTuAvgC+QACgVyEAoFwhNQAAoFghtgEZGQAAGxkAoFohAKBdITgAAKBeIWwAAKBEIHcAbgAAoCIjYwByAADgNdi73IAIRWFiY2RlZmdpamxub3JzdHYARhlKGVoZXhlmGWkZkhmWGZkZnRmgGa0ZxhnLGc8Z4BkjGmygZyIAoIwqgAFjbXAAUBlTGVgZ9SF0ZfVhbQBhAOSgswM6FgCghipyImV2ZQAfYQABaXliGWUZcgBjAB1hM2RvAHQAIWGAoWUibHFzAMYEcBl6GfGhZSLOBAAAdhlsAGEAbgD0AN8EgKF+KmNkbACBGYQZjBljAACgqSpvAHQAb6CAKmyggioAoIQqZeDbIgD+cwAAoJQqcgAA4DXYJN3noGsirATtIWVsAKA3IWMAeQBTZIChdyJFYWoApxmpGasZAKCSKgCgpSoAoKQqAAJFYWVztBm2Gb0ZwhkAoGkicABwoIoq8iFveACgiipxoIgq8aCIKrUZaQBtAACg5yJwAGYAAOA12FjdYQB2AOUAYwIAAWNp0xnWGXIAAKAKIW0AAKFzImVs3BneGQCgjioAoJAqAIM+ADtjZGxxco0E6xn0GfgZ/BkBGgABY2nvGfEZAKCnKnIAAKB6Km8AdAAAoNci0CFhcgCglSl1ImVzdAAAoHwqgAJhZGVscwAKGvQZFhrVBCAa8AEPGgAAFBpwAHIAbwD4AFkZcgAAoHgpcQAAAWxxxAQbGmwAZQBzAPMASRlpAO0A5AQAAWVuJxouGnIjdG5lcXEAAOBpIgD+xQAsGgAFQWFiY2Vma29zeUAaQxpmGmoabRqDGocalhrCGtMacgDyAMwCAAJpbG1yShpOGlAaVBpyAHMA8ABxD2YAvWBpAGwA9AASBQABZHJYGlsaYwB5AEpkAKGUIWN3YBpkGmkAcgAAoEgpAKCtIWEAcgAAoA8h6SFyYyVhgAFhbHIAcxp7Gn8a8iF0c3WgZSZpAHQAAKBlJuwhaXAAoCYg4yFvbgCguSJyAADgNdgl3XMAAAFld4wakRphInJvdwAAoCUpYSJyb3cAAKAmKYACYW1vcHIAnxqjGqcauhq+GnIAcgAAoP8h9CFodACgOyJrAAABbHKsGrMaZSRmdGFycm93AACgqSHpJGdodGFycm93AKCqIWYAAOA12Fnd4iFhcgCgFSCAAWNsdADIGswa0BpyAADgNdi93GEAcwDoAGka8iFvaydhAAFicNca2xr1IWxsAKBDIOghZW4AoBAg4Qr2GgAA/RoAAAgbExsaGwAAIRs7GwAAAAA+G2IbmRuVG6sbAACyG80b0htjAHUAdABlADuA7QDtQAChYyBpeQEbBhtyAGMAO4DuAO5AOGQAAWN4CxsNG3kANWRjAGwAO4ChAKFAAAFmcssCFhsA4DXYJt1yAGEAdgBlADuA7ADsQIChSCFpbm8AJxsyGzYbAAFpbisbLxtuAHQAAKAMKnQAAKAtIuYhaW4AoNwpdABhAACgKSHsIWlnM2GAAWFvcABDG1sbXhuAAWNndABJG0sbWRtyACthgAFlbHAAcQVRG1UbaQBuAOUAyAVhAHIA9AByBWgAMWFmAACgtyJlAGQAtWEAoggiY2ZvdGkbbRt1G3kb4SFyZQCgBSFpAG4AdKAeImkAZQAAoN0pZABvAPQAWxsAoisiY2VscIEbhRuPG5QbYQBsAACguiIAAWdyiRuNG2UAcgDzACMQ4wCCG2EicmhrAACgFyryIW9kAKA8KgACY2dwdJ8boRukG6gbeQBRZG8AbgAvYWYAAOA12FrdYQC5Y3UAZQBzAHQAO4C/AL9AAAFjabUbuRtyAADgNdi+3G4AAKIIIkVkc3bCG8QbyBvQAwCg+SJvAHQAAKD1Inag9CIAoPMiaaBiIOwhZGUpYesB1hsAANkbYwB5AFZkbAA7gO8A70AAA2NmbW9zdeYb7hvyG/Ub+hsFHAABaXnqG+0bcgBjADVhOWRyAADgNdgn3eEhdGg3YnAAZgAA4DXYW93jAf8bAAADHHIAAOA12L/c8iFjeVhk6yFjeVRkAARhY2ZnaGpvcxUcGhwiHCYcKhwtHDAcNRzwIXBhdqC6A/BjAAFleR4cIRzkIWlsN2E6ZHIAAOA12CjdciJlZW4AOGFjAHkARWRjAHkAXGRwAGYAAOA12FzdYwByAADgNdjA3IALQUJFSGFiY2RlZmdoamxtbm9wcnN0dXYAXhxtHHEcdRx5HN8cBx0dHTwd3B3tHfEdAR4EHh0eLB5FHrwewx7hHgkfPR9LH4ABYXJ0AGQcZxxpHHIA8gBvB/IAxQLhIWlsAKAbKeEhcnIAoA4pZ6BmIgCgiyphAHIAAKBiKWMJjRwAAJAcAACVHAAAAAAAAAAAAACZHJwcAACmHKgcrRwAANIc9SF0ZTph7SJwdHl2AKC0KXIAYQDuAFoG4iFkYbtjZwAAoegnZGyhHKMcAKCRKeUAiwYAoIUqdQBvADuAqwCrQHIAgKOQIWJmaGxwc3QAuhy/HMIcxBzHHMoczhxmoOQhcwAAoB8pcwAAoB0p6wCyGnAAAKCrIWwAAKA5KWkAbQAAoHMpbAAAoKIhAKGrKmFl1hzaHGkAbAAAoBkpc6CtKgDgrSoA/oABYWJyAOUc6RztHHIAcgAAoAwpcgBrAACgcicAAWFr8Rz4HGMAAAFla/Yc9xx7YFtgAAFlc/wc/hwAoIspbAAAAWR1Ax0FHQCgjykAoI0pAAJhZXV5Dh0RHRodHB3yIW9uPmEAAWRpFR0YHWkAbAA8YewAowbiAPccO2QAAmNxcnMkHScdLB05HWEAAKA2KXUAbwDyoBwgqhEAAWR1MB00HeghYXIAoGcpcyJoYXIAAKBLKWgAAKCyIQCiZCJmZ3FzRB1FB5Qdnh10AIACYWhscnQATh1WHWUdbB2NHXIicm93AHSgkCFhAOkAzxxhI3Jwb29uAAABZHVeHWId7yF3bgCgvSFwAACgvCHlJGZ0YXJyb3dzAKDHIWkiZ2h0AIABYWhzAHUdex2DHXIicm93APOglCGdBmEAcgBwAG8AbwBuAPMAzgtxAHUAaQBnAGEAcgByAG8A9wBlGugkcmVldGltZXMAoMsi8aFkIk0HAACaHWwAYQBuAPQAXgcAon0qY2Rnc6YdqR2xHbcdYwAAoKgqbwB0AG+gfypyoIEqAKCDKmXg2iIA/nMAAKCTKoACYWRlZ3MAwB3GHcod1h3ZHXAAcAByAG8A+ACmHG8AdAAAoNYicQAAAWdxzx3SHXQA8gBGB2cAdADyAHQcdADyAFMHaQDtAGMHgAFpbHIA4h3mHeod8yFodACgfClvAG8A8gDKBgDgNdgp3UWgdiIAoJEqYQH1Hf4dcgAAAWR1YB35HWygvCEAoGopbABrAACghCVjAHkAWWQAomoiYWNodAweDx4VHhkecgDyAGsdbwByAG4AZQDyAGAW4SFyZACgaylyAGkAAKD6JQABaW8hHiQe5CFvdEBh9SFzdGGgsCPjIWhlAKCwIwACRWFlczMeNR48HkEeAKBoInAAcKCJKvIhb3gAoIkqcaCHKvGghyo0HmkAbQAAoOYiAARhYm5vcHR3elIeXB5fHoUelh6mHqsetB4AAW5yVh5ZHmcAAKDsJ3IAAKD9IXIA6wCwBmcAgAFsbXIAZh52Hnse5SFmdAABYXKIB2weaQBnAGgAdABhAHIAcgBvAPcAkwfhInBzdG8AoPwnaQBnAGgAdABhAHIAcgBvAPcAmgdwI2Fycm93AAABbHKNHpEeZQBmAPQAxhxpImdodAAAoKwhgAFhZmwAnB6fHqIecgAAoIUpAOA12F3ddQBzAACgLSppIm1lcwAAoDQqYQGvHrMecwB0AACgFyLhAIoOZaHKJbkeRhLuIWdlAKDKJWEAcgBsoCgAdAAAoJMpgAJhY2htdADMHs8e1R7bHt0ecgDyAJ0GbwByAG4AZQDyANYWYQByAGSgyyEAoG0pAKAOIHIAaQAAoL8iAANhY2hpcXTrHu8e1QfzHv0eBh/xIXVvAKA5IHIAAOA12MHcbQDloXIi+h4AAPweAKCNKgCgjyoAAWJ19xwBH28AcqAYIACgGiDyIW9rQmEAhDwAO2NkaGlscXJCBhcfxh0gHyQfKB8sHzEfAAFjaRsfHR8AoKYqcgAAoHkqcgBlAOUAkx3tIWVzAKDJIuEhcnIAoHYpdSJlc3QAAKB7KgABUGk1HzkfYQByAACglillocMlAgdfEnIAAAFkdUIfRx9zImhhcgAAoEop6CFhcgCgZikAAWVuTx9WH3IjdG5lcXEAAOBoIgD+xQBUHwAHRGFjZGVmaGlsbm9wc3VuH3Ifoh+rH68ftx+7H74f5h/uH/MfBwj/HwsgxCFvdACgOiIAAmNscHJ5H30fiR+eH3IAO4CvAK9AAAFldIEfgx8AoEImZaAgJ3MAZQAAoCAnc6CmIXQAbwCAoaYhZGx1AJQfmB+cH28AdwDuAHkDZQBmAPQA6gbwAOkO6yFlcgCgriUAAW95ph+qH+0hbWEAoCkqPGThIXNoAKAUIOElc3VyZWRhbmdsZQCgISJyAADgNdgq3W8AAKAnIYABY2RuAMQfyR/bH3IAbwA7gLUAtUBhoiMi0B8AANMf1x9zAPQAKxFpAHIAAKDwKm8AdAA7gLcAt0B1AHMA4qESIh4TAADjH3WgOCIAoCoqYwHqH+0fcAAAoNsq8gB+GnAAbAB1APMACAgAAWRw9x/7H+UhbHMAoKciZgAA4DXYXt0AAWN0AyAHIHIAAOA12MLc8CFvcwCgPiJsobwDECAVIPQiaW1hcACguCJhAPAAEyAADEdMUlZhYmNkZWZnaGlqbG1vcHJzdHV2dzwgRyBmIG0geSCqILgg2iDeIBEhFSEyIUMhTSFQIZwhnyHSIQAiIyKLIrEivyIUIwABZ3RAIEMgAODZIjgD9uBrItIgBwmAAWVsdABNIF8gYiBmAHQAAAFhclMgWCByInJvdwAAoM0h6SRnaHRhcnJvdwCgziEA4NgiOAP24Goi0iBfCekkZ2h0YXJyb3cAoM8hAAFEZHEgdSDhIXNoAKCvIuEhc2gAoK4igAJiY25wdACCIIYgiSCNIKIgbABhAACgByL1IXRlRGFnAADgICLSIACiSSJFaW9wlSCYIJwgniAA4HAqOANkAADgSyI4A3MASWFyAG8A+AAyCnUAcgBhoG4mbADzoG4mmwjzAa8gAACzIHAAO4CgAKBAbQBwAOXgTiI4AyoJgAJhZW91eQDBIMogzSDWINkg8AHGIAAAyCAAoEMqbwBuAEhh5CFpbEZhbgBnAGSgRyJvAHQAAOBtKjgDcAAAoEIqPWThIXNoAKATIACjYCJBYWRxc3jpIO0g+SD+IAIhDCFyAHIAAKDXIXIAAAFocvIg9SBrAACgJClvoJch9wAGD28AdAAA4FAiOAN1AGkA9gC7CAABZWkGIQohYQByAACgKCntAN8I6SFzdPOgBCLlCHIAAOA12CvdAAJFZXN0/wgcISshLiHxoXEiIiEAABMJ8aFxIgAJAAAnIWwAYQBuAPQAEwlpAO0AGQlyoG8iAKBvIoABQWFwADghOyE/IXIA8gBeIHIAcgAAoK4hYQByAACg8ipzogsiSiEAAAAAxwtkoPwiAKD6ImMAeQBaZIADQUVhZGVzdABcIV8hYiFmIWkhkyGWIXIA8gBXIADgZiI4A3IAcgAAoJohcgAAoCUggKFwImZxcwBwIYQhjiF0AAABYXJ1IXohcgByAG8A9wBlIWkAZwBoAHQAYQByAHIAbwD3AD4h8aFwImAhAACKIWwAYQBuAPQAZwlz4H0qOAMAoG4iaQDtAG0JcqBuImkA5aDqIkUJaQDkADoKAAFwdKMhpyFmAADgNdhf3YCBrAA7aW4AriGvIcchrEBuAIChCSJFZHYAtyG6Ib8hAOD5IjgDbwB0AADg9SI4A+EB1gjEIcYhAKD3IgCg9iJpAHagDCLhAagJzyHRIQCg/iIAoP0igAFhb3IA2CHsIfEhcgCAoSYiYXN0AOAh5SHpIWwAbABlAOwAywhsAADg/SrlIADgAiI4A2wiaW50AACgFCrjoYAi9yEAAPohdQDlAJsJY+CvKjgDZaCAIvEAkwkAAkFhaXQHIgoiFyIeInIA8gBsIHIAcgAAoZshY3cRIhQiAOAzKTgDAOCdITgDZyRodGFycm93AACgmyFyAGkA5aDrIr4JgANjaGltcHF1AC8iPCJHIpwhTSJQIloigKGBImNlcgA2Iv0JOSJ1AOUABgoA4DXYw9zvIXJ0bQKdIQAAAABEImEAcgDhAOEhbQBloEEi8aBEIiYKYQDyAMsIcwB1AAABYnBWIlgi5QDUCeUA3wmAAWJjcABgInMieCKAoYQiRWVzAGci7glqIgDgxSo4A2UAdABl4IIi0iBxAPGgiCJoImMAZaCBIvEA/gmAoYUiRWVzAH8iFgqCIgDgxio4A2UAdABl4IMi0iBxAPGgiSKAIgACZ2lscpIilCKaIpwi7AAMCWwAZABlADuA8QDxQOcAWwlpI2FuZ2xlAAABbHKkIqoi5SFmdGWg6iLxAEUJaSJnaHQAZaDrIvEAvgltoL0DAKEjAGVzuCK8InIAbwAAoBYhcAAAoAcggARESGFkZ2lscnMAziLSItYi2iLeIugi7SICIw8j4SFzaACgrSLhIXJyAKAEKXAAAOBNItIg4SFzaACgrCIAAWV04iLlIgDgZSLSIADgPgDSIG4iZmluAACg3imAAUFldADzIvci+iJyAHIAAKACKQDgZCLSIHLgPADSIGkAZQAA4LQi0iAAAUF0BiMKI3IAcgAAoAMp8iFpZQDgtSLSIGkAbQAA4Dwi0iCAAUFhbgAaIx4jKiNyAHIAAKDWIXIAAAFociMjJiNrAACgIylvoJYh9wD/DuUhYXIAoCcpUxJqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVCMAAF4jaSN/I4IjjSOeI8AUAAAAAKYjwCMAANoj3yMAAO8jHiQvJD8kRCQAAWNzVyNsFHUAdABlADuA8wDzQAABaXlhI2cjcgBjoJoiO4D0APRAPmSAAmFiaW9zAHEjdCN3I3EBeiNzAOgAdhTsIWFjUWF2AACgOCrvIWxkAKC8KewhaWdTYQABY3KFI4kjaQByAACgvykA4DXYLN1vA5QjAAAAAJYjAACcI24A22JhAHYAZQA7gPIA8kAAoMEpAAFibaEjjAphAHIAAKC1KQACYWNpdKwjryO6I70jcgDyAFkUAAFpcrMjtiNyAACgvinvIXNzAKC7KW4A5QDZCgCgwCmAAWFlaQDFI8gjyyNjAHIATWFnAGEAyWOAAWNkbgDRI9Qj1iPyIW9uv2MAoLYpdQDzAHgBcABmAADgNdhg3YABYWVsAOQj5yPrI3IAAKC3KXIAcAAAoLkpdQDzAHwBAKMoImFkaW9zdvkj/CMPJBMkFiQbJHIA8gBeFIChXSplZm0AAyQJJAwkcgBvoDQhZgAAoDQhO4CqAKpAO4C6ALpA5yFvZgCgtiJyAACgVipsIm9wZQAAoFcqAKBbKoABY2xvACMkJSQrJPIACCRhAHMAaAA7gPgA+EBsAACgmCJpAGwBMyQ4JGQAZQA7gPUA9UBlAHMAYaCXInMAAKA2Km0AbAA7gPYA9kDiIWFyAKA9I+EKXiQAAHokAAB8JJQkAACYJKkkAAAAALUkEQsAAPAkAAAAAAQleiUAAIMlcgCAoSUiYXN0AGUkbyQBCwCBtgA7bGokayS2QGwAZQDsABgDaQJ1JAAAAAB4JG0AAKDzKgCg/Sp5AD9kcgCAAmNpbXB0AIUkiCSLJJkSjyRuAHQAJWBvAGQALmBpAGwAAKAwIOUhbmsAoDEgcgAA4DXYLd2AAWltbwCdJKAkpCR2oMYD1WNtAGEA9AD+B24AZQAAoA4m9KHAA64kAAC0JGMjaGZvcmsAAKDUItZjAAFhdbgkxCRuAAABY2u9JMIkawBooA8hAKAOIfYAaRpzAACkKwBhYmNkZW1zdNMkIRPXJNsk4STjJOck6yTjIWlyAKAjKmkAcgAAoCIqAAFvdYsW3yQAoCUqAKByKm4AO4CxALFAaQBtAACgJip3AG8AAKAnKoABaXB1APUk+iT+JO4idGludACgFSpmAADgNdhh3W4AZAA7gKMAo0CApHoiRWFjZWlub3N1ABMlFSUYJRslTCVRJVklSSV1JQCgsypwAACgtyp1AOUAPwtjoK8qgKJ6ImFjZW5zACclLSU0JTYlSSVwAHAAcgBvAPgAFyV1AHIAbAB5AGUA8QA/C/EAOAuAAWFlcwA8JUElRSXwInByb3gAoLkqcQBxAACgtSppAG0AAKDoImkA7QBEC20AZQDzoDIgIguAAUVhcwBDJVclRSXwAEAlgAFkZnAATwtfJXElgAFhbHMAZSVpJW0l7CFhcgCgLiPpIW5lAKASI/UhcmYAoBMjdKAdIu8AWQvyIWVsAKCwIgABY2l9JYElcgAA4DXYxdzIY24iY3NwAACgCCAAA2Zpb3BzdZElKxuVJZolnyWkJXIAAOA12C7dcABmAADgNdhi3XIiaW1lAACgVyBjAHIAAOA12MbcgAFhZW8AqiW6JcAldAAAAWVpryW2JXIAbgBpAG8AbgDzABkFbgB0AACgFipzAHQAZaA/APEACRj0AG0LgApBQkhhYmNkZWZoaWxtbm9wcnN0dXgA4yXyJfYl+iVpJpAmpia9JtUm5ib4JlonaCdxJ3UnnietJ7EnyCfiJ+cngAFhcnQA6SXsJe4lcgDyAJkM8gD6AuEhaWwAoBwpYQByAPIA3BVhAHIAAKBkKYADY2RlbnFydAAGJhAmEyYYJiYmKyZaJgABZXUKJg0mAOA9IjEDdABlAFVhaQDjACAN7SJwdHl2AKCzKWcAgKHpJ2RlbAAgJiImJCYAoJIpAKClKeUA9wt1AG8AO4C7ALtAcgAApZIhYWJjZmhscHN0dz0mQCZFJkcmSiZMJk4mUSZVJlgmcAAAoHUpZqDlIXMAAKAgKQCgMylzAACgHinrALka8ACVHmwAAKBFKWkAbQAAoHQpbAAAoKMhAKCdIQABYWleJmImaQBsAACgGilvAG6gNiJhAGwA8wB2C4ABYWJyAG8mciZ2JnIA8gAvEnIAawAAoHMnAAFha3omgSZjAAABZWt/JoAmfWBdYAABZXOFJocmAKCMKWwAAAFkdYwmjiYAoI4pAKCQKQACYWV1eZcmmiajJqUm8iFvbllhAAFkaZ4moSZpAGwAV2HsAA8M4gCAJkBkAAJjbHFzrSawJrUmuiZhAACgNylkImhhcgAAoGkpdQBvAPKgHSCjAWgAAKCzIYABYWNnAMMm0iaUC2wAgKEcIWlwcwDLJs4migxuAOUAoAxhAHIA9ADaC3QAAKCtJYABaWxyANsm3ybjJvMhaHQAoH0pbwBvAPIANgwA4DXYL90AAWFv6ib1JnIAAAFkde8m8SYAoMEhbKDAIQCgbCl2oMED8WOAAWducwD+Jk4nUCdoAHQAAANhaGxyc3QKJxInISc1Jz0nRydyInJvdwB0oJIhYQDpAFYmYSNycG9vbgAAAWR1GiceJ28AdwDuAPAmcAAAoMAh5SFmdAABYWgnJy0ncgByAG8AdwDzAAkMYQByAHAAbwBvAG4A8wATBGklZ2h0YXJyb3dzAACgySFxAHUAaQBnAGEAcgByAG8A9wBZJugkcmVldGltZXMAoMwiZwDaYmkAbgBnAGQAbwB0AHMAZQDxABwYgAFhaG0AYCdjJ2YncgDyAAkMYQDyABMEAKAPIG8idXN0AGGgsSPjIWhlAKCxI+0haWQAoO4qAAJhYnB0fCeGJ4knmScAAW5ygCeDJ2cAAKDtJ3IAAKD+IXIA6wAcDIABYWZsAI8nkieVJ3IAAKCGKQDgNdhj3XUAcwAAoC4qaSJtZXMAAKA1KgABYXCiJ6gncgBnoCkAdAAAoJQp7yJsaW50AKASKmEAcgDyADwnAAJhY2hxuCe8J6EMwCfxIXVvAKA6IHIAAOA12MfcAAFidYAmxCdvAPKgGSCoAYABaGlyAM4n0ifWJ3IAZQDlAE0n7SFlcwCgyiJpAIChuSVlZmwAXAxjEt4n9CFyaQCgzinsInVoYXIAoGgpAKAeIWENBSgJKA0oSyhVKIYoAACLKLAoAAAAAOMo5ygAABApJCkxKW0pcSmHKaYpAACYKgAAAACxKmMidXRlAFthcQB1AO8ABR+ApHsiRWFjZWlucHN5ABwoHignKCooLygyKEEoRihJKACgtCrwASMoAAAlKACguCpvAG4AYWF1AOUAgw1koLAqaQBsAF9hcgBjAF1hgAFFYXMAOCg6KD0oAKC2KnAAAKC6KmkAbQAAoOki7yJsaW50AKATKmkA7QCIDUFkbwB0AGKixSKRFgAAAABTKACgZiqAA0FhY21zdHgAYChkKG8ocyh1KHkogihyAHIAAKDYIXIAAAFocmkoayjrAJAab6CYIfcAzAd0ADuApwCnQGkAO2D3IWFyAKApKW0AAAFpbn4ozQBuAHUA8wDOAHQAAKA2J3IA7+A12DDdIxkAAmFjb3mRKJUonSisKHIAcAAAoG8mAAFoeZkonChjAHkASWRIZHIAdABtAqUoAAAAAKgoaQDkAFsPYQByAGEA7ABsJDuArQCtQAABZ22zKLsobQBhAAChwwNmdroouijCY4CjPCJkZWdsbnByAMgozCjPKNMo1yjaKN4obwB0AACgairxoEMiCw5FoJ4qAKCgKkWgnSoAoJ8qZQAAoEYi7CF1cwCgJCrhIXJyAKByKWEAcgDyAPwMAAJhZWl07Sj8KAEpCCkAAWxz8Sj4KGwAcwBlAHQAbQDpAH8oaABwAACgMyrwImFyc2wAoOQpAAFkbFoPBSllAACgIyNloKoqc6CsKgDgrCoA/oABZmxwABUpGCkfKfQhY3lMZGKgLwBhoMQpcgAAoD8jZgAA4DXYZN1hAAABZHIoKRcDZQBzAHWgYCZpAHQAAKBgJoABY3N1ADYpRilhKQABYXU6KUApcABzoJMiAOCTIgD+cABzoJQiAOCUIgD+dQAAAWJwSylWKQChjyJlcz4NUCllAHQAZaCPIvEAPw0AoZAiZXNIDVspZQB0AGWgkCLxAEkNAKGhJWFmZilbBHIAZQFrKVwEAKChJWEAcgDyAAMNAAJjZW10dyl7KX8pgilyAADgNdjI3HQAbQDuAM4AaQDsAAYpYQByAOYAVw0AAWFyiimOKXIA5qAGJhESAAFhbpIpoylpImdodAAAAWVwmSmgKXAAcwBpAGwAbwDuANkXaADpAKAkcwCvYIACYmNtbnAArin8KY4NJSooKgCkgiJFZGVtbnByc7wpvinCKcgpzCnUKdgp3CkAoMUqbwB0AACgvSpkoIYibwB0AACgwyr1IWx0AKDBKgABRWXQKdIpAKDLKgCgiiLsIXVzAKC/KuEhcnIAoHkpgAFlaXUA4inxKfQpdAAAoYIiZW7oKewpcQDxoIYivSllAHEA8aCKItEpbQAAoMcqAAFicPgp+ikAoNUqAKDTKmMAgKJ7ImFjZW5zAAcqDSoUKhYqRihwAHAAcgBvAPgAIyh1AHIAbAB5AGUA8QCDDfEAfA2AAWFlcwAcKiIqPShwAHAAcgBvAPgAPChxAPEAOShnAACgaiYApoMiMTIzRWRlaGxtbnBzPCo/KkIqRSpHKlIqWCpjKmcqaypzKncqO4C5ALlAO4CyALJAO4CzALNAAKDGKgABb3NLKk4qdAAAoL4qdQBiAACg2CpkoIcibwB0AACgxCpzAAABb3VdKmAqbAAAoMknYgAAoNcq4SFycgCgeyn1IWx0AKDCKgABRWVvKnEqAKDMKgCgiyLsIXVzAKDAKoABZWl1AH0qjCqPKnQAAKGDImVugyqHKnEA8aCHIkYqZQBxAPGgiyJwKm0AAKDIKgABYnCTKpUqAKDUKgCg1iqAAUFhbgCdKqEqrCpyAHIAAKDZIXIAAAFocqYqqCrrAJUab6CZIfcAxQf3IWFyAKAqKWwAaQBnADuA3wDfQOELzyrZKtwq6SrsKvEqAAD1KjQrAAAAAAAAAAAAAEwrbCsAAHErvSsAAAAAAADRK3IC1CoAAAAA2CrnIWV0AKAWI8RjcgDrAOUKgAFhZXkA4SrkKucq8iFvbmVh5CFpbGNhQmRvAPQAIg5sInJlYwAAoBUjcgAA4DXYMd0AAmVpa2/7KhIrKCsuK/IBACsAAAkrZQAAATRm6g0EK28AcgDlAOsNYQBzorgDECsAAAAAEit5AG0A0WMAAWNuFislK2sAAAFhcxsrIStwAHAAcgBvAPgAFw5pAG0AAKA8InMA8AD9DQABYXMsKyEr8AAXDnIAbgA7gP4A/kDsATgrOyswG2QA5QBnAmUAcwCAgdcAO2JkAEMrRCtJK9dAYaCgInIAAKAxKgCgMCqAAWVwcwBRK1MraSvhAAkh4qKkIlsrXysAAAAAYytvAHQAAKA2I2kAcgAAoPEqb+A12GXdcgBrAACg2irhAHgociJpbWUAAKA0IIABYWlwAHYreSu3K2QA5QC+DYADYWRlbXBzdACFK6MrmiunK6wrsCuzK24iZ2xlAACitSVkbHFykCuUK5ornCvvIXduAKC/JeUhZnRloMMl8QACBwCgXCJpImdodABloLkl8QBdDG8AdAAAoOwlaSJudXMAAKA6KuwhdXMAoDkqYgAAoM0p6SFtZQCgOyrlInppdW0AoOIjgAFjaHQAwivKK80rAAFyecYrySsA4DXYydxGZGMAeQBbZPIhb2tnYQABaW/UK9creAD0ANERaCJlYWQAAAFsct4r5ytlAGYAdABhAHIAcgBvAPcAXQbpJGdodGFycm93AKCgIQAJQUhhYmNkZmdobG1vcHJzdHV3CiwNLBEsHSwnLDEsQCxLLFIsYix6LIQsjyzLLOgs7Sz/LAotcgDyAAkDYQByAACgYykAAWNyFSwbLHUAdABlADuA+gD6QPIACQ1yAOMBIywAACUseQBeZHYAZQBtYQABaXkrLDAscgBjADuA+wD7QENkgAFhYmgANyw6LD0scgDyANEO7CFhY3FhYQDyAOAOAAFpckQsSCzzIWh0AKB+KQDgNdgy3XIAYQB2AGUAO4D5APlAYQFWLF8scgAAAWxyWixcLACgvyEAoL4hbABrAACggCUAAWN0Zix2LG8CbCwAAAAAcyxyAG4AZaAcI3IAAKAcI28AcAAAoA8jcgBpAACg+CUAAWFsfiyBLGMAcgBrYTuAqACoQAABZ3CILIssbwBuAHNhZgAA4DXYZt0AA2FkaGxzdZksniynLLgsuyzFLHIAcgBvAPcACQ1vAHcAbgBhAHIAcgBvAPcA2A5hI3Jwb29uAAABbHKvLLMsZQBmAPQAWyxpAGcAaAD0AF0sdQDzAKYOaQAAocUDaGzBLMIs0mNvAG4AxWPwI2Fycm93cwCgyCGAAWNpdADRLOEs5CxvAtcsAAAAAN4scgBuAGWgHSNyAACgHSNvAHAAAKAOI24AZwBvYXIAaQAAoPklYwByAADgNdjK3IABZGlyAPMs9yz6LG8AdAAAoPAi7CFkZWlhaQBmoLUlAKC0JQABYW0DLQYtcgDyAMosbAA7gPwA/EDhIm5nbGUAoKcpgAdBQkRhY2RlZmxub3Byc3oAJy0qLTAtNC2bLZ0toS2/LcMtxy3TLdgt3C3gLfwtcgDyABADYQByAHag6CoAoOkqYQBzAOgA/gIAAW5yOC08LechcnQAoJwpgANla25wcnN0AJkpSC1NLVQtXi1iLYItYQBwAHAA4QAaHG8AdABoAGkAbgDnAKEXgAFoaXIAoSmzJFotbwBwAPQAdCVooJUh7wD4JgABaXVmLWotZwBtAOEAuygAAWJwbi14LXMjZXRuZXEAceCKIgD+AODLKgD+cyNldG5lcQBx4IsiAP4A4MwqAP4AAWhyhi2KLWUAdADhABIraSNhbmdsZQAAAWxyki2WLeUhZnQAoLIiaSJnaHQAAKCzInkAMmThIXNoAKCiIoABZWxyAKcttC24LWKiKCKuLQAAAACyLWEAcgAAoLsicQAAoFoi7CFpcACg7iIAAWJ0vC1eD2EA8gBfD3IAAOA12DPddAByAOkAlS1zAHUAAAFicM0t0C0A4IIi0iAA4IMi0iBwAGYAAOA12GfdcgBvAPAAWQt0AHIA6QCaLQABY3XkLegtcgAA4DXYy9wAAWJw7C30LW4AAAFFZXUt8S0A4IoiAP5uAAABRWV/LfktAOCLIgD+6SJnemFnAKCaKYADY2Vmb3BycwANLhAuJS4pLiMuLi40LukhcmN1YQABZGkULiEuAAFiZxguHC5hAHIAAKBfKmUAcaAnIgCgWSLlIXJwAKAYIXIAAOA12DTdcABmAADgNdho3WWgQCJhAHQA6ABqD2MAcgAA4DXYzNzjCuQRUC4AAFQuAABYLmIuAAAAAGMubS5wLnQuAAAAAIguki4AAJouJxIqEnQAcgDpAB0ScgAA4DXYNd0AAUFhWy5eLnIA8gDnAnIA8gCTB75jAAFBYWYuaS5yAPIA4AJyAPIAjAdhAPAAeh5pAHMAAKD7IoABZHB0APgReS6DLgABZmx9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg"); - -// node_modules/entities/dist/esm/generated/decode-data-xml.js -var xmlDecodeTree = /* @__PURE__ */ decodeBase64("AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg"); - -// node_modules/entities/dist/esm/internal/bin-trie-flags.js -var BinTrieFlags; -(function(BinTrieFlags) { - BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH"; - BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13"; - BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH"; - BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE"; -})(BinTrieFlags || (BinTrieFlags = {})); - -// node_modules/entities/dist/esm/decode.js -var CharCodes; -(function(CharCodes) { - CharCodes[CharCodes["NUM"] = 35] = "NUM"; - CharCodes[CharCodes["SEMI"] = 59] = "SEMI"; - CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS"; - CharCodes[CharCodes["ZERO"] = 48] = "ZERO"; - CharCodes[CharCodes["NINE"] = 57] = "NINE"; - CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A"; - CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F"; - CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X"; - CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z"; - CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A"; - CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F"; - CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z"; -})(CharCodes || (CharCodes = {})); -var TO_LOWER_BIT = 32; -function isNumber(code) { - return code >= CharCodes.ZERO && code <= CharCodes.NINE; -} -function isHexadecimalCharacter(code) { - return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F; -} -function isAsciiAlphaNumeric(code) { - return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code); -} -function isEntityInAttributeInvalidEnd(code) { - return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code); -} -var EntityDecoderState; -(function(EntityDecoderState) { - EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart"; - EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart"; - EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal"; - EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex"; - EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity"; -})(EntityDecoderState || (EntityDecoderState = {})); -var DecodingMode; -(function(DecodingMode) { - DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy"; - DecodingMode[DecodingMode["Strict"] = 1] = "Strict"; - DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute"; -})(DecodingMode || (DecodingMode = {})); - -class EntityDecoder { - constructor(decodeTree, emitCodePoint, errors) { - this.decodeTree = decodeTree; - this.emitCodePoint = emitCodePoint; - this.errors = errors; - this.state = EntityDecoderState.EntityStart; - this.consumed = 1; - this.result = 0; - this.treeIndex = 0; - this.excess = 1; - this.decodeMode = DecodingMode.Strict; - this.runConsumed = 0; - } - startEntity(decodeMode) { - this.decodeMode = decodeMode; - this.state = EntityDecoderState.EntityStart; - this.result = 0; - this.treeIndex = 0; - this.excess = 1; - this.consumed = 1; - this.runConsumed = 0; - } - write(input, offset) { - switch (this.state) { - case EntityDecoderState.EntityStart: { - if (input.charCodeAt(offset) === CharCodes.NUM) { - this.state = EntityDecoderState.NumericStart; - this.consumed += 1; - return this.stateNumericStart(input, offset + 1); - } - this.state = EntityDecoderState.NamedEntity; - return this.stateNamedEntity(input, offset); - } - case EntityDecoderState.NumericStart: { - return this.stateNumericStart(input, offset); - } - case EntityDecoderState.NumericDecimal: { - return this.stateNumericDecimal(input, offset); - } - case EntityDecoderState.NumericHex: { - return this.stateNumericHex(input, offset); - } - case EntityDecoderState.NamedEntity: { - return this.stateNamedEntity(input, offset); - } - } - } - stateNumericStart(input, offset) { - if (offset >= input.length) { - return -1; - } - if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) { - this.state = EntityDecoderState.NumericHex; - this.consumed += 1; - return this.stateNumericHex(input, offset + 1); - } - this.state = EntityDecoderState.NumericDecimal; - return this.stateNumericDecimal(input, offset); - } - stateNumericHex(input, offset) { - while (offset < input.length) { - const char = input.charCodeAt(offset); - if (isNumber(char) || isHexadecimalCharacter(char)) { - const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10; - this.result = this.result * 16 + digit; - this.consumed++; - offset++; - } else { - return this.emitNumericEntity(char, 3); - } - } - return -1; - } - stateNumericDecimal(input, offset) { - while (offset < input.length) { - const char = input.charCodeAt(offset); - if (isNumber(char)) { - this.result = this.result * 10 + (char - CharCodes.ZERO); - this.consumed++; - offset++; - } else { - return this.emitNumericEntity(char, 2); - } - } - return -1; - } - emitNumericEntity(lastCp, expectedLength) { - var _a; - if (this.consumed <= expectedLength) { - (_a = this.errors) === null || _a === undefined || _a.absenceOfDigitsInNumericCharacterReference(this.consumed); - return 0; - } - if (lastCp === CharCodes.SEMI) { - this.consumed += 1; - } else if (this.decodeMode === DecodingMode.Strict) { - return 0; - } - this.emitCodePoint(replaceCodePoint(this.result), this.consumed); - if (this.errors) { - if (lastCp !== CharCodes.SEMI) { - this.errors.missingSemicolonAfterCharacterReference(); - } - this.errors.validateNumericCharacterReference(this.result); - } - return this.consumed; - } - stateNamedEntity(input, offset) { - const { decodeTree } = this; - let current = decodeTree[this.treeIndex]; - let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; - while (offset < input.length) { - if (valueLength === 0 && (current & BinTrieFlags.FLAG13) !== 0) { - const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; - if (this.runConsumed === 0) { - const firstChar = current & BinTrieFlags.JUMP_TABLE; - if (input.charCodeAt(offset) !== firstChar) { - return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity(); - } - offset++; - this.excess++; - this.runConsumed++; - } - while (this.runConsumed < runLength) { - if (offset >= input.length) { - return -1; - } - const charIndexInPacked = this.runConsumed - 1; - const packedWord = decodeTree[this.treeIndex + 1 + (charIndexInPacked >> 1)]; - const expectedChar = charIndexInPacked % 2 === 0 ? packedWord & 255 : packedWord >> 8 & 255; - if (input.charCodeAt(offset) !== expectedChar) { - this.runConsumed = 0; - return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity(); - } - offset++; - this.excess++; - this.runConsumed++; - } - this.runConsumed = 0; - this.treeIndex += 1 + (runLength >> 1); - current = decodeTree[this.treeIndex]; - valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; - } - if (offset >= input.length) - break; - const char = input.charCodeAt(offset); - if (char === CharCodes.SEMI && valueLength !== 0 && (current & BinTrieFlags.FLAG13) !== 0) { - return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess); - } - this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char); - if (this.treeIndex < 0) { - return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity(); - } - current = decodeTree[this.treeIndex]; - valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14; - if (valueLength !== 0) { - if (char === CharCodes.SEMI) { - return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess); - } - if (this.decodeMode !== DecodingMode.Strict && (current & BinTrieFlags.FLAG13) === 0) { - this.result = this.treeIndex; - this.consumed += this.excess; - this.excess = 0; - } - } - offset++; - this.excess++; - } - return -1; - } - emitNotTerminatedNamedEntity() { - var _a; - const { result, decodeTree } = this; - const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14; - this.emitNamedEntityData(result, valueLength, this.consumed); - (_a = this.errors) === null || _a === undefined || _a.missingSemicolonAfterCharacterReference(); - return this.consumed; - } - emitNamedEntityData(result, valueLength, consumed) { - const { decodeTree } = this; - this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13) : decodeTree[result + 1], consumed); - if (valueLength === 3) { - this.emitCodePoint(decodeTree[result + 2], consumed); - } - return consumed; - } - end() { - var _a; - switch (this.state) { - case EntityDecoderState.NamedEntity: { - return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0; - } - case EntityDecoderState.NumericDecimal: { - return this.emitNumericEntity(0, 2); - } - case EntityDecoderState.NumericHex: { - return this.emitNumericEntity(0, 3); - } - case EntityDecoderState.NumericStart: { - (_a = this.errors) === null || _a === undefined || _a.absenceOfDigitsInNumericCharacterReference(this.consumed); - return 0; - } - case EntityDecoderState.EntityStart: { - return 0; - } - } - } -} -function getDecoder(decodeTree) { - let returnValue = ""; - const decoder = new EntityDecoder(decodeTree, (data) => returnValue += fromCodePoint(data)); - return function decodeWithTrie(input, decodeMode) { - let lastIndex = 0; - let offset = 0; - while ((offset = input.indexOf("&", offset)) >= 0) { - returnValue += input.slice(lastIndex, offset); - decoder.startEntity(decodeMode); - const length = decoder.write(input, offset + 1); - if (length < 0) { - lastIndex = offset + decoder.end(); - break; - } - lastIndex = offset + length; - offset = length === 0 ? lastIndex + 1 : lastIndex; - } - const result = returnValue + input.slice(lastIndex); - returnValue = ""; - return result; - }; -} -function determineBranch(decodeTree, current, nodeIndex, char) { - const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; - const jumpOffset = current & BinTrieFlags.JUMP_TABLE; - if (branchCount === 0) { - return jumpOffset !== 0 && char === jumpOffset ? nodeIndex : -1; - } - if (jumpOffset) { - const value = char - jumpOffset; - return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIndex + value] - 1; - } - const packedKeySlots = branchCount + 1 >> 1; - let lo = 0; - let hi = branchCount - 1; - while (lo <= hi) { - const mid = lo + hi >>> 1; - const slot = mid >> 1; - const packed = decodeTree[nodeIndex + slot]; - const midKey = packed >> (mid & 1) * 8 & 255; - if (midKey < char) { - lo = mid + 1; - } else if (midKey > char) { - hi = mid - 1; - } else { - return decodeTree[nodeIndex + packedKeySlots + mid]; - } - } - return -1; -} -var htmlDecoder = /* @__PURE__ */ getDecoder(htmlDecodeTree); -var xmlDecoder = /* @__PURE__ */ getDecoder(xmlDecodeTree); -function decodeHTML(htmlString, mode = DecodingMode.Legacy) { - return htmlDecoder(htmlString, mode); -} -function decodeHTMLAttribute(htmlAttribute) { - return htmlDecoder(htmlAttribute, DecodingMode.Attribute); -} -function decodeXML(xmlString) { - return xmlDecoder(xmlString, DecodingMode.Strict); -} - -// node_modules/entities/dist/esm/escape.js -var xmlCodeMap = new Map([ - [34, """], - [38, "&"], - [39, "'"], - [60, "<"], - [62, ">"] -]); -var getCodePoint = String.prototype.codePointAt == null ? (c, index) => (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index) : (input, index) => input.codePointAt(index); -function getEscaper(regex, map) { - return function escape(data) { - let match; - let lastIndex = 0; - let result = ""; - while (match = regex.exec(data)) { - if (lastIndex !== match.index) { - result += data.substring(lastIndex, match.index); - } - result += map.get(match[0].charCodeAt(0)); - lastIndex = match.index + 1; - } - return result + data.substring(lastIndex); - }; -} -var escapeAttribute = /* @__PURE__ */ getEscaper(/["&\u00A0]/g, new Map([ - [34, """], - [38, "&"], - [160, " "] -])); -var escapeText = /* @__PURE__ */ getEscaper(/[&<>\u00A0]/g, new Map([ - [38, "&"], - [60, "<"], - [62, ">"], - [160, " "] -])); -// node_modules/entities/dist/esm/index.js -var EntityLevel; -(function(EntityLevel) { - EntityLevel[EntityLevel["XML"] = 0] = "XML"; - EntityLevel[EntityLevel["HTML"] = 1] = "HTML"; -})(EntityLevel || (EntityLevel = {})); -var EncodingMode; -(function(EncodingMode) { - EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8"; - EncodingMode[EncodingMode["ASCII"] = 1] = "ASCII"; - EncodingMode[EncodingMode["Extensive"] = 2] = "Extensive"; - EncodingMode[EncodingMode["Attribute"] = 3] = "Attribute"; - EncodingMode[EncodingMode["Text"] = 4] = "Text"; -})(EncodingMode || (EncodingMode = {})); - -// node_modules/happy-dom/lib/utilities/XMLEncodeUtility.js -var ENCODE_XML_ATTR_REGEXP = /[&"<>\t\n\r]/g; -var ENCODE_HTML_ATTR_REGEXP = /[&"]/g; -var DECODE_TEXT_CONTENT_REGEXP = /&(?:nbsp|lt|gt|amp);/g; -var ENCODE_XML_ATTR_MAP = { - "&": "&", - '"': """, - "<": "<", - ">": ">", - "\t": " ", - "\n": " ", - "\r": " " -}; -var ENCODE_HTML_ATTR_MAP = { - "&": "&", - '"': """ -}; -var DECODE_TEXT_CONTENT_MAP = { - " ": String.fromCharCode(160), - "<": "<", - ">": ">", - "&": "&" -}; - -class XMLEncodeUtility { - static encodeXMLAttributeValue(value) { - if (value === null) { - return ""; - } - return value.replace(ENCODE_XML_ATTR_REGEXP, (char) => ENCODE_XML_ATTR_MAP[char]); - } - static decodeXMLAttributeValue(value) { - if (value === null) { - return ""; - } - return decodeXML(value); - } - static encodeHTMLAttributeValue(value) { - if (value === null) { - return ""; - } - return value.replace(ENCODE_HTML_ATTR_REGEXP, (char) => ENCODE_HTML_ATTR_MAP[char]); - } - static decodeHTMLAttributeValue(value) { - if (value === null) { - return ""; - } - return decodeHTMLAttribute(value); - } - static encodeTextContent(text) { - if (text === null) { - return ""; - } - return escapeText(text); - } - static decodeTextContent(text) { - if (text === null) { - return ""; - } - return text.replace(DECODE_TEXT_CONTENT_REGEXP, (entity) => DECODE_TEXT_CONTENT_MAP[entity]); - } - static decodeHTMLEntities(value) { - if (value === null) { - return ""; - } - return decodeHTML(value); - } - static decodeXMLEntities(value) { - if (value === null) { - return ""; - } - return decodeXML(value); - } -} - -// node_modules/happy-dom/lib/html-serializer/HTMLSerializer.js -class HTMLSerializer { - options = { - serializableShadowRoots: false, - shadowRoots: null, - allShadowRoots: false, - excludeShadowRootTags: null - }; - constructor(options) { - if (options) { - if (options.serializableShadowRoots) { - this.options.serializableShadowRoots = options.serializableShadowRoots; - } - if (options.shadowRoots) { - this.options.shadowRoots = options.shadowRoots; - } - if (options.allShadowRoots) { - this.options.allShadowRoots = options.allShadowRoots; - } - if (options.excludeShadowRootTags) { - this.options.excludeShadowRootTags = options.excludeShadowRootTags; - } - } - } - serializeToString(root) { - switch (root[nodeType]) { - case NodeTypeEnum_default.elementNode: - const element = root; - const prefix2 = element[prefix]; - const localName2 = element[localName]; - const config = HTMLElementConfig_default[element[localName]]; - const tagName = prefix2 ? `${prefix2}:${localName2}` : localName2; - if (config?.contentModel === HTMLElementConfigContentModelEnum_default.noDescendants) { - return `<${tagName}${this.getAttributes(element)}>`; - } - let innerHTML = ""; - if (element.shadowRoot && (this.options.allShadowRoots || this.options.serializableShadowRoots && element.shadowRoot[serializable] || this.options.shadowRoots?.includes(element.shadowRoot)) && (!this.options.excludeShadowRootTags || !this.options.excludeShadowRootTags.includes(tagName))) { - innerHTML += `"; - } - const childNodes = tagName === "template" ? root.content[nodeArray] : root[nodeArray]; - for (const node of childNodes) { - innerHTML += this.serializeToString(node); - } - return `<${tagName}${this.getAttributes(element)}>${innerHTML}`; - case Node.DOCUMENT_FRAGMENT_NODE: - case Node.DOCUMENT_NODE: - let html = ""; - for (const node of root[nodeArray]) { - html += this.serializeToString(node); - } - return html; - case NodeTypeEnum_default.commentNode: - return ``; - case NodeTypeEnum_default.processingInstructionNode: - return ``; - case NodeTypeEnum_default.textNode: - const parentElement = root.parentElement; - if (parentElement) { - const parentConfig = HTMLElementConfig_default[parentElement[localName]]; - if (parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.rawText) { - return root.textContent; - } - } - return XMLEncodeUtility.encodeTextContent(root.textContent); - case NodeTypeEnum_default.documentTypeNode: - const doctype = root; - const identifier = doctype.publicId ? " PUBLIC" : doctype.systemId ? " SYSTEM" : ""; - const publicId = doctype.publicId ? ` "${doctype.publicId}"` : ""; - const systemId = doctype.systemId ? ` "${doctype.systemId}"` : ""; - return ``; - } - return ""; - } - getAttributes(element) { - let attributeString = ""; - const attributes2 = element[attributes][items]; - if (!attributes2.has(":is") && element[isValue]) { - attributeString += ' is="' + XMLEncodeUtility.encodeHTMLAttributeValue(element[isValue]) + '"'; - } - for (const attribute of attributes2.values()) { - const escapedValue = XMLEncodeUtility.encodeHTMLAttributeValue(attribute[value]); - attributeString += " " + attribute[name] + '="' + escapedValue + '"'; - } - return attributeString; - } -} - -// node_modules/happy-dom/lib/config/SVGElementConfig.js -var SVGElementConfig_default = { - svg: { localName: "svg", className: "SVGSVGElement" }, - animate: { localName: "animate", className: "SVGAnimateElement" }, - animatemotion: { localName: "animateMotion", className: "SVGAnimateMotionElement" }, - animatetransform: { localName: "animateTransform", className: "SVGAnimateTransformElement" }, - circle: { localName: "circle", className: "SVGCircleElement" }, - clippath: { localName: "clipPath", className: "SVGClipPathElement" }, - defs: { localName: "defs", className: "SVGDefsElement" }, - desc: { localName: "desc", className: "SVGDescElement" }, - ellipse: { localName: "ellipse", className: "SVGEllipseElement" }, - feblend: { localName: "feBlend", className: "SVGFEBlendElement" }, - fecolormatrix: { localName: "feColorMatrix", className: "SVGFEColorMatrixElement" }, - fecomponenttransfer: { - localName: "feComponentTransfer", - className: "SVGFEComponentTransferElement" - }, - fecomposite: { localName: "feComposite", className: "SVGFECompositeElement" }, - feconvolvematrix: { localName: "feConvolveMatrix", className: "SVGFEConvolveMatrixElement" }, - fediffuselighting: { localName: "feDiffuseLighting", className: "SVGFEDiffuseLightingElement" }, - fedisplacementmap: { localName: "feDisplacementMap", className: "SVGFEDisplacementMapElement" }, - fedistantlight: { localName: "feDistantLight", className: "SVGFEDistantLightElement" }, - fedropshadow: { localName: "feDropShadow", className: "SVGFEDropShadowElement" }, - feflood: { localName: "feFlood", className: "SVGFEFloodElement" }, - fefunca: { localName: "feFuncA", className: "SVGFEFuncAElement" }, - fefuncb: { localName: "feFuncB", className: "SVGFEFuncBElement" }, - fefuncg: { localName: "feFuncG", className: "SVGFEFuncGElement" }, - fefuncr: { localName: "feFuncR", className: "SVGFEFuncRElement" }, - fegaussianblur: { localName: "feGaussianBlur", className: "SVGFEGaussianBlurElement" }, - feimage: { localName: "feImage", className: "SVGFEImageElement" }, - femerge: { localName: "feMerge", className: "SVGFEMergeElement" }, - femergenode: { localName: "feMergeNode", className: "SVGFEMergeNodeElement" }, - femorphology: { localName: "feMorphology", className: "SVGFEMorphologyElement" }, - feoffset: { localName: "feOffset", className: "SVGFEOffsetElement" }, - fepointlight: { localName: "fePointLight", className: "SVGFEPointLightElement" }, - fespecularlighting: { - localName: "feSpecularLighting", - className: "SVGFESpecularLightingElement" - }, - fespotlight: { localName: "feSpotLight", className: "SVGFESpotLightElement" }, - fetile: { localName: "feTile", className: "SVGFETileElement" }, - feturbulence: { localName: "feTurbulence", className: "SVGFETurbulenceElement" }, - filter: { localName: "filter", className: "SVGFilterElement" }, - foreignobject: { localName: "foreignObject", className: "SVGForeignObjectElement" }, - g: { localName: "g", className: "SVGGElement" }, - image: { localName: "image", className: "SVGImageElement" }, - line: { localName: "line", className: "SVGLineElement" }, - lineargradient: { localName: "linearGradient", className: "SVGLinearGradientElement" }, - marker: { localName: "marker", className: "SVGMarkerElement" }, - mask: { localName: "mask", className: "SVGMaskElement" }, - metadata: { localName: "metadata", className: "SVGMetadataElement" }, - mpath: { localName: "mpath", className: "SVGMPathElement" }, - path: { localName: "path", className: "SVGPathElement" }, - pattern: { localName: "pattern", className: "SVGPatternElement" }, - polygon: { localName: "polygon", className: "SVGPolygonElement" }, - polyline: { localName: "polyline", className: "SVGPolylineElement" }, - radialgradient: { localName: "radialGradient", className: "SVGRadialGradientElement" }, - rect: { localName: "rect", className: "SVGRectElement" }, - script: { localName: "script", className: "SVGScriptElement" }, - set: { localName: "set", className: "SVGSetElement" }, - stop: { localName: "stop", className: "SVGStopElement" }, - style: { localName: "style", className: "SVGStyleElement" }, - switch: { localName: "switch", className: "SVGSwitchElement" }, - symbol: { localName: "symbol", className: "SVGSymbolElement" }, - text: { localName: "text", className: "SVGTextElement" }, - textpath: { localName: "textPath", className: "SVGTextPathElement" }, - title: { localName: "title", className: "SVGTitleElement" }, - tspan: { localName: "tspan", className: "SVGTSpanElement" }, - use: { localName: "use", className: "SVGUseElement" }, - view: { localName: "view", className: "SVGViewElement" } -}; - -// node_modules/happy-dom/lib/html-parser/HTMLParser.js -var MARKUP_REGEXP = /<([^\s/!>?]+)|<\/([^\s/!>?]+)\s*>|(|--!>)|()|(>)/gm; -var ATTRIBUTE_REGEXP = /\s*([a-zA-Z0-9-_:.$@?\\<\[\]]+)\s*=\s*([^"'=<>\\`\s]+)|\s*([a-zA-Z0-9-_:.$@?\\<\[\]]+)\s*=\s*"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:.$@?\\<\[\]]+)\s*=\s*'([^']*)('{0,1})|\s*([a-zA-Z0-9-_:.$@?\\<\[\]]+)/gm; -var DOCUMENT_TYPE_ATTRIBUTE_REGEXP = /"([^"]+)"/gm; -var SPACE_REGEXP2 = /\s+/; -var SPACE_IN_BEGINNING_REGEXP = /^\s+/; -var MarkupReadStateEnum; -(function(MarkupReadStateEnum) { - MarkupReadStateEnum["any"] = "any"; - MarkupReadStateEnum["startTag"] = "startTag"; - MarkupReadStateEnum["comment"] = "comment"; - MarkupReadStateEnum["documentType"] = "documentType"; - MarkupReadStateEnum["processingInstruction"] = "processingInstruction"; - MarkupReadStateEnum["rawTextElement"] = "rawTextElement"; -})(MarkupReadStateEnum || (MarkupReadStateEnum = {})); -var HTMLDocumentStructureLevelEnum; -(function(HTMLDocumentStructureLevelEnum) { - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["root"] = 0] = "root"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["doctype"] = 1] = "doctype"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["documentElement"] = 2] = "documentElement"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["head"] = 3] = "head"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["additionalHeadWithoutBody"] = 4] = "additionalHeadWithoutBody"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["body"] = 5] = "body"; - HTMLDocumentStructureLevelEnum[HTMLDocumentStructureLevelEnum["afterBody"] = 6] = "afterBody"; -})(HTMLDocumentStructureLevelEnum || (HTMLDocumentStructureLevelEnum = {})); - -class HTMLParser { - window; - evaluateScripts = false; - isTemplateDocumentFragment = false; - rootNode = null; - rootDocument = null; - nodeStack = []; - tagNameStack = []; - documentStructure = null; - startTagIndex = 0; - markupRegExp = null; - nextElement = null; - currentNode = null; - readState = MarkupReadStateEnum.any; - constructor(window, options) { - this.window = window; - if (options?.evaluateScripts) { - this.evaluateScripts = true; - } - if (options?.isTemplateDocumentFragment) { - this.isTemplateDocumentFragment = true; - } - } - parse(html, rootNode) { - this.rootNode = rootNode || this.window.document.createDocumentFragment(); - this.rootDocument = this.rootNode[nodeType] === NodeTypeEnum_default.documentNode ? this.rootNode : this.window.document; - this.nodeStack = [this.rootNode]; - this.tagNameStack = [null]; - this.currentNode = this.rootNode; - this.readState = MarkupReadStateEnum.any; - this.documentStructure = null; - this.startTagIndex = 0; - this.markupRegExp = new RegExp(MARKUP_REGEXP); - if (this.rootNode[nodeType] === NodeTypeEnum_default.documentNode) { - const { doctype, documentElement, head, body } = this.rootNode; - if (!documentElement || !head || !body) { - throw new Error(`Failed to parse HTML: The root node must have "documentElement", "head" and "body". - -We should not end up here and it is therefore a bug in Happy DOM. Please report this issue.`); - } - this.documentStructure = { - nodes: { - doctype: doctype || null, - documentElement, - head, - body - }, - level: HTMLDocumentStructureLevelEnum.root - }; - } - if (this.rootNode instanceof this.window.HTMLHtmlElement) { - const head = this.rootDocument.createElement("head"); - const body = this.rootDocument.createElement("body"); - while (this.rootNode[nodeArray].length > 0) { - this.rootNode[removeChild](this.rootNode[nodeArray][this.rootNode[nodeArray].length - 1]); - } - this.rootNode[appendChild](head); - this.rootNode[appendChild](body); - this.documentStructure = { - nodes: { - doctype: null, - documentElement: this.rootNode, - head, - body - }, - level: HTMLDocumentStructureLevelEnum.documentElement - }; - } - let match; - let lastIndex = 0; - html = String(html); - while (match = this.markupRegExp.exec(html)) { - switch (this.readState) { - case MarkupReadStateEnum.any: - if (match.index !== lastIndex && (match[1] || match[2] || match[3] || match[4] || match[5] !== undefined || match[6])) { - this.parsePlainText(html.substring(lastIndex, match.index)); - } - if (match[1]) { - this.nextElement = this.getStartTagElement(match[1]); - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum.startTag; - } else if (match[2]) { - this.parseEndTag(match[2]); - } else if (match[3]) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum.comment; - } else if (match[5] !== undefined) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum.documentType; - } else if (match[6]) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum.processingInstruction; - } else { - this.parsePlainText(html.substring(lastIndex, this.markupRegExp.lastIndex)); - } - break; - case MarkupReadStateEnum.startTag: - if (match[7] || match[8] || match[2]) { - if (this.nextElement) { - const attributeString = html.substring(this.startTagIndex, match[2] ? this.markupRegExp.lastIndex - 1 : match.index); - const isSelfClosed = !!match[7]; - this.parseEndOfStartTag(attributeString, isSelfClosed); - } else { - this.readState = MarkupReadStateEnum.any; - } - } - break; - case MarkupReadStateEnum.comment: - if (match[4]) { - this.parseComment(html.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum.documentType: - if (match[7] || match[8]) { - this.parseDocumentType(html.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum.processingInstruction: - if (match[7] || match[8]) { - this.parseComment("?" + html.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum.rawTextElement: - if (match[2]) { - this.parseRawTextElementContent(match[2], html.substring(this.startTagIndex, match.index)); - } - break; - } - lastIndex = this.markupRegExp.lastIndex; - } - if (lastIndex !== html.length && this.currentNode) { - this.parsePlainText(html.substring(lastIndex)); - } - return this.rootNode; - } - parsePlainText(text) { - if (this.documentStructure) { - const level = this.documentStructure.level; - const { documentElement, head, body } = this.documentStructure.nodes; - const htmlText = (this.currentNode === this.rootNode || this.currentNode === documentElement) && level < HTMLDocumentStructureLevelEnum.head && body[elementArray].length === 0 ? text.replace(SPACE_IN_BEGINNING_REGEXP, "") : text; - if (htmlText) { - const textNode = this.rootDocument.createTextNode(XMLEncodeUtility.decodeHTMLEntities(htmlText)); - if (this.currentNode === head && level === HTMLDocumentStructureLevelEnum.additionalHeadWithoutBody) { - documentElement[insertBefore](textNode, body, true); - } else if (this.currentNode === this.rootNode || this.currentNode === documentElement || this.currentNode === head && level >= HTMLDocumentStructureLevelEnum.body) { - if (level === HTMLDocumentStructureLevelEnum.head) { - documentElement[insertBefore](textNode, body, true); - } else if (body.lastChild?.[nodeType] === NodeTypeEnum_default.textNode) { - body.lastChild[data] += text; - } else { - body[appendChild](textNode, true); - } - } else { - this.currentNode[appendChild](textNode, true); - } - } - } else { - const textNode = this.rootDocument.createTextNode(XMLEncodeUtility.decodeHTMLEntities(text)); - this.currentNode[appendChild](textNode, true); - } - } - parseEndOfStartTag(attributeString, isSelfClosed) { - if (attributeString && (!this.documentStructure || this.nextElement !== this.documentStructure.nodes.head || this.documentStructure.level < HTMLDocumentStructureLevelEnum.body)) { - const attributeRegexp = new RegExp(ATTRIBUTE_REGEXP); - let attributeMatch; - while (attributeMatch = attributeRegexp.exec(attributeString)) { - if (attributeMatch[1] && attributeMatch[2] || attributeMatch[3] && attributeMatch[5] === '"' || attributeMatch[6] && attributeMatch[8] === "'" || attributeMatch[9]) { - const name2 = attributeMatch[1] || attributeMatch[3] || attributeMatch[6] || attributeMatch[9] || ""; - const rawValue = attributeMatch[2] || attributeMatch[4] || attributeMatch[7] || ""; - const value2 = rawValue ? XMLEncodeUtility.decodeHTMLAttributeValue(rawValue) : ""; - const attributes2 = this.nextElement[attributes]; - if (this.nextElement[namespaceURI] === NamespaceURI_default.svg) { - const nameParts = name2.split(":"); - let namespaceURI2 = null; - switch (nameParts[0]) { - case "xmlns": - namespaceURI2 = !nameParts[1] || nameParts[1] === "xlink" ? NamespaceURI_default.xmlns : null; - break; - case "xlink": - namespaceURI2 = NamespaceURI_default.xlink; - break; - } - if (!attributes2.getNamedItemNS(namespaceURI2, nameParts[1] ?? name2)) { - const attribute = NodeFactory.createNode(this.rootDocument, this.window.Attr); - attribute[namespaceURI] = namespaceURI2; - attribute[name] = name2; - attribute[localName] = namespaceURI2 && nameParts[1] ? nameParts[1] : name2; - attribute[prefix] = namespaceURI2 && nameParts[1] ? nameParts[0] : null; - attribute[value] = value2; - attributes2[setNamedItem](attribute); - } - } else if (!attributes2.getNamedItem(name2)) { - const attributeItem = this.rootDocument.createAttribute(name2); - attributeItem[value] = value2; - attributes2[setNamedItem](attributeItem); - } - this.startTagIndex += attributeMatch[0].length; - } else if (!attributeMatch[1] && (attributeMatch[3] && !attributeMatch[5] || attributeMatch[6] && !attributeMatch[8])) { - return; - } - } - } - const tagName2 = this.nextElement[tagName]; - const lowerTagName = tagName2.toLowerCase(); - const config = HTMLElementConfig_default[lowerTagName]; - let previousCurrentNode = null; - while (previousCurrentNode !== this.rootNode) { - const parentLowerTagName = this.currentNode[tagName]?.toLowerCase(); - const parentConfig = parentLowerTagName ? HTMLElementConfig_default[parentLowerTagName] : null; - if (previousCurrentNode === this.currentNode) { - throw new Error("Failed to parse HTML: The parser is stuck in an infinite loop. Please report this issue."); - } - previousCurrentNode = this.currentNode; - if (config?.contentModel === HTMLElementConfigContentModelEnum_default.noFirstLevelSelfDescendants && this.tagNameStack[this.tagNameStack.length - 1] === tagName2 || parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.textOrComments || parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.noForbiddenFirstLevelDescendants && parentConfig?.forbiddenDescendants?.includes(lowerTagName) || parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.permittedDescendants && !parentConfig?.permittedDescendants?.includes(lowerTagName) && (!config || !config.addPermittedParent || HTMLElementConfig_default[config.addPermittedParent].permittedParents && !HTMLElementConfig_default[config.addPermittedParent].permittedParents.includes(parentLowerTagName) || HTMLElementConfig_default[config.addPermittedParent].permittedDescendants && !HTMLElementConfig_default[config.addPermittedParent].permittedDescendants.includes(lowerTagName))) { - if (parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.permittedDescendants && parentConfig.moveForbiddenDescendant && !parentConfig.moveForbiddenDescendant.exclude.includes(lowerTagName)) { - let before = this.currentNode; - while (before) { - if (!before.parentNode || !HTMLElementConfig_default[before.parentNode[localName]]?.permittedDescendants || HTMLElementConfig_default[before.parentNode[localName]]?.permittedDescendants?.includes(lowerTagName)) { - break; - } else { - before = before.parentNode; - } - } - if (before && before.parentNode) { - before.parentNode.insertBefore(this.nextElement, before); - } else { - before.appendChild(this.nextElement); - } - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum.any; - return; - } - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - } else if (config?.contentModel === HTMLElementConfigContentModelEnum_default.noSelfDescendants && this.tagNameStack.includes(tagName2)) { - while (this.currentNode !== this.rootNode) { - if (this.currentNode[tagName] === tagName2) { - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - break; - } - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - } - } else if (!this.isTemplateDocumentFragment && config?.permittedParents && !config.permittedParents.includes(parentLowerTagName)) { - if (!config.addPermittedParent || HTMLElementConfig_default[config.addPermittedParent].permittedParents && !HTMLElementConfig_default[config.addPermittedParent].permittedParents.includes(parentLowerTagName) || HTMLElementConfig_default[config.addPermittedParent].permittedDescendants && !HTMLElementConfig_default[config.addPermittedParent].permittedDescendants.includes(lowerTagName)) { - this.readState = MarkupReadStateEnum.any; - this.startTagIndex = this.markupRegExp.lastIndex; - return; - } - const permittedParent = this.rootDocument.createElement(config.addPermittedParent); - this.currentNode[appendChild](permittedParent, true); - this.nodeStack.push(permittedParent); - this.tagNameStack.push(permittedParent[tagName]); - this.currentNode = permittedParent; - } else { - break; - } - } - if (this.documentStructure) { - const { documentElement, head, body } = this.documentStructure.nodes; - const level = this.documentStructure.level; - if ((!config || config.contentModel !== HTMLElementConfigContentModelEnum_default.rawText) && this.nextElement !== documentElement && this.nextElement !== head && this.nextElement !== body) { - if (documentElement && (this.currentNode === this.rootNode || this.currentNode === documentElement || this.currentNode === head && level >= HTMLDocumentStructureLevelEnum.body)) { - if (level < HTMLDocumentStructureLevelEnum.body) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.afterBody; - } - body[appendChild](this.nextElement, true); - } else { - this.currentNode[appendChild](this.nextElement, true); - } - } - } else { - this.currentNode[appendChild](this.nextElement, true); - } - if (!this.documentStructure || this.nextElement !== this.documentStructure.nodes.body || this.documentStructure.level <= HTMLDocumentStructureLevelEnum.body) { - this.currentNode = this.nextElement; - this.nodeStack.push(this.currentNode); - this.tagNameStack.push(tagName2); - if (this.documentStructure && this.nextElement === this.documentStructure.nodes.body) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.afterBody; - } - if (config?.contentModel === HTMLElementConfigContentModelEnum_default.noDescendants || isSelfClosed && this.currentNode[namespaceURI] === NamespaceURI_default.svg) { - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - this.readState = MarkupReadStateEnum.any; - } else { - this.readState = config?.contentModel === HTMLElementConfigContentModelEnum_default.rawText ? MarkupReadStateEnum.rawTextElement : MarkupReadStateEnum.any; - } - } else { - this.readState = MarkupReadStateEnum.any; - } - this.startTagIndex = this.markupRegExp.lastIndex; - } - parseEndTag(tagName) { - const name = this.currentNode[namespaceURI] === NamespaceURI_default.html ? StringUtility.asciiUpperCase(tagName) : SVGElementConfig_default[StringUtility.asciiLowerCase(tagName)]?.localName || tagName; - const index = this.tagNameStack.lastIndexOf(name); - if (index !== -1) { - this.nodeStack.splice(index, this.nodeStack.length - index); - this.tagNameStack.splice(index, this.tagNameStack.length - index); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - } - } - parseComment(comment) { - const commentNode = this.rootDocument.createComment(XMLEncodeUtility.decodeHTMLEntities(comment)); - if (this.documentStructure) { - const level = this.documentStructure.level; - const { documentElement, head, body } = this.documentStructure.nodes; - let beforeNode = null; - if (this.currentNode === this.rootNode && level === HTMLDocumentStructureLevelEnum.root) { - beforeNode = documentElement; - } else if (this.currentNode === documentElement && level === HTMLDocumentStructureLevelEnum.documentElement) { - beforeNode = head; - } else if (this.currentNode === documentElement && level === HTMLDocumentStructureLevelEnum.head) { - beforeNode = body; - } - this.currentNode[insertBefore](commentNode, beforeNode, true); - } else { - this.currentNode[appendChild](commentNode, true); - } - this.readState = MarkupReadStateEnum.any; - } - parseDocumentType(text) { - const decodedText = XMLEncodeUtility.decodeHTMLEntities(text); - if (this.documentStructure) { - let { doctype } = this.documentStructure.nodes; - const documentType = this.getDocumentType(decodedText); - if (documentType) { - if (this.currentNode === this.rootNode && this.documentStructure.level === HTMLDocumentStructureLevelEnum.root) { - if (doctype) { - doctype[name] = documentType.name; - doctype[publicId] = documentType.publicId; - doctype[systemId] = documentType.systemId; - } else { - doctype = this.rootNode.implementation.createDocumentType(documentType.name, documentType.publicId, documentType.systemId); - this.rootNode.insertBefore(doctype, this.rootNode.documentElement); - } - this.documentStructure.level = HTMLDocumentStructureLevelEnum.doctype; - } - } else { - this.parseComment(decodedText); - } - } else { - if (!this.getDocumentType(decodedText)) { - this.parseComment(decodedText); - } - } - this.readState = MarkupReadStateEnum.any; - } - parseRawTextElementContent(tagName2, text) { - const upperTagName = StringUtility.asciiUpperCase(tagName2); - if (upperTagName !== this.currentNode[tagName]) { - return; - } - if (upperTagName === "SCRIPT") { - this.currentNode[disableEvaluation] = !this.evaluateScripts; - } else if (upperTagName === "LINK") { - this.currentNode[disableEvaluation] = !this.evaluateScripts; - } - this.currentNode[appendChild](this.rootDocument.createTextNode(text), true); - const rawTextElement = this.currentNode; - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - this.readState = MarkupReadStateEnum.any; - if (this.documentStructure) { - const { documentElement, body } = this.documentStructure.nodes; - if (documentElement && (this.currentNode === this.rootNode || this.currentNode === documentElement)) { - body[appendChild](rawTextElement, true); - } else { - this.currentNode[appendChild](rawTextElement, true); - } - } else { - this.currentNode[appendChild](rawTextElement, true); - } - } - getStartTagElement(tagName) { - const lowerTagName = StringUtility.asciiLowerCase(tagName); - const namespaceURI2 = this.currentNode[namespaceURI]; - if (lowerTagName === "svg") { - return this.rootDocument.createElementNS(NamespaceURI_default.svg, "svg"); - } - if (namespaceURI2 === NamespaceURI_default.svg) { - return this.rootDocument.createElementNS(NamespaceURI_default.svg, SVGElementConfig_default[lowerTagName]?.localName || tagName); - } - switch (lowerTagName) { - case "html": - if (!this.documentStructure) { - return null; - } - if (this.documentStructure.level < HTMLDocumentStructureLevelEnum.documentElement) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.documentElement; - } - return this.documentStructure.nodes.documentElement ?? null; - case "head": - if (!this.documentStructure) { - return null; - } - if (this.documentStructure.level < HTMLDocumentStructureLevelEnum.head) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.head; - } else if (this.documentStructure.level === HTMLDocumentStructureLevelEnum.head) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.additionalHeadWithoutBody; - } - return this.documentStructure.nodes.head ?? null; - case "body": - if (!this.documentStructure) { - return null; - } - if (this.documentStructure.level < HTMLDocumentStructureLevelEnum.body) { - this.documentStructure.level = HTMLDocumentStructureLevelEnum.body; - } - return this.documentStructure.nodes.body ?? null; - default: - return this.rootDocument.createElementNS(NamespaceURI_default.html, lowerTagName); - } - } - getDocumentType(value) { - if (!value.toUpperCase().startsWith("DOCTYPE")) { - return null; - } - const docTypeSplit = value.split(SPACE_REGEXP2); - if (docTypeSplit.length <= 1) { - return null; - } - const docTypeString = docTypeSplit.slice(1).join(" "); - const attributes = []; - const attributeRegExp = new RegExp(DOCUMENT_TYPE_ATTRIBUTE_REGEXP, "gm"); - const isPublic = docTypeString.toUpperCase().includes("PUBLIC"); - let attributeMatch; - while (attributeMatch = attributeRegExp.exec(docTypeString)) { - attributes.push(attributeMatch[1]); - } - const publicId = isPublic ? attributes[0] || "" : ""; - const systemId = isPublic ? attributes[1] || "" : attributes[0] || ""; - return { - name: docTypeSplit[1].toLowerCase(), - publicId, - systemId - }; - } -} - -// node_modules/happy-dom/lib/utilities/AttributeUtility.js -var HTML_INVALID_ATTRIBUTE_NAME_CHARACTER_REGEX = /[\x00-\x1F\x7F\x80-\x9F "\'><=\/\uFDD0-\uFDEF\uFFFE\uFFFF\u1FFFE\u1FFFF\u2FFFE\u2FFFF\u3FFFE\u3FFFF\u4FFFE\u4FFFF\u5FFFE\u5FFFF\u6FFFE\u6FFFF\u7FFFE\u7FFFF\u8FFFE\u8FFFF\u9FFFE\u9FFFF\uAFFFE\uAFFFF\uBFFFE\uBFFFF\uCFFFE\uCFFFF\uDFFFE\uDFFFF\uEFFFE\uEFFFF\uFFFFE\uFFFFF\u10FFFE\u10FFFF]/; - -class AttributeUtility { - static validateAttributeName(name, contentType, context) { - const { method, instance } = context; - if (contentType === "text/html") { - const normalizedName = String(name).toLowerCase(); - if (HTML_INVALID_ATTRIBUTE_NAME_CHARACTER_REGEX.test(normalizedName) || normalizedName.length === 0 || normalizedName[0] === "-") { - throw new DOMException(`Uncaught InvalidCharacterError: Failed to execute '${method}' on '${instance}': '${name}' is not a valid attribute name.`, DOMExceptionNameEnum_default.invalidCharacterError); - } - } - } -} - -// node_modules/happy-dom/lib/nodes/element/ElementEventAttributeUtility.js -class ElementEventAttributeUtility { - static getEventListener(element, property) { - const cached = element[propertyEventListeners].get(property); - if (cached) { - return cached; - } - const window = element[ownerDocument][defaultView]; - if (!window) { - return null; - } - const browserSettings = new WindowBrowserContext(window).getSettings(); - if (!browserSettings || !browserSettings.enableJavaScriptEvaluation) { - return null; - } - const code = element.getAttribute(property); - if (!code) { - return null; - } - let newCode = `(function anonymous($happy_dom, event) {`; - if (browserSettings && !browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCode += `try { -`; - } - newCode += code; - if (browserSettings && !browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCode += "} catch(e) { $happy_dom.dispatchError(e); }"; - } - newCode += "})"; - let listener = null; - try { - listener = window[evaluateScript](newCode, { - filename: window.location.href - }).bind(element, { - dispatchError: window[dispatchError].bind(window) - }); - } catch (e) { - const error = new window.SyntaxError(`Failed to read the '${property}' property from '${element.constructor.name}': ${e.message}`); - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - throw error; - } else { - window[dispatchError](error); - return null; - } - } - if (listener) { - element[propertyEventListeners].set(property, listener); - } - return listener; - } -} - -// node_modules/happy-dom/lib/nodes/element/Element.js -class Element extends Node { - static [tagName] = null; - static [localName] = null; - static [namespaceURI] = null; - [classList] = null; - [isValue] = null; - [nodeType] = NodeTypeEnum_default.elementNode; - [prefix] = null; - [shadowRoot] = null; - [scrollHeight] = 0; - [scrollWidth] = 0; - [scrollTop] = 0; - [scrollLeft] = 0; - [attributes] = new NamedNodeMap(this); - [attributesProxy] = null; - [children] = null; - [computedStyle] = null; - [pointerCaptures] = new Set; - [propertyEventListeners] = new Map; - constructor() { - super(); - if (!this[tagName]) { - this[tagName] = null; - } - if (!this[localName]) { - this[localName] = null; - } - if (!this[namespaceURI]) { - this[namespaceURI] = null; - } - } - get onfullscreenerror() { - return ElementEventAttributeUtility.getEventListener(this, "onfullscreenerror"); - } - set onfullscreenerror(value) { - this[propertyEventListeners].set("onfullscreenerror", value); - } - get onfullscreenchange() { - return ElementEventAttributeUtility.getEventListener(this, "onfullscreenchange"); - } - set onfullscreenchange(value) { - this[propertyEventListeners].set("onfullscreenchange", value); - } - get onbeforecopy() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforecopy"); - } - set onbeforecopy(value) { - this[propertyEventListeners].set("onbeforecopy", value); - } - get onbeforecut() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforecut"); - } - set onbeforecut(value) { - this[propertyEventListeners].set("onbeforecut", value); - } - get onbeforepaste() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforepaste"); - } - set onbeforepaste(value) { - this[propertyEventListeners].set("onbeforepaste", value); - } - get onsearch() { - return ElementEventAttributeUtility.getEventListener(this, "onsearch"); - } - set onsearch(value) { - this[propertyEventListeners].set("onsearch", value); - } - get tagName() { - return this[tagName]; - } - get prefix() { - return this[prefix]; - } - get shadowRoot() { - const shadowRoot2 = this[shadowRoot]; - return shadowRoot2 && shadowRoot2[mode] === "open" ? shadowRoot2 : null; - } - get scrollHeight() { - return this[scrollHeight]; - } - get scrollWidth() { - return this[scrollWidth]; - } - get scrollTop() { - return this[scrollTop]; - } - set scrollTop(value) { - this[scrollTop] = value; - } - get scrollLeft() { - return this[scrollLeft]; - } - set scrollLeft(value) { - this[scrollLeft] = value; - } - get attributes() { - if (!this[attributesProxy]) { - this[attributesProxy] = NamedNodeMapProxyFactory.createProxy(this[attributes]); - } - return this[attributesProxy]; - } - get namespaceURI() { - return this[namespaceURI]; - } - get children() { - if (!this[children]) { - const elements = this[elementArray]; - this[children] = new HTMLCollection(illegalConstructor, () => elements); - } - return this[children]; - } - get classList() { - if (!this[classList]) { - this[classList] = new DOMTokenList(illegalConstructor, this, "class"); - } - return this[classList]; - } - set classList(value) { - this.setAttribute("class", value); - } - get id() { - return this.getAttribute("id") || ""; - } - set id(id) { - this.setAttribute("id", id); - } - get className() { - return this.getAttribute("class") || ""; - } - set className(className) { - this.setAttribute("class", className); - } - get nodeName() { - return this[tagName]; - } - get localName() { - return this[localName]; - } - get role() { - return this.getAttribute("role") || ""; - } - set role(role) { - this.setAttribute("role", role); - } - get previousElementSibling() { - return NonDocumentChildNodeUtility.previousElementSibling(this); - } - get nextElementSibling() { - return NonDocumentChildNodeUtility.nextElementSibling(this); - } - get textContent() { - let result = ""; - for (const childNode of this[nodeArray]) { - if (childNode[nodeType] === NodeTypeEnum_default.elementNode || childNode[nodeType] === NodeTypeEnum_default.textNode) { - result += childNode.textContent; - } - } - return result; - } - set textContent(textContent) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - if (textContent) { - this.appendChild(this[ownerDocument].createTextNode(textContent)); - } - } - get innerHTML() { - return this.getHTML(); - } - set innerHTML(html) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - new HTMLParser(this[window]).parse(html, this); - } - get outerHTML() { - return new HTMLSerializer().serializeToString(this); - } - set outerHTML(html) { - const childNodes = new HTMLParser(this[window]).parse(html)[nodeArray]; - this.replaceWith(...childNodes); - } - get childElementCount() { - return this[elementArray].length; - } - get firstElementChild() { - return this[elementArray][0] ?? null; - } - get lastElementChild() { - const children2 = this[elementArray]; - return children2[children2.length - 1] ?? null; - } - get slot() { - return this.getAttributeNS(null, "slot") || ""; - } - set slot(title) { - this.setAttribute("slot", title); - } - getInnerHTML(options) { - const serializer = new HTMLSerializer({ - allShadowRoots: !!options?.includeShadowRoots - }); - let html = ""; - for (const node of this[nodeArray]) { - html += serializer.serializeToString(node); - } - return html; - } - getHTML(options) { - const serializer = new HTMLSerializer({ - serializableShadowRoots: !!options?.serializableShadowRoots, - shadowRoots: options?.shadowRoots ?? null - }); - let html = ""; - for (const node of this[nodeArray]) { - html += serializer.serializeToString(node); - } - return html; - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[tagName] = this[tagName]; - clone[localName] = this[localName]; - clone[namespaceURI] = this[namespaceURI]; - if (this[shadowRoot]?.[clonable]) { - clone[shadowRoot] = this[shadowRoot].cloneNode(deep); - clone[shadowRoot][host] = clone; - } - clone[attributes] = new NamedNodeMap(clone); - for (const attr of this[attributes][items].values()) { - clone[attributes].setNamedItem(attr.cloneNode(deep)); - } - return clone; - } - remove() { - ChildNodeUtility.remove(this); - } - replaceWith(...nodes) { - ChildNodeUtility.replaceWith(this, ...nodes); - } - before(...nodes) { - ChildNodeUtility.before(this, ...nodes); - } - after(...nodes) { - ChildNodeUtility.after(this, ...nodes); - } - append(...nodes) { - ParentNodeUtility.append(this, ...nodes); - } - prepend(...nodes) { - ParentNodeUtility.prepend(this, ...nodes); - } - replaceChildren(...nodes) { - ParentNodeUtility.replaceChildren(this, ...nodes); - } - insertAdjacentElement(position, element) { - if (position === "beforebegin") { - if (!this.parentElement) { - return null; - } - this.parentElement.insertBefore(element, this); - } else if (position === "afterbegin") { - this.insertBefore(element, this.firstChild); - } else if (position === "beforeend") { - this.appendChild(element); - } else if (position === "afterend") { - if (!this.parentElement) { - return null; - } - this.parentElement.insertBefore(element, this.nextSibling); - } - return element; - } - insertAdjacentHTML(position, text) { - const childNodes = new HTMLParser(this[window]).parse(text)[nodeArray]; - while (childNodes.length) { - this.insertAdjacentElement(position, childNodes[0]); - } - } - insertAdjacentText(position, text) { - if (!text) { - return; - } - const textNode = this[ownerDocument].createTextNode(text); - this.insertAdjacentElement(position, textNode); - } - setAttribute(name2, value2) { - AttributeUtility.validateAttributeName(name2, this[ownerDocument][contentType], { method: "setAttribute", instance: "Element" }); - name2 = String(name2); - const namespaceURI2 = this[namespaceURI]; - if (namespaceURI2 === NamespaceURI_default.html) { - const attribute = this[ownerDocument].createAttribute(name2); - attribute[value] = String(value2); - this[attributes][setNamedItem](attribute); - } else { - const nameParts = name2.split(":"); - let attributeNamespaceURI = null; - switch (nameParts[0]) { - case "xmlns": - attributeNamespaceURI = !nameParts[1] || nameParts[1] === "xlink" ? NamespaceURI_default.xmlns : null; - break; - case "xlink": - attributeNamespaceURI = NamespaceURI_default.xlink; - break; - } - const attribute = NodeFactory.createNode(this[ownerDocument], this[window].Attr); - attribute[namespaceURI] = attributeNamespaceURI; - attribute[name] = name2; - attribute[localName] = attributeNamespaceURI && nameParts[1] ? nameParts[1] : name2; - attribute[prefix] = attributeNamespaceURI && nameParts[1] ? nameParts[0] : null; - attribute[value] = String(value2); - this[attributes][setNamedItem](attribute); - } - } - setAttributeNS(namespaceURI2, name, value2) { - const attribute = this[ownerDocument].createAttributeNS(namespaceURI2, name); - if (!namespaceURI2 && attribute[prefix]) { - throw new this[window].DOMException(`Failed to execute 'setAttributeNS' on 'Element': '' is an invalid namespace for attributes.`, DOMExceptionNameEnum_default.namespaceError); - } - attribute[value] = String(value2); - this[attributes].setNamedItemNS(attribute); - } - getAttributeNames() { - const names = []; - for (const item of this[attributes][items].values()) { - names.push(item[name]); - } - return names; - } - getAttribute(name) { - const attribute = this[attributes].getNamedItem(name); - if (attribute) { - return attribute[value]; - } - return null; - } - toggleAttribute(name, force) { - name = name.toLowerCase(); - const attribute = this[attributes].getNamedItem(name); - if (attribute) { - if (force === true) { - return true; - } - this[attributes][removeNamedItem](attribute); - return false; - } - if (force === false) { - return false; - } - this.setAttribute(name, ""); - return true; - } - getAttributeNS(namespace, localName2) { - const attribute = this.getAttributeNodeNS(namespace, localName2); - if (attribute) { - return attribute[value]; - } - return null; - } - hasAttribute(name) { - return !!this.getAttributeNode(name); - } - hasAttributeNS(namespace, localName2) { - return this[attributes].getNamedItemNS(namespace, localName2) !== null; - } - hasAttributes() { - return this[attributes][items].size > 0; - } - removeAttribute(name) { - const item = this[attributes].getNamedItem(name); - if (item) { - this[attributes][removeNamedItem](item); - } - } - removeAttributeNS(namespace, localName2) { - const item = this[attributes].getNamedItemNS(namespace, localName2); - if (item) { - this[attributes][removeNamedItem](item); - } - } - attachShadow(init) { - const window2 = this[window]; - if (!init) { - throw new window2.TypeError("Failed to execute 'attachShadow' on 'Element': 1 argument required, but only 0 present."); - } - if (!init.mode) { - throw new window2.TypeError("Failed to execute 'attachShadow' on 'Element': Failed to read the 'mode' property from 'ShadowRootInit': Required member is undefined."); - } - if (init.mode !== "open" && init.mode !== "closed") { - throw new window2.TypeError(`Failed to execute 'attachShadow' on 'Element': Failed to read the 'mode' property from 'ShadowRootInit': The provided value '${init.mode}' is not a valid enum value of type ShadowRootMode.`); - } - if (this[shadowRoot]) { - throw new window2.DOMException("Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree."); - } - const shadowRoot2 = NodeFactory.createNode(this[ownerDocument], this[window].ShadowRoot); - this[shadowRoot] = shadowRoot2; - shadowRoot2[host] = this; - shadowRoot2[mode] = init.mode; - shadowRoot2[clonable] = !!init.clonable; - shadowRoot2[delegatesFocus] = !!init.delegateFocus; - shadowRoot2[serializable] = !!init.serializable; - shadowRoot2[slotAssignment] = init.slotAssignment === "manual" ? "manual" : "named"; - shadowRoot2[connectedToNode](); - return this[shadowRoot]; - } - toString() { - return this.outerHTML; - } - getBoundingClientRect() { - return new DOMRect; - } - getClientRects() { - const domRectList = new DOMRectList(illegalConstructor); - domRectList.push(this.getBoundingClientRect()); - return domRectList; - } - setPointerCapture(pointerId) { - this[pointerCaptures].add(pointerId); - } - hasPointerCapture(pointerId) { - return this[pointerCaptures].has(pointerId); - } - releasePointerCapture(pointerId) { - this[pointerCaptures].delete(pointerId); - } - matches(selector) { - return !!QuerySelector.matches(this, selector); - } - closest(selector) { - let parent = this; - while (parent) { - if (QuerySelector.matches(parent, selector)) { - return parent; - } - parent = parent.parentElement; - } - return null; - } - querySelectorAll(selector) { - return QuerySelector.querySelectorAll(this, selector); - } - querySelector(selector) { - return QuerySelector.querySelector(this, selector); - } - getElementsByClassName(className) { - return ParentNodeUtility.getElementsByClassName(this, className); - } - getElementsByTagName(tagName2) { - return ParentNodeUtility.getElementsByTagName(this, tagName2); - } - getElementsByTagNameNS(namespaceURI2, tagName2) { - return ParentNodeUtility.getElementsByTagNameNS(this, namespaceURI2, tagName2); - } - setAttributeNode(attribute) { - return this[attributes].setNamedItem(attribute); - } - setAttributeNodeNS(attribute) { - return this[attributes].setNamedItemNS(attribute); - } - getAttributeNode(name) { - return this[attributes].getNamedItem(name); - } - getAttributeNodeNS(namespace, localName2) { - return this[attributes].getNamedItemNS(namespace, localName2); - } - removeAttributeNode(attribute) { - if (attribute[ownerElement] !== this) { - throw new this[window].DOMException("Failed to execute 'removeAttributeNode' on 'Element': The node provided is owned by another element."); - } - this[attributes][removeNamedItem](attribute); - return attribute; - } - scroll(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this[window].TypeError("Failed to execute 'scroll' on 'Element': The provided value is not of type 'ScrollToOptions'."); - } - const options = typeof x === "object" ? x : { left: x, top: y }; - if (options.behavior === "smooth") { - this[window].setTimeout(() => { - if (options.top !== undefined) { - const top = Number(options.top); - this.scrollTop = isNaN(top) ? 0 : top; - } - if (options.left !== undefined) { - const left = Number(options.left); - this.scrollLeft = isNaN(left) ? 0 : left; - } - }); - } else { - if (options.top !== undefined) { - const top = Number(options.top); - this.scrollTop = isNaN(top) ? 0 : top; - } - if (options.left !== undefined) { - const left = Number(options.left); - this.scrollLeft = isNaN(left) ? 0 : left; - } - } - } - scrollTo(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this[window].TypeError("Failed to execute 'scrollTo' on 'Element': The provided value is not of type 'ScrollToOptions'."); - } - this.scroll(x, y); - } - scrollBy(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this[window].TypeError("Failed to execute 'scrollBy' on 'Element': The provided value is not of type 'ScrollToOptions'."); - } - const options = typeof x === "object" ? x : { left: x, top: y }; - this.scroll({ - left: this.scrollLeft + (options.left ?? 0), - top: this.scrollTop + (options.top ?? 0), - behavior: options.behavior - }); - } - scrollIntoView(_options) {} - checkVisibility(options) { - if (!this[isConnected]) { - return false; - } - let parent = this; - while (parent) { - const computedStyle2 = this[window].getComputedStyle(parent); - if (computedStyle2.display === "none") { - return false; - } - if (computedStyle2.display === "contents") { - let isChildVisible = false; - for (const child of parent[elementArray]) { - const childComputedStyle = this[window].getComputedStyle(child); - if (childComputedStyle.display !== "none") { - isChildVisible = true; - break; - } - } - if (!isChildVisible) { - return false; - } - } - if ((options?.opacityProperty || options?.checkOpacity) && computedStyle2.opacity === "0") { - return false; - } - if ((options?.visibilityProperty || options?.checkVisibilityCSS) && computedStyle2.visibility === "hidden") { - return false; - } - parent = parent.parentElement; - } - return true; - } - [appendChild](node, disableValidations = false) { - const returnValue = super[appendChild](node, disableValidations); - this.#onSlotChange(node); - return returnValue; - } - [removeChild](node) { - const returnValue = super[removeChild](node); - this.#onSlotChange(node); - return returnValue; - } - [insertBefore](newNode, referenceNode, disableValidations = false) { - const returnValue = super[insertBefore](newNode, referenceNode, disableValidations); - this.#onSlotChange(newNode); - return returnValue; - } - [onSetAttribute](attribute, replacedAttribute) { - if (!attribute[name]) { - return; - } - const oldValue = replacedAttribute ? replacedAttribute[value] : null; - if (attribute[name] === "slot" && this[parentNode] && this[parentNode][shadowRoot]) { - const shadowRoot2 = this[parentNode][shadowRoot]; - if (shadowRoot2 && attribute[value] !== oldValue) { - if (oldValue !== null && replacedAttribute) { - const slot = shadowRoot2.querySelector(`slot[name="${replacedAttribute[value]}"]`); - if (slot) { - slot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } else { - const slot = shadowRoot2.querySelector("slot:not([name])"); - if (slot) { - slot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } - const slot = shadowRoot2.querySelector(`slot[name="${attribute[value]}"]`); - if (slot) { - slot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } - } - if (this[attribute[name]] !== undefined && attribute[name][0] === "o" && attribute[name][1] === "n") { - this[propertyEventListeners].delete(attribute[name]); - } - if (attribute[name] === "id" && this[isConnected]) { - if (replacedAttribute?.[value]) { - this.#removeIdentifierFromWindow(replacedAttribute[value]); - } - this.#addIdentifierToWindow(attribute[value]); - } - this[reportMutation](new MutationRecord({ - type: MutationTypeEnum_default.attributes, - target: this, - attributeName: attribute[name], - oldValue - })); - } - [onRemoveAttribute](removedAttribute) { - if (removedAttribute[name] === "slot" && this[parentNode] && this[parentNode][shadowRoot]) { - const shadowRoot2 = this[parentNode][shadowRoot]; - const namedSlot = shadowRoot2.querySelector(`slot[name="${removedAttribute[value]}"]`); - const defaultSlot = shadowRoot2.querySelector("slot:not([name])"); - if (namedSlot) { - namedSlot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - if (defaultSlot) { - defaultSlot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } - if (removedAttribute[name] === "id" && this[isConnected]) { - this.#removeIdentifierFromWindow(removedAttribute[value]); - } - this[reportMutation](new MutationRecord({ - type: MutationTypeEnum_default.attributes, - target: this, - attributeName: removedAttribute[name], - oldValue: removedAttribute[value] - })); - } - [connectedToDocument]() { - const id = this.getAttribute("id"); - if (id) { - this.#addIdentifierToWindow(id); - } - super[connectedToDocument](); - this[window][customElementReactionStack].enqueueReaction(this, "connectedCallback"); - if (this[shadowRoot]) { - for (const childNode of this[nodeArray]) { - this.#onSlotChange(childNode); - } - } - } - [disconnectedFromDocument]() { - super[disconnectedFromDocument](); - const id = this.getAttribute("id"); - if (id) { - this.#removeIdentifierFromWindow(id); - } - this[window][customElementReactionStack].enqueueReaction(this, "disconnectedCallback"); - } - [destroy]() { - const id = this.getAttribute("id"); - if (id) { - this.#removeIdentifierFromWindow(id); - } - this[window][customElementReactionStack].enqueueReaction(this, "disconnectedCallback"); - super[destroy](); - if (this[shadowRoot]) { - this[shadowRoot][destroy](); - } - this[classList] = null; - this[shadowRoot] = null; - this[attributesProxy] = null; - this[children] = null; - this[computedStyle] = null; - this[propertyEventListeners].clear(); - this[attributes][itemsByNamespaceURI].clear(); - this[attributes][itemsByName].clear(); - this[attributes][items].clear(); - } - #addIdentifierToWindow(id) { - if (!id) { - return; - } - const document = this[ownerDocument]; - const window2 = this[window]; - if (this[rootNode] && this[rootNode] !== document) { - return; - } - if (!document[elementIdMap].has(id)) { - document[elementIdMap].set(id, { elements: [], htmlCollection: null }); - } - const entry = document[elementIdMap].get(id); - if (!entry) { - return; - } - const element = this[proxy] || this; - entry.elements.push(element); - if (entry.elements.length > 1) { - if (!entry.htmlCollection) { - entry.htmlCollection = new HTMLCollection(illegalConstructor, () => entry.elements); - } - if (!(id in window2) || window2[id] === entry.elements[0]) { - window2[id] = entry.htmlCollection; - } - } else if (!(id in window2) || entry.htmlCollection !== null && window2[id] === entry.htmlCollection) { - window2[id] = element; - } - } - #removeIdentifierFromWindow(id) { - if (!id) { - return; - } - const document = this[ownerDocument]; - const window2 = this[window]; - if (this[rootNode] && this[rootNode] !== document) { - return; - } - const entry = document[elementIdMap].get(id); - if (!entry) { - return; - } - const element = this[proxy] || this; - const index = entry.elements.indexOf(element); - if (index !== -1) { - entry.elements.splice(index, 1); - } - if (entry.elements.length === 1) { - if (window2[id] === entry.htmlCollection) { - window2[id] = entry.elements[0]; - } - entry.htmlCollection = null; - } else if (!entry.elements.length) { - document[elementIdMap].delete(id); - if (window2[id] === element || window2[id] === entry.htmlCollection) { - delete window2[id]; - } - } - } - #onSlotChange(addedOrRemovedNode) { - const shadowRoot2 = this[shadowRoot]; - if (!shadowRoot2 || !this[isConnected]) { - return; - } - const slotName = addedOrRemovedNode["getAttribute"] ? addedOrRemovedNode.getAttribute("slot") : null; - if (slotName) { - const slot = shadowRoot2.querySelector(`slot[name="${slotName}"]`); - if (slot) { - slot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } else if (addedOrRemovedNode[nodeType] !== NodeTypeEnum_default.commentNode) { - const slot = shadowRoot2.querySelector("slot:not([name])"); - if (slot) { - slot.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } - } -} - -// node_modules/happy-dom/lib/nodes/html-element/HTMLElementUtility.js -class HTMLElementUtility { - static blur(element) { - const target = element[proxy] || element; - const document = target[ownerDocument]; - if (document[activeElement] !== target || !target[isConnected] || target.disabled) { - return; - } - const relatedTarget = document[nextActiveElement] ?? null; - document[activeElement] = null; - document[clearCache](); - target.dispatchEvent(new FocusEvent("blur", { - relatedTarget, - bubbles: false, - composed: true, - cancelable: true - })); - target.dispatchEvent(new FocusEvent("focusout", { - relatedTarget, - bubbles: true, - composed: true, - cancelable: true - })); - } - static focus(element) { - const target = element[proxy] || element; - const document = target[ownerDocument]; - if (document[activeElement] === target || !target[isConnected] || target.disabled || this.isInert(target)) { - return; - } - document[nextActiveElement] = target; - const relatedTarget = document[activeElement]; - if (document[activeElement] !== null) { - document[activeElement].blur(); - } - document[nextActiveElement] = null; - document[activeElement] = target; - document[clearCache](); - target.dispatchEvent(new FocusEvent("focus", { - relatedTarget, - bubbles: false, - composed: true - })); - target.dispatchEvent(new FocusEvent("focusin", { - relatedTarget, - bubbles: true, - composed: true - })); - } - static isInert(element) { - let current = element[proxy] || element; - while (current && typeof current.getAttribute === "function") { - if (current.getAttribute("inert") !== null) { - return true; - } - current = current[parentNode]; - } - return false; - } -} - -// node_modules/happy-dom/lib/dom/DOMStringMapUtility.js -class DOMStringMapUtility { - static kebabToCamelCase(text) { - const parts = text.split("-"); - for (let i = 0, max = parts.length;i < max; i++) { - parts[i] = i > 0 ? parts[i].charAt(0).toUpperCase() + parts[i].slice(1) : parts[i]; - } - return parts.join(""); - } - static camelCaseToKebab(text) { - return text.toString().replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase()); - } -} - -// node_modules/happy-dom/lib/dom/DOMStringMap.js -class DOMStringMap { - constructor(illegalConstructorSymbol, element) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - return new Proxy(this, { - get(_target, property) { - const attribute = element.getAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property)); - if (attribute !== null) { - return attribute; - } - }, - set(_target, property, value) { - element.setAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property), value); - return true; - }, - deleteProperty(_target, property) { - element.removeAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property)); - return true; - }, - ownKeys(_target) { - const keys = []; - for (const items of element[attributes][itemsByName].values()) { - if (items[0][name].startsWith("data-")) { - keys.push(DOMStringMapUtility.kebabToCamelCase(items[0][name].replace("data-", ""))); - } - } - return keys; - }, - has(_target, property) { - return element.hasAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property)); - }, - defineProperty(_target, property, descriptor) { - if (descriptor.value === undefined) { - return false; - } - element.setAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property), descriptor.value); - return true; - }, - getOwnPropertyDescriptor(_target, property) { - const attribute = element.getAttribute("data-" + DOMStringMapUtility.camelCaseToKebab(property)); - if (!attribute) { - return; - } - return { - value: attribute, - writable: true, - enumerable: true, - configurable: true - }; - } - }); - } -} - -// node_modules/happy-dom/lib/nodes/html-element/HTMLElement.js -class HTMLElement extends Element { - static observedAttributes; - [accessKey] = ""; - [offsetHeight] = 0; - [offsetWidth] = 0; - [offsetLeft] = 0; - [offsetTop] = 0; - [clientHeight] = 0; - [clientWidth] = 0; - [clientLeft] = 0; - [clientTop] = 0; - [style] = null; - [dataset] = null; - #customElementDefineCallback = null; - get oncancel() { - return ElementEventAttributeUtility.getEventListener(this, "oncancel"); - } - set oncancel(value) { - this[propertyEventListeners].set("oncancel", value); - } - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onscroll() { - return ElementEventAttributeUtility.getEventListener(this, "onscroll"); - } - set onscroll(value) { - this[propertyEventListeners].set("onscroll", value); - } - get onselect() { - return ElementEventAttributeUtility.getEventListener(this, "onselect"); - } - set onselect(value) { - this[propertyEventListeners].set("onselect", value); - } - get onwheel() { - return ElementEventAttributeUtility.getEventListener(this, "onwheel"); - } - set onwheel(value) { - this[propertyEventListeners].set("onwheel", value); - } - get oncopy() { - return ElementEventAttributeUtility.getEventListener(this, "oncopy"); - } - set oncopy(value) { - this[propertyEventListeners].set("oncopy", value); - } - get oncut() { - return ElementEventAttributeUtility.getEventListener(this, "oncut"); - } - set oncut(value) { - this[propertyEventListeners].set("oncut", value); - } - get onpaste() { - return ElementEventAttributeUtility.getEventListener(this, "onpaste"); - } - set onpaste(value) { - this[propertyEventListeners].set("onpaste", value); - } - get oncompositionend() { - return ElementEventAttributeUtility.getEventListener(this, "oncompositionend"); - } - set oncompositionend(value) { - this[propertyEventListeners].set("oncompositionend", value); - } - get oncompositionstart() { - return ElementEventAttributeUtility.getEventListener(this, "oncompositionstart"); - } - set oncompositionstart(value) { - this[propertyEventListeners].set("oncompositionstart", value); - } - get oncompositionupdate() { - return ElementEventAttributeUtility.getEventListener(this, "oncompositionupdate"); - } - set oncompositionupdate(value) { - this[propertyEventListeners].set("oncompositionupdate", value); - } - get onblur() { - return ElementEventAttributeUtility.getEventListener(this, "onblur"); - } - set onblur(value) { - this[propertyEventListeners].set("onblur", value); - } - get onfocus() { - return ElementEventAttributeUtility.getEventListener(this, "onfocus"); - } - set onfocus(value) { - this[propertyEventListeners].set("onfocus", value); - } - get onfocusin() { - return ElementEventAttributeUtility.getEventListener(this, "onfocusin"); - } - set onfocusin(value) { - this[propertyEventListeners].set("onfocusin", value); - } - get onfocusout() { - return ElementEventAttributeUtility.getEventListener(this, "onfocusout"); - } - set onfocusout(value) { - this[propertyEventListeners].set("onfocusout", value); - } - get onkeydown() { - return ElementEventAttributeUtility.getEventListener(this, "onkeydown"); - } - set onkeydown(value) { - this[propertyEventListeners].set("onkeydown", value); - } - get onkeyup() { - return ElementEventAttributeUtility.getEventListener(this, "onkeyup"); - } - set onkeyup(value) { - this[propertyEventListeners].set("onkeyup", value); - } - get onauxclick() { - return ElementEventAttributeUtility.getEventListener(this, "onauxclick"); - } - set onauxclick(value) { - this[propertyEventListeners].set("onauxclick", value); - } - get onclick() { - return ElementEventAttributeUtility.getEventListener(this, "onclick"); - } - set onclick(value) { - this[propertyEventListeners].set("onclick", value); - } - get oncontextmenu() { - return ElementEventAttributeUtility.getEventListener(this, "oncontextmenu"); - } - set oncontextmenu(value) { - this[propertyEventListeners].set("oncontextmenu", value); - } - get ondblclick() { - return ElementEventAttributeUtility.getEventListener(this, "ondblclick"); - } - set ondblclick(value) { - this[propertyEventListeners].set("ondblclick", value); - } - get onmousedown() { - return ElementEventAttributeUtility.getEventListener(this, "onmousedown"); - } - set onmousedown(value) { - this[propertyEventListeners].set("onmousedown", value); - } - get onmouseenter() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseenter"); - } - set onmouseenter(value) { - this[propertyEventListeners].set("onmouseenter", value); - } - get onmouseleave() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseleave"); - } - set onmouseleave(value) { - this[propertyEventListeners].set("onmouseleave", value); - } - get onmousemove() { - return ElementEventAttributeUtility.getEventListener(this, "onmousemove"); - } - set onmousemove(value) { - this[propertyEventListeners].set("onmousemove", value); - } - get onmouseout() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseout"); - } - set onmouseout(value) { - this[propertyEventListeners].set("onmouseout", value); - } - get onmouseover() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseover"); - } - set onmouseover(value) { - this[propertyEventListeners].set("onmouseover", value); - } - get onmouseup() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseup"); - } - set onmouseup(value) { - this[propertyEventListeners].set("onmouseup", value); - } - get ontouchcancel() { - return ElementEventAttributeUtility.getEventListener(this, "ontouchcancel"); - } - set ontouchcancel(value) { - this[propertyEventListeners].set("ontouchcancel", value); - } - get ontouchend() { - return ElementEventAttributeUtility.getEventListener(this, "ontouchend"); - } - set ontouchend(value) { - this[propertyEventListeners].set("ontouchend", value); - } - get ontouchmove() { - return ElementEventAttributeUtility.getEventListener(this, "ontouchmove"); - } - set ontouchmove(value) { - this[propertyEventListeners].set("ontouchmove", value); - } - get ontouchstart() { - return ElementEventAttributeUtility.getEventListener(this, "ontouchstart"); - } - set ontouchstart(value) { - this[propertyEventListeners].set("ontouchstart", value); - } - get oninvalid() { - return ElementEventAttributeUtility.getEventListener(this, "oninvalid"); - } - set oninvalid(value) { - this[propertyEventListeners].set("oninvalid", value); - } - get onanimationcancel() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationcancel"); - } - set onanimationcancel(value) { - this[propertyEventListeners].set("onanimationcancel", value); - } - get onanimationend() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationend"); - } - set onanimationend(value) { - this[propertyEventListeners].set("onanimationend", value); - } - get onanimationiteration() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationiteration"); - } - set onanimationiteration(value) { - this[propertyEventListeners].set("onanimationiteration", value); - } - get onanimationstart() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationstart"); - } - set onanimationstart(value) { - this[propertyEventListeners].set("onanimationstart", value); - } - get onbeforeinput() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforeinput"); - } - set onbeforeinput(value) { - this[propertyEventListeners].set("onbeforeinput", value); - } - get oninput() { - return ElementEventAttributeUtility.getEventListener(this, "oninput"); - } - set oninput(value) { - this[propertyEventListeners].set("oninput", value); - } - get onchange() { - return ElementEventAttributeUtility.getEventListener(this, "onchange"); - } - set onchange(value) { - this[propertyEventListeners].set("onchange", value); - } - get ongotpointercapture() { - return ElementEventAttributeUtility.getEventListener(this, "ongotpointercapture"); - } - set ongotpointercapture(value) { - this[propertyEventListeners].set("ongotpointercapture", value); - } - get onlostpointercapture() { - return ElementEventAttributeUtility.getEventListener(this, "onlostpointercapture"); - } - set onlostpointercapture(value) { - this[propertyEventListeners].set("onlostpointercapture", value); - } - get onpointercancel() { - return ElementEventAttributeUtility.getEventListener(this, "onpointercancel"); - } - set onpointercancel(value) { - this[propertyEventListeners].set("onpointercancel", value); - } - get onpointerdown() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerdown"); - } - set onpointerdown(value) { - this[propertyEventListeners].set("onpointerdown", value); - } - get onpointerenter() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerenter"); - } - set onpointerenter(value) { - this[propertyEventListeners].set("onpointerenter", value); - } - get onpointerleave() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerleave"); - } - set onpointerleave(value) { - this[propertyEventListeners].set("onpointerleave", value); - } - get onpointermove() { - return ElementEventAttributeUtility.getEventListener(this, "onpointermove"); - } - set onpointermove(value) { - this[propertyEventListeners].set("onpointermove", value); - } - get onpointerout() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerout"); - } - set onpointerout(value) { - this[propertyEventListeners].set("onpointerout", value); - } - get onpointerover() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerover"); - } - set onpointerover(value) { - this[propertyEventListeners].set("onpointerover", value); - } - get onpointerup() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerup"); - } - set onpointerup(value) { - this[propertyEventListeners].set("onpointerup", value); - } - get ontransitioncancel() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitioncancel"); - } - set ontransitioncancel(value) { - this[propertyEventListeners].set("ontransitioncancel", value); - } - get ontransitionend() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionend"); - } - set ontransitionend(value) { - this[propertyEventListeners].set("ontransitionend", value); - } - get ontransitionrun() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionrun"); - } - set ontransitionrun(value) { - this[propertyEventListeners].set("ontransitionrun", value); - } - get ontransitionstart() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionstart"); - } - set ontransitionstart(value) { - this[propertyEventListeners].set("ontransitionstart", value); - } - get accessKey() { - return this[accessKey]; - } - set accessKey(accessKey2) { - this[accessKey] = accessKey2; - } - get contentEditable() { - const contentEditable = String(this.getAttribute("contentEditable")).toLowerCase(); - switch (contentEditable) { - case "false": - case "true": - case "plaintext-only": - return contentEditable; - default: - return "inherit"; - } - } - set contentEditable(contentEditable) { - contentEditable = String(contentEditable).toLowerCase(); - switch (contentEditable) { - case "false": - case "true": - case "plaintext-only": - case "inherit": - this.setAttribute("contentEditable", contentEditable); - break; - default: - throw new this[window].SyntaxError(`Failed to set the 'contentEditable' property on 'HTMLElement': The value provided ('${contentEditable}') is not one of 'true', 'false', 'plaintext-only', or 'inherit'.`); - } - } - get isContentEditable() { - const contentEditable = this.contentEditable; - if (contentEditable === "true" || contentEditable === "plaintext-only") { - return true; - } - if (contentEditable === "inherit") { - return this[parentNode]?.isContentEditable ?? false; - } - return false; - } - get offsetHeight() { - return this[offsetHeight]; - } - get offsetWidth() { - return this[offsetWidth]; - } - get offsetLeft() { - return this[offsetLeft]; - } - get offsetTop() { - return this[offsetTop]; - } - get clientHeight() { - return this[clientHeight]; - } - get clientWidth() { - return this[clientWidth]; - } - get clientLeft() { - return this[clientLeft]; - } - get clientTop() { - return this[clientTop]; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? -1 : parsed; - } - return -1; - } - set tabIndex(tabIndex) { - const parsed = Number(tabIndex); - if (isNaN(parsed)) { - this.setAttribute("tabindex", "0"); - } else { - this.setAttribute("tabindex", String(parsed)); - } - } - get innerText() { - if (!this[isConnected]) { - return this.textContent; - } - let result = ""; - for (const childNode of this[nodeArray]) { - if (childNode[nodeType] === NodeTypeEnum_default.elementNode) { - const childElement = childNode; - const computedStyle = this[window].getComputedStyle(childElement); - if (childElement[tagName] !== "SCRIPT" && childElement[tagName] !== "STYLE" && childElement[tagName] !== "svg") { - const display = computedStyle.display; - if (display !== "none") { - const textTransform = computedStyle.textTransform; - const innerText = childElement.innerText; - if ((display === "block" || display === "flex") && result && innerText) { - result += ` -`; - } - let text = innerText; - switch (textTransform) { - case "uppercase": - text = text.toUpperCase(); - break; - case "lowercase": - text = text.toLowerCase(); - break; - case "capitalize": - text = text.replace(/(^|\s)\S/g, (l) => l.toUpperCase()); - break; - } - result += text; - } - } - } else if (childNode[nodeType] === NodeTypeEnum_default.textNode) { - result += childNode.textContent.replace(/[\n\r]/, ""); - } - } - return result; - } - set innerText(text) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - const texts = text.split(/[\n\r]/); - const ownerDocument2 = this[ownerDocument]; - for (let i = 0, max = texts.length;i < max; i++) { - if (i !== 0) { - this.appendChild(ownerDocument2.createElement("br")); - } - this.appendChild(ownerDocument2.createTextNode(texts[i])); - } - } - get outerText() { - return this.innerText; - } - set outerText(text) { - if (!this[parentNode]) { - throw new this[window].DOMException("Failed to set the 'outerHTML' property on 'Element': This element has no parent node."); - } - const texts = text.split(/[\n\r]/); - for (let i = 0, max = texts.length;i < max; i++) { - if (i !== 0) { - this[parentNode].insertBefore(this[ownerDocument].createElement("br"), this); - } - this[parentNode].insertBefore(this[ownerDocument].createTextNode(texts[i]), this); - } - this[parentNode].removeChild(this); - } - get style() { - if (!this[style]) { - this[style] = new CSSStyleDeclaration(illegalConstructor, this[window], { element: this }); - } - return this[style]; - } - set style(cssText) { - this.style.cssText = typeof cssText === "string" ? cssText : ""; - } - get dataset() { - return this[dataset] ??= new DOMStringMap(illegalConstructor, this); - } - get dir() { - return this.getAttribute("dir") || ""; - } - set dir(direction) { - this.setAttribute("dir", direction); - } - get hidden() { - return this.getAttribute("hidden") !== null; - } - set hidden(hidden) { - if (!hidden) { - this.removeAttribute("hidden"); - } else { - this.setAttribute("hidden", ""); - } - } - get inert() { - return this.getAttribute("inert") !== null; - } - set inert(inert) { - if (!inert) { - this.removeAttribute("inert"); - } else { - this.setAttribute("inert", ""); - } - } - get lang() { - return this.getAttribute("lang") || ""; - } - set lang(lang) { - this.setAttribute("lang", lang); - } - get title() { - return this.getAttribute("title") || ""; - } - set title(title) { - this.setAttribute("title", title); - } - get popover() { - const value = this.getAttribute("popover"); - switch (value) { - case null: - return null; - case "": - case "auto": - return "auto"; - case "manual": - return "manual"; - default: - return "manual"; - } - } - set popover(value) { - if (value === null) { - this.removeAttribute("popover"); - return; - } - this.setAttribute("popover", value); - } - click() { - this.dispatchEvent(new PointerEvent("click", { - bubbles: true, - composed: true, - cancelable: true - })); - } - blur() { - HTMLElementUtility.blur(this); - } - focus() { - HTMLElementUtility.focus(this); - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[accessKey] = this[accessKey]; - return clone; - } - [connectedToDocument]() { - const window2 = this[window]; - const localName2 = this[localName]; - const allCallbacks = window2.customElements[callbacks]; - if (this.constructor === window2.HTMLElement && localName2.includes("-") && allCallbacks) { - if (!this.#customElementDefineCallback) { - const callback = this.#onCustomElementConnected.bind(this); - const callbacks = allCallbacks.get(localName2); - if (callbacks) { - callbacks.unshift(callback); - } else { - allCallbacks.set(localName2, [callback]); - } - this.#customElementDefineCallback = callback; - } - } - super[connectedToDocument](); - } - [disconnectedFromDocument]() { - const window2 = this[window]; - const localName2 = this[localName]; - const allCallbacks = window2.customElements[callbacks]; - if (this.constructor === window2.HTMLElement && localName2.includes("-") && allCallbacks) { - const callbacks = allCallbacks.get(localName2); - if (callbacks && this.#customElementDefineCallback) { - const index = callbacks.indexOf(this.#customElementDefineCallback); - if (index !== -1) { - callbacks.splice(index, 1); - } - if (!callbacks.length) { - allCallbacks.delete(localName2); - } - this.#customElementDefineCallback = null; - } - } - super[disconnectedFromDocument](); - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - this[window][customElementReactionStack].enqueueReaction(this, "attributeChangedCallback", [attribute.name, replacedAttribute?.value ?? null, attribute.value]); - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - this[window][customElementReactionStack].enqueueReaction(this, "attributeChangedCallback", [removedAttribute.name, removedAttribute.value, null]); - } - [destroy]() { - super[destroy](); - this[style] = null; - this[dataset] = null; - } - #onCustomElementConnected() { - if (!this[parentNode]) { - return; - } - const window2 = this[window]; - const localName2 = this[localName]; - const newElement = this[ownerDocument].createElement(localName2); - const newCache = newElement[cache]; - newElement[nodeArray] = this[nodeArray]; - newElement[elementArray] = this[elementArray]; - newElement[childNodes] = null; - newElement[children] = null; - newElement[isConnected] = this[isConnected]; - newElement[rootNode] = this[rootNode]; - newElement[formNode] = this[formNode]; - newElement[parentNode] = this[parentNode]; - newElement[selectNode] = this[selectNode]; - newElement[textAreaNode] = this[textAreaNode]; - newElement[mutationListeners] = this[mutationListeners]; - newElement[isValue] = this[isValue]; - newElement[cache] = this[cache]; - newElement[affectsCache] = this[affectsCache]; - newElement[attributes][itemsByNamespaceURI] = this[attributes][itemsByNamespaceURI]; - newElement[attributes][itemsByName] = this[attributes][itemsByName]; - newElement[attributes][items] = this[attributes][items]; - for (const attr of newElement[attributes][items].values()) { - attr[ownerElement] = newElement; - } - this[clearCache](); - this[nodeArray] = []; - this[elementArray] = []; - this[childNodes] = null; - this[children] = null; - this[parentNode] = null; - this[rootNode] = null; - this[formNode] = null; - this[selectNode] = null; - this[textAreaNode] = null; - this[mutationListeners] = []; - this[isValue] = null; - this[cache] = newCache; - this[affectsCache] = []; - this[attributes][itemsByNamespaceURI] = new Map; - this[attributes][itemsByName] = new Map; - this[attributes][items] = new Map; - for (const node of newElement[nodeArray]) { - node[parentNode] = newElement; - } - const parentChildNodes = newElement[parentNode][nodeArray]; - const parentChildElements = newElement[parentNode][elementArray]; - parentChildNodes[parentChildNodes.indexOf(this)] = newElement; - parentChildElements[parentChildElements.indexOf(this)] = newElement; - const allCallbacks = window2.customElements[callbacks]; - const callbacks2 = allCallbacks.get(localName2); - if (callbacks2 && this.#customElementDefineCallback) { - const index = callbacks2.indexOf(this.#customElementDefineCallback); - if (index !== -1) { - callbacks2.splice(index, 1); - } - if (!callbacks2.length) { - allCallbacks.delete(localName2); - } - this.#customElementDefineCallback = null; - } - if (newElement[isConnected]) { - if (newElement[shadowRoot]) { - newElement[shadowRoot][isConnected] = true; - } - newElement[connectedToDocument](); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-hyperlink-element/HTMLHyperlinkElementUtility.js -class HTMLHyperlinkElementUtility { - element; - constructor(element) { - this.element = element; - } - getOrigin() { - try { - return new URL(this.getHref()).origin; - } catch (e) { - return ""; - } - } - getHref() { - if (!this.element.hasAttribute("href")) { - return ""; - } - try { - return new URL(this.element.getAttribute("href"), this.element[ownerDocument].location.href).href; - } catch (e) { - return this.element.getAttribute("href"); - } - } - setHref(href) { - this.element.setAttribute("href", href); - } - getProtocol() { - try { - return new URL(this.getHref()).protocol; - } catch (e) { - return ""; - } - } - setProtocol(protocol) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.protocol = protocol; - this.element.setAttribute("href", url.href); - } - getUsername() { - try { - return new URL(this.getHref()).username; - } catch (e) { - return ""; - } - } - setUsername(username) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.username = username; - this.element.setAttribute("href", url.href); - } - getPassword() { - try { - return new URL(this.getHref()).password; - } catch (e) { - return ""; - } - } - setPassword(password) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.password = password; - this.element.setAttribute("href", url.href); - } - getHost() { - try { - return new URL(this.getHref()).host; - } catch (e) { - return ""; - } - } - setHost(host) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.host = host; - this.element.setAttribute("href", url.href); - } - getHostname() { - try { - return new URL(this.getHref()).hostname; - } catch (e) { - return ""; - } - } - setHostname(hostname) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.hostname = hostname; - this.element.setAttribute("href", url.href); - } - getPort() { - try { - return new URL(this.getHref()).port; - } catch (e) { - return ""; - } - } - setPort(port) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.port = port; - this.element.setAttribute("href", url.href); - } - getPathname() { - try { - return new URL(this.getHref()).pathname; - } catch (e) { - return ""; - } - } - setPathname(pathname) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.pathname = pathname; - this.element.setAttribute("href", url.href); - } - getSearch() { - try { - return new URL(this.getHref()).search; - } catch (e) { - return ""; - } - } - setSearch(search) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.search = search; - this.element.setAttribute("href", url.href); - } - getHash() { - const href = this.element.getAttribute("href"); - if (href?.[0] === "#") { - return href; - } - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return ""; - } - return url.hash; - } - setHash(hash) { - let url; - try { - url = new URL(this.getHref()); - } catch (e) { - return; - } - url.hash = hash; - this.element.setAttribute("href", url.href); - } -} - -// node_modules/happy-dom/lib/nodes/html-anchor-element/HTMLAnchorElement.js -class HTMLAnchorElement extends HTMLElement { - [relList] = null; - #htmlHyperlinkElementUtility = new HTMLHyperlinkElementUtility(this); - get download() { - return this.getAttribute("download") || ""; - } - set download(download) { - this.setAttribute("download", download); - } - get hash() { - return this.#htmlHyperlinkElementUtility.getHash(); - } - set hash(hash) { - this.#htmlHyperlinkElementUtility.setHash(hash); - } - get href() { - return this.#htmlHyperlinkElementUtility.getHref(); - } - set href(href) { - this.#htmlHyperlinkElementUtility.setHref(href); - } - get hreflang() { - return this.getAttribute("hreflang") || ""; - } - set hreflang(hreflang) { - this.setAttribute("hreflang", hreflang); - } - get origin() { - return this.#htmlHyperlinkElementUtility.getOrigin(); - } - get ping() { - return this.getAttribute("ping") || ""; - } - set ping(ping) { - this.setAttribute("ping", ping); - } - get protocol() { - return this.#htmlHyperlinkElementUtility.getProtocol(); - } - set protocol(protocol) { - this.#htmlHyperlinkElementUtility.setProtocol(protocol); - } - get username() { - return this.#htmlHyperlinkElementUtility.getUsername(); - } - set username(username) { - this.#htmlHyperlinkElementUtility.setUsername(username); - } - get password() { - return this.#htmlHyperlinkElementUtility.getPassword(); - } - set password(password) { - this.#htmlHyperlinkElementUtility.setPassword(password); - } - get pathname() { - return this.#htmlHyperlinkElementUtility.getPathname(); - } - set pathname(pathname) { - this.#htmlHyperlinkElementUtility.setPathname(pathname); - } - get port() { - return this.#htmlHyperlinkElementUtility.getPort(); - } - set port(port) { - this.#htmlHyperlinkElementUtility.setPort(port); - } - get host() { - return this.#htmlHyperlinkElementUtility.getHost(); - } - set host(host) { - this.#htmlHyperlinkElementUtility.setHost(host); - } - get hostname() { - return this.#htmlHyperlinkElementUtility.getHostname(); - } - set hostname(hostname) { - this.#htmlHyperlinkElementUtility.setHostname(hostname); - } - get referrerPolicy() { - return this.getAttribute("referrerPolicy") || ""; - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerPolicy", referrerPolicy); - } - get rel() { - return this.getAttribute("rel") || ""; - } - set rel(rel) { - this.setAttribute("rel", rel); - } - get relList() { - if (!this[relList]) { - this[relList] = new DOMTokenList(illegalConstructor, this, "rel"); - } - return this[relList]; - } - set relList(value) { - this.setAttribute("rel", value); - } - get search() { - return this.#htmlHyperlinkElementUtility.getSearch(); - } - set search(search) { - this.#htmlHyperlinkElementUtility.setSearch(search); - } - get target() { - return this.getAttribute("target") || ""; - } - set target(target) { - this.setAttribute("target", target); - } - get text() { - return this.textContent; - } - set text(text) { - this.textContent = text; - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - toString() { - return this.href; - } - dispatchEvent(event) { - const returnValue = super.dispatchEvent(event); - if (!event[defaultPrevented] && event.type === "click" && event instanceof MouseEvent && (event.eventPhase === EventPhaseEnum_default.none || event.eventPhase === EventPhaseEnum_default.bubbling)) { - const href = this.href; - if (href) { - const features = []; - if (this.relList.contains("noreferrer")) { - features.push("noreferrer"); - } - if (this.relList.contains("noopener")) { - features.push("noopener"); - } - this[window].open(href, this.target || "_self", features.join(",")); - if (this[window].closed) { - event.stopImmediatePropagation(); - } - } - } - return returnValue; - } -} - -// node_modules/happy-dom/lib/nodes/html-area-element/HTMLAreaElement.js -class HTMLAreaElement extends HTMLElement { - [relList] = null; - #htmlHyperlinkElementUtility = new HTMLHyperlinkElementUtility(this); - get alt() { - return this.getAttribute("alt") || ""; - } - set alt(alt) { - this.setAttribute("alt", alt); - } - get coords() { - return this.getAttribute("coords") || ""; - } - set coords(coords) { - this.setAttribute("coords", coords); - } - get shape() { - return this.getAttribute("shape") || ""; - } - set shape(shape) { - this.setAttribute("shape", shape); - } - get download() { - return this.getAttribute("download") || ""; - } - set download(download) { - this.setAttribute("download", download); - } - get referrerPolicy() { - return this.getAttribute("referrerPolicy") || ""; - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerPolicy", referrerPolicy); - } - get ping() { - return this.getAttribute("ping") || ""; - } - set ping(ping) { - this.setAttribute("ping", ping); - } - get rel() { - return this.getAttribute("rel") || ""; - } - set rel(rel) { - this.setAttribute("rel", rel); - } - get relList() { - if (!this[relList]) { - this[relList] = new DOMTokenList(illegalConstructor, this, "rel"); - } - return this[relList]; - } - set relList(value) { - this.setAttribute("rel", value); - } - get target() { - return this.getAttribute("target") || ""; - } - set target(target) { - this.setAttribute("target", target); - } - get origin() { - return this.#htmlHyperlinkElementUtility.getOrigin(); - } - get href() { - return this.#htmlHyperlinkElementUtility.getHref(); - } - set href(href) { - this.#htmlHyperlinkElementUtility.setHref(href); - } - get protocol() { - return this.#htmlHyperlinkElementUtility.getProtocol(); - } - set protocol(protocol) { - this.#htmlHyperlinkElementUtility.setProtocol(protocol); - } - get username() { - return this.#htmlHyperlinkElementUtility.getUsername(); - } - set username(username) { - this.#htmlHyperlinkElementUtility.setUsername(username); - } - get password() { - return this.#htmlHyperlinkElementUtility.getPassword(); - } - set password(password) { - this.#htmlHyperlinkElementUtility.setPassword(password); - } - get host() { - return this.#htmlHyperlinkElementUtility.getHost(); - } - set host(host) { - this.#htmlHyperlinkElementUtility.setHost(host); - } - get hostname() { - return this.#htmlHyperlinkElementUtility.getHostname(); - } - set hostname(hostname) { - this.#htmlHyperlinkElementUtility.setHostname(hostname); - } - get port() { - return this.#htmlHyperlinkElementUtility.getPort(); - } - set port(port) { - this.#htmlHyperlinkElementUtility.setPort(port); - } - get pathname() { - return this.#htmlHyperlinkElementUtility.getPathname(); - } - set pathname(pathname) { - this.#htmlHyperlinkElementUtility.setPathname(pathname); - } - get search() { - return this.#htmlHyperlinkElementUtility.getSearch(); - } - set search(search) { - this.#htmlHyperlinkElementUtility.setSearch(search); - } - get hash() { - return this.#htmlHyperlinkElementUtility.getHash(); - } - set hash(hash) { - this.#htmlHyperlinkElementUtility.setHash(hash); - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - toString() { - return this.href; - } - dispatchEvent(event) { - const returnValue = super.dispatchEvent(event); - if (!event[defaultPrevented] && event[type] === "click" && event[eventPhase] === EventPhaseEnum_default.none && event instanceof MouseEvent) { - const href = this.href; - if (href) { - this[window].open(href, this.target || "_self"); - if (this[window].closed) { - event.stopImmediatePropagation(); - } - } - } - return returnValue; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TimeRanges.js -class TimeRanges { - constructor(illegalConstructorSymbol) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - } - get length() { - return 0; - } - get [Symbol.toStringTag]() { - return "TimeRanges"; - } - toLocaleString() { - return "[object TimeRanges]"; - } - toString() { - return "[object TimeRanges]"; - } - start(_index) { - return 0; - } - end(_index) { - return 0; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/MediaStream.js -import Crypto2 from "crypto"; - -// node_modules/happy-dom/lib/event/events/MediaStreamTrackEvent.js -class MediaStreamTrackEvent extends Event { - track; - constructor(type, eventInit = null) { - super(type, eventInit); - this.track = eventInit?.track ?? null; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/MediaStream.js -class MediaStream extends EventTarget { - active = true; - id = Crypto2.randomUUID(); - onaddtrack = null; - onremovetrack = null; - [tracks] = []; - constructor(streamOrTracks) { - super(); - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - if (streamOrTracks !== undefined) { - this[tracks] = streamOrTracks instanceof MediaStream ? streamOrTracks[tracks].slice() : streamOrTracks; - } - } - addTrack(track) { - if (this[tracks].includes(track)) { - return; - } - this[tracks].push(track); - this.dispatchEvent(new MediaStreamTrackEvent("addtrack", { track })); - } - clone() { - return new this.constructor(this); - } - getAudioTracks() { - return this[tracks].filter((track) => track.kind === "audio"); - } - getTrackById(id) { - for (const track of this[tracks]) { - if (track.id === id) { - return track; - } - } - return null; - } - getVideoTracks() { - return this[tracks].filter((track) => track.kind === "video"); - } - removeTrack(track) { - const index = this[tracks].indexOf(track); - if (index === -1) { - return; - } - this[tracks].splice(index, 1); - this.dispatchEvent(new MediaStreamTrackEvent("removetrack", { track })); - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TextTrackKindEnum.js -var TextTrackKindEnum; -(function(TextTrackKindEnum) { - TextTrackKindEnum["subtitles"] = "subtitles"; - TextTrackKindEnum["captions"] = "captions"; - TextTrackKindEnum["descriptions"] = "descriptions"; - TextTrackKindEnum["chapters"] = "chapters"; - TextTrackKindEnum["metadata"] = "metadata"; -})(TextTrackKindEnum || (TextTrackKindEnum = {})); -var TextTrackKindEnum_default = TextTrackKindEnum; - -// node_modules/happy-dom/lib/nodes/html-media-element/HTMLMediaElement.js -class HTMLMediaElement extends HTMLElement { - [volume] = 1; - [paused] = true; - [currentTime] = 0; - [playbackRate] = 1; - [defaultPlaybackRate] = 1; - [muted] = false; - [defaultMuted] = false; - [preservesPitch] = true; - [buffered] = new TimeRanges(illegalConstructor); - [duration] = NaN; - [error] = null; - [ended] = false; - [networkState] = 0; - [readyState] = 0; - [seeking] = false; - [seekable] = new TimeRanges(illegalConstructor); - [sinkId] = ""; - [played] = new TimeRanges(illegalConstructor); - [remote] = new this[window].RemotePlayback; - [controlsList] = null; - [mediaKeys] = null; - [srcObject] = null; - [textTracks] = []; - get onabort() { - return ElementEventAttributeUtility.getEventListener(this, "onabort"); - } - set onabort(value) { - this[propertyEventListeners].set("onabort", value); - } - get oncanplay() { - return ElementEventAttributeUtility.getEventListener(this, "oncanplay"); - } - set oncanplay(value) { - this[propertyEventListeners].set("oncanplay", value); - } - get oncanplaythrough() { - return ElementEventAttributeUtility.getEventListener(this, "oncanplaythrough"); - } - set oncanplaythrough(value) { - this[propertyEventListeners].set("oncanplaythrough", value); - } - get ondurationchange() { - return ElementEventAttributeUtility.getEventListener(this, "ondurationchange"); - } - set ondurationchange(value) { - this[propertyEventListeners].set("ondurationchange", value); - } - get onemptied() { - return ElementEventAttributeUtility.getEventListener(this, "onemptied"); - } - set onemptied(value) { - this[propertyEventListeners].set("onemptied", value); - } - get onended() { - return ElementEventAttributeUtility.getEventListener(this, "onended"); - } - set onended(value) { - this[propertyEventListeners].set("onended", value); - } - get onloadeddata() { - return ElementEventAttributeUtility.getEventListener(this, "onloadeddata"); - } - set onloadeddata(value) { - this[propertyEventListeners].set("onloadeddata", value); - } - get onloadedmetadata() { - return ElementEventAttributeUtility.getEventListener(this, "onloadedmetadata"); - } - set onloadedmetadata(value) { - this[propertyEventListeners].set("onloadedmetadata", value); - } - get onloadstart() { - return ElementEventAttributeUtility.getEventListener(this, "onloadstart"); - } - set onloadstart(value) { - this[propertyEventListeners].set("onloadstart", value); - } - get onpause() { - return ElementEventAttributeUtility.getEventListener(this, "onpause"); - } - set onpause(value) { - this[propertyEventListeners].set("onpause", value); - } - get onplay() { - return ElementEventAttributeUtility.getEventListener(this, "onplay"); - } - set onplay(value) { - this[propertyEventListeners].set("onplay", value); - } - get onplaying() { - return ElementEventAttributeUtility.getEventListener(this, "onplaying"); - } - set onplaying(value) { - this[propertyEventListeners].set("onplaying", value); - } - get onprogress() { - return ElementEventAttributeUtility.getEventListener(this, "onprogress"); - } - set onprogress(value) { - this[propertyEventListeners].set("onprogress", value); - } - get onratechange() { - return ElementEventAttributeUtility.getEventListener(this, "onratechange"); - } - set onratechange(value) { - this[propertyEventListeners].set("onratechange", value); - } - get onresize() { - return ElementEventAttributeUtility.getEventListener(this, "onresize"); - } - set onresize(value) { - this[propertyEventListeners].set("onresize", value); - } - get onseeked() { - return ElementEventAttributeUtility.getEventListener(this, "onseeked"); - } - set onseeked(value) { - this[propertyEventListeners].set("onseeked", value); - } - get onseeking() { - return ElementEventAttributeUtility.getEventListener(this, "onseeking"); - } - set onseeking(value) { - this[propertyEventListeners].set("onseeking", value); - } - get onstalled() { - return ElementEventAttributeUtility.getEventListener(this, "onstalled"); - } - set onstalled(value) { - this[propertyEventListeners].set("onstalled", value); - } - get onsuspend() { - return ElementEventAttributeUtility.getEventListener(this, "onsuspend"); - } - set onsuspend(value) { - this[propertyEventListeners].set("onsuspend", value); - } - get ontimeupdate() { - return ElementEventAttributeUtility.getEventListener(this, "ontimeupdate"); - } - set ontimeupdate(value) { - this[propertyEventListeners].set("ontimeupdate", value); - } - get onvolumechange() { - return ElementEventAttributeUtility.getEventListener(this, "onvolumechange"); - } - set onvolumechange(value) { - this[propertyEventListeners].set("onvolumechange", value); - } - get onwaiting() { - return ElementEventAttributeUtility.getEventListener(this, "onwaiting"); - } - set onwaiting(value) { - this[propertyEventListeners].set("onwaiting", value); - } - get buffered() { - return this[buffered]; - } - get duration() { - return this[duration]; - } - get error() { - return this[error]; - } - get ended() { - return this[ended]; - } - get networkState() { - return this[networkState]; - } - get readyState() { - return this[readyState]; - } - get remote() { - return this[remote]; - } - get seeking() { - return this[seeking]; - } - get seekable() { - return this[seekable]; - } - get sinkId() { - return this[sinkId]; - } - get played() { - return this[played]; - } - get autoplay() { - return this.getAttribute("autoplay") !== null; - } - set autoplay(autoplay) { - if (!autoplay) { - this.removeAttribute("autoplay"); - } else { - this.setAttribute("autoplay", ""); - } - } - get controls() { - return this.getAttribute("controls") !== null; - } - set controls(controls) { - if (!controls) { - this.removeAttribute("controls"); - } else { - this.setAttribute("controls", ""); - } - } - get loop() { - return this.getAttribute("loop") !== null; - } - set loop(loop) { - if (!loop) { - this.removeAttribute("loop"); - } else { - this.setAttribute("loop", ""); - } - } - get preload() { - return this.getAttribute("preload") || "auto"; - } - set preload(preload) { - this.setAttribute("preload", preload); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src"); - } - } - set src(src) { - this.setAttribute("src", src); - if (Boolean(src)) { - this.dispatchEvent(new Event("canplay", { bubbles: false, cancelable: false })); - this.dispatchEvent(new Event("durationchange", { bubbles: false, cancelable: false })); - } - } - get controlsList() { - if (this[controlsList] === null) { - this[controlsList] = new DOMTokenList(illegalConstructor, this, "controlslist"); - } - return this[controlsList]; - } - set controlsList(value) { - this.setAttribute("controlslist", value); - } - get mediaKeys() { - return this[mediaKeys]; - } - get muted() { - if (this[muted]) { - return this[muted]; - } - if (!this[defaultMuted]) { - return this.getAttribute("muted") !== null; - } - return false; - } - set muted(muted2) { - this[muted] = !!muted2; - if (!muted2 && !this[defaultMuted]) { - this.removeAttribute("muted"); - } else { - this.setAttribute("muted", ""); - } - } - get defaultMuted() { - return this[defaultMuted]; - } - set defaultMuted(defaultMuted2) { - this[defaultMuted] = !!defaultMuted2; - if (!this[defaultMuted] && !this[muted]) { - this.removeAttribute("muted"); - } else { - this.setAttribute("muted", ""); - } - } - get disableRemotePlayback() { - return this.getAttribute("disableremoteplayback") !== null; - } - set disableRemotePlayback(disableRemotePlayback) { - if (!disableRemotePlayback) { - this.removeAttribute("disableremoteplayback"); - } else { - this.setAttribute("disableremoteplayback", ""); - } - } - get srcObject() { - return this[srcObject]; - } - set srcObject(srcObject2) { - if (srcObject2 !== null && !(srcObject2 instanceof MediaStream)) { - throw new this[window].TypeError(`Failed to set the 'srcObject' property on 'HTMLMediaElement': The provided value is not of type 'MediaStream'.`); - } - this[srcObject] = srcObject2; - } - get textTracks() { - const items2 = []; - for (const track of this[textTracks]) { - items2.push(track); - } - for (const track of this.querySelectorAll("track")[items]) { - items2.push(track.track); - } - return new this[window].TextTrackList(illegalConstructor, items2); - } - get currentSrc() { - const src = this.src; - if (src) { - return src; - } - const sourceElement = this.querySelector("source"); - return sourceElement ? sourceElement.src : ""; - } - get volume() { - return this[volume]; - } - set volume(volume2) { - const parsedVolume = Number(volume2); - if (isNaN(parsedVolume)) { - throw new this[window].TypeError(`Failed to set the 'volume' property on 'HTMLMediaElement': The provided double value is non-finite.`); - } - if (parsedVolume < 0 || parsedVolume > 1) { - throw new this[window].DOMException(`Failed to set the 'volume' property on 'HTMLMediaElement': The volume provided (${parsedVolume}) is outside the range [0, 1].`, DOMExceptionNameEnum_default.indexSizeError); - } - this[volume] = parsedVolume; - } - get crossOrigin() { - const crossOrigin = this.getAttribute("crossorigin"); - if (crossOrigin === "use-credentials") { - return "use-credentials"; - } - if (crossOrigin !== null) { - return "anonymous"; - } - return null; - } - set crossOrigin(crossOrigin) { - this.setAttribute("crossorigin", crossOrigin); - } - get currentTime() { - return this[currentTime]; - } - set currentTime(currentTime2) { - const parsedCurrentTime = Number(currentTime2); - if (isNaN(parsedCurrentTime)) { - throw new this[window].TypeError(`Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite.`); - } - this[currentTime] = parsedCurrentTime; - } - get playbackRate() { - return this[playbackRate]; - } - set playbackRate(playbackRate2) { - const parsedPlaybackRate = Number(playbackRate2); - if (isNaN(parsedPlaybackRate)) { - throw new this[window].TypeError(`Failed to set the 'playbackRate' property on 'HTMLMediaElement': The provided double value is non-finite.`); - } - this[playbackRate] = parsedPlaybackRate; - } - get defaultPlaybackRate() { - return this[defaultPlaybackRate]; - } - set defaultPlaybackRate(defaultPlaybackRate2) { - const parsedDefaultPlaybackRate = Number(defaultPlaybackRate2); - if (isNaN(parsedDefaultPlaybackRate)) { - throw new this[window].TypeError(`Failed to set the 'defaultPlaybackRate' property on 'HTMLMediaElement': The provided double value is non-finite.`); - } - this[defaultPlaybackRate] = parsedDefaultPlaybackRate; - } - get preservesPitch() { - return this[preservesPitch]; - } - set preservesPitch(preservesPitch2) { - this[preservesPitch] = Boolean(preservesPitch2); - } - get paused() { - return this[paused]; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - addTextTrack(kind2, label2, language2) { - const window2 = this[window]; - if (arguments.length === 0) { - throw new window2.TypeError(`Failed to execute 'addTextTrack' on 'HTMLMediaElement': 1 argument required, but only 0 present.`); - } - if (!TextTrackKindEnum_default[kind2]) { - throw new window2.TypeError(`Failed to execute 'addTextTrack' on 'HTMLMediaElement': The provided value '${kind2}' is not a valid enum value of type TextTrackKind.`); - } - const track = new window2.TextTrack(illegalConstructor); - track[kind] = kind2; - track[label] = label2 || ""; - track[language] = language2 || ""; - this[textTracks].push(track); - return track; - } - pause() { - if (this[paused]) { - return; - } - this[paused] = true; - this.dispatchEvent(new Event("pause", { bubbles: false, cancelable: false })); - } - async play() { - if (!this[paused]) { - return; - } - this[paused] = false; - this.dispatchEvent(new Event("play", { bubbles: false, cancelable: false })); - this.dispatchEvent(new Event("playing", { bubbles: false, cancelable: false })); - } - canPlayType(_type) { - return ""; - } - fastSeek(_time) {} - load() { - this.dispatchEvent(new Event("emptied", { bubbles: false, cancelable: false })); - } - async setMediaKeys(mediaKeys2) { - this[mediaKeys] = mediaKeys2; - } - async setSinkId(sinkId2) { - this[sinkId] = sinkId2; - } - captureStream() { - return new this[window].MediaStream; - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } -} - -// node_modules/happy-dom/lib/nodes/html-audio-element/HTMLAudioElement.js -class HTMLAudioElement extends HTMLMediaElement { -} - -// node_modules/happy-dom/lib/nodes/html-base-element/HTMLBaseElement.js -class HTMLBaseElement extends HTMLElement { - get href() { - if (!this.hasAttribute("href")) { - return this[ownerDocument].location.href; - } - try { - return new URL(this.getAttribute("href"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("href"); - } - } - set href(href) { - this.setAttribute("href", href); - } - get target() { - return this.getAttribute("target") || ""; - } - set target(target) { - this.setAttribute("target", target); - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } -} - -// node_modules/happy-dom/lib/nodes/html-body-element/HTMLBodyElement.js -class HTMLBodyElement extends HTMLElement { - get onafterprint() { - return ElementEventAttributeUtility.getEventListener(this, "onafterprint"); - } - set onafterprint(value) { - this[propertyEventListeners].set("onafterprint", value); - } - get onbeforeprint() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforeprint"); - } - set onbeforeprint(value) { - this[propertyEventListeners].set("onbeforeprint", value); - } - get onbeforeunload() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforeunload"); - } - set onbeforeunload(value) { - this[propertyEventListeners].set("onbeforeunload", value); - } - get ongamepadconnected() { - return ElementEventAttributeUtility.getEventListener(this, "ongamepadconnected"); - } - set ongamepadconnected(value) { - this[propertyEventListeners].set("ongamepadconnected", value); - } - get ongamepaddisconnected() { - return ElementEventAttributeUtility.getEventListener(this, "ongamepaddisconnected"); - } - set ongamepaddisconnected(value) { - this[propertyEventListeners].set("ongamepaddisconnected", value); - } - get onhashchange() { - return ElementEventAttributeUtility.getEventListener(this, "onhashchange"); - } - set onhashchange(value) { - this[propertyEventListeners].set("onhashchange", value); - } - get onlanguagechange() { - return ElementEventAttributeUtility.getEventListener(this, "onlanguagechange"); - } - set onlanguagechange(value) { - this[propertyEventListeners].set("onlanguagechange", value); - } - get onmessage() { - return ElementEventAttributeUtility.getEventListener(this, "onmessage"); - } - set onmessage(value) { - this[propertyEventListeners].set("onmessage", value); - } - get onmessageerror() { - return ElementEventAttributeUtility.getEventListener(this, "onmessageerror"); - } - set onmessageerror(value) { - this[propertyEventListeners].set("onmessageerror", value); - } - get onoffline() { - return ElementEventAttributeUtility.getEventListener(this, "onoffline"); - } - set onoffline(value) { - this[propertyEventListeners].set("onoffline", value); - } - get ononline() { - return ElementEventAttributeUtility.getEventListener(this, "ononline"); - } - set ononline(value) { - this[propertyEventListeners].set("ononline", value); - } - get onpagehide() { - return ElementEventAttributeUtility.getEventListener(this, "onpagehide"); - } - set onpagehide(value) { - this[propertyEventListeners].set("onpagehide", value); - } - get onpageshow() { - return ElementEventAttributeUtility.getEventListener(this, "onpageshow"); - } - set onpageshow(value) { - this[propertyEventListeners].set("onpageshow", value); - } - get onpopstate() { - return ElementEventAttributeUtility.getEventListener(this, "onpopstate"); - } - set onpopstate(value) { - this[propertyEventListeners].set("onpopstate", value); - } - get onrejectionhandled() { - return ElementEventAttributeUtility.getEventListener(this, "onrejectionhandled"); - } - set onrejectionhandled(value) { - this[propertyEventListeners].set("onrejectionhandled", value); - } - get onstorage() { - return ElementEventAttributeUtility.getEventListener(this, "onstorage"); - } - set onstorage(value) { - this[propertyEventListeners].set("onstorage", value); - } - get onunhandledrejection() { - return ElementEventAttributeUtility.getEventListener(this, "onunhandledrejection"); - } - set onunhandledrejection(value) { - this[propertyEventListeners].set("onunhandledrejection", value); - } - get onunload() { - return ElementEventAttributeUtility.getEventListener(this, "onunload"); - } - set onunload(value) { - this[propertyEventListeners].set("onunload", value); - } -} - -// node_modules/happy-dom/lib/nodes/html-br-element/HTMLBRElement.js -class HTMLBRElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/validity-state/ValidityState.js -var EMAIL_REGEXP = /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/; -var URL_REGEXP2 = /^(?:(?:https?|HTTPS?|ftp|FTP):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)(?:\.(?:[a-zA-Z\u00a1-\uffff0-9]-*)*[a-zA-Z\u00a1-\uffff0-9]+)*)(?::\d{2,5})?(?:[\/?#]\S*)?$/; - -class ValidityState { - element; - constructor(element) { - this.element = element; - } - get badInput() { - return this.element[localName] === "input" && (this.element.type === "number" || this.element.type === "range") && this.element.value.length > 0 && !/^[-+]?(?:\d+|\d*[.,]\d+)$/.test(this.element.value); - } - get customError() { - return this.element[validationMessage].length > 0; - } - get patternMismatch() { - return this.element[localName] === "input" && this.element.hasAttribute("pattern") && this.element.value.length > 0 && this.element.value.replace(new RegExp(this.element.getAttribute("pattern")), "").length > 0; - } - get rangeOverflow() { - return this.element[localName] === "input" && this.element.hasAttribute("max") && (this.element.type === "number" || this.element.type === "range") && this.element.value.length > 0 && Number(this.element.value) > Number(this.element.getAttribute("max")); - } - get rangeUnderflow() { - return this.element[localName] === "input" && this.element.hasAttribute("min") && (this.element.type === "number" || this.element.type === "range") && this.element.value.length > 0 && Number(this.element.value) < Number(this.element.getAttribute("min")); - } - get stepMismatch() { - return this.element[localName] === "input" && (this.element.type === "number" || this.element.type === "range") && (this.element.hasAttribute("step") && this.element.getAttribute("step") !== "any" && Number(this.element.value) % Number(this.element.getAttribute("step")) !== 0 || !this.element.hasAttribute("step") && Number(this.element.value) % 1 !== 0); - } - get tooLong() { - return (this.element[localName] === "input" || this.element[localName] === "textarea") && this.element.maxLength > 0 && this.element.value.length > this.element.maxLength; - } - get tooShort() { - return (this.element[localName] === "input" || this.element[localName] === "textarea") && this.element.minLength > 0 && this.element.value.length > 0 && this.element.value.length < this.element.minLength; - } - get typeMismatch() { - return this.element[localName] === "input" && this.element.value.length > 0 && (this.element.type === "email" && !EMAIL_REGEXP.test(this.element.value) || this.element.type === "url" && !URL_REGEXP2.test(this.element.value)); - } - get valueMissing() { - if (!this.element.required || this.element[localName] === "object" || this.element[localName] === "output") { - return false; - } - if (this.element[localName] === "input") { - if (this.element.type === "checkbox") { - return !this.element.checked; - } else if (this.element.type === "radio") { - if (this.element.checked) { - return false; - } - if (!this.element.name) { - return true; - } - const root = this.element[formNode] || this.element.getRootNode(); - return !root || !root.querySelector(`input[name="${this.element.name}"]:checked`); - } - } - return this.element.value.length === 0; - } - get valid() { - return !this.badInput && !this.customError && !this.patternMismatch && !this.rangeOverflow && !this.rangeUnderflow && !this.stepMismatch && !this.tooLong && !this.tooShort && !this.typeMismatch && !this.valueMissing; - } -} - -// node_modules/happy-dom/lib/nodes/html-label-element/HTMLLabelElementUtility.js -class HTMLLabelElementUtility { - static getAssociatedLabelElements(element) { - const id = element.id; - let labels; - if (id && element[isConnected]) { - const rootNode2 = element[rootNode] || element[ownerDocument]; - labels = rootNode2.querySelectorAll(`label[for="${id}"]`)[items].slice(); - } else { - labels = []; - } - let parent = element[parentNode]; - while (parent) { - if (parent["tagName"] === "LABEL") { - labels.push(parent); - break; - } - parent = parent[parentNode]; - } - return new NodeList_default(illegalConstructor, labels); - } -} - -// node_modules/happy-dom/lib/nodes/html-button-element/HTMLButtonElement.js -import { URL as URL8 } from "url"; -var BUTTON_TYPES = ["submit", "reset", "button", "menu"]; - -class HTMLButtonElement extends HTMLElement { - [validationMessage] = ""; - [validity] = new ValidityState(this); - [formNode] = null; - [popoverTargetElement] = null; - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get value() { - return this.getAttribute("value") || ""; - } - set value(value) { - this.setAttribute("value", value); - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - get type() { - const type = this.getAttribute("type"); - if (type === null || !BUTTON_TYPES.includes(type)) { - return "submit"; - } - return type; - } - set type(value) { - this.setAttribute("type", value); - } - get formAction() { - if (!this.hasAttribute("formaction")) { - return this[ownerDocument].location.href; - } - try { - return new URL8(this.getAttribute("formaction"), this[ownerDocument].location.href).href; - } catch (e) { - return ""; - } - } - set formAction(formAction) { - this.setAttribute("formaction", formAction); - } - get formEnctype() { - return this.getAttribute("formenctype") || ""; - } - set formEnctype(formEnctype) { - this.setAttribute("formenctype", formEnctype); - } - get formMethod() { - return this.getAttribute("formmethod") || ""; - } - set formMethod(formMethod) { - this.setAttribute("formmethod", formMethod); - } - get formNoValidate() { - return this.getAttribute("formnovalidate") !== null; - } - set formNoValidate(formNoValidate) { - if (!formNoValidate) { - this.removeAttribute("formnovalidate"); - } else { - this.setAttribute("formnovalidate", ""); - } - } - get formTarget() { - return this.getAttribute("formtarget") || ""; - } - set formTarget(formTarget) { - this.setAttribute("formtarget", formTarget); - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } - get popoverTargetElement() { - return this[popoverTargetElement]; - } - set popoverTargetElement(popoverTargetElement2) { - if (popoverTargetElement2 !== null && !(popoverTargetElement2 instanceof HTMLElement)) { - throw new this[window].TypeError(`Failed to set the 'popoverTargetElement' property on 'HTMLInputElement': Failed to convert value to 'Element'.`); - } - this[popoverTargetElement] = popoverTargetElement2; - } - get popoverTargetAction() { - const value = this.getAttribute("popovertargetaction"); - if (value === null || value !== "hide" && value !== "show" && value !== "toggle") { - return "toggle"; - } - return value; - } - set popoverTargetAction(value) { - this.setAttribute("popovertargetaction", value); - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - checkValidity() { - const valid = this.disabled || this.type === "reset" || this.type === "button" || this[validity].valid; - if (!valid) { - this.dispatchEvent(new Event("invalid", { bubbles: true, cancelable: true })); - } - return valid; - } - reportValidity() { - return this.checkValidity(); - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } - dispatchEvent(event) { - if (event.type === "click" && event instanceof MouseEvent && event.eventPhase === EventPhaseEnum_default.none && this.disabled) { - return false; - } - const returnValue = super.dispatchEvent(event); - if (!event[defaultPrevented] && event.type === "click" && event.eventPhase === EventPhaseEnum_default.none && event instanceof MouseEvent) { - const type = this.type; - if (type === "submit" || type === "reset") { - const form = this.form; - if (form) { - if (type === "submit" && this[isConnected]) { - form.requestSubmit(this); - } else if (type === "reset") { - form.reset(); - } - } - } - } - return returnValue; - } -} - -// node_modules/happy-dom/lib/canvas/OffscreenCanvas.js -class OffscreenCanvas { - [context] = null; - width; - height; - constructor(width, height) { - this.width = width; - this.height = height; - } - getContext(contextType, contextAttributes) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'getContext' on 'OffscreenCanvas': Browser frame is not available. This happens when the browser is closing.`); - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - return null; - } - this[context] = adapter.getContext({ - window: this[window], - browserFrame, - canvas: this - }, contextType, contextAttributes); - return this[context]; - } - convertToBlob(options) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'getContext' on 'OffscreenCanvas': Browser frame is not available. This happens when the browser is closing.`); - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - return new Promise((resolve) => { - this[window].requestAnimationFrame(() => resolve(new Blob([], options))); - }); - } - return new Promise((resolve, reject) => { - adapter.toBlob({ - window: this[window], - browserFrame, - canvas: this - }, (blob) => { - if (blob) { - resolve(blob); - } else { - reject(new this[window].DOMException(`Failed to execute 'convertToBlob' on 'OffscreenCanvas': The canvas could not be converted to a Blob.`, DOMExceptionNameEnum_default.encodingError)); - } - }, options?.type, options?.quality); - }); - } - transferToImageBitmap() { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'getContext' on 'OffscreenCanvas': Browser frame is not available. This happens when the browser is closing.`); - } - const window2 = this[window]; - const settings = new WindowBrowserContext(window2).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - return new window2.ImageBitmap(illegalConstructor, this[window], this); - } - const context2 = this[context]; - if (!context2) { - throw new this[window].TypeError(`Failed to execute 'transferToImageBitmap' on 'OffscreenCanvas': Cannot transfer an ImageBitmap from an OffscreenCanvas with no context`); - } - const imageBitmap = new window2.ImageBitmap(illegalConstructor, this[window], this); - context2.clearRect(0, 0, this.width, this.height); - return imageBitmap; - } -} - -// node_modules/happy-dom/lib/nodes/html-canvas-element/HTMLCanvasElement.js -var DEVICE_ID = "S3F/aBCdEfGHIjKlMnOpQRStUvWxYz1234567890+1AbC2DEf2GHi3jK34le+ab12C3+1aBCdEf=="; -var CanvasModeEnum; -(function(CanvasModeEnum) { - CanvasModeEnum["none"] = "none"; - CanvasModeEnum["context"] = "context"; - CanvasModeEnum["offscreen"] = "offscreen"; -})(CanvasModeEnum || (CanvasModeEnum = {})); - -class HTMLCanvasElement extends HTMLElement { - #mode = CanvasModeEnum.none; - #offscreenCanvas = null; - get oncontextlost() { - return ElementEventAttributeUtility.getEventListener(this, "oncontextlost"); - } - set oncontextlost(value) { - this[propertyEventListeners].set("oncontextlost", value); - } - get oncontextrestored() { - return ElementEventAttributeUtility.getEventListener(this, "oncontextrestored"); - } - set oncontextrestored(value) { - this[propertyEventListeners].set("oncontextrestored", value); - } - get onwebglcontextcreationerror() { - return ElementEventAttributeUtility.getEventListener(this, "onwebglcontextcreationerror"); - } - set onwebglcontextcreationerror(value) { - this[propertyEventListeners].set("onwebglcontextcreationerror", value); - } - get onwebglcontextlost() { - return ElementEventAttributeUtility.getEventListener(this, "onwebglcontextlost"); - } - set onwebglcontextlost(value) { - this[propertyEventListeners].set("onwebglcontextlost", value); - } - get onwebglcontextrestored() { - return ElementEventAttributeUtility.getEventListener(this, "onwebglcontextrestored"); - } - set onwebglcontextrestored(value) { - this[propertyEventListeners].set("onwebglcontextrestored", value); - } - get width() { - const width = this.getAttribute("width"); - if (width === null) { - return 300; - } - const parsed = parseInt(width, 10); - return isNaN(parsed) ? 300 : parsed; - } - set width(width) { - this.setAttribute("width", String(width)); - } - get height() { - const height = this.getAttribute("height"); - if (height === null) { - return 150; - } - const parsed = parseInt(height, 10); - return isNaN(parsed) ? 150 : parsed; - } - set height(height) { - this.setAttribute("height", String(height)); - } - captureStream(frameRate) { - const stream = new this[window].MediaStream; - const track = new this[window].CanvasCaptureMediaStreamTrack(illegalConstructor, this); - track[kind] = "video"; - track[capabilities].deviceId = DEVICE_ID; - track[capabilities].aspectRatio.max = this.width; - track[capabilities].height.max = this.height; - track[capabilities].width.max = this.width; - track[settings].deviceId = DEVICE_ID; - if (frameRate !== undefined) { - track[capabilities].frameRate.max = frameRate; - track[settings].frameRate = frameRate; - } - stream.addTrack(track); - return stream; - } - getContext(contextType, contextAttributes) { - if (this.#mode === CanvasModeEnum.offscreen) { - throw new this[window].DOMException(`Failed to execute 'getContext' on 'HTMLCanvasElement': Cannot get context from a canvas that has transferred its control to offscreen.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.#mode = CanvasModeEnum.context; - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'getContext' on 'HTMLCanvasElement': Browser frame is not available. This happens when the browser is closing.`); - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - return null; - } - return adapter.getContext({ - browserFrame, - window: this[window], - canvas: this - }, contextType, contextAttributes); - } - toDataURL(type, quality) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'toDataURL' on 'HTMLCanvasElement': Browser frame is not available. This happens when the browser is closing.`); - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - return `data:${type || "image/png"};base64,${Buffer.from([]).toString("base64")}`; - } - if (this.#offscreenCanvas) { - return adapter.toDataURL({ - browserFrame, - window: this[window], - canvas: this.#offscreenCanvas - }, type, quality); - } - return adapter.toDataURL({ - browserFrame, - window: this[window], - canvas: this - }, type, quality); - } - toBlob(callback, type, quality) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - throw new this[window].Error(`Failed to execute 'toBlob' on 'HTMLCanvasElement': Browser frame is not available. This happens when the browser is closing.`); - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - const adapter = settings?.canvasAdapter; - if (!adapter) { - this[window].requestAnimationFrame(() => callback(new Blob([], { type: type || "image/png" }))); - return; - } - if (this.#offscreenCanvas) { - adapter.toBlob({ - browserFrame, - window: this[window], - canvas: this.#offscreenCanvas - }, callback, type, quality); - return; - } - adapter.toBlob({ - browserFrame, - window: this[window], - canvas: this - }, callback, type, quality); - } - transferControlToOffscreen() { - if (this.#mode === CanvasModeEnum.context) { - throw new this[window].DOMException(`Failed to execute 'transferControlToOffscreen' on 'HTMLCanvasElement': Cannot transfer control from a canvas that has a rendering context.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (this.#mode === CanvasModeEnum.offscreen) { - throw new this[window].DOMException(`Failed to execute 'transferControlToOffscreen' on 'HTMLCanvasElement': Cannot transfer control from a canvas for more than one time.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.#mode = CanvasModeEnum.offscreen; - this.#offscreenCanvas = new OffscreenCanvas(this.width, this.height); - return this.#offscreenCanvas; - } -} - -// node_modules/happy-dom/lib/nodes/html-d-list-element/HTMLDListElement.js -class HTMLDListElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-data-element/HTMLDataElement.js -class HTMLDataElement extends HTMLElement { - get value() { - return this.getAttribute("value") || ""; - } - set value(value) { - this.setAttribute("value", value); - } -} - -// node_modules/happy-dom/lib/nodes/html-data-list-element/HTMLDataListElement.js -class HTMLDataListElement extends HTMLElement { - [options] = null; - get options() { - if (!this[options]) { - this[options] = ParentNodeUtility.getElementsByTagName(this, "OPTION"); - } - return this[options]; - } -} - -// node_modules/happy-dom/lib/nodes/html-details-element/HTMLDetailsElement.js -class HTMLDetailsElement extends HTMLElement { - get ontoggle() { - return ElementEventAttributeUtility.getEventListener(this, "ontoggle"); - } - set ontoggle(value) { - this[propertyEventListeners].set("ontoggle", value); - } - get open() { - return this.getAttribute("open") !== null; - } - set open(open) { - if (open) { - this.setAttribute("open", ""); - } else { - this.removeAttribute("open"); - } - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "open") { - if (attribute[value] !== replacedAttribute?.[value]) { - this.dispatchEvent(new Event("toggle")); - } - } - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - if (removedAttribute && removedAttribute[name] === "open") { - this.dispatchEvent(new Event("toggle")); - } - } - dispatchEvent(event) { - const returnValue = super.dispatchEvent(event); - if (!event[defaultPrevented] && event.type === "click" && event.eventPhase === EventPhaseEnum_default.bubbling && event instanceof MouseEvent) { - const target2 = event[target]; - if (target2) { - if (target2[localName] === "summary" && target2[parentNode] === this) { - this.open = !this.open; - } else { - let summaryElement = target2; - for (const element of this[elementArray]) { - if (element[localName] === "summary") { - summaryElement = element; - break; - } - } - if (summaryElement && summaryElement.contains(target2)) { - this.open = !this.open; - } - } - } - } - return returnValue; - } -} - -// node_modules/happy-dom/lib/nodes/html-dialog-element/HTMLDialogElement.js -class HTMLDialogElement extends HTMLElement { - [returnValue] = ""; - get oncancel() { - return ElementEventAttributeUtility.getEventListener(this, "oncancel"); - } - set oncancel(value) { - this[propertyEventListeners].set("oncancel", value); - } - get onclose() { - return ElementEventAttributeUtility.getEventListener(this, "onclose"); - } - set onclose(value) { - this[propertyEventListeners].set("onclose", value); - } - get returnValue() { - return this[returnValue]; - } - set returnValue(value) { - this[returnValue] = String(value); - } - set open(open) { - if (open) { - this.setAttribute("open", ""); - } else { - this.removeAttribute("open"); - } - } - get open() { - return this.getAttribute("open") !== null; - } - close(returnValue2) { - const wasOpen = this.open; - this.removeAttribute("open"); - this.returnValue = returnValue2 !== undefined ? String(returnValue2) : ""; - if (wasOpen) { - this.dispatchEvent(new Event("close")); - } - } - showModal() { - this.setAttribute("open", ""); - } - show() { - this.setAttribute("open", ""); - } -} - -// node_modules/happy-dom/lib/nodes/html-div-element/HTMLDivElement.js -class HTMLDivElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-embed-element/HTMLEmbedElement.js -class HTMLEmbedElement extends HTMLElement { - get height() { - return this.getAttribute("height") || ""; - } - set height(height) { - this.setAttribute("height", height); - } - get width() { - return this.getAttribute("width") || ""; - } - set width(width) { - this.setAttribute("width", width); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src"); - } - } - set src(src) { - this.setAttribute("src", src); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } -} - -// node_modules/happy-dom/lib/nodes/html-field-set-element/HTMLFieldSetElement.js -class HTMLFieldSetElement extends HTMLElement { - [elements] = null; - [formNode] = null; - get elements() { - if (!this[elements]) { - this[elements] = new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(this, "input,button,textarea,select")[items]); - } - return this[elements]; - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get type() { - return "fieldset"; - } - get validationMessage() { - return ""; - } - get willValidate() { - return false; - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - checkValidity() { - return true; - } - reportValidity() { - return true; - } - setCustomValidity(_message) {} -} - -// node_modules/happy-dom/lib/nodes/html-form-element/HTMLFormControlsCollection.js -class HTMLFormControlsCollection extends HTMLCollection { - constructor(illegalConstructorSymbol, ownerElement2) { - super(illegalConstructorSymbol, () => ownerElement2[getFormControlItems]()); - this[ownerElement] = ownerElement2; - } - namedItem(name) { - return this[ownerElement][getFormControlNamedItem](name); - } -} - -// node_modules/happy-dom/lib/browser/utilities/BrowserFrameFactory.js -class BrowserFrameFactory { - static createChildFrame(parentFrame) { - const frame = new parentFrame.constructor(parentFrame.page); - frame.parentFrame = parentFrame; - parentFrame.childFrames.push(frame); - return frame; - } - static destroyFrame(frame) { - const exceptionObserver2 = frame.page.context.browser[exceptionObserver]; - if (frame.closed) { - return Promise.resolve(); - } - frame.closed = true; - return new Promise((resolve, reject) => { - if (!frame.window) { - resolve(); - return; - } - if (frame.parentFrame) { - const index = frame.parentFrame.childFrames.indexOf(frame); - if (index !== -1) { - frame.parentFrame.childFrames.splice(index, 1); - } - } - if (!frame.childFrames.length) { - frame[asyncTaskManager].destroy().then(() => { - if (exceptionObserver2 && frame.window) { - exceptionObserver2.disconnect(frame.window); - } - frame.window = { closed: true }; - frame[openerFrame] = null; - frame[openerWindow] = null; - if (frame[listeners]) { - frame[listeners].navigation = []; - } - resolve(); - }).catch((error) => reject(error)); - if (frame.window) { - frame.window[destroy](); - } - return; - } - Promise.all(frame.childFrames.slice().map((childFrame) => this.destroyFrame(childFrame))).then(() => { - frame[asyncTaskManager].destroy().then(() => { - if (exceptionObserver2 && frame.window) { - exceptionObserver2.disconnect(frame.window); - } - frame.window = { closed: true }; - frame[openerFrame] = null; - frame[openerWindow] = null; - if (frame[listeners]) { - frame[listeners].navigation = []; - } - resolve(); - }).catch((error) => reject(error)); - if (frame.window) { - frame.window[destroy](); - } - }).catch((error) => reject(error)); - }); - } -} - -// node_modules/happy-dom/lib/browser/enums/BrowserNavigationCrossOriginPolicyEnum.js -var BrowserNavigationCrossOriginPolicyEnum; -(function(BrowserNavigationCrossOriginPolicyEnum) { - BrowserNavigationCrossOriginPolicyEnum["anyOrigin"] = "anyOrigin"; - BrowserNavigationCrossOriginPolicyEnum["sameOrigin"] = "sameOrigin"; - BrowserNavigationCrossOriginPolicyEnum["strictOrigin"] = "strictOrigin"; -})(BrowserNavigationCrossOriginPolicyEnum || (BrowserNavigationCrossOriginPolicyEnum = {})); -var BrowserNavigationCrossOriginPolicyEnum_default = BrowserNavigationCrossOriginPolicyEnum; - -// node_modules/happy-dom/lib/browser/utilities/BrowserFrameValidator.js -class BrowserFrameValidator { - static validateCrossOriginPolicy(frame, toURL) { - const settings = frame.page.context.browser.settings; - let fromURL = frame.page.mainFrame.window.location; - if (frame[openerFrame]) { - fromURL = frame[openerFrame].window.location; - } else if (frame.parentFrame) { - fromURL = frame.parentFrame.window.location; - } - if (settings.navigation.crossOriginPolicy === BrowserNavigationCrossOriginPolicyEnum_default.sameOrigin && fromURL.protocol !== "about:" && toURL.protocol !== "about:" && toURL.protocol !== "javascript:" && fromURL.origin !== toURL.origin) { - return false; - } - if (settings.navigation.crossOriginPolicy === BrowserNavigationCrossOriginPolicyEnum_default.strictOrigin && fromURL.protocol === "https:" && toURL.protocol === "http:") { - return false; - } - return true; - } - static validateFrameNavigation(frame) { - const settings = frame.page.context.browser.settings; - if (frame.page.context.browser.windowClass && frame.page.context === frame.page.context.browser.defaultContext && frame.page.context.pages[0] === frame.page && frame.page.mainFrame === frame) { - return false; - } - if (settings.navigation.disableMainFrameNavigation && frame.page.mainFrame === frame) { - return false; - } - if (settings.navigation.disableChildFrameNavigation && frame.page.mainFrame !== frame) { - return false; - } - if (settings.navigation.disableChildPageNavigation && !!frame[openerFrame]) { - return false; - } - return true; - } -} - -// node_modules/happy-dom/lib/browser/utilities/BrowserFrameNavigator.js -class BrowserFrameNavigator { - static async navigate(options) { - const { windowClass, frame, url, formData, method, goToOptions, disableHistory } = options; - const exceptionObserver2 = frame.page.context.browser[exceptionObserver]; - const referrer2 = goToOptions?.referrer || frame.window.location.origin; - const targetURL = BrowserFrameURL.getRelativeURL(frame, url); - const targetURLWithoutHash = new URL(targetURL.href.split("#")[0]); - const currentURLWithoutHash = new URL(frame.url.split("#")[0]); - const resolveNavigationListeners = () => { - const listeners2 = frame[listeners].navigation; - frame[listeners].navigation = []; - for (const listener of listeners2) { - listener(); - } - }; - if (!frame.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - if (targetURLWithoutHash.href === currentURLWithoutHash.href && targetURL.hash && targetURL.hash !== frame.window?.location.hash) { - const history2 = frame[history]; - if (!disableHistory) { - history2.currentItem.popState = true; - history2.push({ - title: "", - href: targetURL.href, - state: null, - popState: true, - scrollRestoration: HistoryScrollRestorationEnum_default.manual, - method: method || (formData ? "POST" : "GET"), - formData: formData || null - }); - } - frame.window.location[setURL](frame, targetURL.href); - return null; - } - if (targetURL.protocol === "javascript:") { - if (frame && frame.page.context.browser.settings.enableJavaScriptEvaluation) { - const readyStateManager2 = frame.window[readyStateManager]; - const asyncTaskManager2 = frame[asyncTaskManager]; - const taskID = readyStateManager2.startTask(); - const code = targetURL.href.replace("javascript:", ""); - await new Promise((resolve) => { - frame.window.requestAnimationFrame(() => { - const immediate = setImmediate(() => { - asyncTaskManager2.endTask(taskID); - resolve(null); - }); - const taskID = asyncTaskManager2.startTask(() => () => { - clearImmediate(immediate); - resolve(null); - }); - frame.window[evaluateScript](code, { filename: frame.url }); - }); - }); - readyStateManager2.endTask(taskID); - resolveNavigationListeners(); - } - return null; - } - if (!BrowserFrameValidator.validateCrossOriginPolicy(frame, targetURL)) { - return null; - } - if (!BrowserFrameValidator.validateFrameNavigation(frame)) { - if (!frame.page.context.browser.settings.navigation.disableFallbackToSetURL) { - frame.window.location[setURL](frame, targetURL.href); - } - return null; - } - if (!disableHistory) { - const history2 = frame[history]; - history2.push({ - title: "", - href: targetURL.href, - state: null, - popState: false, - scrollRestoration: HistoryScrollRestorationEnum_default.auto, - method: method || (formData ? "POST" : "GET"), - formData: formData || null - }); - } - const previousWindow = frame.window; - const previousAsyncTaskManager = frame[asyncTaskManager]; - const width = previousWindow.innerWidth; - const height = previousWindow.innerHeight; - const devicePixelRatio = previousWindow.devicePixelRatio; - const parentWindow = frame.parentFrame ? frame.parentFrame.window : frame.page.mainFrame.window; - const topWindow = frame.page.mainFrame.window; - frame[asyncTaskManager] = new AsyncTaskManager(frame); - frame.window = new windowClass(frame, { url: targetURL.href, width, height }); - frame.window[parent] = parentWindow; - frame.window[top] = topWindow; - frame.window.devicePixelRatio = devicePixelRatio; - if (exceptionObserver2) { - exceptionObserver2.observe(frame.window); - } - if (referrer2) { - frame.window.document[referrer] = referrer2; - } - const destroyTaskID = frame[asyncTaskManager].startTask(); - const destroyWindowAndAsyncTaskManager = () => { - previousAsyncTaskManager.destroy().then(() => { - if (exceptionObserver2) { - exceptionObserver2.disconnect(previousWindow); - } - frame[asyncTaskManager].endTask(destroyTaskID); - }); - previousWindow[destroy](); - }; - if (frame.childFrames.length) { - Promise.all(frame.childFrames.map((childFrame) => BrowserFrameFactory.destroyFrame(childFrame))).then(destroyWindowAndAsyncTaskManager); - } else { - destroyWindowAndAsyncTaskManager(); - } - if (targetURL.protocol === "about:") { - if (goToOptions?.beforeContentCallback) { - goToOptions.beforeContentCallback(frame.window); - } - if (frame.page.context.browser.settings.navigation.beforeContentCallback) { - frame.page.context.browser.settings.navigation.beforeContentCallback(frame.window); - } - await new Promise((resolve) => frame.page.mainFrame.window.requestAnimationFrame(resolve)); - resolveNavigationListeners(); - return null; - } - const readyStateManager2 = frame.window[readyStateManager]; - const asyncTaskManager2 = frame[asyncTaskManager]; - const abortController = new frame.window.AbortController; - const timeout = setTimeout(() => { - asyncTaskManager2.endTimer(timeout); - abortController.abort(new frame.window.DOMException("The operation was aborted. Request timed out.", DOMExceptionNameEnum_default.timeoutError)); - }, goToOptions?.timeout ?? 30000); - asyncTaskManager2.startTimer(timeout); - const taskID = readyStateManager2.startTask(); - const finalize = () => { - clearTimeout(timeout); - asyncTaskManager2.endTimer(timeout); - readyStateManager2.endTask(taskID); - resolveNavigationListeners(); - }; - const headers = new frame.window.Headers(goToOptions?.headers); - let response; - let responseText; - if (goToOptions?.hard) { - headers.set("Cache-Control", "no-cache"); - } - const fetch2 = new Fetch({ - browserFrame: frame, - window: frame.window, - url: targetURL.href, - disableSameOriginPolicy: true, - init: { - referrer: referrer2, - referrerPolicy: goToOptions?.referrerPolicy || "origin", - signal: abortController.signal, - method: method || (formData ? "POST" : "GET"), - headers, - body: formData - } - }); - try { - response = await fetch2.send(); - if (frame.parentFrame) { - const originURL = frame.parentFrame.window.location; - const xFrameOptions = response.headers?.get("X-Frame-Options")?.toLowerCase(); - const isSameOrigin = originURL.origin === targetURL.origin || targetURL.origin === "null"; - if (xFrameOptions === "deny" || xFrameOptions === "sameorigin" && !isSameOrigin) { - throw new Error(`Refused to display '${url}' in a frame because it set 'X-Frame-Options' to '${xFrameOptions}'.`); - } - } - responseText = await response.text(); - } catch (error) { - finalize(); - throw error; - } - if (!frame.window) { - return null; - } - if (response.url) { - frame.window[location][setURL](frame, response.url); - } - if (!response.ok) { - frame.page.console.error(`GET ${targetURL.href} ${response.status} (${response.statusText})`); - } - if (goToOptions?.beforeContentCallback) { - goToOptions.beforeContentCallback(frame.window); - } - if (frame.page.context.browser.settings.navigation.beforeContentCallback) { - frame.page.context.browser.settings.navigation.beforeContentCallback(frame.window); - } - await new Promise((resolve) => { - frame.window.requestAnimationFrame(() => { - let immediate; - const taskID = asyncTaskManager2.startTask(() => () => { - clearImmediate(immediate); - resolve(null); - }); - immediate = setImmediate(() => { - asyncTaskManager2.endTask(taskID); - resolve(null); - }); - frame.content = responseText; - }); - }); - finalize(); - return response; - } - static navigateBack(options) { - const { windowClass, frame, goToOptions } = options; - const history2 = frame[history]; - const historyItem = history2.items[history2.items.indexOf(history2.currentItem) - 1]; - if (!historyItem) { - return new Promise((resolve) => { - frame.window.requestAnimationFrame(() => { - const listeners2 = frame[listeners].navigation; - frame[listeners].navigation = []; - for (const listener of listeners2) { - listener(); - } - resolve(null); - }); - }); - } - const fromOrigin = new URL(history2.currentItem.href).origin; - const toOrigin = new URL(historyItem.href).origin; - history2.currentItem = historyItem; - if (!historyItem.popState || fromOrigin !== toOrigin) { - return BrowserFrameNavigator.navigate({ - windowClass, - frame, - goToOptions: { - ...goToOptions, - referrer: frame.url - }, - url: historyItem.href, - method: historyItem.method, - formData: historyItem.formData, - disableHistory: true - }); - } - frame.window.location[setURL](frame, historyItem.href); - frame.window.dispatchEvent(new frame.window.PopStateEvent("popstate", { - state: historyItem.state, - hasUAVisualTransition: false - })); - return Promise.resolve(null); - } - static navigateForward(options) { - const { windowClass, frame, goToOptions } = options; - const history2 = frame[history]; - const historyItem = history2.items[history2.items.indexOf(history2.currentItem) + 1]; - if (!historyItem) { - return new Promise((resolve) => { - frame.window.requestAnimationFrame(() => { - const listeners2 = frame[listeners].navigation; - frame[listeners].navigation = []; - for (const listener of listeners2) { - listener(); - } - resolve(null); - }); - }); - } - const fromOrigin = new URL(history2.currentItem.href).origin; - const toOrigin = new URL(historyItem.href).origin; - history2.currentItem = historyItem; - if (!historyItem.popState || fromOrigin !== toOrigin) { - return BrowserFrameNavigator.navigate({ - windowClass, - frame, - goToOptions: { - ...goToOptions, - referrer: frame.url - }, - url: historyItem.href, - method: historyItem.method, - formData: historyItem.formData, - disableHistory: true - }); - } - frame.window.location[setURL](frame, historyItem.href); - frame.window.dispatchEvent(new frame.window.PopStateEvent("popstate", { - state: historyItem.state, - hasUAVisualTransition: false - })); - return Promise.resolve(null); - } - static navigateSteps(options) { - if (!options.steps) { - return this.reload(options); - } - const { windowClass, frame, goToOptions, steps } = options; - const history2 = frame[history]; - const fromIndex = history2.items.indexOf(history2.currentItem); - const toIndex = fromIndex + steps; - const historyItem = history2.items[toIndex]; - if (!historyItem) { - return new Promise((resolve) => { - frame.window.requestAnimationFrame(() => { - const listeners2 = frame[listeners].navigation; - frame[listeners].navigation = []; - for (const listener of listeners2) { - listener(); - } - resolve(null); - }); - }); - } - const fromOrigin = new URL(history2.currentItem.href).origin; - let isPopState = true; - if (steps < 0) { - for (let i = fromIndex;i > toIndex; i--) { - if (!history2.items[i].popState || fromOrigin !== new URL(history2.items[i].href).origin) { - isPopState = false; - break; - } - } - } else { - for (let i = fromIndex;i < toIndex; i++) { - if (!history2.items[i].popState || fromOrigin !== new URL(history2.items[i].href).origin) { - isPopState = false; - break; - } - } - } - history2.currentItem = historyItem; - if (!isPopState) { - return BrowserFrameNavigator.navigate({ - windowClass, - frame, - goToOptions: { - ...goToOptions, - referrer: frame.url - }, - url: historyItem.href, - method: historyItem.method, - formData: historyItem.formData, - disableHistory: true - }); - } - frame.window.location[setURL](frame, historyItem.href); - frame.window.dispatchEvent(new frame.window.PopStateEvent("popstate", { - state: historyItem.state, - hasUAVisualTransition: false - })); - return Promise.resolve(null); - } - static reload(options) { - const { windowClass, frame, goToOptions } = options; - const history2 = frame[history]; - return BrowserFrameNavigator.navigate({ - windowClass, - frame, - goToOptions: { - ...goToOptions, - referrer: frame.url - }, - url: history2.currentItem.href, - method: history2.currentItem.method, - formData: history2.currentItem.formData, - disableHistory: true - }); - } -} - -// node_modules/happy-dom/lib/nodes/html-form-element/RadioNodeList.js -class RadioNodeList extends NodeList_default { - get value() { - for (const node of this[items]) { - if (node.checked) { - return node.value; - } - } - return null; - } -} - -// node_modules/happy-dom/lib/nodes/html-form-element/HTMLFormElement.js -class HTMLFormElement extends HTMLElement { - [elements] = null; - [proxy]; - constructor() { - super(); - const methodBinder = new ClassMethodBinder(this, [ - HTMLFormElement, - HTMLElement, - Element, - Node, - EventTarget - ]); - const proxy2 = new Proxy(this, { - get: (target, property) => { - if (property === "length") { - return target[getFormControlItems]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getFormControlItems]()[index]; - } - return target[getFormControlNamedItem](property) || undefined; - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getFormControlItems]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const items = target[getFormControlItems](); - const index = Number(property); - if (!isNaN(index) && index >= 0 && index < items.length) { - return true; - } - property = String(property); - for (let i = 0;i < items.length; i++) { - const item = items[i]; - const name = item.getAttribute("id") || item.getAttribute("name"); - if (name && name === property) { - return true; - } - } - return false; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (!descriptor.value) { - Object.defineProperty(target, property, descriptor); - return true; - } - const index = Number(descriptor.value); - if (isNaN(index)) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target) { - return Object.getOwnPropertyDescriptor(target, property); - } - const items = target[getFormControlItems](); - const index = Number(property); - if (!isNaN(index) && index >= 0 && index < items.length) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - for (let i = 0;i < items.length; i++) { - const item = items[i]; - const name = item.getAttribute("id") || item.getAttribute("name"); - if (name && name === property) { - return { - value: item, - writable: false, - enumerable: true, - configurable: true - }; - } - } - } - }); - this[proxy] = proxy2; - this[formNode] = proxy2; - return proxy2; - } - get onformdata() { - return ElementEventAttributeUtility.getEventListener(this, "onformdata"); - } - set onformdata(value) { - this[propertyEventListeners].set("onformdata", value); - } - get onreset() { - return ElementEventAttributeUtility.getEventListener(this, "onreset"); - } - set onreset(value) { - this[propertyEventListeners].set("onreset", value); - } - get onsubmit() { - return ElementEventAttributeUtility.getEventListener(this, "onsubmit"); - } - set onsubmit(value) { - this[propertyEventListeners].set("onsubmit", value); - } - get elements() { - if (!this[elements]) { - this[elements] = new HTMLFormControlsCollection(illegalConstructor, this); - } - return this[elements]; - } - get length() { - return this[getFormControlItems]().length; - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get method() { - return this.getAttribute("method") || "get"; - } - set method(method) { - this.setAttribute("method", method); - } - get target() { - return this.getAttribute("target") || ""; - } - set target(target) { - this.setAttribute("target", target); - } - get action() { - if (!this.hasAttribute("action")) { - return this[ownerDocument].location.href; - } - try { - return new URL(this.getAttribute("action"), this[ownerDocument].location.href).href; - } catch (e) { - return ""; - } - } - set action(action) { - this.setAttribute("action", action); - } - get encoding() { - return this.getAttribute("encoding") || ""; - } - set encoding(encoding) { - this.setAttribute("encoding", encoding); - } - get enctype() { - return this.getAttribute("enctype") || ""; - } - set enctype(enctype) { - this.setAttribute("enctype", enctype); - } - get autocomplete() { - return this.getAttribute("autocomplete") || ""; - } - set autocomplete(autocomplete) { - this.setAttribute("autocomplete", autocomplete); - } - get acceptCharset() { - return this.getAttribute("acceptcharset") || ""; - } - set acceptCharset(acceptCharset) { - this.setAttribute("acceptcharset", acceptCharset); - } - get noValidate() { - return this.getAttribute("novalidate") !== null; - } - set noValidate(noValidate) { - if (!noValidate) { - this.removeAttribute("novalidate"); - } else { - this.setAttribute("novalidate", ""); - } - } - submit() { - this.#submit(); - } - requestSubmit(submitter) { - const noValidate = submitter?.formNoValidate || this.noValidate; - if (noValidate || this.checkValidity()) { - const event = new SubmitEvent("submit", { - bubbles: true, - cancelable: true, - submitter: submitter || this[proxy] - }); - this.dispatchEvent(event); - if (!event.defaultPrevented) { - this.#submit(submitter); - } - } - } - reset() { - for (const element of this[getFormControlItems]()) { - switch (element[tagName]) { - case "TEXTAREA": - element[value] = null; - break; - case "INPUT": - element[value] = null; - element[checked] = null; - break; - case "OUTPUT": - element.textContent = element[defaultValue]; - break; - case "SELECT": - let hasSelectedAttribute = false; - for (const option of element.options) { - if (option.hasAttribute("selected")) { - hasSelectedAttribute = true; - option.selected = true; - break; - } - } - if (!hasSelectedAttribute && element.options.length > 0) { - element.options[0].selected = true; - } - break; - } - } - this.dispatchEvent(new Event("reset", { bubbles: true, cancelable: true })); - } - checkValidity() { - const radioValidationState = {}; - let isFormValid = true; - for (const element of this[getFormControlItems]()) { - if (element[tagName] === "INPUT" && element.type === "radio" && element.name) { - if (!radioValidationState[element.name]) { - radioValidationState[element.name] = true; - if (!element.checkValidity()) { - isFormValid = false; - } - } - } else if (!element.checkValidity()) { - isFormValid = false; - } - } - return isFormValid; - } - reportValidity() { - return this.checkValidity(); - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - [getFormControlItems]() { - const elements2 = QuerySelector.querySelectorAll(this, "input,select,textarea,button,fieldset,object,output")[items].slice(); - if (this[isConnected]) { - const id = this.getAttribute("id"); - if (id) { - for (const element of QuerySelector.querySelectorAll(this[ownerDocument], `input[form="${id}"],select[form="${id}"],textarea[form="${id}"],button[form="${id}"],fieldset[form="${id}"],object[form="${id}"],output[form="${id}"]`)[items]) { - if (!elements2.includes(element)) { - elements2.push(element); - } - } - } - } - return elements2; - } - [getFormControlNamedItem](name) { - const items = this[getFormControlItems](); - const namedItems = []; - name = String(name); - for (const item of items) { - if (item.getAttribute("id") === name || item.getAttribute("name") === name) { - namedItems.push(item); - } - } - if (!namedItems.length) { - return null; - } - if (namedItems.length === 1) { - return namedItems[0]; - } - return new RadioNodeList(illegalConstructor, namedItems); - } - #submit(submitter) { - const method = submitter?.formMethod || this.method; - if (method === "dialog") { - let dialog = null; - let parent = this; - while (parent) { - if (parent[tagName] === "DIALOG") { - dialog = parent; - break; - } - parent = parent.parentElement; - } - if (dialog) { - dialog.close(submitter?.value); - return; - } - } - const action = submitter?.hasAttribute("formaction") ? submitter?.formAction || this.action : this.action; - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - return; - } - if (!action) { - this[ownerDocument].location.hash = "#blocked"; - return; - } - const formData = new this[window].FormData(this, submitter); - let targetFrame; - switch (submitter?.formTarget || this.target) { - default: - case "_self": - targetFrame = browserFrame; - break; - case "_top": - targetFrame = browserFrame.page.mainFrame; - break; - case "_parent": - targetFrame = browserFrame.parentFrame ?? browserFrame; - break; - case "_blank": - const newPage = browserFrame.page.context.newPage(); - targetFrame = newPage.mainFrame; - targetFrame[openerFrame] = browserFrame; - break; - } - if (method === "get") { - const url = new URL(action); - url.search = ""; - for (const [key, value] of formData) { - if (typeof value === "string") { - url.searchParams.append(key, value); - } - } - BrowserFrameNavigator.navigate({ - windowClass: this[ownerDocument][defaultView]?.constructor, - frame: targetFrame, - url: url.href, - goToOptions: { - referrer: browserFrame.page.mainFrame.window.location.origin - } - }); - return; - } - BrowserFrameNavigator.navigate({ - windowClass: this[ownerDocument][defaultView]?.constructor, - frame: targetFrame, - method, - url: action, - formData, - goToOptions: { - referrer: browserFrame.page.mainFrame.window.location.origin - } - }); - } -} - -// node_modules/happy-dom/lib/nodes/html-head-element/HTMLHeadElement.js -class HTMLHeadElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-heading-element/HTMLHeadingElement.js -class HTMLHeadingElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-hr-element/HTMLHRElement.js -class HTMLHRElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-html-element/HTMLHtmlElement.js -class HTMLHtmlElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/window/CrossOriginBrowserWindow.js -class CrossOriginBrowserWindow extends EventTarget { - window = this; - location; - [self] = this; - #targetWindow; - constructor(target, parent2) { - super(); - this[parent] = parent2 ?? this; - this[top] = parent2 ?? this; - this.location = new Proxy({}, { - get: () => { - throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum_default.securityError); - }, - set: () => { - throw new DOMException(`Blocked a frame with origin "${this.parent.location.origin}" from accessing a cross-origin frame.`, DOMExceptionNameEnum_default.securityError); - } - }); - this.#targetWindow = target; - } - get self() { - return this[self]; - } - set self(self2) { - this[self] = self2; - } - get top() { - return this[top]; - } - get parent() { - return this[parent]; - } - set parent(parent2) { - this[parent] = parent2; - } - get opener() { - return this.#targetWindow.opener; - } - get closed() { - return this.#targetWindow.closed; - } - blur() { - this.#targetWindow.blur(); - } - focus() { - this.#targetWindow.focus(); - } - close() { - this.#targetWindow.close(); - } - postMessage(message, targetOrigin = "*", transfer) { - this.#targetWindow.postMessage(message, targetOrigin, transfer); - } -} - -// node_modules/happy-dom/lib/nodes/html-iframe-element/HTMLIFrameElement.js -var SANDBOX_FLAGS = [ - "allow-downloads", - "allow-forms", - "allow-modals", - "allow-orientation-lock", - "allow-pointer-lock", - "allow-popups", - "allow-popups-to-escape-sandbox", - "allow-presentation", - "allow-same-origin", - "allow-scripts", - "allow-top-navigation", - "allow-top-navigation-by-user-activation", - "allow-top-navigation-to-custom-protocols" -]; - -class HTMLIFrameElement extends HTMLElement { - [sandbox] = null; - #contentWindowContainer = { - window: null - }; - #iframe = null; - #loadedSrcdoc = null; - get onload() { - return ElementEventAttributeUtility.getEventListener(this, "onload"); - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src"); - } - } - set src(src) { - this.setAttribute("src", src); - } - get allow() { - return this.getAttribute("allow") || ""; - } - set allow(allow) { - this.setAttribute("allow", allow); - } - get height() { - return this.getAttribute("height") || ""; - } - set height(height) { - this.setAttribute("height", height); - } - get width() { - return this.getAttribute("width") || ""; - } - set width(width) { - this.setAttribute("width", width); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get sandbox() { - if (!this[sandbox]) { - this[sandbox] = new DOMTokenList(illegalConstructor, this, "sandbox"); - } - return this[sandbox]; - } - set sandbox(sandbox2) { - this.setAttribute("sandbox", sandbox2); - } - get srcdoc() { - return this.getAttribute("srcdoc") || ""; - } - set srcdoc(srcdoc) { - this.setAttribute("srcdoc", srcdoc); - } - get referrerPolicy() { - return this.getAttribute("referrerpolicy") || ""; - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerpolicy", referrerPolicy); - } - get contentDocument() { - return this.#contentWindowContainer.window?.document ?? null; - } - get contentWindow() { - return this.#contentWindowContainer.window; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - [connectedToDocument]() { - super[connectedToDocument](); - this.#loadPage(); - } - [disconnectedFromDocument]() { - super[disconnectedFromDocument](); - this.#unloadPage(); - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "srcdoc") { - this.#loadPage(); - } - if (attribute[name] === "src" && attribute[value] && !this.hasAttribute("srcdoc") && attribute[value] !== replacedAttribute?.[value]) { - this.#loadPage(); - } - if (attribute[name] === "sandbox") { - this.#validateSandboxFlags(); - } - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - if (removedAttribute[name] === "srcdoc" || removedAttribute[name] === "src") { - this.#loadPage(); - } - } - #validateSandboxFlags() { - const window2 = this[window]; - const invalidFlags = []; - for (const token of this.sandbox) { - if (!SANDBOX_FLAGS.includes(token)) { - invalidFlags.push(token); - } - } - if (invalidFlags.length === 1) { - window2.console.error(`Error while parsing the 'sandbox' attribute: '${invalidFlags[0]}' is an invalid sandbox flag.`); - } else if (invalidFlags.length > 1) { - window2.console.error(`Error while parsing the 'sandbox' attribute: '${invalidFlags.join(`', '`)}' are invalid sandbox flags.`); - } - } - #loadPage() { - if (!this[isConnected]) { - this.#unloadPage(); - return; - } - const srcdoc = this.getAttribute("srcdoc"); - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return; - } - if (srcdoc !== null) { - if (this.#loadedSrcdoc === srcdoc) { - return; - } - this.#unloadPage(); - this.#iframe = BrowserFrameFactory.createChildFrame(browserFrame); - this.#iframe.url = "about:srcdoc"; - this.#contentWindowContainer.window = this.#iframe.window; - this.#iframe.window[top] = browserFrame.window.top; - this.#iframe.window[parent] = browserFrame.window; - this.#iframe.window.document.open(); - this.#iframe.window.document.write(srcdoc); - this.#loadedSrcdoc = srcdoc; - this[window].requestAnimationFrame(() => this.dispatchEvent(new Event("load"))); - return; - } - if (this.#loadedSrcdoc !== null) { - this.#unloadPage(); - } - const originURL = browserFrame.window.location; - const targetURL = BrowserFrameURL.getRelativeURL(browserFrame, this.src); - if (this.#iframe && this.#iframe.window.location.href === targetURL.href) { - return; - } - if (browserFrame.page.context.browser.settings.disableIframePageLoading) { - const error = new window2.DOMException(`Failed to load iframe page "${targetURL.href}". Iframe page loading is disabled.`, DOMExceptionNameEnum_default.notSupportedError); - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - return; - } - const isSameOrigin = originURL.origin === targetURL.origin || targetURL.origin === "null"; - const parentWindow = isSameOrigin ? window2 : new CrossOriginBrowserWindow(window2); - this.#iframe = this.#iframe ?? BrowserFrameFactory.createChildFrame(browserFrame); - this.#iframe.window[top] = parentWindow; - this.#iframe.window[parent] = parentWindow; - this.#iframe.goto(targetURL.href, { - referrer: originURL.origin, - referrerPolicy: this.referrerPolicy - }).then(() => this.dispatchEvent(new Event("load"))).catch((error) => { - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - }); - this.#contentWindowContainer.window = isSameOrigin ? this.#iframe.window : new CrossOriginBrowserWindow(this.#iframe.window, window2); - } - #unloadPage() { - if (this.#iframe) { - BrowserFrameFactory.destroyFrame(this.#iframe); - this.#iframe = null; - } - this.#contentWindowContainer.window = null; - this.#loadedSrcdoc = null; - } -} - -// node_modules/happy-dom/lib/nodes/html-image-element/HTMLImageElement.js -var import_buffer_image_size = __toESM(require_lib(), 1); -var DATA_URL_REGEX = /^\s*data:([^,]+)?,(.*)/; - -class HTMLImageElement extends HTMLElement { - [tagName] = "IMG"; - [complete] = true; - [naturalHeight] = 0; - [naturalWidth] = 0; - [loading] = "auto"; - [x] = 0; - [y] = 0; - [buffer] = null; - get onload() { - return ElementEventAttributeUtility.getEventListener(this, "onload"); - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get complete() { - return this[complete]; - } - get naturalHeight() { - return this[naturalHeight]; - } - get naturalWidth() { - return this[naturalWidth]; - } - get loading() { - const loading2 = this.getAttribute("loading"); - return loading2 === "eager" || loading2 === "lazy" ? loading2 : "auto"; - } - set loading(loading2) { - this.setAttribute("loading", loading2); - } - get x() { - return this[x]; - } - get y() { - return this[y]; - } - get decoding() { - return this.getAttribute("decoding") || "auto"; - } - set decoding(decoding) { - this.setAttribute("decoding", decoding); - } - get crossOrigin() { - return this.getAttribute("crossOrigin"); - } - set crossOrigin(crossOrigin) { - if (crossOrigin === "anonymous" || crossOrigin === "use-credentials") { - this.setAttribute("crossOrigin", crossOrigin); - } - } - get alt() { - return this.getAttribute("alt") || ""; - } - set alt(alt) { - this.setAttribute("alt", alt); - } - get currentSrc() { - return this.src; - } - get width() { - const width = this.getAttribute("width"); - if (width === null) { - return this[naturalWidth]; - } - const parsed = parseInt(width, 10); - return isNaN(parsed) || parsed <= 0 ? this[naturalWidth] : parsed; - } - set width(width) { - this.setAttribute("width", String(width)); - } - get height() { - const height = this.getAttribute("height"); - if (height === null) { - return this[naturalHeight]; - } - const parsed = parseInt(height, 10); - return isNaN(parsed) || parsed <= 0 ? this[naturalHeight] : parsed; - } - set height(height) { - this.setAttribute("height", String(height)); - } - get isMap() { - return this.getAttribute("ismap") !== null; - } - set isMap(isMap) { - if (!isMap) { - this.removeAttribute("ismap"); - } else { - this.setAttribute("ismap", ""); - } - } - get referrerPolicy() { - return this.getAttribute("referrerpolicy") || ""; - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerpolicy", referrerPolicy); - } - get sizes() { - return this.getAttribute("sizes") || ""; - } - set sizes(sizes) { - this.setAttribute("sizes", sizes); - } - get src() { - const href = this.getAttribute("src"); - if (!href) { - return ""; - } - return this.#parseUrl(href) || this.getAttribute("src") || ""; - } - set src(src) { - this.setAttribute("src", src); - } - get srcset() { - return this.getAttribute("srcset") || ""; - } - set srcset(srcset) { - this.setAttribute("srcset", srcset); - } - get useMap() { - return this.getAttribute("usemap") || ""; - } - set useMap(useMap) { - this.setAttribute("usemap", useMap); - } - decode() { - return Promise.resolve(); - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "src") { - const url = this.#parseUrl(attribute[value]); - if (!url) { - this[complete] = true; - this[naturalHeight] = 0; - this[naturalWidth] = 0; - this.dispatchEvent(new this[window].Event("error")); - return; - } - if (this.#loadDataUrl(url)) { - return; - } - const settings = new WindowBrowserContext(this[window]).getSettings(); - if (settings?.enableImageFileLoading) { - this.#loadUrlSource(this.src); - } - } - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - if (removedAttribute[name] === "src") { - this[complete] = true; - this[naturalHeight] = 0; - this[naturalWidth] = 0; - this[buffer] = null; - } - } - #parseUrl(src) { - if (src === null) { - return null; - } - try { - return new URL(src, this[ownerDocument].location.href).href; - } catch {} - return null; - } - #loadDataUrl(src) { - const dataUrlMatch = src.match(DATA_URL_REGEX); - if (dataUrlMatch) { - const buffer2 = Buffer.from(dataUrlMatch[2], "base64"); - this[complete] = true; - this[buffer] = buffer2; - try { - const dimensions = import_buffer_image_size.default(buffer2); - this[naturalHeight] = dimensions.height; - this[naturalWidth] = dimensions.width; - } catch (e) { - this[naturalHeight] = 0; - this[naturalWidth] = 0; - } - this.dispatchEvent(new this[window].Event("load")); - return true; - } - return false; - } - async#loadUrlSource(src) { - this[complete] = false; - this[naturalHeight] = 0; - this[naturalWidth] = 0; - this[buffer] = null; - let response = null; - let error = null; - try { - response = await this[window].fetch(src); - } catch (e) { - error = e; - } - if (error || !response?.ok) { - this[complete] = true; - this.dispatchEvent(new this[window].Event("error")); - if (response) { - this[window].console.error(`GET ${src} ${response.status} (${response.statusText}).`); - } else if (error) { - this[window].console.error(error); - } - return; - } - let buffer2; - try { - buffer2 = await response.buffer(); - } catch (e) { - this[complete] = true; - this.dispatchEvent(new this[window].Event("error")); - return; - } - this[complete] = true; - this[buffer] = buffer2; - try { - const dimensions = import_buffer_image_size.default(buffer2); - this[naturalHeight] = dimensions.height; - this[naturalWidth] = dimensions.width; - } catch (e) { - this[naturalHeight] = 0; - this[naturalWidth] = 0; - } - this.dispatchEvent(new this[window].Event("load")); - } -} - -// node_modules/happy-dom/lib/nodes/html-input-element/FileList.js -class FileList extends Array { - constructor() { - super(0); - } - get [Symbol.toStringTag]() { - return this.constructor.name; - } - item(index) { - return this[index] || null; - } -} - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElementValueSanitizer.js -var NEW_LINES_REGEXP = /[\n\r]/gm; -var parseInts = (a) => a.map((v) => parseInt(v, 10)); - -class HTMLInputElementValueSanitizer { - static sanitize(input, value) { - switch (input.type) { - case "password": - case "search": - case "tel": - case "text": - return value.replace(NEW_LINES_REGEXP, ""); - case "color": - return /^#[a-fA-F\d]{6}$/.test(value) ? value.toLowerCase() : "#000000"; - case "email": - if (input.multiple) { - return value.split(",").map((token) => token.trim()).join(","); - } - return value.trim().replace(NEW_LINES_REGEXP, ""); - case "number": - return !isNaN(Number.parseFloat(value)) ? value : ""; - case "range": { - const number = Number.parseFloat(value); - const min = parseFloat(input.min) || 0; - const max = parseFloat(input.max) || 100; - if (isNaN(number)) { - return max < min ? String(min) : String((min + max) / 2); - } else if (number < min) { - return String(min); - } else if (number > max) { - return String(max); - } - return value; - } - case "url": - return value.trim().replace(NEW_LINES_REGEXP, ""); - case "date": - return this.sanitizeDate(value); - case "datetime-local": { - const match = value.match(/^(\d\d\d\d)-(\d\d)-(\d\d)[T ](\d\d):(\d\d)(?::(\d\d)(?:\.(\d{1,3}))?)?$/); - if (!match) { - return ""; - } - const dateString = this.sanitizeDate(value.slice(0, 10)); - let timeString = this.sanitizeTime(value.slice(11)); - if (!(dateString && timeString)) { - return ""; - } - if (match[6] !== undefined) { - if (timeString.indexOf(".") !== -1) { - timeString = timeString.replace(/(?:\.0*|(\.\d+?)0+)$/, "$1"); - } - timeString = timeString.replace(/(\d\d:\d\d)(:00)$/, "$1"); - } - return dateString + "T" + timeString; - } - case "month": - if (!(value.match(/^(\d\d\d\d)-(\d\d)$/) && this.parseMonthComponent(value))) { - return ""; - } - return this.checkBoundaries(value, input.min, input.max) ? value : ""; - case "time": { - value = this.sanitizeTime(value); - return value && this.checkBoundaries(value, input.min, input.max) ? value : ""; - } - case "week": { - const match = value.match(/^(\d\d\d\d)-W(\d\d)$/); - if (!match) { - return ""; - } - const [intY, intW] = parseInts(match.slice(1, 3)); - if (intY <= 0 || intW < 1 || intW > 53) { - return ""; - } - const lastWeek = this.lastIsoWeekOfYear(intY); - if (intW < 1 || intW > 52 + lastWeek) { - return ""; - } - if (!this.checkBoundaries(value, input.min, input.max)) { - return ""; - } - return value; - } - } - return value; - } - static checkBoundaries(value, min, max) { - if (min && min > value) { - return false; - } else if (max && max < value) { - return false; - } - return true; - } - static parseMonthComponent(value) { - const [Y, M] = value.split("-"); - const [intY, intM] = parseInts([Y, M]); - if (isNaN(intY) || isNaN(intM) || intY <= 0 || intM < 1 || intM > 12) { - return ""; - } - return value; - } - static lastIsoWeekOfYear = (year) => { - const date = new Date(+year, 11, 31); - const day = (date.getDay() + 6) % 7; - date.setDate(date.getDate() - day + 3); - const firstThursday = date.getTime(); - date.setMonth(0, 1); - if (date.getDay() !== 4) { - date.setMonth(0, 1 + (4 - date.getDay() + 7) % 7); - } - return 1 + Math.ceil((firstThursday - date.getTime()) / 604800000); - }; - static sanitizeDate(value) { - const match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/); - if (!match) { - return ""; - } - const month = this.parseMonthComponent(value.slice(0, 7)); - if (!month) { - return ""; - } - const [intY, intM, intD] = parseInts(match.slice(1, 4)); - if (intD < 1 || intD > 31) { - return ""; - } - const lastDayOfMonth = new Date(intY, intM, 0).getDate(); - if (intD > lastDayOfMonth) { - return ""; - } - return value; - } - static sanitizeTime(value) { - const match = value.match(/^(\d{2}):(\d{2})(?::(\d{2}(?:\.(\d{1,3}))?))?$/); - if (!match) { - return ""; - } - const [intH, intM] = parseInts(match.slice(1, 3)); - const ms = parseFloat(match[3] || "0") * 1000; - if (intH > 23 || intM > 59 || ms > 59999) { - return ""; - } - if (ms === 0) { - return `${match[1]}:${match[2]}`; - } else { - return `${match[1]}:${match[2]}${ms >= 1e4 ? `:${ms / 1000}` : `:0${ms / 1000}`}`; - } - } -} - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElementSelectionModeEnum.js -var HTMLInputElementSelectionModeEnum; -(function(HTMLInputElementSelectionModeEnum) { - HTMLInputElementSelectionModeEnum["preserve"] = "preserve"; - HTMLInputElementSelectionModeEnum["select"] = "select"; - HTMLInputElementSelectionModeEnum["start"] = "start"; - HTMLInputElementSelectionModeEnum["end"] = "end"; -})(HTMLInputElementSelectionModeEnum || (HTMLInputElementSelectionModeEnum = {})); -var HTMLInputElementSelectionModeEnum_default = HTMLInputElementSelectionModeEnum; - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElementSelectionDirectionEnum.js -var HTMLInputElementSelectionDirectionEnum; -(function(HTMLInputElementSelectionDirectionEnum) { - HTMLInputElementSelectionDirectionEnum["none"] = "none"; - HTMLInputElementSelectionDirectionEnum["forward"] = "forward"; - HTMLInputElementSelectionDirectionEnum["backward"] = "backward"; -})(HTMLInputElementSelectionDirectionEnum || (HTMLInputElementSelectionDirectionEnum = {})); -var HTMLInputElementSelectionDirectionEnum_default = HTMLInputElementSelectionDirectionEnum; - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElementValueStepping.js -class HTMLInputElementValueStepping { - static step(input, direction, increment) { - const type = input.type; - switch (type) { - case "number": - return this.getNumberValue(input, direction, increment); - case "date": - case "month": - case "week": - case "time": - case "datetime-local": - case "range": - return null; - default: - throw new DOMException("This form element is not steppable."); - } - } - static getNumberValue(input, direction, increment) { - const stepValue = input.step; - const minValue = input.min; - const maxValue = input.max; - const min = minValue !== "" ? Number(minValue) : null; - const max = maxValue !== "" ? Number(maxValue) : null; - let value = Number(input.value); - let step = stepValue !== "" ? Number(stepValue) : 1; - value = isNaN(value) ? 0 : value; - step = isNaN(step) || step === 0 ? 1 : step; - if (min !== null && !isNaN(min) && max !== null && !isNaN(max) && (min > max || max < min)) { - return input.value; - } - if (increment === 0) { - return input.value; - } - const validIncrementValue = increment !== undefined ? Math.ceil(increment / step) * step : step; - const candidate = value + validIncrementValue * direction; - const minOrZero = min !== null && !isNaN(min) ? min : 0; - switch (direction) { - case -1: - if (min !== null && !isNaN(min) && candidate < min) { - return String(min); - } - return String(candidate + (value - minOrZero) % step); - case 1: - if (max !== null && !isNaN(max) && candidate > max) { - return String(minOrZero + Math.floor((max - minOrZero) / step) * step); - } - return String(candidate - (value - minOrZero) % step); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElementDateUtility.js -class HTMLInputElementDateUtility { - static dateIsoWeek(date) { - date = typeof date === "number" ? new Date(date) : date; - date = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); - date.setUTCDate(date.getUTCDate() + 4 - (date.getUTCDay() || 7)); - const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1)); - const weekNo = Math.ceil(((date - yearStart) / 86400000 + 1) / 7); - return `${date.getUTCFullYear()}-W${weekNo < 10 ? "0" : ""}${weekNo}`; - } - static isoWeekDate(isoWeek) { - const [, Y, W] = isoWeek.match(/^(\d{4})-W(\d{2})$/) || []; - if (!Y || !W || Number(W) > 53 || Number(W) < 1) { - return new Date("x"); - } - const date = new Date(`${Y}-01-01T00:00Z`); - const jan4th = new Date(`${Y}-01-04T00:00Z`); - const jan4thDay = (jan4th.getUTCDay() + 6) % 7; - const ordinalDate = 1 + (Number(W) - 1) * 7 - jan4thDay + 3; - date.setUTCDate(ordinalDate); - if (date.getUTCFullYear() > Number(Y)) { - return new Date("x"); - } - return date; - } -} - -// node_modules/happy-dom/lib/nodes/html-input-element/HTMLInputElement.js -import { URL as URL9 } from "url"; -var INPUT_TYPE_STATES = new Set([ - "hidden", - "text", - "search", - "tel", - "url", - "email", - "password", - "date", - "month", - "week", - "time", - "datetime-local", - "number", - "range", - "color", - "checkbox", - "radio", - "file", - "submit", - "image", - "reset", - "button" -]); - -class HTMLInputElement extends HTMLElement { - [value] = null; - [height] = 0; - [width] = 0; - [checked] = null; - [validationMessage] = ""; - [validity] = new ValidityState(this); - [files] = new FileList; - [indeterminate] = false; - [formNode] = null; - [popoverTargetElement] = null; - #selectionStart = null; - #selectionEnd = null; - #selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - get oninput() { - return ElementEventAttributeUtility.getEventListener(this, "oninput"); - } - set oninput(value2) { - this[propertyEventListeners].set("oninput", value2); - } - get oninvalid() { - return ElementEventAttributeUtility.getEventListener(this, "oninvalid"); - } - set oninvalid(value2) { - this[propertyEventListeners].set("oninvalid", value2); - } - get onselectionchange() { - return ElementEventAttributeUtility.getEventListener(this, "onselectionchange"); - } - set onselectionchange(value2) { - this[propertyEventListeners].set("onselectionchange", value2); - } - get defaultChecked() { - return this.hasAttribute("checked"); - } - set defaultChecked(defaultChecked) { - if (defaultChecked) { - this.setAttribute("checked", ""); - } else { - this.removeAttribute("checked"); - } - } - get files() { - return this[files]; - } - set files(files2) { - this[files] = files2; - } - get formAction() { - if (!this.hasAttribute("formaction")) { - return this[ownerDocument].location.href; - } - try { - return new URL9(this.getAttribute("formaction"), this[ownerDocument].location.href).href; - } catch (e) { - return ""; - } - } - set formAction(formAction) { - this.setAttribute("formaction", formAction); - } - get formEnctype() { - return this.getAttribute("formenctype") || ""; - } - set formEnctype(formEnctype) { - this.setAttribute("formenctype", formEnctype); - } - get formMethod() { - return this.getAttribute("formmethod") || ""; - } - set formMethod(formMethod) { - this.setAttribute("formmethod", formMethod); - } - get formNoValidate() { - return this.getAttribute("formnovalidate") !== null; - } - set formNoValidate(formNoValidate) { - if (!formNoValidate) { - this.removeAttribute("formnovalidate"); - } else { - this.setAttribute("formnovalidate", ""); - } - } - get formTarget() { - return this.getAttribute("formtarget") || ""; - } - set formTarget(formTarget) { - this.setAttribute("formtarget", formTarget); - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get height() { - return this[height]; - } - set height(height2) { - this[height] = height2; - this.setAttribute("height", String(height2)); - } - get width() { - return this[width]; - } - set width(width2) { - this[width] = width2; - this.setAttribute("width", String(width2)); - } - get size() { - const size = this.getAttribute("size"); - if (size !== null) { - return parseInt(size); - } - return 20; - } - set size(size) { - this.setAttribute("size", String(size)); - } - get minLength() { - const minLength = this.getAttribute("minlength"); - if (minLength !== null) { - return parseInt(minLength); - } - return -1; - } - set minLength(minlength) { - this.setAttribute("minlength", String(minlength)); - } - get maxLength() { - const maxLength = this.getAttribute("maxlength"); - if (maxLength !== null) { - return parseInt(maxLength); - } - return -1; - } - set maxLength(maxLength) { - this.setAttribute("maxlength", String(maxLength)); - } - get type() { - const value2 = (this.getAttribute("type") ?? "").toLowerCase(); - return INPUT_TYPE_STATES.has(value2) ? value2 : "text"; - } - set type(type) { - this.setAttribute("type", type.toLowerCase()); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get alt() { - return this.getAttribute("alt") || ""; - } - set alt(alt) { - this.setAttribute("alt", alt); - } - get min() { - return this.getAttribute("min") || ""; - } - set min(min) { - this.setAttribute("min", min); - } - get max() { - return this.getAttribute("max") || ""; - } - set max(max) { - this.setAttribute("max", max); - } - get pattern() { - return this.getAttribute("pattern") || ""; - } - set pattern(pattern) { - this.setAttribute("pattern", pattern); - } - get placeholder() { - return this.getAttribute("placeholder") || ""; - } - set placeholder(placeholder) { - this.setAttribute("placeholder", placeholder); - } - get step() { - return this.getAttribute("step") || ""; - } - set step(step) { - this.setAttribute("step", step); - } - get inputMode() { - return this.getAttribute("inputmode") || ""; - } - set inputMode(inputmode) { - this.setAttribute("inputmode", inputmode); - } - get accept() { - return this.getAttribute("accept") || ""; - } - set accept(accept) { - this.setAttribute("accept", accept); - } - get allowdirs() { - return this.getAttribute("allowdirs") || ""; - } - set allowdirs(allowdirs) { - this.setAttribute("allowdirs", allowdirs); - } - get autocomplete() { - return this.getAttribute("autocomplete") || ""; - } - set autocomplete(autocomplete) { - this.setAttribute("autocomplete", autocomplete); - } - get src() { - return this.getAttribute("src") || ""; - } - set src(src) { - this.setAttribute("src", src); - } - get defaultValue() { - return this.getAttribute("value") || ""; - } - set defaultValue(defaultValue) { - this.setAttribute("value", defaultValue); - } - get readOnly() { - return this.getAttribute("readonly") !== null; - } - set readOnly(readOnly) { - if (!readOnly) { - this.removeAttribute("readonly"); - } else { - this.setAttribute("readonly", ""); - } - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - get autofocus() { - return this.getAttribute("autofocus") !== null; - } - set autofocus(autofocus) { - if (!autofocus) { - this.removeAttribute("autofocus"); - } else { - this.setAttribute("autofocus", ""); - } - } - get required() { - return this.getAttribute("required") !== null; - } - set required(required) { - if (!required) { - this.removeAttribute("required"); - } else { - this.setAttribute("required", ""); - } - } - get indeterminate() { - return this[indeterminate]; - } - set indeterminate(indeterminate2) { - this[indeterminate] = Boolean(indeterminate2); - } - get multiple() { - return this.getAttribute("multiple") !== null; - } - set multiple(multiple) { - if (!multiple) { - this.removeAttribute("multiple"); - } else { - this.setAttribute("multiple", ""); - } - } - get checked() { - if (this[checked] !== null) { - return this[checked]; - } - return this.getAttribute("checked") !== null; - } - set checked(checked2) { - this.#setChecked(checked2); - } - get value() { - switch (this.type) { - case "hidden": - case "submit": - case "image": - case "reset": - case "button": - return this.getAttribute("value") || ""; - case "checkbox": - case "radio": - const attritube = this.getAttribute("value"); - return attritube !== null ? attritube : "on"; - case "file": - return this[files].length > 0 ? "/fake/path/" + this[files][0].name : ""; - } - if (this[value] === null) { - return this.getAttribute("value") || ""; - } - return this[value]; - } - set value(value2) { - value2 = value2 === null ? "" : String(value2); - switch (this.type) { - case "hidden": - case "submit": - case "image": - case "reset": - case "button": - case "checkbox": - case "radio": - this.setAttribute("value", value2); - break; - case "file": - if (value2 !== null && value2 !== "") { - throw new this[window].DOMException('Input elements of type "file" may only programmatically set the value to empty string.', DOMExceptionNameEnum_default.invalidStateError); - } - this[files] = new FileList; - break; - default: - const oldValue = this.value; - this[value] = HTMLInputElementValueSanitizer.sanitize(this, value2); - if (oldValue !== this[value]) { - this.#selectionStart = this[value].length; - this.#selectionEnd = this[value].length; - this.#selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - } - break; - } - } - get selectionStart() { - if (!this.#isSelectionSupported()) { - return null; - } - if (this.#selectionStart === null) { - return this.value.length; - } - return this.#selectionStart; - } - set selectionStart(start) { - if (!this.#isSelectionSupported()) { - throw new this[window].DOMException(`The input element's type (${this.type}) does not support selection.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.setSelectionRange(start, Math.max(start, this.selectionEnd), this.#selectionDirection); - } - get selectionEnd() { - if (!this.#isSelectionSupported()) { - return null; - } - if (this.#selectionEnd === null) { - return this.value.length; - } - return this.#selectionEnd; - } - set selectionEnd(end) { - if (!this.#isSelectionSupported()) { - throw new this[window].DOMException(`The input element's type (${this.type}) does not support selection.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.setSelectionRange(this.selectionStart, end, this.#selectionDirection); - } - get selectionDirection() { - if (!this.#isSelectionSupported()) { - return null; - } - return this.#selectionDirection; - } - set selectionDirection(direction) { - if (!this.#isSelectionSupported()) { - throw new this[window].DOMException(`The input element's type (${this.type}) does not support selection.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.setSelectionRange(this.#selectionStart, this.#selectionEnd, direction); - } - get willValidate() { - return this.type !== "hidden" && this.type !== "reset" && this.type !== "button" && !this.disabled && !this["readOnly"]; - } - get valueAsDate() { - switch (this.type) { - case "date": - case "month": - return isNaN(new Date(String(this.value)).getTime()) ? null : new Date(this.value); - case "week": { - const d = HTMLInputElementDateUtility.isoWeekDate(this.value); - return isNaN(d.getTime()) ? null : d; - } - case "time": { - const d = new Date(`1970-01-01T${this.value}Z`); - return isNaN(d.getTime()) ? null : d; - } - default: - return null; - } - } - set valueAsDate(value2) { - if (!["date", "month", "time", "week"].includes(this.type)) { - throw new this[window].DOMException("Failed to set the 'valueAsDate' property on 'HTMLInputElement': This input element does not support Date values.", DOMExceptionNameEnum_default.invalidStateError); - } - if (typeof value2 !== "object") { - throw new this[window].TypeError("Failed to set the 'valueAsDate' property on 'HTMLInputElement': Failed to convert value to 'object'."); - } else if (value2 && !(value2 instanceof Date)) { - throw new this[window].TypeError("Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value is not a Date."); - } else if (value2 === null || isNaN(value2.getTime())) { - this.value = ""; - return; - } - switch (this.type) { - case "date": - this.value = value2.toISOString().split("T")[0]; - break; - case "month": - this.value = value2.toISOString().split("T")[0].slice(0, -3); - break; - case "time": - this.value = value2.toISOString().split("T")[1].slice(0, 5); - break; - case "week": - this.value = HTMLInputElementDateUtility.dateIsoWeek(value2); - break; - } - } - get valueAsNumber() { - const value2 = this.value; - if (!this.type.match(/^(range|number|date|datetime-local|month|time|week)$/) || !value2) { - return NaN; - } - switch (this.type) { - case "number": - return parseFloat(value2); - case "range": { - const number = parseFloat(value2); - const min = parseFloat(this.min) || 0; - const max = parseFloat(this.max) || 100; - if (isNaN(number)) { - return max < min ? min : (min + max) / 2; - } else if (number < min) { - return min; - } else if (number > max) { - return max; - } - return number; - } - case "date": - return new Date(value2).getTime(); - case "datetime-local": - return new Date(value2).getTime() - new Date(value2).getTimezoneOffset() * 60000; - case "month": - return (new Date(value2).getUTCFullYear() - 1970) * 12 + new Date(value2).getUTCMonth(); - case "time": - return new Date("1970-01-01T" + value2).getTime() - new Date("1970-01-01T00:00:00").getTime(); - case "week": { - const match = value2.match(/^(\d{4})-W(\d{2})$/); - if (!match) { - return NaN; - } - const d = new Date(Date.UTC(parseInt(match[1], 10), 0)); - const day = d.getUTCDay(); - const diff = ((day === 0 ? -6 : 1) - day) * 86400000 + parseInt(match[2], 10) * 604800000; - return d.getTime() + diff; - } - default: - return NaN; - } - } - set valueAsNumber(value2) { - switch (this.type) { - case "number": - case "range": - this.value = Number(value2).toString(); - break; - case "date": - case "datetime-local": { - const d = new Date(Number(value2)); - if (isNaN(d.getTime())) { - this.value = ""; - break; - } - if (this.type == "date") { - this.value = d.toISOString().slice(0, 10); - } else { - this.value = d.toISOString().slice(0, -1); - } - break; - } - case "month": - if (!Number.isInteger(value2) || value2 < 0) { - this.value = ""; - } else { - this.value = new Date(Date.UTC(1970, Number(value2))).toISOString().slice(0, 7); - } - break; - case "time": - if (!Number.isInteger(value2) || value2 < 0) { - this.value = ""; - } else { - this.value = new Date(Number(value2)).toISOString().slice(11, -1); - } - break; - case "week": { - const d = new Date(Number(value2)); - this.value = isNaN(d.getTime()) ? "" : HTMLInputElementDateUtility.dateIsoWeek(d); - break; - } - default: - throw new this[window].DOMException("Failed to set the 'valueAsNumber' property on 'HTMLInputElement': This input element does not support Number values.", DOMExceptionNameEnum_default.invalidStateError); - } - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } - get list() { - const id = this.getAttribute("list"); - if (!id) { - return null; - } - const rootNode2 = this[rootNode] || this[ownerDocument]; - return rootNode2.querySelector(`datalist#${id}`); - } - get popoverTargetElement() { - return this[popoverTargetElement]; - } - set popoverTargetElement(popoverTargetElement2) { - if (popoverTargetElement2 !== null && !(popoverTargetElement2 instanceof HTMLElement)) { - throw new this[window].TypeError(`Failed to set the 'popoverTargetElement' property on 'HTMLInputElement': Failed to convert value to 'Element'.`); - } - this[popoverTargetElement] = popoverTargetElement2; - } - get popoverTargetAction() { - const value2 = this.getAttribute("popovertargetaction"); - if (value2 === null || value2 !== "hide" && value2 !== "show" && value2 !== "toggle") { - return "toggle"; - } - return value2; - } - set popoverTargetAction(value2) { - this.setAttribute("popovertargetaction", value2); - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } - select() { - if (!this.#isSelectionSupported()) { - return; - } - this.#selectionStart = 0; - this.#selectionEnd = this.value.length; - this.#selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - this.dispatchEvent(new Event("select", { bubbles: true, cancelable: false })); - } - setSelectionRange(start, end, direction = "none") { - if (!this.#isSelectionSupported()) { - throw new this[window].DOMException(`The input element's type (${this.type}) does not support selection.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.#selectionEnd = Math.min(end, this.value.length); - this.#selectionStart = Math.min(start, this.#selectionEnd); - this.#selectionDirection = direction === HTMLInputElementSelectionDirectionEnum_default.forward || direction === HTMLInputElementSelectionDirectionEnum_default.backward ? direction : HTMLInputElementSelectionDirectionEnum_default.none; - this.dispatchEvent(new Event("select", { bubbles: true, cancelable: false })); - } - setRangeText(replacement, start = null, end = null, selectionMode = HTMLInputElementSelectionModeEnum_default.preserve) { - if (!this.#isSelectionSupported()) { - throw new this[window].DOMException(`The input element's type (${this.type}) does not support selection.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (start === null) { - start = this.#selectionStart; - } - if (end === null) { - end = this.#selectionEnd; - } - if (start > end) { - throw new this[window].DOMException("The index is not in the allowed range.", DOMExceptionNameEnum_default.invalidStateError); - } - start = Math.min(start, this.value.length); - end = Math.min(end, this.value.length); - const val = this.value; - let selectionStart = this.#selectionStart; - let selectionEnd = this.#selectionEnd; - this.value = val.slice(0, start) + replacement + val.slice(end); - const newEnd = start + this.value.length; - switch (selectionMode) { - case HTMLInputElementSelectionModeEnum_default.select: - this.setSelectionRange(start, newEnd); - break; - case HTMLInputElementSelectionModeEnum_default.start: - this.setSelectionRange(start, start); - break; - case HTMLInputElementSelectionModeEnum_default.end: - this.setSelectionRange(newEnd, newEnd); - break; - default: - const delta = replacement.length - (end - start); - if (selectionStart > end) { - selectionStart += delta; - } else if (selectionStart > start) { - selectionStart = start; - } - if (selectionEnd > end) { - selectionEnd += delta; - } else if (selectionEnd > start) { - selectionEnd = newEnd; - } - this.setSelectionRange(selectionStart, selectionEnd); - break; - } - } - checkValidity() { - const valid = this.disabled || this.readOnly || this.type === "hidden" || this.type === "reset" || this.type === "button" || this[validity].valid; - if (!valid) { - this.dispatchEvent(new Event("invalid", { bubbles: true, cancelable: true })); - } - return valid; - } - reportValidity() { - return this.checkValidity(); - } - stepUp(increment) { - const newValue = HTMLInputElementValueStepping.step(this, 1, increment); - if (newValue !== null) { - this.value = newValue; - } - } - stepDown(increment) { - const newValue = HTMLInputElementValueStepping.step(this, -1, increment); - if (newValue !== null) { - this.value = newValue; - } - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[value] = this[value]; - clone[height] = this[height]; - clone[width] = this[width]; - clone[files] = this[files].slice(); - clone.#selectionStart = this.#selectionStart; - clone.#selectionEnd = this.#selectionEnd; - clone.#selectionDirection = this.#selectionDirection; - return clone; - } - dispatchEvent(event) { - if (event[type] !== "click" || event[eventPhase] !== EventPhaseEnum_default.none || !(event instanceof MouseEvent)) { - return super.dispatchEvent(event); - } - if (this.disabled) { - return false; - } - let previousCheckedValue = null; - let previousIndeterminateValue = this[indeterminate]; - const type2 = this.type; - if (type2 === "checkbox" || type2 === "radio") { - previousCheckedValue = this.checked; - this.#setChecked(type2 === "checkbox" ? !previousCheckedValue : true); - if (type2 === "checkbox") { - previousIndeterminateValue = this[indeterminate]; - this[indeterminate] = false; - } - } - const returnValue = super.dispatchEvent(event); - if (event[type] !== "click" || event[eventPhase] !== EventPhaseEnum_default.none || !(event instanceof MouseEvent)) { - return returnValue; - } - if (event[defaultPrevented]) { - if (previousCheckedValue !== null) { - this.#setChecked(previousCheckedValue); - this[indeterminate] = previousIndeterminateValue; - } - } else { - const type2 = this.type; - if (type2 === "checkbox" && this[isConnected]) { - this.dispatchEvent(new Event("input", { bubbles: true, cancelable: true })); - this.dispatchEvent(new Event("change", { bubbles: true, cancelable: true })); - } else if (type2 === "radio" && !previousCheckedValue && this[isConnected]) { - this.dispatchEvent(new Event("input", { bubbles: true, cancelable: true })); - this.dispatchEvent(new Event("change", { bubbles: true, cancelable: true })); - } else if (type2 === "submit" || type2 === "reset") { - const form = this.form; - if (form) { - if (type2 === "submit" && this[isConnected]) { - form.requestSubmit(this); - } else if (type2 === "reset") { - form.reset(); - } - } - } - } - return returnValue; - } - #isSelectionSupported() { - const inputType = this.type; - return inputType === "text" || inputType === "search" || inputType === "url" || inputType === "tel" || inputType === "password"; - } - #setChecked(checked2) { - this[checked] = checked2; - this[clearCache](); - if (checked2 && this.type === "radio" && this.name) { - const root = this[formNode] || this.getRootNode(); - const radioButtons = root.querySelectorAll(`input[type="radio"][name="${this.name}"]`); - for (const radioButton of radioButtons) { - if (radioButton !== this) { - radioButton[checked] = false; - } - } - } - } -} - -// node_modules/happy-dom/lib/nodes/html-label-element/HTMLLabelElement.js -class HTMLLabelElement extends HTMLElement { - get htmlFor() { - const htmlFor = this.getAttribute("for"); - if (htmlFor !== null) { - return htmlFor; - } - return htmlFor !== null ? htmlFor : ""; - } - set htmlFor(htmlFor) { - this.setAttribute("for", htmlFor); - } - get control() { - const htmlFor = this.getAttribute("for"); - if (htmlFor !== null) { - if (!htmlFor || !this[isConnected]) { - return null; - } - const control = this[rootNode].getElementById(htmlFor); - if (control) { - switch (control[tagName]) { - case "INPUT": - return control.type !== "hidden" ? control : null; - case "BUTTON": - case "METER": - case "OUTPUT": - case "PROGRESS": - case "SELECT": - case "TEXTAREA": - return control; - default: - return null; - } - } - } - return this.querySelector('button,input:not([type="hidden"]),meter,output,progress,select,textarea'); - } - get form() { - return this.control?.form || null; - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - dispatchEvent(event) { - const returnValue = super.dispatchEvent(event); - if (!event[defaultPrevented] && event.type === "click" && (event.eventPhase === EventPhaseEnum_default.atTarget || event.eventPhase === EventPhaseEnum_default.bubbling) && event instanceof MouseEvent) { - const control = this.control; - if (control && event.target !== control) { - control.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true })); - } - } - return returnValue; - } -} - -// node_modules/happy-dom/lib/nodes/html-legend-element/HTMLLegendElement.js -class HTMLLegendElement extends HTMLElement { - get form() { - let parent = this; - while (parent) { - if (parent instanceof HTMLFieldSetElement) { - return parent.form; - } - parent = parent.parentNode; - } - return null; - } -} - -// node_modules/happy-dom/lib/nodes/html-li-element/HTMLLIElement.js -class HTMLLIElement extends HTMLElement { - get value() { - if (!this.hasAttribute("value")) { - return 0; - } - const parsedValue = Number(this.getAttribute("value")); - return isNaN(parsedValue) ? 0 : parsedValue; - } - set value(value) { - const parsedValue = Number(value); - this.setAttribute("value", isNaN(parsedValue) ? "0" : String(parsedValue)); - } -} - -// node_modules/happy-dom/lib/fetch/SyncFetch.js -import FS3 from "fs"; -import Path4 from "path"; -import ChildProcess from "child_process"; - -// node_modules/happy-dom/lib/fetch/utilities/SyncFetchScriptBuilder.js -class SyncFetchScriptBuilder { - static getScript(request) { - const sortedHeaders = {}; - const headerNames = Object.keys(request.headers).sort(); - for (const name of headerNames) { - sortedHeaders[name] = request.headers[name]; - } - return ` - const sendRequest = require('http${request.url.protocol === "https:" ? "s" : ""}').request; - const options = ${JSON.stringify({ - method: request.method, - headers: sortedHeaders, - agent: false, - rejectUnauthorized: !request.disableStrictSSL, - key: request.url.protocol === "https:" ? FetchHTTPSCertificate_default.key : undefined, - cert: request.url.protocol === "https:" ? FetchHTTPSCertificate_default.cert : undefined - }, null, 4)}; - const request = sendRequest(${JSON.stringify(request.url.href)}, options, (incomingMessage) => { - let data = Buffer.alloc(0); - incomingMessage.on('data', (chunk) => { - data = Buffer.concat([data, Buffer.from(chunk)]); - }); - incomingMessage.on('end', () => { - console.log(JSON.stringify({ - error: null, - incomingMessage: { - statusCode: incomingMessage.statusCode, - statusMessage: incomingMessage.statusMessage, - rawHeaders: incomingMessage.rawHeaders, - data: data.toString('base64') - } - })); - }); - incomingMessage.on('error', (error) => { - console.log(JSON.stringify({ error: error.message, incomingMessage: null })); - }); - }); - request.write(Buffer.from('${request.body ? request.body.toString("base64") : ""}', 'base64')); - request.end(); - `; - } -} - -// node_modules/happy-dom/lib/fetch/SyncFetch.js -import Zlib2 from "zlib"; -class SyncFetch { - request; - redirectCount = 0; - disableCache; - disableSameOriginPolicy; - interceptor; - requestHeaders; - #browserFrame; - #window; - #unfilteredHeaders = null; - constructor(options) { - this.#browserFrame = options.browserFrame; - this.#window = options.window; - this.#unfilteredHeaders = options.unfilteredHeaders ?? null; - this.request = typeof options.url === "string" || options.url instanceof URL2 ? new options.window.Request(options.url, options.init) : options.url; - if (options.contentType) { - this.request[contentType] = options.contentType; - } - this.redirectCount = options.redirectCount ?? 0; - this.disableCache = options.disableCache ?? false; - this.disableSameOriginPolicy = options.disableSameOriginPolicy ?? this.#browserFrame.page.context.browser.settings.fetch.disableSameOriginPolicy ?? false; - this.interceptor = this.#browserFrame.page.context.browser.settings.fetch.interceptor; - this.requestHeaders = this.#browserFrame.page.context.browser.settings.fetch.requestHeaders; - } - send() { - FetchRequestReferrerUtility.prepareRequest(new URL2(this.#window.location.href), this.request); - if (this.requestHeaders) { - for (const header of this.requestHeaders) { - if (!header.url || (typeof header.url === "string" ? header.url.startsWith(this.request.url) : this.request.url.match(header.url))) { - for (const [key, value] of Object.entries(header.headers)) { - this.request.headers.set(key, value); - } - } - } - } - if (this.interceptor?.beforeSyncRequest) { - const beforeRequestResponse = this.interceptor.beforeSyncRequest({ - request: this.request, - window: this.#window - }); - if (typeof beforeRequestResponse === "object") { - return beforeRequestResponse; - } - } - FetchRequestValidationUtility.validateSchema(this.request); - if (this.request.signal[aborted]) { - if (this.request.signal[reason] !== undefined) { - throw this.request.signal[reason]; - } - throw new this.#window.DOMException("signal is aborted without reason", DOMExceptionNameEnum_default.abortError); - } - if (this.request[url].protocol === "data:") { - const result = DataURIParser.parse(this.request.url); - const response = { - status: 200, - statusText: "OK", - ok: true, - url: this.request.url, - redirected: false, - headers: new this.#window.Headers({ "Content-Type": result.type }), - body: result.buffer, - [virtualServerFile]: null - }; - const interceptedResponse = this.interceptor?.afterSyncResponse ? this.interceptor.afterSyncResponse({ - window: this.#window, - response, - request: this.request - }) : undefined; - return typeof interceptedResponse === "object" ? interceptedResponse : response; - } - if (this.request[url].protocol === "http:" && this.#window.location.protocol === "https:") { - throw new this.#window.DOMException(`Mixed Content: The page at '${this.#window.location.href}' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '${this.request.url}'. This request has been blocked; the content must be served over HTTPS.`, DOMExceptionNameEnum_default.securityError); - } - const cachedResponse = this.getCachedResponse(); - if (cachedResponse) { - return cachedResponse; - } - const virtualServerResponse = this.getVirtualServerResponse(); - if (virtualServerResponse) { - return virtualServerResponse; - } - if (!this.compliesWithCrossOriginPolicy()) { - this.#window.console.warn(`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "${this.request.url}".`); - throw new this.#window.DOMException(`Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "${this.request.url}".`, DOMExceptionNameEnum_default.networkError); - } - return this.sendRequest(); - } - getCachedResponse() { - if (this.disableCache) { - return null; - } - let cachedResponse = this.#browserFrame.page.context.responseCache.get(this.request); - if (!cachedResponse || cachedResponse.response.waitingForBody) { - return null; - } - if (cachedResponse.state === CachedResponseStateEnum_default.stale) { - const headers = new this.#window.Headers(cachedResponse.request.headers); - if (cachedResponse.etag) { - headers.set("If-None-Match", cachedResponse.etag); - } else { - if (!cachedResponse.lastModified) { - return null; - } - headers.set("If-Modified-Since", new Date(cachedResponse.lastModified).toUTCString()); - } - if (cachedResponse.etag || !cachedResponse.staleWhileRevalidate) { - const fetch2 = new SyncFetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: this.request.url, - init: { headers, method: cachedResponse.request.method }, - disableCache: true, - disableSameOriginPolicy: true - }); - const validateResponse = fetch2.send(); - const body = validateResponse.status !== 304 ? validateResponse.body : null; - cachedResponse = this.#browserFrame.page.context.responseCache.add(this.request, { - ...validateResponse, - body, - waitingForBody: false - }); - if (validateResponse.status !== 304) { - return validateResponse; - } - } else { - const fetch2 = new Fetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: this.request.url, - init: { headers, method: cachedResponse.request.method }, - disableCache: true, - disableSameOriginPolicy: true - }); - fetch2.send().then((response) => { - response.buffer().then((body) => { - this.#browserFrame.page.context.responseCache.add(this.request, { - ...response, - body, - waitingForBody: false - }); - }); - }); - } - } - if (!cachedResponse || cachedResponse.response.waitingForBody) { - return null; - } - return { - status: cachedResponse.response.status, - statusText: cachedResponse.response.statusText, - ok: true, - url: cachedResponse.response.url, - redirected: false, - headers: cachedResponse.response.headers, - body: cachedResponse.response.body, - [virtualServerFile]: cachedResponse.response[virtualServerFile] || null - }; - } - getVirtualServerResponse() { - let filePath = VirtualServerUtility.getFilepath(this.#window, this.request.url); - if (!filePath) { - return null; - } - if (this.request.method !== "GET") { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} 404 (Not Found)`); - const response = VirtualServerUtility.getNotFoundSyncResponse(this.#window, this.request.url); - const interceptedResponse = this.interceptor?.afterSyncResponse ? this.interceptor.afterSyncResponse({ - window: this.#window, - response, - request: this.request - }) : undefined; - return typeof interceptedResponse === "object" ? interceptedResponse : response; - } - let buffer; - try { - const stat = FS3.statSync(filePath); - filePath = stat.isDirectory() ? Path4.join(filePath, "index.html") : filePath; - buffer = FS3.readFileSync(filePath); - } catch { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} 404 (Not Found)`); - const response = VirtualServerUtility.getNotFoundSyncResponse(this.#window, this.request.url); - const interceptedResponse = this.interceptor?.afterSyncResponse ? this.interceptor.afterSyncResponse({ - window: this.#window, - response, - request: this.request - }) : undefined; - return typeof interceptedResponse === "object" ? interceptedResponse : response; - } - const response = { - status: 200, - statusText: "", - ok: true, - url: this.request.url, - redirected: false, - headers: new this.#window.Headers, - body: buffer, - [virtualServerFile]: filePath - }; - const interceptedResponse = this.interceptor?.afterSyncResponse ? this.interceptor.afterSyncResponse({ - window: this.#window, - response, - request: this.request - }) : undefined; - const returnResponse = typeof interceptedResponse === "object" ? interceptedResponse : response; - this.#browserFrame.page.context.responseCache.add(this.request, { - ...returnResponse, - waitingForBody: false, - virtual: true - }); - return returnResponse; - } - compliesWithCrossOriginPolicy() { - if (this.disableSameOriginPolicy || !FetchCORSUtility.isCORS(this.#window.location.href, this.request[url])) { - return true; - } - const cachedPreflightResponse = this.#browserFrame.page.context.preflightResponseCache.get(this.request); - if (cachedPreflightResponse) { - if (cachedPreflightResponse.allowOrigin !== "*" && cachedPreflightResponse.allowOrigin !== this.#window.location.origin) { - return false; - } - if (cachedPreflightResponse.allowMethods.length !== 0 && !cachedPreflightResponse.allowMethods.includes(this.request.method)) { - return false; - } - return true; - } - const requestHeaders = []; - for (const [header] of this.request.headers) { - requestHeaders.push(header.toLowerCase()); - } - const corsHeaders = new this.#window.Headers({ - "Access-Control-Request-Method": this.request.method, - Origin: this.#window.location.origin - }); - if (requestHeaders.length > 0) { - corsHeaders.set("Access-Control-Request-Headers", requestHeaders.slice().sort().join(",")); - } - const fetch2 = new SyncFetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: this.request.url, - init: { method: "OPTIONS" }, - disableCache: true, - disableSameOriginPolicy: true, - unfilteredHeaders: corsHeaders - }); - const response = fetch2.send(); - if (!response.ok) { - return false; - } - const allowOrigin = response.headers.get("Access-Control-Allow-Origin"); - if (!allowOrigin) { - return false; - } - if (allowOrigin !== "*" && allowOrigin !== this.#window.location.origin) { - return false; - } - const allowMethods = []; - if (response.headers.has("Access-Control-Allow-Methods")) { - const allowMethodsHeader = response.headers.get("Access-Control-Allow-Methods"); - if (allowMethodsHeader !== "*") { - for (const method of allowMethodsHeader.split(",")) { - allowMethods.push(method.trim().toUpperCase()); - } - } - } - if (allowMethods.length !== 0 && !allowMethods.includes(this.request.method)) { - return false; - } - return true; - } - sendRequest() { - if (!this.request[bodyBuffer] && this.request.body) { - throw new this.#window.DOMException(`Streams are not supported as request body for synchronous requests.`, DOMExceptionNameEnum_default.notSupportedError); - } - const script = SyncFetchScriptBuilder.getScript({ - url: this.request[url], - method: this.request.method, - headers: FetchRequestHeaderUtility.getRequestHeaders({ - browserFrame: this.#browserFrame, - window: this.#window, - request: this.request, - baseHeaders: this.#unfilteredHeaders - }), - disableStrictSSL: this.#browserFrame.page.context.browser.settings.fetch.disableStrictSSL, - body: this.request[bodyBuffer] - }); - const content = ChildProcess.execFileSync(process.argv[0], ["-e", script], { - encoding: "buffer", - maxBuffer: 1024 * 1024 * 1024 - }); - if (!content.length) { - throw new this.#window.DOMException(`Synchronous fetch to "${this.request.url}" failed.`, DOMExceptionNameEnum_default.networkError); - } - const { error, incomingMessage } = JSON.parse(content.toString()); - if (error) { - throw new this.#window.DOMException(`Synchronous fetch to "${this.request.url}" failed. Error: ${error}`, DOMExceptionNameEnum_default.networkError); - } - const headers = FetchResponseHeaderUtility.parseResponseHeaders({ - browserFrame: this.#browserFrame, - requestURL: this.request[url], - rawHeaders: incomingMessage.rawHeaders - }); - const response = { - status: incomingMessage.statusCode, - statusText: incomingMessage.statusMessage, - ok: incomingMessage.statusCode >= 200 && incomingMessage.statusCode < 300, - url: this.request.url, - redirected: this.redirectCount > 0, - headers, - body: this.parseIResponseBody({ - headers, - status: incomingMessage.statusCode, - body: Buffer.from(incomingMessage.data, "base64") - }) - }; - const redirectedResponse = this.handleRedirectResponse(response) || response; - if (!this.disableCache && !redirectedResponse.redirected) { - this.#browserFrame.page.context.responseCache.add(this.request, { - status: redirectedResponse.status, - statusText: redirectedResponse.statusText, - url: redirectedResponse.url, - headers: redirectedResponse.headers, - body: redirectedResponse.body, - waitingForBody: false - }); - } - const interceptedResponse = this.interceptor?.afterSyncResponse ? this.interceptor.afterSyncResponse({ - window: this.#window, - response: redirectedResponse, - request: this.request - }) : undefined; - const returnResponse = typeof interceptedResponse === "object" ? interceptedResponse : redirectedResponse; - if (!returnResponse.ok) { - this.#browserFrame.page.console.error(`${this.request.method} ${this.request.url} ${returnResponse.status} (${returnResponse.statusText})`); - } - return returnResponse; - } - parseIResponseBody(options) { - const contentEncodingHeader = options.headers.get("Content-Encoding"); - if (this.request.method === "HEAD" || contentEncodingHeader === null || options.status === 204 || options.status === 304) { - return options.body; - } - try { - if (contentEncodingHeader === "gzip" || contentEncodingHeader === "x-gzip") { - return Zlib2.gunzipSync(options.body, { - flush: Zlib2.constants.Z_SYNC_FLUSH, - finishFlush: Zlib2.constants.Z_SYNC_FLUSH - }); - } - if (contentEncodingHeader === "deflate" || contentEncodingHeader === "x-deflate") { - return Zlib2.inflateSync(options.body); - } - if (contentEncodingHeader === "br") { - return Zlib2.brotliDecompressSync(options.body); - } - } catch (error) { - throw new this.#window.DOMException(`Failed to read response body. Error: ${error.message}.`, DOMExceptionNameEnum_default.encodingError); - } - return options.body; - } - handleRedirectResponse(response) { - if (!FetchResponseRedirectUtility.isRedirect(response.status)) { - return null; - } - switch (this.request.redirect) { - case "error": - throw new this.#window.DOMException(`URI requested responds with a redirect, redirect mode is set to "error": ${this.request.url}`, DOMExceptionNameEnum_default.abortError); - case "manual": - return null; - case "follow": - const locationHeader = response.headers.get("Location"); - const shouldBecomeGetRequest = response.status === 303 || (response.status === 301 || response.status === 302) && this.request.method === "POST"; - let locationURL = null; - if (locationHeader !== null) { - try { - locationURL = new URL2(locationHeader, this.request.url); - } catch { - throw new this.#window.DOMException(`URI requested responds with an invalid redirect URL: ${locationHeader}`, DOMExceptionNameEnum_default.uriMismatchError); - } - } - if (locationURL === null) { - return null; - } - if (FetchResponseRedirectUtility.isMaxRedirectsReached(this.redirectCount)) { - throw new this.#window.DOMException(`Maximum redirects reached at: ${this.request.url}`, DOMExceptionNameEnum_default.networkError); - } - const headers = new this.#window.Headers(this.request.headers); - const requestInit = { - method: this.request.method, - signal: this.request.signal, - referrer: this.request.referrer, - referrerPolicy: this.request.referrerPolicy, - credentials: this.request.credentials, - headers, - body: this.request[bodyBuffer] - }; - if (this.request.credentials === "omit" || this.request.credentials === "same-origin" && FetchCORSUtility.isCORS(this.#window.location.href, locationURL)) { - headers.delete("cookie"); - headers.delete("cookie2"); - } - if (shouldBecomeGetRequest) { - requestInit.method = "GET"; - requestInit.body = undefined; - headers.delete("Content-Length"); - headers.delete("Content-Type"); - } - const responseReferrerPolicy = FetchRequestReferrerUtility.getReferrerPolicyFromHeader(headers); - if (responseReferrerPolicy) { - requestInit.referrerPolicy = responseReferrerPolicy; - } - const fetch2 = new SyncFetch({ - browserFrame: this.#browserFrame, - window: this.#window, - url: locationURL, - init: requestInit, - redirectCount: this.redirectCount + 1, - contentType: !shouldBecomeGetRequest ? this.request[contentType] : null - }); - return fetch2.send(); - default: - throw new this.#window.DOMException(`Redirect option '${this.request.redirect}' is not a valid value of TRequestRedirect`); - } - } -} - -// node_modules/happy-dom/lib/fetch/ResourceFetch.js -class ResourceFetch { - window; - constructor(window) { - this.window = window; - } - async fetch(url, destination, options) { - const browserFrame = new WindowBrowserContext(this.window).getBrowserFrame(); - if (!browserFrame) { - return { - content: "", - virtualServerFile: null - }; - } - if (destination === "script" || destination === "style") { - const preloadKey = PreloadUtility.getKey({ - url: String(url), - destination, - mode: "cors", - credentialsMode: options?.credentials || "same-origin" - }); - const preloadEntry = this.window.document[preloads].get(preloadKey); - if (preloadEntry) { - this.window.document[preloads].delete(preloadKey); - const response = preloadEntry.response || await preloadEntry.onResponseAvailable(); - if (response && !response.ok) { - throw new this.window.DOMException(`Failed to perform request to "${new URL2(url, this.window.location.href).href}". Status ${preloadEntry.response?.status || "0"} ${preloadEntry.response?.statusText || "Unknown"}.`); - } - return { - content: preloadEntry.response?.[buffer]?.toString() || "", - virtualServerFile: preloadEntry.response?.[virtualServerFile] || null - }; - } - } - const fetch2 = new Fetch({ - browserFrame, - window: this.window, - url, - disableSameOriginPolicy: destination === "script" || destination === "style", - disablePreload: true, - init: { - credentials: options?.credentials, - referrerPolicy: options?.referrerPolicy - } - }); - const response = await fetch2.send(); - if (!response.ok) { - throw new this.window.DOMException(`Failed to perform request to "${new URL2(url, this.window.location.href).href}". Status ${response.status} ${response.statusText}.`); - } - return { - content: await response.text(), - virtualServerFile: response[virtualServerFile] || null - }; - } - fetchSync(url, destination, options) { - const browserFrame = new WindowBrowserContext(this.window).getBrowserFrame(); - if (!browserFrame) { - return { - content: "", - virtualServerFile: null - }; - } - if (destination === "script" || destination === "style") { - const preloadKey = PreloadUtility.getKey({ - url: String(url), - destination, - mode: "cors", - credentialsMode: options?.credentials || "same-origin" - }); - const preloadEntry = this.window.document[preloads].get(preloadKey); - if (preloadEntry && preloadEntry.response) { - this.window.document[preloads].delete(preloadKey); - const response = preloadEntry.response; - if (!response.ok) { - throw new this.window.DOMException(`Failed to perform request to "${new URL2(url, this.window.location.href).href}". Status ${preloadEntry.response.status} ${preloadEntry.response.statusText}.`); - } - return { - content: preloadEntry.response?.[buffer]?.toString() || "", - virtualServerFile: preloadEntry.response?.[virtualServerFile] || null - }; - } - } - const fetch2 = new SyncFetch({ - browserFrame, - window: this.window, - url, - disableSameOriginPolicy: true, - init: { - credentials: options?.credentials, - referrerPolicy: options?.referrerPolicy - } - }); - const response = fetch2.send(); - if (!response.ok) { - throw new this.window.DOMException(`Failed to perform request to "${new URL2(url, this.window.location.href).href}". Status ${response.status} ${response.statusText}.`); - } - return { - content: response.body?.toString() || "", - virtualServerFile: response[virtualServerFile] || null - }; - } -} - -// node_modules/happy-dom/lib/module/CSSModule.js -class CSSModule { - url; - #window; - #source; - #exports = null; - constructor(init) { - this.#window = init.window; - this.url = init.url; - this.#source = init.source; - } - async evaluate() { - if (this.#exports) { - return this.#exports; - } - const styleSheet = new this.#window.CSSStyleSheet; - styleSheet.replaceSync(this.#source); - this.#exports = { default: styleSheet }; - return this.#exports; - } - async preload() { - await this.evaluate(); - } -} - -// node_modules/happy-dom/lib/module/JSONModule.js -class JSONModule { - url; - #window; - #source; - #exports = null; - constructor(init) { - this.#window = init.window; - this.url = init.url; - this.#source = init.source; - } - async evaluate() { - if (this.#exports) { - return this.#exports; - } - let result; - try { - result = JSON.parse(this.#source); - } catch (error) { - throw new this.#window.TypeError(`Failed to parse module "${this.url.href}": ${error.message}`); - } - this.#exports = { default: result }; - return this.#exports; - } - async preload() { - await this.evaluate(); - } -} - -// node_modules/happy-dom/lib/module/UnresolvedModule.js -class UnresolvedModule { - url; - #window; - #hooks = []; - #error = null; - constructor(init) { - this.#window = init.window; - this.url = init.url; - } - async evaluate() { - throw new this.#window.TypeError("Unresolved module. We should never end up here."); - } - async preload() { - throw new this.#window.TypeError("Unresolved module. We should never end up here."); - } - addResolveListener(resolve, reject) { - if (this.#error) { - reject(this.#error); - return; - } - this.#hooks.push({ resolve, reject }); - } - resolve(error) { - if (error) { - this.#error = error; - } - for (const hook of this.#hooks) { - if (error) { - hook.reject(error); - } else { - hook.resolve(null); - } - } - } -} - -// node_modules/happy-dom/lib/module/ECMAScriptModule.js -import { URL as URL11 } from "url"; - -// node_modules/happy-dom/lib/module/ModuleURLUtility.js -import { URL as URL10 } from "url"; -import Path5 from "path"; -import FS4 from "fs"; -var MAIN_FIELDS = ["module", "main"]; -var EXTENSIONS = [".js", ".mjs"]; - -class ModuleURLUtility { - static nodeModuleResolveCache = new Map; - static packageJsonCache = new Map; - static getURL(window, parentURL, url) { - const parentURLString = typeof parentURL === "string" ? parentURL : parentURL.href; - const importMap = window[moduleImportMap]; - const resolved = this.resolveURL(window, parentURLString, url); - if (!importMap) { - return new URL10(resolved, parentURLString); - } - if (importMap.scopes.length) { - for (const scope of importMap.scopes) { - if (parentURLString.includes(scope.scope)) { - for (const rule of scope.rules) { - if (resolved.startsWith(rule.from)) { - return new URL10(rule.to + resolved.replace(rule.from, ""), parentURLString); - } - } - } - } - } - if (importMap.imports.length) { - for (const rule of importMap.imports) { - if (resolved.startsWith(rule.from)) { - return new URL10(rule.to + resolved.replace(rule.from, ""), parentURLString); - } - } - } - return new URL10(resolved, parentURLString); - } - static clearCache() { - this.nodeModuleResolveCache.clear(); - this.packageJsonCache.clear(); - } - static resolveURL(window, parentURL, url) { - const settings = new WindowBrowserContext(window).getSettings(); - if (!settings) { - return url; - } - let resolvedURL = url; - if (settings.module.resolveNodeModules) { - resolvedURL = this.resolveNodeModuleURL(settings.module.resolveNodeModules, url); - } - if (settings.module.urlResolver) { - resolvedURL = settings.module.urlResolver({ url: resolvedURL, parentURL, window }); - } - return resolvedURL; - } - static resolveNodeModuleURL(resolveNodeModules, url) { - if (url[0] === "." || url[0] === "/" || url.startsWith("http://") || url.startsWith("https://")) { - return url; - } - const slash = resolveNodeModules.url[resolveNodeModules.url.length - 1] === "/" ? "" : "/"; - const baseURL = `${resolveNodeModules.url}${slash}`; - const nodeModulesDirectory = Path5.resolve(resolveNodeModules.directory); - const parts = url.split("/"); - const cached = this.nodeModuleResolveCache.get(url); - if (cached) { - return cached; - } - const packageName = url[0] === "@" ? `${parts[0]}/${parts[1]}` : parts[0]; - let packageJson = this.packageJsonCache.get(packageName); - if (!packageJson) { - try { - packageJson = JSON.parse(FS4.readFileSync(Path5.join(nodeModulesDirectory, packageName, "package.json"), "utf-8")); - this.packageJsonCache.set(packageName, packageJson); - } catch { - return url; - } - } - if (url[0] === "@" && parts.length === 2 || parts.length === 1) { - if (packageJson.exports?.["."]?.import) { - const resolvedURL = `${baseURL}${packageName}/${packageJson.exports["."].import.replace("./", "")}`; - this.nodeModuleResolveCache.set(url, resolvedURL); - return resolvedURL; - } - const mainFields = resolveNodeModules.mainFields || MAIN_FIELDS; - for (const field of mainFields) { - if (packageJson[field] && FS4.existsSync(Path5.join(nodeModulesDirectory, packageName, packageJson[field]))) { - const resolvedURL = `${baseURL}${url}/${packageJson[field]}`; - this.nodeModuleResolveCache.set(url, resolvedURL); - return resolvedURL; - } - } - return url; - } - const subPath = parts.slice(url[0] === "@" ? 2 : 1).join("/"); - if (packageJson.exports) { - for (const key of Object.keys(packageJson.exports)) { - const importEntry = Array.isArray(packageJson.exports[key].import) ? packageJson.exports[key].import[0] : packageJson.exports[key].import; - if (importEntry) { - const regExp = new RegExp(`^${key.replace("./", "").replace(/\./g, "\\.").replace(/\*/g, "(.*)")}$`); - const match = subPath.match(regExp); - if (match) { - const resolvedSubPath = importEntry.replace("./", "").replace("*", match[1]); - const resolvedURL = `${baseURL}${packageName}/${resolvedSubPath}`; - this.nodeModuleResolveCache.set(url, resolvedURL); - return resolvedURL; - } - } - } - } - if (!url.endsWith(".js") && !url.endsWith(".mjs")) { - for (const ext of EXTENSIONS) { - if (FS4.existsSync(Path5.join(nodeModulesDirectory, `${url}${ext}`))) { - const resolvedURL = `${baseURL}${url}${ext}`; - this.nodeModuleResolveCache.set(url, resolvedURL); - return resolvedURL; - } - } - } else { - if (FS4.existsSync(Path5.join(nodeModulesDirectory, url))) { - const resolvedURL = `${baseURL}${url}`; - this.nodeModuleResolveCache.set(url, resolvedURL); - return resolvedURL; - } - } - return url; - } -} - -// node_modules/happy-dom/lib/module/ECMAScriptModuleCompiler.js -var STATEMENT_REGEXP = /import\.meta\.([a-zA-Z]+)|import\s*["']([^"']+)["'];{0,1}|import\s*\(([^)]+)\)|(import[\s{])|[\s}]from\s*["']([^"']+)["'](\s+with\s*{\s*type\s*:\s*["']([^"']+)["']\s*}){0,1}([;\s]*)|export(\s+[a-zA-Z0-9-_$]+\s+|\s+\*\s+|\s+\*\s+as\s+["'a-zA-Z0-9-_$]+\s+|\s*{[^}]+}\s*)from\s*["']([^"']+)["']|export\s*(default\s+){0,1}(async\s+){0,1}(function\*{0,1}|class)\s*([^({\s]+)|(export\s*default\s*)|export\s*{([^}]+)}|export\s+(var|let|const)\s+([^=;]+)(=|;)/gm; -var SYNTAX_REGEXP = /(\/)|(\(|\))|({|})|(\[|\])|(\${)|(`)|(')|(")|(\n)/gm; -var IMPORT_REGEXP = /{([^}]+)}|\*\s+as\s+([a-zA-Z0-9-_$]+)|([a-zA-Z0-9-_$]+)/gm; -var VALID_VARIABLE_NAME_REGEXP = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/; -var PRECEDING_STATEMENT_TOKEN_REGEXP = /['"`(){}\s;=><\[\]+-,:&]/; -var PRECEDING_REGEXP_TOKEN_REGEXP = /['"`({};=><\[+-,:&]/; -var MULTILINE_COMMENT_REGEXP = /\/\*|\*\//gm; -var EXPORT_REGEXP = /export\s*/; -var EXPORT_DEFAULT_REGEXP = /export\s*default\s*/; -var ENDS_WITH_SEMICOLON_REGEXP = /;\s*$/; - -class ECMAScriptModuleCompiler { - window; - debug = false; - count = { - comment: 0, - singleLineComment: 0, - parentheses: 0, - curlyBraces: 0, - squareBrackets: 0, - regExp: 0, - regExpSquareBrackets: 0, - escapeTemplateString: 0, - simpleString: 0, - doubleString: 0 - }; - debugCount = { - comment: [], - singleLineComment: [], - parentheses: [], - curlyBraces: [], - squareBrackets: [], - regExp: [], - regExpSquareBrackets: [], - escapeTemplateString: [], - simpleString: [], - doubleString: [] - }; - templateString = []; - constructor(window) { - this.window = window; - } - compile(moduleURL, code, sourceURL = null) { - const browserContext = new WindowBrowserContext(this.window).getBrowserContext(); - if (!browserContext) { - return { imports: [], execute: async () => {} }; - } - const browserSettings = browserContext.browser.settings; - if (!browserSettings.module.disableCache && sourceURL) { - const cached = browserContext[moduleCache].get(moduleURL); - if (cached) { - return { - imports: cached.imports, - execute: this.window[evaluateScript](cached.code, { - filename: sourceURL - }) - }; - } - } - this.reset(); - const regExp = new RegExp(STATEMENT_REGEXP); - const imports = []; - const resolvableCircularImports = []; - const count = this.count; - let newCode = ""; - let newCodeStart = ""; - let newCodeEnd = ""; - let match = null; - let precedingToken; - let textBetweenStatements; - let isTopLevel = true; - let lastIndex = 0; - let importStartIndex = -1; - while (match = regExp.exec(code)) { - precedingToken = code[match.index - 1] || " "; - textBetweenStatements = code.substring(lastIndex, match.index); - this.parseSyntax(textBetweenStatements, lastIndex); - if (importStartIndex === -1) { - newCode += textBetweenStatements; - } - isTopLevel = count.comment === 0 && count.singleLineComment === 0 && count.parentheses === 0 && count.curlyBraces === 0 && count.squareBrackets === 0 && count.regExp === 0 && count.simpleString === 0 && count.doubleString === 0 && this.templateString.length === 0; - if (match[1] && count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && (this.templateString.length === 0 || this.templateString[0] > 0) && PRECEDING_STATEMENT_TOKEN_REGEXP.test(this.getNonSpacePrecedingToken(code, match.index))) { - newCode += `$happy_dom.importMeta.${match[1]}`; - } else if (match[2] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - imports.push({ - url: ModuleURLUtility.getURL(this.window, moduleURL, match[2]).href, - type: "esm" - }); - } else if (match[3] && count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && (this.templateString.length === 0 || this.templateString[0] > 0) && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - newCode += `$happy_dom.dynamicImport(${match[3]})`; - } else if (match[4] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - if (importStartIndex !== -1) { - throw new this.window.TypeError(`Failed to parse module: Unexpected import statement in "${moduleURL}"`); - } - importStartIndex = match.index + match[0].length - 1; - } else if (match[5] && isTopLevel && importStartIndex !== -1) { - const url = ModuleURLUtility.getURL(this.window, moduleURL, match[5]).href; - const variables = code.substring(importStartIndex, match.index + 1); - const importRegExp = new RegExp(IMPORT_REGEXP); - let importMatch = null; - while (importMatch = importRegExp.exec(variables)) { - if (importMatch[1]) { - const parts = this.removeMultilineComments(importMatch[1]).split(/\s*,\s*/); - const properties = []; - for (const part of parts) { - const nameParts = part.trim().split(/\s+as\s+/); - const alias = (nameParts[1] || nameParts[0]).replace(/["']/g, ""); - const name = nameParts[0].replace(/["']/g, ""); - if (alias && name) { - if (name === alias) { - properties.push({ name }); - } else { - properties.push({ name, alias }); - } - } - } - if (!match[7] || match[7] === "esm") { - resolvableCircularImports.push({ url, properties }); - } - newCodeStart += `let {${properties.map((property) => property.alias ? `"${property.name}": ${property.alias}` : property.name).join(", ")}} = $happy_dom.imports.get('${url}')${match[8]}`; - } else if (importMatch[2]) { - newCodeStart += `const ${importMatch[2]} = $happy_dom.imports.get('${url}')${match[8]}`; - } else if (importMatch[3]) { - if (!match[7] || match[7] === "esm") { - resolvableCircularImports.push({ - url, - properties: [{ name: "default", alias: importMatch[3] }] - }); - } - newCodeStart += `let ${importMatch[3]} = $happy_dom.imports.get('${url}').default${match[8]}`; - } - } - importStartIndex = -1; - imports.push({ url, type: match[7] || "esm" }); - } else if (match[9] && match[10] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - const url = ModuleURLUtility.getURL(this.window, moduleURL, match[10]).href; - const imported = match[9].trim(); - if (imported === "*") { - newCode += `Object.assign($happy_dom.exports, $happy_dom.imports.get('${url}'))`; - imports.push({ url, type: "esm" }); - } else if (imported[0] === "*") { - const parts = imported.split(/\s+as\s+/); - if (parts.length === 2) { - const exportName = parts[1].replace(/["']/g, ""); - newCode += `$happy_dom.exports['${exportName}'] = $happy_dom.imports.get('${url}')`; - imports.push({ url, type: "esm" }); - } - } else if (imported[0] === "{") { - const parts = this.removeMultilineComments(imported).slice(1, -1).split(/\s*,\s*/); - const exportCode = []; - for (const part of parts) { - const nameParts = part.trim().split(/\s+as\s+/); - const exportName = (nameParts[1] || nameParts[0]).replace(/["']/g, ""); - const importName = nameParts[0].replace(/["']/g, ""); - if (exportName && importName) { - exportCode.push(`$happy_dom.exports['${exportName}'] = $happy_dom.imports.get('${url}')['${importName}']`); - } - } - newCode += exportCode.join(`; -`); - imports.push({ url, type: "esm" }); - } - } else if (match[13] && match[14] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - const name = match[14].replace("*", ""); - if (name) { - if (match[11]) { - newCode += match[0].replace(EXPORT_DEFAULT_REGEXP, ""); - newCodeEnd += `$happy_dom.exports.default = ${name}; -`; - } else { - newCode += match[0].replace(EXPORT_REGEXP, ""); - newCodeEnd += `$happy_dom.exports['${name}'] = ${name}; -`; - } - } else { - if (match[11]) { - newCode += `$happy_dom.exports.default = ${match[12] || ""}${match[13]}${name ? " " : ""}${match[14]}`; - } else { - throw new this.window.SyntaxError(`Failed to parse module: Missing function or class name in export statement in "${moduleURL}"`); - } - } - } else if (match[15] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - newCode += "$happy_dom.exports.default = "; - } else if (match[16] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - const parts = this.removeMultilineComments(match[16]).split(/\s*,\s*/); - const exportCode = []; - for (const part of parts) { - const nameParts = part.trim().split(/\s+as\s+/); - const exportName = (nameParts[1] || nameParts[0]).replace(/["']/g, ""); - const importName = nameParts[0].replace(/["']/g, ""); - if (exportName && importName && VALID_VARIABLE_NAME_REGEXP.test(importName)) { - exportCode.push(`$happy_dom.exports['${exportName}'] = ${importName}`); - } - } - newCode += exportCode.join(`; -`); - } else if (match[17] && isTopLevel && PRECEDING_STATEMENT_TOKEN_REGEXP.test(precedingToken)) { - if (match[19] === "=") { - const exportName = this.removeMultilineComments(match[18]).trim(); - if (exportName[0] === "{" && exportName[exportName.length - 1] === "}" || exportName[0] === "[" && exportName[exportName.length - 1] === "]") { - const parts = exportName.slice(1, -1).split(/\s*,\s*/); - for (const part of parts) { - const nameParts = part.trim().split(/\s*:\s*/); - const exportName = (nameParts[1] || nameParts[0]).replace(/["']/g, ""); - if (exportName) { - newCodeEnd += `$happy_dom.exports['${exportName}'] = ${exportName}; -`; - } - } - newCode += match[0].replace(EXPORT_REGEXP, ""); - } else { - newCode += match[0].replace(EXPORT_REGEXP, ""); - newCodeEnd += `$happy_dom.exports['${exportName}'] = ${exportName}; -`; - } - } else { - newCode += match[0].replace(EXPORT_REGEXP, ""); - const parts = this.removeMultilineComments(match[18]).split(","); - for (const part of parts) { - const exportName = part.trim(); - newCodeEnd += `$happy_dom.exports['${exportName}'] = ${exportName}; -`; - } - } - } else if (importStartIndex !== -1) { - const unparsed = code.substring(importStartIndex, match.index + 1); - newCode += unparsed; - this.parseSyntax(unparsed, importStartIndex); - } else { - newCode += match[0]; - this.parseSyntax(match[0], match.index); - } - lastIndex = regExp.lastIndex; - } - if (this.debug) { - return { - imports, - execute: async () => {} - }; - } - if (!!newCodeStart && !ENDS_WITH_SEMICOLON_REGEXP.test(newCodeStart)) { - newCodeStart = ` -${newCodeStart};`; - } - if (!browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCodeStart = "(async function anonymous($happy_dom) { try {" + newCodeStart; - } else { - newCodeStart = "(async function anonymous($happy_dom) {" + newCodeStart; - } - newCode = newCodeStart + newCode; - if (lastIndex === 0) { - newCode += code; - } else { - newCode += code.substring(lastIndex); - } - newCode += ` -` + newCodeEnd; - if (resolvableCircularImports.length > 0) { - newCode += `$happy_dom.addCircularImportResolver(() => { -`; - for (const circularImport of resolvableCircularImports) { - for (const property of circularImport.properties) { - if (property.alias) { - newCode += `${property.alias} = $happy_dom.imports.get('${circularImport.url}')['${property.name}']; -`; - } else { - newCode += `${property.name} = $happy_dom.imports.get('${circularImport.url}')['${property.name}']; -`; - } - } - } - newCode += "});"; - } - if (!browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCode += `} catch(e) { $happy_dom.dispatchError(e); }`; - } - newCode += "})"; - let execute; - try { - execute = this.window[evaluateScript](newCode, { - filename: sourceURL || moduleURL - }); - } catch (e) { - const compileError = this.getError(moduleURL, code, sourceURL); - const error = compileError ? new this.window.SyntaxError(`Failed to parse module in '${moduleURL}'. Execution error: ${e.message}. Compile error: ${compileError}`) : e; - e.message = `Failed to parse module in '${sourceURL}': ${error.message}`; - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - throw error; - } else { - this.window[dispatchError](error); - return { - imports, - execute: async () => {} - }; - } - } - if (!browserSettings.module.disableCache && sourceURL) { - browserContext[moduleCache].set(moduleURL, { - imports, - code: newCode - }); - } - return { imports, execute }; - } - parseSyntax(code, index) { - const regExp = new RegExp(SYNTAX_REGEXP); - const count = this.count; - const debug = this.debug; - const debugCount = this.debugCount; - let match = null; - let precedingToken; - let isEscaped; - index++; - while (match = regExp.exec(code)) { - precedingToken = code[match.index - 1] || " "; - isEscaped = precedingToken === "\\" && code[match.index - 2] !== "\\"; - if (match[1]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.singleLineComment === 0 && count.regExpSquareBrackets === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.comment === 1) { - if (precedingToken === "*") { - count.comment = 0; - if (debug) { - debugCount.comment.length = 0; - } - } - } else { - if (count.regExp === 0) { - if (code[match.index + 1] === "*") { - count.comment = 1; - if (debug) { - debugCount.comment = [index + match.index]; - } - } else if (code[match.index + 1] === "/") { - count.singleLineComment = 1; - if (debug) { - debugCount.singleLineComment = [index + match.index]; - } - } else { - if (PRECEDING_REGEXP_TOKEN_REGEXP.test(this.getNonSpacePrecedingToken(code, match.index))) { - count.regExp = 1; - if (debug) { - debugCount.regExp = [index + match.index]; - } - } - } - } else if (!isEscaped) { - count.regExp = 0; - if (debug) { - debugCount.regExp.length = 0; - } - } - } - } - } else if (match[2]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.regExp === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (match[2] === "(") { - count.parentheses++; - if (debug) { - debugCount.parentheses.push(index + match.index); - } - } else if (match[2] === ")" && count.parentheses > 0) { - count.parentheses--; - if (debug) { - debugCount.parentheses.pop(); - } - } - } - } else if (match[3]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.regExp === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (match[3] === "{") { - if (this.templateString.length) { - this.templateString[0]++; - } - count.curlyBraces++; - if (debug) { - debugCount.curlyBraces.push(index + match.index); - } - } else if (match[3] === "}") { - if (this.templateString.length && this.templateString[0] > 0) { - this.templateString[0]--; - } - if (count.curlyBraces > 0) { - count.curlyBraces--; - if (debug) { - debugCount.curlyBraces.pop(); - } - } - } - } - } else if (match[4]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.regExp === 1) { - if (!isEscaped) { - if (match[4] === "[" && count.regExpSquareBrackets === 0) { - count.regExpSquareBrackets = 1; - if (debug) { - debugCount.regExpSquareBrackets = [index + match.index]; - } - } else if (match[4] === "]" && count.regExpSquareBrackets === 1) { - count.regExpSquareBrackets = 0; - if (debug) { - debugCount.regExpSquareBrackets.length = 0; - } - } - } - } else { - if (match[4] === "[") { - count.squareBrackets++; - if (debug) { - debugCount.squareBrackets.push(index + match.index); - } - } else if (match[4] === "]" && count.squareBrackets > 0) { - count.squareBrackets--; - if (debug) { - debugCount.squareBrackets.pop(); - } - } - } - } - } else if (match[5]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped) { - if (this.templateString[0] === 0) { - this.templateString[0] = 1; - count.curlyBraces++; - if (debug) { - debugCount.curlyBraces.push(index + match.index); - } - } - } - } else if (match[6]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped) { - if (this.templateString?.[0] === 0) { - this.templateString.shift(); - } else { - this.templateString.unshift(0); - } - } - } else if (match[7]) { - if (count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.simpleString === 0) { - count.simpleString = 1; - if (debug) { - debugCount.simpleString = [index + match.index]; - } - } else { - count.simpleString = 0; - if (debug) { - debugCount.simpleString.length = 0; - } - } - } - } else if (match[8]) { - if (count.simpleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.doubleString === 0) { - count.doubleString = 1; - if (debug) { - debugCount.doubleString = [index + match.index]; - } - } else { - count.doubleString = 0; - if (debug) { - debugCount.doubleString.length = 0; - } - } - } - } else if (match[9]) { - count.singleLineComment = 0; - if (debug) { - debugCount.singleLineComment.length = 0; - } - } - } - } - getError(moduleURL, code, sourceURL) { - if (this.count.comment === 0 && this.count.singleLineComment === 0 && this.count.parentheses === 0 && this.count.curlyBraces === 0 && this.count.squareBrackets === 0 && this.count.regExp === 0 && this.count.regExpSquareBrackets === 0 && this.count.simpleString === 0 && this.count.doubleString === 0) { - return null; - } - if (!this.debug) { - this.debug = true; - this.compile(moduleURL, code, sourceURL); - } - const debugCount = this.debugCount; - if (debugCount.comment.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.comment[0]); - return `Missing end of comment on line ${line} and column ${column}`; - } else if (debugCount.regExp.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.regExp[0]); - return `Missing end of regular expression on line ${line} and column ${column}`; - } else if (debugCount.regExpSquareBrackets.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.regExpSquareBrackets[0]); - return `Missing end of regular expression square brackets on line ${line} and column ${column}`; - } else if (debugCount.simpleString.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.simpleString[0]); - return `Missing end of single quote string on line ${line} and column ${column}`; - } else if (debugCount.doubleString.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.doubleString[0]); - return `Missing end of double quote string on line ${line} and column ${column}`; - } else if (debugCount.parentheses.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.parentheses[0]); - return `Missing end of parentheses on line ${line} and column ${column}`; - } else if (debugCount.curlyBraces.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.curlyBraces[0]); - return `Missing end of curly braces on line ${line} and column ${column}`; - } else if (debugCount.squareBrackets.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.squareBrackets[0]); - return `Missing end of square brackets on line ${line} and column ${column}`; - } else if (debugCount.escapeTemplateString.length > 0) { - const { line, column } = this.getLineAndColumn(code, debugCount.escapeTemplateString[0]); - return `Missing end of escaped template string on line ${line} and column ${column}`; - } - return null; - } - getLineAndColumn(code, index) { - const lines = code.substring(0, index).split(` -`); - const line = lines.length; - const column = lines[lines.length - 1].length; - return { line, column }; - } - getNonSpacePrecedingToken(code, index) { - index--; - let nonSpacePrecedingToken = code[index]; - while (nonSpacePrecedingToken === " " || nonSpacePrecedingToken === ` -` || nonSpacePrecedingToken === "\t") { - index--; - nonSpacePrecedingToken = code[index]; - } - return nonSpacePrecedingToken || ";"; - } - removeMultilineComments(code) { - const regexp = new RegExp(MULTILINE_COMMENT_REGEXP); - let match; - let count = 0; - let lastIndex = 0; - let newCode = ""; - while (match = regexp.exec(code)) { - if (count === 0) { - newCode += code.substring(lastIndex, match.index); - } - if (match[0] === "/*") { - count++; - } else if (match[0] === "*/" && count > 0) { - count--; - } - lastIndex = regexp.lastIndex; - } - newCode += code.substring(lastIndex); - return newCode; - } - reset() { - this.count = { - comment: 0, - singleLineComment: 0, - parentheses: 0, - curlyBraces: 0, - squareBrackets: 0, - regExp: 0, - regExpSquareBrackets: 0, - escapeTemplateString: 0, - simpleString: 0, - doubleString: 0 - }; - this.debugCount = { - comment: [], - singleLineComment: [], - parentheses: [], - curlyBraces: [], - squareBrackets: [], - regExp: [], - regExpSquareBrackets: [], - escapeTemplateString: [], - simpleString: [], - doubleString: [] - }; - this.templateString = []; - } -} - -// node_modules/happy-dom/lib/module/ECMAScriptModule.js -var EMPTY_COMPILED_RESULT = { imports: [], execute: async () => {} }; - -class ECMAScriptModule { - url; - [window]; - #source; - #sourceURL; - #preloaded = false; - #compiled = null; - #exports = null; - #evaluateQueue = null; - #factory; - constructor(init) { - this[window] = init.window; - this.url = init.url; - this.#source = init.source; - this.#sourceURL = init.sourceURL || null; - this.#factory = init.factory; - } - async evaluate(parentUrls = [], circularResolver = null) { - if (this.#evaluateQueue) { - if (parentUrls.includes(this.url.href)) { - if (circularResolver) { - this.#evaluateQueue.push(circularResolver); - } - return this.#exports; - } - return new Promise((resolve) => { - this.#evaluateQueue.push(resolve); - }); - } - if (this.#exports) { - return this.#exports; - } - const compiled = this.#compile(); - const modulePromises = []; - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return {}; - } - const exports = {}; - this.#exports = exports; - this.#evaluateQueue = []; - for (const moduleImport of compiled.imports) { - modulePromises.push(this.#factory.getModule(moduleImport.url, { - with: { type: moduleImport.type } - })); - } - const imports = new Map; - let circularImportResolver = null; - const circularImportResolverCallback = () => { - if (circularImportResolver) { - circularImportResolver(); - } - }; - if (modulePromises.length) { - const modules = await Promise.all(modulePromises); - const newParentUrls = [...parentUrls, this.url.href]; - for (const module of modules) { - if (module instanceof ECMAScriptModule) { - const exports = await module.evaluate(newParentUrls, circularImportResolverCallback); - imports.set(module.url.href, exports); - } else { - const exports = await module.evaluate(); - imports.set(module.url.href, exports); - } - } - } - const href = this.url.href; - compiled.execute({ - dispatchError: window2[dispatchError].bind(window2), - dynamicImport: this.#factory.importModule.bind(this.#factory), - importMeta: { - url: href, - resolve: (url) => new URL11(url, href).href - }, - imports, - exports, - addCircularImportResolver: (resolver) => circularImportResolver = resolver - }); - const evaluateQueue = this.#evaluateQueue; - this.#evaluateQueue = null; - for (const resolve of evaluateQueue) { - resolve(exports); - } - return exports; - } - async preload() { - if (this.#preloaded) { - return; - } - this.#preloaded = true; - const compiled = this.#compile(); - const modulePromises = []; - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return; - } - for (const moduleImport of compiled.imports) { - modulePromises.push(this.#factory.getModule(moduleImport.url, { - with: { type: moduleImport.type } - })); - } - const modules = await Promise.all(modulePromises); - const promises = []; - for (const module of modules) { - promises.push(module.preload()); - } - await Promise.all(promises); - } - #compile() { - if (this.#compiled) { - return this.#compiled; - } - this.#compiled = EMPTY_COMPILED_RESULT; - const compiler = new ECMAScriptModuleCompiler(this[window]); - this.#compiled = compiler.compile(this.url.href, this.#source, this.#sourceURL); - return this.#compiled; - } -} - -// node_modules/happy-dom/lib/module/ModuleFactory.js -class ModuleFactory { - window; - parentURL; - constructor(window, parentURL) { - this.window = window; - this.parentURL = parentURL; - } - async getModule(url, options) { - const window = this.window; - const parentURL = this.parentURL; - const absoluteURL = ModuleURLUtility.getURL(window, parentURL, url); - const absoluteURLString = absoluteURL.href; - const type = options?.with?.type || "esm"; - if (type !== "esm" && type !== "css" && type !== "json") { - throw new window.TypeError(`Failed to import module "${absoluteURL}" from "${parentURL}": Unknown type "${type}"`); - } - const cached = window[modules][type].get(absoluteURLString); - if (cached) { - if (cached instanceof UnresolvedModule) { - await new Promise((resolve, reject) => { - cached.addResolveListener(resolve, reject); - }); - return window[modules][type].get(absoluteURLString); - } - return cached; - } - const browserFrame = new WindowBrowserContext(window).getBrowserFrame(); - if (!browserFrame) { - throw new window.TypeError(`Failed to import module "${absoluteURL}" from "${parentURL}": Window is closed and is no longer attached to a frame`); - } - const unresolvedModule = new UnresolvedModule({ window, url: absoluteURL }); - const readyStateManager2 = window[readyStateManager]; - const taskID = readyStateManager2.startTask(); - window[modules][type].set(absoluteURLString, unresolvedModule); - const resourceFetch = new ResourceFetch(window); - let response; - try { - response = await resourceFetch.fetch(absoluteURL, "module"); - } catch (error) { - readyStateManager2.endTask(taskID); - unresolvedModule.resolve(error); - throw error; - } - readyStateManager2.endTask(taskID); - let module; - switch (type) { - case "json": - module = new JSONModule({ window, url: absoluteURL, source: response.content }); - break; - case "css": - module = new CSSModule({ window, url: absoluteURL, source: response.content }); - break; - case "esm": - module = new ECMAScriptModule({ - window, - url: absoluteURL, - source: response.content, - sourceURL: response.virtualServerFile || absoluteURLString, - factory: new ModuleFactory(window, absoluteURL) - }); - break; - } - window[modules][type].set(absoluteURLString, module); - unresolvedModule.resolve(); - return module; - } - async importModule(url, options) { - const browserFrame = new WindowBrowserContext(this.window).getBrowserFrame(); - if (!browserFrame) { - return {}; - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - const taskID = asyncTaskManager2?.startTask(); - const module = await this.getModule(url, options); - const exports = await module.evaluate(); - asyncTaskManager2.endTask(taskID); - return exports; - } -} - -// node_modules/happy-dom/lib/fetch/preload/PreloadEntry.js -class PreloadEntry { - integrityMetadata = null; - response = null; - error = null; - #callback = null; - onResponseAvailable() { - return new Promise((resolve, reject) => { - this.#callback = { resolve, reject }; - }); - } - responseAvailable(error, response) { - this.response = response; - this.error = error; - if (!this.#callback) { - return; - } - if (error) { - this.#callback.reject(error); - } else if (!response) { - this.#callback.reject(new Error("Response is null")); - } else { - this.#callback.resolve(response); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-link-element/HTMLLinkElement.js -class HTMLLinkElement extends HTMLElement { - [sheet] = null; - [disableEvaluation] = false; - [relList] = null; - #loadedStyleSheetURL = null; - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onload() { - return ElementEventAttributeUtility.getEventListener(this, "onload"); - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get sheet() { - return this[sheet]; - } - get relList() { - if (!this[relList]) { - this[relList] = new DOMTokenList(illegalConstructor, this, "rel", ["stylesheet", "modulepreload", "preload"]); - } - return this[relList]; - } - set relList(value) { - this.setAttribute("rel", value); - } - get as() { - return this.getAttribute("as") || ""; - } - set as(as) { - this.setAttribute("as", as); - } - get crossOrigin() { - return this.getAttribute("crossorigin") || ""; - } - set crossOrigin(crossOrigin) { - this.setAttribute("crossorigin", crossOrigin); - } - get href() { - if (!this.hasAttribute("href")) { - return ""; - } - try { - return new URL(this.getAttribute("href"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("href"); - } - } - set href(href) { - this.setAttribute("href", href); - } - get hreflang() { - return this.getAttribute("hreflang") || ""; - } - set hreflang(hreflang) { - this.setAttribute("hreflang", hreflang); - } - get media() { - return this.getAttribute("media") || ""; - } - set media(media) { - this.setAttribute("media", media); - } - get referrerPolicy() { - return this.getAttribute("referrerPolicy") || ""; - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerPolicy", referrerPolicy); - } - get rel() { - return this.getAttribute("rel") || ""; - } - set rel(rel) { - this.setAttribute("rel", rel); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } - [connectedToDocument]() { - super[connectedToDocument](); - const rel = this.getAttribute("rel"); - const href = this.getAttribute("href"); - if (rel && href) { - switch (rel) { - case "stylesheet": - this.#loadStyleSheet(href); - break; - case "modulepreload": - this.#preloadModule(href); - break; - case "preload": - this.#preloadResource(href); - break; - } - } - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "rel" || attribute[name] === "href") { - const rel = this.getAttribute("rel"); - const href = this.getAttribute("href"); - if (rel && href) { - switch (rel) { - case "stylesheet": - this.#loadStyleSheet(href); - break; - case "modulepreload": - this.#preloadModule(href); - break; - case "preload": - this.#preloadResource(href); - break; - } - } - } - } - async#preloadModule(url) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - const browserSettings = new WindowBrowserContext(window2).getSettings(); - if (!browserFrame || !browserSettings || !this[isConnected] || browserSettings.disableJavaScriptFileLoading || !browserSettings.enableJavaScriptEvaluation) { - return; - } - const moduleFactory = new ModuleFactory(window2, window2.location); - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - const module = await moduleFactory.getModule(url); - await module.preload(); - } else { - try { - const module = await moduleFactory.getModule(url); - await module.preload(); - } catch (error) { - browserFrame.page.console.error(error); - window2[dispatchError](error); - return; - } - } - } - async#preloadResource(url) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - const as = this.as; - if (!browserFrame || !this[isConnected] || as !== "script" && as !== "style" && as !== "fetch") { - return; - } - const browserSettings = browserFrame.page.context.browser.settings; - if (as === "script" && (browserSettings.disableJavaScriptFileLoading || !browserSettings.enableJavaScriptEvaluation)) { - return; - } - if (as === "style" && browserSettings.disableCSSFileLoading) { - return; - } - const absoluteURL = new URL(url, window2.location.href).href; - const preloadKey = PreloadUtility.getKey({ - url: absoluteURL, - destination: as, - mode: "cors", - credentialsMode: this.crossOrigin === "use-credentials" ? "include" : "same-origin" - }); - if (window2.document[preloads].has(preloadKey)) { - return; - } - const preloadEntry = new PreloadEntry; - window2.document[preloads].set(preloadKey, preloadEntry); - const fetch2 = new Fetch({ - browserFrame, - window: window2, - url: absoluteURL, - disableSameOriginPolicy: as === "script" || as === "style", - disablePreload: true, - init: { - credentials: this.crossOrigin === "use-credentials" ? "include" : "same-origin" - } - }); - try { - const response = await fetch2.send(); - if (!response[buffer]) { - await response.buffer(); - } - preloadEntry.responseAvailable(null, response); - } catch (error) { - preloadEntry.responseAvailable(error, null); - window2.document[preloads].delete(preloadKey); - browserFrame.page.console.error(`Failed to preload resource "${absoluteURL}": ${error.message}`); - } - } - async#loadStyleSheet(url) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame || url === null) { - return; - } - const browserSettings = browserFrame.page.context.browser.settings; - if (this[disableEvaluation] || !this[isConnected]) { - return; - } - let absoluteURL; - try { - absoluteURL = new URL(url, window2.location.href).href; - } catch (error) { - return; - } - if (this.#loadedStyleSheetURL === absoluteURL) { - return; - } - if (browserSettings && browserSettings.disableCSSFileLoading) { - if (browserSettings.handleDisabledFileLoadingAsSuccess) { - this.dispatchEvent(new Event("load")); - } else { - const error = new window2.DOMException(`Failed to load external stylesheet "${absoluteURL}". CSS file loading is disabled.`, DOMExceptionNameEnum_default.notSupportedError); - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - } - return; - } - const resourceFetch = new ResourceFetch(window2); - const readyStateManager2 = window2[readyStateManager]; - this.#loadedStyleSheetURL = absoluteURL; - const taskID = readyStateManager2.startTask(); - let response = null; - let error = null; - try { - response = await resourceFetch.fetch(absoluteURL, "style", { - credentials: this.crossOrigin === "use-credentials" ? "include" : "same-origin" - }); - } catch (e) { - error = e; - } - readyStateManager2.endTask(taskID); - if (error) { - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - } else { - const styleSheet = new this[ownerDocument][window].CSSStyleSheet; - styleSheet.replaceSync(response.content); - this[sheet] = styleSheet; - const document = this[ownerDocument]; - if (document) { - for (const item of document[affectsComputedStyleCache]) { - item.result = null; - } - document[affectsComputedStyleCache] = []; - } - this.dispatchEvent(new Event("load")); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-map-element/HTMLMapElement.js -class HTMLMapElement extends HTMLElement { - [areas] = null; - get areas() { - if (!this[areas]) { - this[areas] = ParentNodeUtility.getElementsByTagName(this, "area"); - } - return this[areas]; - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TextTrackCueList.js -class TextTrackCueList extends Array { - constructor(illegalConstructorSymbol) { - super(); - if (illegalConstructorSymbol !== 1 && illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - } - getCueById(id) { - for (const cue of this) { - if (cue.id === id) { - return cue; - } - } - return null; - } -} - -// node_modules/happy-dom/lib/nodes/html-menu-element/HTMLMenuElement.js -class HTMLMenuElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-meta-element/HTMLMetaElement.js -class HTMLMetaElement extends HTMLElement { - get content() { - return this.getAttribute("content") || ""; - } - set content(content) { - this.setAttribute("content", content); - } - get httpEquiv() { - return this.getAttribute("http-equiv") || ""; - } - set httpEquiv(httpEquiv) { - this.setAttribute("http-equiv", httpEquiv); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get scheme() { - return this.getAttribute("scheme") || ""; - } - set scheme(scheme) { - this.setAttribute("scheme", scheme); - } -} - -// node_modules/happy-dom/lib/nodes/html-meter-element/HTMLMeterElement.js -class HTMLMeterElement extends HTMLElement { - get high() { - if (!this.hasAttribute("high")) { - return 1; - } - const parsedValue = parseFloat(this.getAttribute("high") || ""); - if (isNaN(parsedValue) || parsedValue > 1) { - return 1; - } - return parsedValue < 0 ? 0 : parsedValue; - } - set high(high) { - high = typeof high !== "number" ? Number(high) : high; - if (isNaN(high)) { - throw new this[window].TypeError("Failed to set the 'high' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("high", String(high)); - } - get low() { - if (!this.hasAttribute("low")) { - return 0; - } - const parsedValue = parseFloat(this.getAttribute("low") || ""); - if (isNaN(parsedValue) || parsedValue < 0) { - return 0; - } - return parsedValue > 1 ? 1 : parsedValue; - } - set low(low) { - low = typeof low !== "number" ? Number(low) : low; - if (isNaN(low)) { - throw new this[window].TypeError("Failed to set the 'low' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("low", String(low)); - } - get max() { - if (!this.hasAttribute("max")) { - return 1; - } - const parsedValue = parseFloat(this.getAttribute("max") || ""); - if (isNaN(parsedValue) || parsedValue > 1) { - return 1; - } - return parsedValue < 0 ? 0 : parsedValue; - } - set max(max) { - max = typeof max !== "number" ? Number(max) : max; - if (isNaN(max)) { - throw new this[window].TypeError("Failed to set the 'max' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("max", String(max)); - } - get min() { - if (!this.hasAttribute("min")) { - return 0; - } - const parsedValue = parseFloat(this.getAttribute("min") || ""); - if (isNaN(parsedValue) || parsedValue < 0) { - return 0; - } - return parsedValue > 1 ? 1 : parsedValue; - } - set min(min) { - min = typeof min !== "number" ? Number(min) : min; - if (isNaN(min)) { - throw new this[window].TypeError("Failed to set the 'min' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("min", String(min)); - } - get optimum() { - if (!this.hasAttribute("optimum")) { - return 0.5; - } - const parsedValue = parseFloat(this.getAttribute("optimum") || ""); - if (isNaN(parsedValue)) { - return 0.5; - } - if (parsedValue < 0) { - return 0; - } - return parsedValue > 1 ? 1 : parsedValue; - } - set optimum(optimum) { - optimum = typeof optimum !== "number" ? Number(optimum) : optimum; - if (isNaN(optimum)) { - throw new this[window].TypeError("Failed to set the 'optimum' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("optimum", String(optimum)); - } - get value() { - if (!this.hasAttribute("value")) { - return 0; - } - const parsedValue = parseFloat(this.getAttribute("value") || ""); - if (isNaN(parsedValue) || parsedValue < 0) { - return 0; - } - return parsedValue > 1 ? 1 : parsedValue; - } - set value(value) { - value = typeof value !== "number" ? Number(value) : value; - if (isNaN(value)) { - throw new this[window].TypeError("Failed to set the 'value' property on 'HTMLMeterElement': The provided double value is non-finite."); - } - this.setAttribute("value", String(value)); - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } -} - -// node_modules/happy-dom/lib/nodes/html-mod-element/HTMLModElement.js -class HTMLModElement extends HTMLElement { - get cite() { - if (!this.hasAttribute("cite")) { - return ""; - } - try { - return new URL(this.getAttribute("cite"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("cite"); - } - } - set cite(cite) { - this.setAttribute("cite", cite); - } - get dateTime() { - return this.getAttribute("datetime") || ""; - } - set dateTime(dateTime) { - this.setAttribute("datetime", dateTime); - } -} - -// node_modules/happy-dom/lib/nodes/html-o-list-element/HTMLOListElement.js -class HTMLOListElement extends HTMLElement { - get reversed() { - return this.getAttribute("reversed") !== null; - } - set reversed(reversed) { - if (!reversed) { - this.removeAttribute("reversed"); - } else { - this.setAttribute("reversed", ""); - } - } - get start() { - if (!this.hasAttribute("start")) { - return 1; - } - const parsedValue = Number(this.getAttribute("start") || ""); - if (isNaN(parsedValue)) { - return 1; - } - return parsedValue; - } - set start(start) { - if (typeof start !== "number") { - start = Number(start); - } - if (isNaN(start)) { - start = 0; - } - this.setAttribute("start", String(start)); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } -} - -// node_modules/happy-dom/lib/nodes/html-object-element/HTMLObjectElement.js -class HTMLObjectElement extends HTMLElement { - [formNode] = null; - [validationMessage] = ""; - [validity] = new ValidityState(this); - get contentDocument() { - return null; - } - get contentWindow() { - return null; - } - get data() { - if (!this.hasAttribute("data")) { - return ""; - } - try { - return new URL(this.getAttribute("data"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("data"); - } - } - set data(data) { - this.setAttribute("data", data); - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get height() { - return this.getAttribute("height") || ""; - } - set height(height) { - this.setAttribute("height", height); - } - get width() { - return this.getAttribute("width") || ""; - } - set width(width) { - this.setAttribute("width", width); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get willValidate() { - return false; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - checkValidity() { - return true; - } - reportValidity() { - return this.checkValidity(); - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } -} - -// node_modules/happy-dom/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js -class HTMLOptGroupElement extends HTMLElement { - get label() { - return this.getAttribute("label") || ""; - } - set label(label) { - if (!label) { - this.removeAttribute("label"); - } else { - this.setAttribute("label", label); - } - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-option-element/HTMLOptionElement.js -class HTMLOptionElement extends HTMLElement { - [selectedness] = false; - [dirtyness] = false; - [selectNode] = null; - get text() { - return this.innerText; - } - set text(text) { - this.innerText = text; - } - get index() { - if (!this[selectNode]) { - return 0; - } - const options = QuerySelector.querySelectorAll(this[selectNode], "option")[items]; - return options.indexOf(this); - } - get form() { - return this[selectNode]?.form || null; - } - get selected() { - return this[selectedness]; - } - set selected(selected) { - const selectNode2 = this[selectNode]; - this[dirtyness] = true; - this[selectedness] = Boolean(selected); - if (selectNode2) { - selectNode2[updateSelectedness](this[selectedness] ? this : null); - } - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - get value() { - return this.getAttribute("value") ?? this.textContent; - } - set value(value) { - this.setAttribute("value", value); - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (!this[dirtyness] && attribute[name] === "selected" && replacedAttribute?.[value] !== attribute[value]) { - const selectNode2 = this[selectNode]; - this[selectedness] = true; - if (selectNode2) { - selectNode2[updateSelectedness](this); - } - } - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - if (removedAttribute && !this[dirtyness] && removedAttribute[name] === "selected") { - const selectNode2 = this[selectNode]; - this[selectedness] = false; - if (selectNode2) { - selectNode2[updateSelectedness](); - } - } - } - [connectedToNode]() { - super[connectedToNode](); - if (this[selectNode]) { - this[selectNode][updateSelectedness](); - } - } - [disconnectedFromNode]() { - if (this[selectNode]) { - this[selectNode][updateSelectedness](); - } - super[disconnectedFromNode](); - } -} - -// node_modules/happy-dom/lib/nodes/html-output-element/HTMLOutputElement.js -class HTMLOutputElement extends HTMLElement { - [formNode] = null; - [validationMessage] = ""; - [validity] = new ValidityState(this); - [defaultValue] = ""; - get defaultValue() { - return this[defaultValue]; - } - set defaultValue(defaultValue2) { - this[defaultValue] = defaultValue2; - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get htmlFor() { - return this.getAttribute("for") || ""; - } - set htmlFor(htmlFor) { - this.setAttribute("for", htmlFor); - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get value() { - return this.textContent || ""; - } - set value(value) { - this.textContent = value; - } - get type() { - return "output"; - } - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get willValidate() { - return false; - } - checkValidity() { - return true; - } - reportValidity() { - return this.checkValidity(); - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } -} - -// node_modules/happy-dom/lib/nodes/html-paragraph-element/HTMLParagraphElement.js -class HTMLParagraphElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-param-element/HTMLParamElement.js -class HTMLParamElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-picture-element/HTMLPictureElement.js -class HTMLPictureElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-pre-element/HTMLPreElement.js -class HTMLPreElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-progress-element/HTMLProgressElement.js -class HTMLProgressElement extends HTMLElement { - get max() { - if (!this.hasAttribute("max")) { - return 1; - } - const parsedValue = parseFloat(this.getAttribute("max") || ""); - if (isNaN(parsedValue) || parsedValue < 0) { - return 1; - } - return parsedValue; - } - set max(max) { - max = typeof max !== "number" ? Number(max) : max; - if (isNaN(max)) { - throw new this[window].TypeError("Failed to set the 'max' property on 'HTMLProgressElement': The provided double value is non-finite."); - } - this.setAttribute("max", max < 0 ? "1" : String(max)); - } - get value() { - if (!this.hasAttribute("value")) { - return 0; - } - const parsedValue = parseFloat(this.getAttribute("value") || ""); - if (isNaN(parsedValue) || parsedValue < 0) { - return 0; - } - return parsedValue; - } - set value(value) { - value = typeof value !== "number" ? Number(value) : value; - if (isNaN(value)) { - throw new this[window].TypeError("Failed to set the 'value' property on 'HTMLProgressElement': The provided double value is non-finite."); - } - this.setAttribute("value", value < 0 ? "0" : String(value)); - } - get position() { - if (!this.hasAttribute("value")) { - return -1; - } - return this.value / this.max; - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } -} - -// node_modules/happy-dom/lib/nodes/html-quote-element/HTMLQuoteElement.js -class HTMLQuoteElement extends HTMLElement { - get cite() { - if (!this.hasAttribute("cite")) { - return ""; - } - try { - return new URL(this.getAttribute("cite"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("cite"); - } - } - set cite(cite) { - this.setAttribute("cite", cite); - } -} - -// node_modules/happy-dom/lib/javascript/JavaScriptCompiler.js -var STATEMENT_REGEXP2 = /import\s*\(([^)]+)\)/gm; -var SYNTAX_REGEXP2 = /(\/)|(\(|\))|({|})|(\[|\])|(\${)|(`)|(')|(")|(\n)/gm; -var PRECEDING_STATEMENT_TOKEN_REGEXP2 = /['"`(){}\s;=><\[\]+-,:&]/; -var PRECEDING_REGEXP_TOKEN_REGEXP2 = /['"`({};=><\[+-,:&]/; - -class JavaScriptCompiler { - window; - count = { - comment: 0, - singleLineComment: 0, - parentheses: 0, - curlyBraces: 0, - squareBrackets: 0, - regExp: 0, - regExpSquareBrackets: 0, - escapeTemplateString: 0, - simpleString: 0, - doubleString: 0 - }; - templateString = []; - constructor(window) { - this.window = window; - } - compile(sourceURL, code) { - const browserSettings = new WindowBrowserContext(this.window).getSettings(); - if (!browserSettings) { - return { execute: () => {} }; - } - const regExp = new RegExp(STATEMENT_REGEXP2); - const count = this.count; - let newCode = "(function anonymous($happy_dom) {"; - let match = null; - let precedingToken; - let textBetweenStatements; - let lastIndex = 0; - const importStartIndex = -1; - if (!browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCode += "try {"; - } - while (match = regExp.exec(code)) { - precedingToken = code[match.index - 1] || " "; - textBetweenStatements = code.substring(lastIndex, match.index); - this.parseSyntax(textBetweenStatements, lastIndex); - if (importStartIndex === -1) { - newCode += textBetweenStatements; - } - if (match[1] && count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && (this.templateString.length === 0 || this.templateString[0] > 0) && PRECEDING_STATEMENT_TOKEN_REGEXP2.test(precedingToken)) { - newCode += `$happy_dom.dynamicImport(${match[1]})`; - } else { - newCode += match[0]; - this.parseSyntax(match[0], match.index); - } - lastIndex = regExp.lastIndex; - } - if (lastIndex === 0) { - newCode += code; - } else { - newCode += code.substring(lastIndex); - } - if (!browserSettings.disableErrorCapturing && browserSettings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch) { - newCode += "} catch (error) { $happy_dom.dispatchError(error); }"; - } - newCode += "})"; - try { - return { - execute: this.window[evaluateScript](newCode, { - filename: sourceURL - }) - }; - } catch (error) { - error.message = `Failed to parse JavaScript in '${sourceURL}': ${error.message}`; - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - throw error; - } else { - this.window[dispatchError](error); - return { - execute: () => {} - }; - } - } - } - parseSyntax(code, index) { - const regExp = new RegExp(SYNTAX_REGEXP2); - const count = this.count; - let match = null; - let precedingToken; - let isEscaped; - index++; - while (match = regExp.exec(code)) { - precedingToken = code[match.index - 1] || " "; - isEscaped = precedingToken === "\\" && code[match.index - 2] !== "\\"; - if (match[1]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.singleLineComment === 0 && count.regExpSquareBrackets === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.comment === 1) { - if (precedingToken === "*") { - count.comment = 0; - } - } else { - if (count.regExp === 0) { - if (code[match.index + 1] === "*") { - count.comment = 1; - } else if (code[match.index + 1] === "/") { - count.singleLineComment = 1; - } else { - if (PRECEDING_REGEXP_TOKEN_REGEXP2.test(this.getNonSpacePrecedingToken(code, match.index))) { - count.regExp = 1; - } - } - } else if (!isEscaped) { - count.regExp = 0; - } - } - } - } else if (match[2]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.regExp === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (match[2] === "(") { - count.parentheses++; - } else if (match[2] === ")" && count.parentheses > 0) { - count.parentheses--; - } - } - } else if (match[3]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.regExp === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (match[3] === "{") { - if (this.templateString.length) { - this.templateString[0]++; - } - count.curlyBraces++; - } else if (match[3] === "}") { - if (this.templateString.length && this.templateString[0] > 0) { - this.templateString[0]--; - } - if (count.curlyBraces > 0) { - count.curlyBraces--; - } - } - } - } else if (match[4]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.regExp === 1) { - if (!isEscaped) { - if (match[4] === "[" && count.regExpSquareBrackets === 0) { - count.regExpSquareBrackets = 1; - } else if (match[4] === "]" && count.regExpSquareBrackets === 1) { - count.regExpSquareBrackets = 0; - } - } - } else { - if (match[4] === "[") { - count.squareBrackets++; - } else if (match[4] === "]" && count.squareBrackets > 0) { - count.squareBrackets--; - } - } - } - } else if (match[5]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped) { - if (this.templateString[0] === 0) { - this.templateString[0] = 1; - count.curlyBraces++; - } - } - } else if (match[6]) { - if (count.simpleString === 0 && count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped) { - if (this.templateString?.[0] === 0) { - this.templateString.shift(); - } else { - this.templateString.unshift(0); - } - } - } else if (match[7]) { - if (count.doubleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.simpleString === 0) { - count.simpleString = 1; - } else { - count.simpleString = 0; - } - } - } else if (match[8]) { - if (count.simpleString === 0 && count.comment === 0 && count.singleLineComment === 0 && count.regExp === 0 && !isEscaped && (this.templateString.length === 0 || this.templateString[0] > 0)) { - if (count.doubleString === 0) { - count.doubleString = 1; - } else { - count.doubleString = 0; - } - } - } else if (match[9]) { - count.singleLineComment = 0; - } - } - } - getNonSpacePrecedingToken(code, index) { - index--; - let nonSpacePrecedingToken = code[index]; - while (nonSpacePrecedingToken === " " || nonSpacePrecedingToken === ` -` || nonSpacePrecedingToken === "\t") { - index--; - nonSpacePrecedingToken = code[index]; - } - return nonSpacePrecedingToken || ";"; - } -} - -// node_modules/happy-dom/lib/nodes/html-script-element/HTMLScriptElement.js -class HTMLScriptElement extends HTMLElement { - [disableEvaluation] = false; - [blocking] = null; - #loadedScriptURL = null; - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onload() { - return ElementEventAttributeUtility.getEventListener(this, "onload"); - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } - get blocking() { - if (!this[blocking]) { - this[blocking] = new DOMTokenList(illegalConstructor, this, "blocking"); - } - return this[blocking]; - } - set blocking(value) { - this.setAttribute("blocking", value); - } - get crossOrigin() { - return this.getAttribute("crossorigin") || ""; - } - set crossOrigin(crossOrigin) { - this.setAttribute("crossorigin", crossOrigin); - } - get fetchPriority() { - const fetchPriority = this.getAttribute("fetchpriority"); - switch (fetchPriority) { - case "high": - case "low": - case "normal": - return fetchPriority; - default: - return "auto"; - } - } - set fetchPriority(fetchPriority) { - this.setAttribute("fetchpriority", fetchPriority); - } - get noModule() { - return this.getAttribute("nomodule") !== null; - } - set noModule(noModule) { - if (noModule) { - this.setAttribute("nomodule", ""); - } else { - this.removeAttribute("nomodule"); - } - } - get integrity() { - return this.getAttribute("integrity") || ""; - } - set integrity(integrity) { - this.setAttribute("integrity", integrity); - } - get referrerPolicy() { - const referrerPolicy = this.getAttribute("referrerpolicy"); - switch (referrerPolicy) { - case "no-referrer": - case "no-referrer-when-downgrade": - case "same-origin": - case "origin": - case "strict-origin": - case "origin-when-cross-origin": - case "strict-origin-when-cross-origin": - case "unsafe-url": - return referrerPolicy; - default: - return ""; - } - } - set referrerPolicy(referrerPolicy) { - this.setAttribute("referrerpolicy", referrerPolicy); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src"); - } - } - set src(src) { - this.setAttribute("src", src); - } - get charset() { - return this.getAttribute("charset") || ""; - } - set charset(charset) { - this.setAttribute("charset", charset); - } - get lang() { - return this.getAttribute("lang") || ""; - } - set lang(lang) { - this.setAttribute("lang", lang); - } - get async() { - return this.getAttribute("async") !== null; - } - set async(async) { - if (!async) { - this.removeAttribute("async"); - } else { - this.setAttribute("async", ""); - } - } - get defer() { - return this.getAttribute("defer") !== null; - } - set defer(defer) { - if (!defer) { - this.removeAttribute("defer"); - } else { - this.setAttribute("defer", ""); - } - } - get text() { - return this.textContent; - } - set text(text) { - this.textContent = text; - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - [connectedToDocument]() { - const browserSettings = new WindowBrowserContext(this[window]).getSettings(); - super[connectedToDocument](); - if (this[disableEvaluation]) { - return; - } - const src = this.getAttribute("src"); - if (src !== null) { - if (this.getAttribute("type") === "module") { - this.#loadModule(src); - } else { - this.#loadScript(src); - } - } else if (browserSettings && browserSettings.enableJavaScriptEvaluation) { - const source = this.textContent; - const type = this.getAttribute("type"); - if (source) { - if (type === "module") { - this.#evaluateModule(source); - } else if (type === "importmap") { - this.#evaluateImportMap(source); - } else if (type === null || type === "application/x-ecmascript" || type === "application/x-javascript" || type.startsWith("text/javascript")) { - this.#evaluateScript(source); - } - } - } - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "src" && attribute[value] !== null && this[isConnected]) { - if (this.getAttribute("type") === "module") { - this.#loadModule(attribute[value]); - } else { - this.#loadScript(attribute[value]); - } - } - } - #evaluateModule(source) { - const url = this[ownerDocument].location; - const window2 = this[window]; - const browserSettings = new WindowBrowserContext(window2).getSettings(); - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame || !browserSettings || !browserSettings.enableJavaScriptEvaluation) { - return; - } - this[ownerDocument][currentScript] = this; - const factory = new ModuleFactory(window2, url); - const module = new ECMAScriptModule({ window: window2, url, source, factory }); - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - module.evaluate(); - } else { - module.evaluate().catch((error) => { - window2[dispatchError](error); - }); - } - this[ownerDocument][currentScript] = null; - this.dispatchEvent(new Event("load")); - } - async#evaluateImportMap(source) { - const window2 = this[window]; - const browserSettings = new WindowBrowserContext(window2).getSettings(); - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame || !browserSettings || window2[moduleImportMap] || !browserSettings.enableJavaScriptEvaluation) { - return; - } - let json; - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - json = JSON.parse(source); - } else { - try { - json = JSON.parse(source); - } catch (error) { - window2[dispatchError](error); - return; - } - } - if (json.imports || json.scopes) { - const importMap = { - imports: [], - scopes: [] - }; - if (json.imports) { - for (const key of Object.keys(json.imports)) { - importMap.imports.push({ - from: key, - to: json.imports[key] - }); - } - } - if (json.scopes) { - for (const scopeKey of Object.keys(json.scopes)) { - const scope = { - scope: scopeKey, - rules: [] - }; - for (const importKey of Object.keys(json.scopes[scopeKey])) { - const value = json.scopes[scopeKey][importKey]; - scope.rules.push({ - from: importKey, - to: value - }); - } - importMap.scopes.push(scope); - } - } - window2[moduleImportMap] = importMap; - } - } - #evaluateScript(code) { - const window2 = this[window]; - const browserSettings = new WindowBrowserContext(window2).getSettings(); - if (!browserSettings) { - return; - } - this[ownerDocument][currentScript] = this; - const compiler = new JavaScriptCompiler(window2); - const compiled = compiler.compile(window2.location.href, code); - const moduleFactory = new ModuleFactory(window2, window2.location); - compiled.execute({ - dynamicImport: moduleFactory.importModule.bind(moduleFactory), - dispatchError: window2[dispatchError].bind(window2) - }); - this[ownerDocument][currentScript] = null; - } - async#loadModule(url) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - const browserSettings = new WindowBrowserContext(window2).getSettings(); - if (!browserFrame || !browserSettings) { - return; - } - if (!url || !this[isConnected] || this.getAttribute("type") !== "module") { - return; - } - if (browserSettings && (browserSettings.disableJavaScriptFileLoading || !browserSettings.enableJavaScriptEvaluation)) { - if (browserSettings.handleDisabledFileLoadingAsSuccess) { - this.dispatchEvent(new Event("load")); - } else { - const error = new window2.DOMException(`Failed to load module "${url}". JavaScript file loading is disabled.`, DOMExceptionNameEnum_default.notSupportedError); - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - } - return; - } - const moduleFactory = new ModuleFactory(window2, window2.location); - if (browserSettings.disableErrorCapturing || browserSettings.errorCapture !== BrowserErrorCaptureEnum_default.tryAndCatch) { - const module = await moduleFactory.getModule(url); - await module.evaluate(); - } else { - try { - const module = await moduleFactory.getModule(url); - await module.evaluate(); - } catch (error) { - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - return; - } - } - this.dispatchEvent(new Event("load")); - } - async#loadScript(url) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return; - } - const browserSettings = browserFrame.page.context.browser.settings; - const type = this.getAttribute("type"); - if (!url || !this[isConnected] || type !== null && type !== "application/x-ecmascript" && type !== "application/x-javascript" && !type.startsWith("text/javascript")) { - return; - } - let absoluteURL; - try { - absoluteURL = new URL(url, window2.location.href); - } catch (error) { - return; - } - const absoluteURLString = absoluteURL.toString(); - if (this.#loadedScriptURL === absoluteURLString) { - return; - } - if (browserSettings && (browserSettings.disableJavaScriptFileLoading || !browserSettings.enableJavaScriptEvaluation)) { - if (browserSettings.handleDisabledFileLoadingAsSuccess) { - this.dispatchEvent(new Event("load")); - } else { - const error = new window2.DOMException(`Failed to load script "${absoluteURL}". JavaScript file loading is disabled.`, DOMExceptionNameEnum_default.notSupportedError); - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - } - return; - } - this.#loadedScriptURL = absoluteURLString; - const resourceFetch = new ResourceFetch(window2); - const async = this.getAttribute("async") !== null || this.getAttribute("defer") !== null; - let response = null; - if (async) { - const readyStateManager2 = window2[readyStateManager]; - const taskID = readyStateManager2.startTask(); - try { - response = await resourceFetch.fetch(absoluteURLString, "script", { - credentials: this.crossOrigin === "use-credentials" ? "include" : "same-origin", - referrerPolicy: this.referrerPolicy - }); - } catch (error) { - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - readyStateManager2.endTask(taskID); - return; - } - readyStateManager2.endTask(taskID); - } else { - try { - response = resourceFetch.fetchSync(absoluteURLString, "script", { - credentials: this.crossOrigin === "use-credentials" ? "include" : "same-origin", - referrerPolicy: this.referrerPolicy - }); - } catch (error) { - browserFrame.page.console.error(error); - this.dispatchEvent(new Event("error")); - return; - } - } - this[ownerDocument][currentScript] = this; - const compiler = new JavaScriptCompiler(window2); - const compiled = compiler.compile(response.virtualServerFile || absoluteURLString, response.content); - const moduleFactory = new ModuleFactory(window2, window2.location); - compiled.execute({ - dynamicImport: moduleFactory.importModule.bind(moduleFactory), - dispatchError: window2[dispatchError].bind(window2) - }); - this[ownerDocument][currentScript] = null; - this.dispatchEvent(new Event("load")); - } - static supports(type) { - switch (type) { - case "classic": - case "module": - case "importmap": - return true; - case "speculationrules": - default: - return false; - } - } -} - -// node_modules/happy-dom/lib/nodes/html-select-element/HTMLOptionsCollection.js -class HTMLOptionsCollection extends HTMLCollection { - constructor(illegalConstructorSymbol, ownerElement2) { - super(illegalConstructorSymbol, () => QuerySelector.querySelectorAll(ownerElement2, "option")[items]); - this[ownerElement] = ownerElement2; - } - get selectedIndex() { - return this[ownerElement].selectedIndex; - } - set selectedIndex(selectedIndex) { - this[ownerElement].selectedIndex = selectedIndex; - } - add(element, before) { - this[ownerElement].add(element, before); - } - remove(index) { - this[ownerElement].remove(index); - } -} - -// node_modules/happy-dom/lib/nodes/html-select-element/HTMLSelectElement.js -class HTMLSelectElement extends HTMLElement { - [validationMessage] = ""; - [validity] = new ValidityState(this); - [options] = null; - [selectedOptions] = null; - [selectedIndex] = -1; - [proxy]; - constructor() { - super(); - const methodBinder = new ClassMethodBinder(this, [ - HTMLSelectElement, - HTMLElement, - Element, - Node, - EventTarget - ]); - const proxy2 = new Proxy(this, { - get: (target, property) => { - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return QuerySelector.querySelectorAll(target, "option")[items][index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - return true; - } - if (!newValue || !(newValue instanceof HTMLOptionElement)) { - throw new target[window].Error(`TypeError: Failed to set an indexed property [${index}] on 'HTMLSelectElement': parameter 2 is not of type 'HTMLOptionElement'.`); - } - const options2 = QuerySelector.querySelectorAll(target, "option")[items]; - const childNodes = target[nodeArray]; - while (childNodes.length) { - target[removeChild](childNodes[0]); - } - for (let i = 0;i <= index; i++) { - if (i === index) { - target[appendChild](newValue); - } else if (options2[i]) { - target[appendChild](options2[i]); - } else { - target[appendChild](target[ownerDocument].createElement("option")); - } - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(QuerySelector.querySelectorAll(target, "option")[items]); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - if (!isNaN(index)) { - return !!QuerySelector.querySelectorAll(target, "option")[items][index]; - } - return false; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - const index = Number(property); - if (isNaN(index)) { - Object.defineProperty(target, property, descriptor); - return true; - } - if (!descriptor.value || !(descriptor.value instanceof HTMLOptionElement)) { - throw new target[window].Error(`TypeError: Failed to set an indexed property [${index}] on 'HTMLSelectElement': parameter 2 is not of type 'HTMLOptionElement'.`); - } - const options2 = QuerySelector.querySelectorAll(target, "option")[items]; - const childNodes = target[nodeArray]; - while (childNodes.length) { - target[removeChild](childNodes[0]); - } - for (let i = 0;i <= index; i++) { - if (i === index) { - target[appendChild](descriptor.value); - } else if (options2[i]) { - target[appendChild](options2[i]); - } else { - target[appendChild](target[ownerDocument].createElement("option")); - } - } - return true; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target) { - return Object.getOwnPropertyDescriptor(target, property); - } - const index = Number(property); - if (isNaN(index)) { - return; - } - const options2 = QuerySelector.querySelectorAll(target, "option")[items]; - if (!options2[index]) { - return; - } - return { - value: options2[index], - writable: true, - enumerable: true, - configurable: true - }; - } - }); - this[proxy] = proxy2; - this[selectNode] = proxy2; - return proxy2; - } - get onchange() { - return ElementEventAttributeUtility.getEventListener(this, "onchange"); - } - set onchange(value) { - this[propertyEventListeners].set("onchange", value); - } - get oninput() { - return ElementEventAttributeUtility.getEventListener(this, "oninput"); - } - set oninput(value) { - this[propertyEventListeners].set("oninput", value); - } - get length() { - return QuerySelector.querySelectorAll(this, "option")[items].length; - } - get options() { - if (!this[options]) { - this[options] = new HTMLOptionsCollection(illegalConstructor, this); - } - return this[options]; - } - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - get multiple() { - return this.getAttribute("multiple") !== null; - } - set multiple(multiple) { - if (!multiple) { - this.removeAttribute("multiple"); - } else { - this.setAttribute("multiple", ""); - } - } - get autofocus() { - return this.getAttribute("autofocus") !== null; - } - set autofocus(autofocus) { - if (!autofocus) { - this.removeAttribute("autofocus"); - } else { - this.setAttribute("autofocus", ""); - } - } - get required() { - return this.getAttribute("required") !== null; - } - set required(required) { - if (!required) { - this.removeAttribute("required"); - } else { - this.setAttribute("required", ""); - } - } - get type() { - return this.hasAttributeNS(null, "multiple") ? "select-multiple" : "select-one"; - } - get value() { - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - for (let i = 0, max = options2.length;i < max; i++) { - const option = options2[i]; - if (option[selectedness]) { - return option.value; - } - } - return ""; - } - set value(value) { - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - this[selectedIndex] = -1; - for (let i = 0, max = options2.length;i < max; i++) { - const option = options2[i]; - if (option.value === value) { - option[selectedness] = true; - option[dirtyness] = true; - this[selectedIndex] = i; - } else { - option[selectedness] = false; - } - } - } - get selectedIndex() { - return this[selectedIndex]; - } - set selectedIndex(selectedIndex2) { - selectedIndex2 = Number(selectedIndex2); - if (isNaN(selectedIndex2)) { - return; - } - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - this[selectedIndex] = -1; - if (typeof selectedIndex2 === "number" && !isNaN(selectedIndex2)) { - for (let i = 0, max = options2.length;i < max; i++) { - options2[i][selectedness] = false; - } - const selectedOption = options2[selectedIndex2]; - if (selectedOption) { - selectedOption[selectedness] = true; - selectedOption[dirtyness] = true; - this[selectedIndex] = selectedIndex2; - } - } - } - get selectedOptions() { - if (!this[selectedOptions]) { - this[selectedOptions] = new HTMLCollection(illegalConstructor, () => { - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - if (options2[selectedOptions]) { - return options2[selectedOptions]; - } - const selectedOptions2 = []; - for (let i = 0, max = options2.length;i < max; i++) { - const option = options2[i]; - if (option[selectedness]) { - selectedOptions2.push(option); - } - } - options2[selectedOptions] = selectedOptions2; - return selectedOptions2; - }); - } - return this[selectedOptions]; - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get willValidate() { - return this.type !== "hidden" && this.type !== "reset" && this.type !== "button" && !this.disabled; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - item(index) { - return this.options.item(index); - } - add(element, before) { - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - if (!before && before !== 0) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this[removeChild](childNodes[0]); - } - for (const option of options2) { - this[appendChild](option); - } - this[appendChild](element); - return; - } - const window2 = this[window]; - if (typeof before !== "number") { - if (!(before instanceof HTMLOptionElement)) { - throw new window2.DOMException("Failed to execute 'add' on 'HTMLFormElement': The node before which the new node is to be inserted before is not an 'HTMLOptionElement'."); - } - before = options2.indexOf(before); - } - const optionsElement = options2[before]; - if (!optionsElement) { - throw new window2.DOMException("Failed to execute 'add' on 'HTMLFormElement': The node before which the new node is to be inserted before is not a child of this node."); - } - const childNodes = this[nodeArray]; - while (childNodes.length) { - this[removeChild](childNodes[0]); - } - for (let i = 0, max = options2.length;i < max; i++) { - if (i === before) { - this[appendChild](element); - } - this[appendChild](options2[i]); - } - } - remove(index) { - if (typeof index === "number") { - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - if (!options2[index]) { - return; - } - const childNodes = this[nodeArray]; - while (childNodes.length) { - this[removeChild](childNodes[0]); - } - for (let i = 0, max = options2.length;i < max; i++) { - if (i !== index) { - this[appendChild](options2[i]); - } - } - } else { - super.remove(); - } - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } - checkValidity() { - const valid = this.disabled || this[validity].valid; - if (!valid) { - this.dispatchEvent(new Event("invalid", { bubbles: true, cancelable: true })); - } - return valid; - } - reportValidity() { - return this.checkValidity(); - } - [updateSelectedness](selectedOption) { - const isMultiple = this.hasAttribute("multiple"); - const options2 = QuerySelector.querySelectorAll(this, "option")[items]; - const selected = []; - if (selectedOption) { - this[selectedIndex] = -1; - } - if (!isMultiple) { - for (let i = 0, max = options2.length;i < max; i++) { - const option = options2[i]; - if (selectedOption) { - option[selectedness] = option === selectedOption; - if (option === selectedOption) { - this[selectedIndex] = i; - } - } - if (option[selectedness]) { - selected.push(option); - } - } - } - const size = this.#getDisplaySize(); - if (size === 1 && !selected.length) { - this[selectedIndex] = -1; - for (let i = 0, max = options2.length;i < max; i++) { - const option = options2[i]; - const parentNode2 = option[parentNode]; - let disabled = option.hasAttributeNS(null, "disabled"); - if (parentNode2 && parentNode2[nodeType] === NodeTypeEnum_default.elementNode && parentNode2[tagName] === "OPTGROUP" && parentNode2.hasAttributeNS(null, "disabled")) { - disabled = true; - } - if (!disabled) { - option[selectedness] = true; - this[selectedIndex] = i; - break; - } - } - } else if (selected.length >= 2) { - this[selectedIndex] = -1; - for (let i = 0, max = options2.length;i < max; i++) { - options2[i][selectedness] = i === selected.length - 1; - if (i === selected.length - 1) { - this[selectedIndex] = i; - } - } - } - } - #getDisplaySize() { - if (this.hasAttributeNS(null, "size")) { - const size = parseInt(this.getAttribute("size")); - if (!isNaN(size) && size >= 0) { - return size; - } - } - return this.hasAttributeNS(null, "multiple") ? 4 : 1; - } -} - -// node_modules/happy-dom/lib/nodes/html-slot-element/HTMLSlotElement.js -var _a2; - -class HTMLSlotElement extends HTMLElement { - [assignedNodes] = []; - get onslotchange() { - return ElementEventAttributeUtility.getEventListener(this, "onslotchange"); - } - set onslotchange(value) { - this[propertyEventListeners].set("onslotchange", value); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - assign(...nodes) { - const shadowRoot = this.getRootNode(); - if (shadowRoot?.[slotAssignment] !== "manual") { - return; - } - const host = shadowRoot.host; - if (!host) { - return; - } - for (const node of nodes) { - if (node instanceof Node) { - if (host[nodeArray].includes(node) && node[nodeType] !== NodeTypeEnum_default.commentNode) { - if (node[assignedToSlot]) { - const index = node[assignedToSlot][assignedNodes].indexOf(node); - if (index !== -1) { - node[assignedToSlot][assignedNodes].splice(index, 1); - } - } - node[assignedToSlot] = this; - this[assignedNodes].push(node); - } - } - } - } - assignedNodes(options) { - return this.#assignedNodes(this.name, options); - } - assignedElements(options) { - return this.#assignedElements(this.name, options); - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - [onSetAttribute](attribute, replacedAttribute) { - super[onSetAttribute](attribute, replacedAttribute); - if (attribute[name] === "name" && attribute[value] !== replacedAttribute?.[value]) { - const replacedAssignedNodes = this.#assignedNodes(replacedAttribute?.[value]); - const assignedNodes2 = this.#assignedNodes(attribute.value); - if (replacedAssignedNodes.length !== assignedNodes2.length) { - this.dispatchEvent(new Event("slotchange", { bubbles: true })); - } else { - for (let i = 0, max = assignedNodes2.length;i < max; i++) { - if (replacedAssignedNodes[i] !== assignedNodes2[i]) { - this.dispatchEvent(new Event("slotchange", { bubbles: true })); - break; - } - } - } - } - } - [onRemoveAttribute](removedAttribute) { - super[onRemoveAttribute](removedAttribute); - if (removedAttribute[name] === "name" && removedAttribute[value] && this.#assignedNodes(removedAttribute.value).length > 0) { - this.dispatchEvent(new Event("slotchange", { bubbles: true })); - } - } - #assignedNodes(name, options) { - const shadowRoot = this.getRootNode(); - if (!shadowRoot?.host) { - return []; - } - if (shadowRoot[slotAssignment] === "manual") { - return this[assignedNodes]; - } - const host = shadowRoot.host; - const flatten = !!options?.flatten; - const assigned = []; - for (const slotNode of host[nodeArray]) { - const slotName = slotNode.slot; - if (name && slotName && slotName === name || !name && !slotName) { - if (flatten && slotNode instanceof _a2) { - for (const slotChild of slotNode.assignedNodes(options)) { - assigned.push(slotChild); - } - } else { - assigned.push(slotNode); - } - } - } - return assigned; - } - #assignedElements(name, options) { - const shadowRoot = this.getRootNode(); - if (!shadowRoot?.host) { - return []; - } - if (shadowRoot[slotAssignment] === "manual") { - const elements = []; - for (const node of this[assignedNodes]) { - if (node instanceof Element) { - elements.push(node); - } - } - return elements; - } - const host = shadowRoot.host; - const flatten = !!options?.flatten; - const assigned = []; - for (const slotElement of host[elementArray]) { - const slotName = slotElement.slot; - if (name && slotName === name || !name && !slotName) { - if (flatten && slotElement instanceof _a2) { - for (const slotChild of slotElement.assignedElements(options)) { - assigned.push(slotChild); - } - } else { - assigned.push(slotElement); - } - } - } - return assigned; - } -} -_a2 = HTMLSlotElement; -var HTMLSlotElement_default = HTMLSlotElement; - -// node_modules/happy-dom/lib/nodes/html-source-element/HTMLSourceElement.js -class HTMLSourceElement extends HTMLElement { - get height() { - const value = Number(this.getAttribute("height")); - return isNaN(value) || value < 0 ? 0 : value; - } - set height(value) { - const parsedValue = Number(value); - this.setAttribute("height", isNaN(parsedValue) || parsedValue < 0 ? "0" : String(parsedValue)); - } - get width() { - const value = Number(this.getAttribute("width")); - return isNaN(value) || value < 0 ? 0 : value; - } - set width(value) { - const parsedValue = Number(value); - this.setAttribute("width", isNaN(parsedValue) || parsedValue < 0 ? "0" : String(parsedValue)); - } - get media() { - return this.getAttribute("media") || ""; - } - set media(value) { - this.setAttribute("media", value); - } - get sizes() { - return this.getAttribute("sizes") || ""; - } - set sizes(value) { - this.setAttribute("sizes", value); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src") || ""; - } - } - set src(src) { - this.setAttribute("src", src); - } - get srcset() { - return this.getAttribute("srcset") || ""; - } - set srcset(value) { - this.setAttribute("srcset", value); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } -} - -// node_modules/happy-dom/lib/nodes/html-span-element/HTMLSpanElement.js -class HTMLSpanElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-style-element/HTMLStyleElement.js -class HTMLStyleElement extends HTMLElement { - [sheet] = null; - [styleNode] = this; - [disabled] = false; - get media() { - return this.getAttribute("media") || ""; - } - set media(media) { - this.setAttribute("media", media); - } - get type() { - return this.getAttribute("type") || ""; - } - set type(type) { - this.setAttribute("type", type); - } - get disabled() { - return this[disabled]; - } - set disabled(disabled2) { - this[disabled] = Boolean(disabled2); - } - get sheet() { - if (!this[isConnected]) { - return null; - } - if (!this[sheet]) { - this[sheet] = new this[ownerDocument][window].CSSStyleSheet; - this[sheet].replaceSync(this.textContent); - } - return this[sheet]; - } - [disconnectedFromDocument]() { - super[disconnectedFromDocument](); - this[sheet] = null; - } - [destroy]() { - super[destroy](); - this[sheet] = null; - } - [updateSheet]() { - if (this[sheet]) { - this[sheet].replaceSync(this.textContent); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-table-caption-element/HTMLTableCaptionElement.js -class HTMLTableCaptionElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-table-cell-element/HTMLTableCellElement.js -class HTMLTableCellElement extends HTMLElement { - get abbr() { - return this.getAttribute("abbr") || ""; - } - set abbr(value) { - this.setAttribute("abbr", value); - } - get cellIndex() { - let parent = this.parentNode; - while (parent) { - if (parent[tagName] === "TR") { - const cells = QuerySelector.querySelectorAll(parent, "td,th")[items]; - return cells.indexOf(this); - } - parent = parent.parentNode; - } - return -1; - } - get colSpan() { - const value = Number(this.getAttribute("colspan")); - return isNaN(value) || value < 1 ? 1 : value; - } - set colSpan(value) { - const parsedValue = Number(value); - this.setAttribute("colspan", isNaN(parsedValue) || parsedValue < 1 ? "1" : String(parsedValue)); - } - get headers() { - return this.getAttribute("headers") || ""; - } - set headers(value) { - this.setAttribute("headers", String(value)); - } - get rowSpan() { - const value = Number(this.getAttribute("rowspan")); - return isNaN(value) || value < 1 ? 1 : value; - } - set rowSpan(value) { - const parsedValue = Number(value); - this.setAttribute("rowspan", isNaN(parsedValue) || parsedValue < 1 ? "1" : String(parsedValue)); - } - get scope() { - return this.getAttribute("scope") || ""; - } - set scope(value) { - this.setAttribute("scope", value); - } -} - -// node_modules/happy-dom/lib/nodes/html-table-col-element/HTMLTableColElement.js -class HTMLTableColElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-table-section-element/HTMLTableSectionElement.js -class HTMLTableSectionElement extends HTMLElement { - insertRow(index = -1) { - if (typeof index !== "number") { - index = -1; - } - const rows = QuerySelector.querySelectorAll(this, "tr")[items]; - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index > rows.length) { - throw new this[window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows (${rows.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - const row = this[ownerDocument].createElement("tr"); - if (index === -1 || index === rows.length) { - this.appendChild(row); - } else { - this.insertBefore(row, rows[index]); - } - return row; - } - deleteRow(index) { - if (arguments.length === 0) { - throw new this[window].TypeError("Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only 0 present."); - } - if (typeof index !== "number") { - index = -1; - } - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - const rows = QuerySelector.querySelectorAll(this, "tr")[items]; - if (index >= rows.length) { - throw new this[window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows in the table (${rows.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index === -1) { - index = rows.length - 1; - } - rows[index].remove(); - } -} - -// node_modules/happy-dom/lib/nodes/html-table-element/HTMLTableElement.js -class HTMLTableElement extends HTMLElement { - [rows] = null; - [tBodies] = null; - get caption() { - return QuerySelector.querySelector(this, "caption"); - } - set caption(caption) { - if (caption) { - if (!(caption instanceof HTMLTableCaptionElement)) { - throw new this[window].TypeError("Failed to set the 'caption' property on 'HTMLTableElement': Failed to convert value to 'HTMLTableCaptionElement'."); - } - this.caption?.remove(); - this.insertBefore(caption, this.firstChild); - } else { - this.caption?.remove(); - } - } - get tHead() { - return QuerySelector.querySelector(this, "thead"); - } - set tHead(tHead) { - if (tHead) { - if (!(tHead instanceof HTMLTableSectionElement)) { - throw new this[window].TypeError("Failed to set the 'tHead' property on 'HTMLTableElement': Failed to convert value to 'HTMLTableSectionElement'."); - } - this.tHead?.remove(); - let found = false; - for (const child of this[elementArray]) { - if (child[tagName] !== "CAPTION" && child[tagName] !== "COLGROUP") { - this.insertBefore(tHead, child); - found = true; - break; - } - } - if (!found) { - this.appendChild(tHead); - } - } else { - this.tHead?.remove(); - } - } - get tFoot() { - return QuerySelector.querySelector(this, "tfoot"); - } - set tFoot(tFoot) { - if (tFoot) { - if (!(tFoot instanceof HTMLTableSectionElement)) { - throw new this[window].TypeError("Failed to set the 'tFoot' property on 'HTMLTableElement': Failed to convert value to 'HTMLTableSectionElement'."); - } - this.tFoot?.remove(); - let found = false; - for (const child of this[elementArray]) { - if (child[tagName] !== "CAPTION" && child[tagName] !== "COLGROUP" && child[tagName] !== "THEAD") { - this.insertBefore(tFoot, child); - found = true; - break; - } - } - if (!found) { - this.appendChild(tFoot); - } - } else { - this.tFoot?.remove(); - } - } - get rows() { - if (!this[rows]) { - this[rows] = new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(this, "tr")[items]); - } - return this[rows]; - } - get tBodies() { - if (!this[tBodies]) { - this[tBodies] = new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(this, "tbody")[items]); - } - return this[tBodies]; - } - createTHead() { - const existingTHead = this.tHead; - if (existingTHead) { - return existingTHead; - } - const tHead = this[ownerDocument].createElement("thead"); - this.tHead = tHead; - return tHead; - } - deleteTHead() { - this.tHead = null; - } - createTFoot() { - const existingTFoot = this.tFoot; - if (existingTFoot) { - return existingTFoot; - } - const tFoot = this[ownerDocument].createElement("tfoot"); - this.tFoot = tFoot; - return tFoot; - } - deleteTFoot() { - this.tFoot = null; - } - createTBody() { - const tBodies2 = QuerySelector.querySelectorAll(this, "tbody")[items]; - const tBody = this[ownerDocument].createElement("tbody"); - if (tBodies2.length > 0) { - const lastTBody = tBodies2[tBodies2.length - 1]; - lastTBody.parentNode?.insertBefore(tBody, lastTBody.nextSibling); - return tBody; - } - this.appendChild(tBody); - return tBody; - } - createCaption() { - const existingCaption = this.caption; - if (existingCaption) { - return existingCaption; - } - const caption = this[ownerDocument].createElement("caption"); - this.caption = caption; - return caption; - } - deleteCaption() { - this.caption = null; - } - insertRow(index = -1) { - if (typeof index !== "number") { - index = -1; - } - const rows2 = QuerySelector.querySelectorAll(this, "tr")[items]; - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index > rows2.length) { - throw new this[window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableElement': The index provided (${index}) is greater than the number of rows (${rows2.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - const row = this[ownerDocument].createElement("tr"); - if (index === -1 || index === rows2.length) { - const tbody = QuerySelector.querySelector(this, "tbody"); - if (tbody) { - tbody.appendChild(row); - } else { - const tbody = this[ownerDocument].createElement("tbody"); - tbody.appendChild(row); - this.appendChild(tbody); - } - return row; - } - rows2[index].parentNode?.insertBefore(row, rows2[index]); - return row; - } - deleteRow(index) { - if (arguments.length === 0) { - throw new this[window].TypeError("Failed to execute 'deleteRow' on 'HTMLTableElement': 1 argument required, but only 0 present."); - } - if (typeof index !== "number") { - index = -1; - } - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - const rows2 = QuerySelector.querySelectorAll(this, "tr")[items]; - if (index >= rows2.length) { - throw new this[window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableElement': The index provided (${index}) is greater than the number of rows in the table (${rows2.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index === -1) { - index = rows2.length - 1; - } - rows2[index].remove(); - } -} - -// node_modules/happy-dom/lib/nodes/html-table-row-element/HTMLTableRowElement.js -class HTMLTableRowElement extends HTMLElement { - [cells] = null; - get cells() { - if (!this[cells]) { - this[cells] = new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(this, "td,th")[items]); - } - return this[cells]; - } - get rowIndex() { - let parent = this.parentNode; - while (parent) { - if (parent[tagName] === "TABLE") { - const rows = QuerySelector.querySelectorAll(parent, "tr")[items]; - return rows.indexOf(this); - } - parent = parent.parentNode; - } - return -1; - } - get sectionRowIndex() { - let parent = this.parentNode; - while (parent) { - if (parent instanceof HTMLTableSectionElement) { - const rows = QuerySelector.querySelectorAll(parent, "tr")[items]; - return rows.indexOf(this); - } - parent = parent.parentNode; - } - return -1; - } - insertCell(index = -1) { - if (typeof index !== "number") { - index = -1; - } - const cells2 = QuerySelector.querySelectorAll(this, "td,th")[items]; - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'insertCell' on 'HTMLTableRowElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index > cells2.length) { - throw new this[window].DOMException(`Failed to execute 'insertCell' on 'HTMLTableRowElement': The index provided (${index}) is greater than the number of cells (${cells2.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - const cell = this[ownerDocument].createElement("td"); - if (index === -1 || index === cells2.length) { - this.appendChild(cell); - return cell; - } - cells2[index].parentNode?.insertBefore(cell, cells2[index]); - return cell; - } - deleteCell(index) { - if (arguments.length === 0) { - throw new this[window].TypeError("Failed to execute 'deleteCell' on 'HTMLTableRowElement': 1 argument required, but only 0 present."); - } - if (typeof index !== "number") { - index = -1; - } - if (index < -1) { - throw new this[window].DOMException(`Failed to execute 'deleteCell' on 'HTMLTableRowElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum_default.indexSizeError); - } - const cells2 = QuerySelector.querySelectorAll(this, "td,th")[items]; - if (index >= cells2.length) { - throw new this[window].DOMException(`Failed to execute 'deleteCell' on 'HTMLTableRowElement': The index provided (${index}) is greater than the number of cells in the row (${cells2.length}).`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index === -1) { - index = cells2.length - 1; - } - cells2[index].remove(); - } -} - -// node_modules/happy-dom/lib/nodes/html-template-element/HTMLTemplateElement.js -class HTMLTemplateElement extends HTMLElement { - [content] = this[ownerDocument].createDocumentFragment(); - get content() { - return this[content]; - } - get innerHTML() { - return this.getHTML(); - } - set innerHTML(html) { - const content2 = this[content]; - const childNodes = content2[nodeArray]; - while (childNodes.length) { - content2.removeChild(childNodes[0]); - } - new HTMLParser(this[window], { isTemplateDocumentFragment: true }).parse(html, this[content]); - } - get firstChild() { - return this[content].firstChild; - } - get lastChild() { - return this[content].lastChild; - } - getInnerHTML(_options) { - const serializer = new HTMLSerializer; - const content2 = this[content]; - let html = ""; - for (const node of content2[nodeArray]) { - html += serializer.serializeToString(node); - } - return html; - } - getHTML(_options) { - const serializer = new HTMLSerializer; - const content2 = this[content]; - let html = ""; - for (const node of content2[nodeArray]) { - html += serializer.serializeToString(node); - } - return html; - } - [appendChild](node, disableValidations = false) { - return this[content][appendChild](node, disableValidations); - } - [removeChild](node) { - return this[content][removeChild](node); - } - [insertBefore](newNode, referenceNode, disableValidations = false) { - return this[content][insertBefore](newNode, referenceNode, disableValidations); - } - [replaceChild](newChild, oldChild) { - return this[content][replaceChild](newChild, oldChild); - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[content] = this[content].cloneNode(deep); - return clone; - } -} - -// node_modules/happy-dom/lib/nodes/html-text-area-element/HTMLTextAreaElement.js -class HTMLTextAreaElement extends HTMLElement { - type = "textarea"; - [validationMessage] = ""; - [validity] = new ValidityState(this); - [value] = null; - [textAreaNode] = this; - [formNode] = null; - #selectionStart = null; - #selectionEnd = null; - #selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - get oninput() { - return ElementEventAttributeUtility.getEventListener(this, "oninput"); - } - set oninput(value2) { - this[propertyEventListeners].set("oninput", value2); - } - get onselectionchange() { - return ElementEventAttributeUtility.getEventListener(this, "onselectionchange"); - } - set onselectionchange(value2) { - this[propertyEventListeners].set("onselectionchange", value2); - } - get validationMessage() { - return this[validationMessage]; - } - get validity() { - return this[validity]; - } - get defaultValue() { - return this.textContent; - } - set defaultValue(defaultValue) { - this.textContent = defaultValue; - } - get minLength() { - const minLength = this.getAttribute("minlength"); - if (minLength !== null) { - return parseInt(minLength); - } - return -1; - } - set minLength(minlength) { - this.setAttribute("minlength", String(minlength)); - } - get maxLength() { - const maxLength = this.getAttribute("maxlength"); - if (maxLength !== null) { - return parseInt(maxLength); - } - return -1; - } - set maxLength(maxLength) { - this.setAttribute("maxlength", String(maxLength)); - } - get name() { - return this.getAttribute("name") || ""; - } - set name(name) { - this.setAttribute("name", name); - } - get placeholder() { - return this.getAttribute("placeholder") || ""; - } - set placeholder(placeholder) { - this.setAttribute("placeholder", placeholder); - } - get inputMode() { - return this.getAttribute("inputmode") || ""; - } - set inputMode(inputmode) { - this.setAttribute("inputmode", inputmode); - } - get cols() { - return this.getAttribute("cols") || ""; - } - set cols(cols) { - this.setAttribute("cols", cols); - } - get rows() { - return this.getAttribute("rows") || ""; - } - set rows(rows) { - this.setAttribute("rows", rows); - } - get autocomplete() { - return this.getAttribute("autocomplete") || ""; - } - set autocomplete(autocomplete) { - this.setAttribute("autocomplete", autocomplete); - } - get readOnly() { - return this.getAttribute("readonly") !== null; - } - set readOnly(readOnly) { - if (!readOnly) { - this.removeAttribute("readonly"); - } else { - this.setAttribute("readonly", ""); - } - } - get disabled() { - return this.getAttribute("disabled") !== null; - } - set disabled(disabled) { - if (!disabled) { - this.removeAttribute("disabled"); - } else { - this.setAttribute("disabled", ""); - } - } - get autofocus() { - return this.getAttribute("autofocus") !== null; - } - set autofocus(autofocus) { - if (!autofocus) { - this.removeAttribute("autofocus"); - } else { - this.setAttribute("autofocus", ""); - } - } - get required() { - return this.getAttribute("required") !== null; - } - set required(required) { - if (!required) { - this.removeAttribute("required"); - } else { - this.setAttribute("required", ""); - } - } - get value() { - if (this[value] === null) { - return this.textContent; - } - return this[value]; - } - set value(value2) { - const oldValue = this[value]; - this[value] = value2; - if (oldValue !== this[value]) { - this.#selectionStart = this[value].length; - this.#selectionEnd = this[value].length; - this.#selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - } - } - get selectionStart() { - if (this.#selectionStart === null) { - return this.value.length; - } - return this.#selectionStart; - } - set selectionStart(start) { - this.setSelectionRange(start, Math.max(start, this.selectionEnd), this.#selectionDirection); - } - get selectionEnd() { - if (this.#selectionEnd === null) { - return this.value.length; - } - return this.#selectionEnd; - } - set selectionEnd(end) { - this.setSelectionRange(this.selectionStart, end, this.#selectionDirection); - } - get selectionDirection() { - return this.#selectionDirection; - } - set selectionDirection(direction) { - this.setSelectionRange(this.selectionStart, this.selectionEnd, direction); - } - get form() { - if (this[formNode]) { - return this[formNode]; - } - const id = this.getAttribute("form"); - if (!id || !this[isConnected]) { - return null; - } - return this[ownerDocument].getElementById(id); - } - get textLength() { - return this.value.length; - } - get labels() { - return HTMLLabelElementUtility.getAssociatedLabelElements(this); - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - if (tabIndex !== null) { - const parsed = Number(tabIndex); - return isNaN(parsed) ? 0 : parsed; - } - return 0; - } - set tabIndex(tabIndex) { - super.tabIndex = tabIndex; - } - select() { - this.#selectionStart = 0; - this.#selectionEnd = this.value.length; - this.#selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - this.dispatchEvent(new Event("select", { bubbles: true, cancelable: false })); - } - setSelectionRange(start, end, direction = "none") { - this.#selectionEnd = Math.min(end, this.value.length); - this.#selectionStart = Math.min(start, this.selectionEnd); - this.#selectionDirection = direction === HTMLInputElementSelectionDirectionEnum_default.forward || direction === HTMLInputElementSelectionDirectionEnum_default.backward ? direction : HTMLInputElementSelectionDirectionEnum_default.none; - this.dispatchEvent(new Event("select", { bubbles: true, cancelable: false })); - } - setRangeText(replacement, start = null, end = null, selectionMode = HTMLInputElementSelectionModeEnum_default.preserve) { - if (start === null) { - start = this.#selectionStart !== null ? this.#selectionStart : 0; - } - if (end === null) { - end = this.#selectionEnd !== null ? this.#selectionEnd : this.value.length; - } - if (start > end) { - throw new this[window].DOMException("The index is not in the allowed range.", DOMExceptionNameEnum_default.invalidStateError); - } - start = Math.min(start, this.value.length); - end = Math.min(end, this.value.length); - const val = this.value; - let selectionStart = this.#selectionStart !== null ? this.#selectionStart : 0; - let selectionEnd = this.#selectionEnd !== null ? this.#selectionEnd : this.value.length; - this.value = val.slice(0, start) + replacement + val.slice(end); - const newEnd = start + this.value.length; - switch (selectionMode) { - case HTMLInputElementSelectionModeEnum_default.select: - this.setSelectionRange(start, newEnd); - break; - case HTMLInputElementSelectionModeEnum_default.start: - this.setSelectionRange(start, start); - break; - case HTMLInputElementSelectionModeEnum_default.end: - this.setSelectionRange(newEnd, newEnd); - break; - default: - const delta = replacement.length - (end - start); - if (selectionStart > end) { - selectionStart += delta; - } else if (selectionStart > start) { - selectionStart = start; - } - if (selectionEnd > end) { - selectionEnd += delta; - } else if (selectionEnd > start) { - selectionEnd = newEnd; - } - this.setSelectionRange(selectionStart, selectionEnd); - break; - } - } - setCustomValidity(message) { - this[validationMessage] = String(message); - } - checkValidity() { - const valid = this.disabled || this.readOnly || this[validity].valid; - if (!valid) { - this.dispatchEvent(new Event("invalid", { bubbles: true, cancelable: true })); - } - return valid; - } - reportValidity() { - return this.checkValidity(); - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[value] = this[value]; - clone.#selectionStart = this.#selectionStart; - clone.#selectionEnd = this.#selectionEnd; - clone.#selectionDirection = this.#selectionDirection; - return clone; - } - [resetSelection]() { - if (this[value] === null) { - this.#selectionStart = null; - this.#selectionEnd = null; - this.#selectionDirection = HTMLInputElementSelectionDirectionEnum_default.none; - } - } -} - -// node_modules/happy-dom/lib/nodes/html-time-element/HTMLTimeElement.js -class HTMLTimeElement extends HTMLElement { - get dateTime() { - return this.getAttribute("dateTime") || ""; - } - set dateTime(dateTime) { - this.setAttribute("dateTime", dateTime); - } -} - -// node_modules/happy-dom/lib/nodes/html-title-element/HTMLTitleElement.js -class HTMLTitleElement extends HTMLElement { - get text() { - let text = ""; - for (const child of this[nodeArray]) { - if (child[nodeType] === NodeTypeEnum_default.textNode) { - text += child.textContent; - } - } - return text; - } - set text(text) { - this.textContent = text; - } - get innerHTML() { - return this.getHTML(); - } - set innerHTML(html) { - this.textContent = html; - } -} - -// node_modules/happy-dom/lib/nodes/html-track-element/HTMLTrackElement.js -class HTMLTrackElement extends HTMLElement { - get oncuechange() { - return ElementEventAttributeUtility.getEventListener(this, "oncuechange"); - } - set oncuechange(value) { - this[propertyEventListeners].set("oncuechange", value); - } - get kind() { - const kind = this.getAttribute("kind"); - if (kind === null) { - return TextTrackKindEnum_default.subtitles; - } - if (!TextTrackKindEnum_default[kind]) { - return TextTrackKindEnum_default.metadata; - } - return kind; - } - set kind(value) { - if (!TextTrackKindEnum_default[value]) { - value = TextTrackKindEnum_default.metadata; - } - this.setAttribute("kind", value); - } - get src() { - if (!this.hasAttribute("src")) { - return ""; - } - try { - return new URL(this.getAttribute("src"), this[ownerDocument].location.href).href; - } catch (e) { - return this.getAttribute("src") || ""; - } - } - set src(src) { - this.setAttribute("src", src); - } - get srclang() { - return this.getAttribute("srclang") || ""; - } - set srclang(value) { - this.setAttribute("srclang", value); - } - get label() { - return this.getAttribute("label") || ""; - } - set label(value) { - this.setAttribute("label", value); - } - get default() { - return this.hasAttribute("default"); - } - set default(value) { - if (value) { - this.setAttribute("default", ""); - } else { - this.removeAttribute("default"); - } - } - get readyState() { - return 0; - } - get track() { - const textTrack = new this[window].TextTrack(illegalConstructor); - textTrack[kind] = this.kind; - textTrack[label] = this.label; - textTrack[language] = this.srclang; - textTrack[mode] = this.default ? "showing" : "disabled"; - textTrack[id] = this.id; - return textTrack; - } -} - -// node_modules/happy-dom/lib/nodes/html-u-list-element/HTMLUListElement.js -class HTMLUListElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-unknown-element/HTMLUnknownElement.js -class HTMLUnknownElement extends HTMLElement { -} - -// node_modules/happy-dom/lib/nodes/html-video-element/HTMLVideoElement.js -class HTMLVideoElement extends HTMLMediaElement { -} - -// node_modules/happy-dom/lib/nodes/processing-instruction/ProcessingInstruction.js -class ProcessingInstruction extends CharacterData { - [nodeType] = NodeTypeEnum_default.processingInstructionNode; - [target] = ""; - get target() { - return this[target]; - } -} - -// node_modules/happy-dom/lib/nodes/document-fragment/DocumentFragment.js -class DocumentFragment extends Node { - [children] = null; - [rootNode] = this; - [nodeType] = NodeTypeEnum_default.documentFragmentNode; - get children() { - if (!this[children]) { - const elements = this[elementArray]; - this[children] = new HTMLCollection(illegalConstructor, () => elements); - } - return this[children]; - } - get childElementCount() { - return this[elementArray].length; - } - get firstElementChild() { - return this[elementArray][0] ?? null; - } - get lastElementChild() { - const children2 = this[elementArray]; - return children2[children2.length - 1] ?? null; - } - get textContent() { - let result = ""; - for (const childNode of this[nodeArray]) { - if (childNode[nodeType] === NodeTypeEnum_default.elementNode || childNode[nodeType] === NodeTypeEnum_default.textNode) { - result += childNode.textContent; - } - } - return result; - } - set textContent(textContent) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - if (textContent) { - this.appendChild(this[ownerDocument].createTextNode(textContent)); - } - } - append(...nodes) { - ParentNodeUtility.append(this, ...nodes); - } - prepend(...nodes) { - ParentNodeUtility.prepend(this, ...nodes); - } - replaceChildren(...nodes) { - ParentNodeUtility.replaceChildren(this, ...nodes); - } - querySelectorAll(selector) { - return QuerySelector.querySelectorAll(this, selector); - } - querySelector(selector) { - return QuerySelector.querySelector(this, selector); - } - getElementById(id) { - return ParentNodeUtility.getElementById(this, id); - } -} - -// node_modules/happy-dom/lib/nodes/shadow-root/ShadowRoot.js -class ShadowRoot extends DocumentFragment { - [adoptedStyleSheets] = []; - [mode] = "open"; - [host] = null; - [clonable] = false; - [delegatesFocus] = false; - [serializable] = false; - [slotAssignment] = "named"; - [propertyEventListeners] = new Map; - get onslotchange() { - return this[propertyEventListeners].get("onslotchange") ?? null; - } - set onslotchange(value) { - this[propertyEventListeners].set("onslotchange", value); - } - get mode() { - return this[mode]; - } - get host() { - return this[host]; - } - get clonable() { - return this[clonable]; - } - get delegatesFocus() { - return this[delegatesFocus]; - } - get serializable() { - return this[serializable]; - } - get slotAssignment() { - return this[slotAssignment]; - } - get fullscreenElement() { - return null; - } - get pictureInPictureElement() { - return null; - } - get pointerLockElement() { - return null; - } - get innerHTML() { - const serializer = new HTMLSerializer; - let html = ""; - for (const node of this[nodeArray]) { - html += serializer.serializeToString(node); - } - return html; - } - set innerHTML(html) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - new HTMLParser(this[window]).parse(html, this); - } - get adoptedStyleSheets() { - return this[adoptedStyleSheets]; - } - set adoptedStyleSheets(value) { - this[adoptedStyleSheets] = value; - } - get activeElement() { - let activeElement2 = this[ownerDocument][activeElement]; - let rootNode = activeElement2?.getRootNode(); - if (!rootNode || rootNode === this[ownerDocument]) { - return null; - } - if (rootNode === this) { - return activeElement2; - } - while (rootNode && rootNode !== this) { - activeElement2 = rootNode.host; - rootNode = activeElement2.getRootNode(); - } - return activeElement2; - } - getAnimations() { - return []; - } - setHTMLUnsafe(html) { - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - new HTMLParser(this[window]).parse(html, this); - } - toString() { - return this.innerHTML; - } - [cloneNode](deep = false) { - const clone = super[cloneNode](deep); - clone[mode] = this[mode]; - clone[clonable] = this[clonable]; - clone[delegatesFocus] = this[delegatesFocus]; - clone[serializable] = this[serializable]; - clone[slotAssignment] = this[slotAssignment]; - return clone; - } -} - -// node_modules/happy-dom/lib/nodes/svg-element/SVGElement.js -class SVGElement extends Element { - [style] = null; - #dataset = null; - get onabort() { - return ElementEventAttributeUtility.getEventListener(this, "onabort"); - } - set onabort(value) { - this[propertyEventListeners].set("onabort", value); - } - get onanimationend() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationend"); - } - set onanimationend(value) { - this[propertyEventListeners].set("onanimationend", value); - } - get onanimationiteration() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationiteration"); - } - set onanimationiteration(value) { - this[propertyEventListeners].set("onanimationiteration", value); - } - get onanimationstart() { - return ElementEventAttributeUtility.getEventListener(this, "onanimationstart"); - } - set onanimationstart(value) { - this[propertyEventListeners].set("onanimationstart", value); - } - get onauxclick() { - return ElementEventAttributeUtility.getEventListener(this, "onauxclick"); - } - set onauxclick(value) { - this[propertyEventListeners].set("onauxclick", value); - } - get onblur() { - return ElementEventAttributeUtility.getEventListener(this, "onblur"); - } - set onblur(value) { - this[propertyEventListeners].set("onblur", value); - } - get oncancel() { - return ElementEventAttributeUtility.getEventListener(this, "oncancel"); - } - set oncancel(value) { - this[propertyEventListeners].set("oncancel", value); - } - get oncanplay() { - return ElementEventAttributeUtility.getEventListener(this, "oncanplay"); - } - set oncanplay(value) { - this[propertyEventListeners].set("oncanplay", value); - } - get oncanplaythrough() { - return ElementEventAttributeUtility.getEventListener(this, "oncanplaythrough"); - } - set oncanplaythrough(value) { - this[propertyEventListeners].set("oncanplaythrough", value); - } - get onchange() { - return ElementEventAttributeUtility.getEventListener(this, "onchange"); - } - set onchange(value) { - this[propertyEventListeners].set("onchange", value); - } - get onclick() { - return ElementEventAttributeUtility.getEventListener(this, "onclick"); - } - set onclick(value) { - this[propertyEventListeners].set("onclick", value); - } - get onclose() { - return ElementEventAttributeUtility.getEventListener(this, "onclose"); - } - set onclose(value) { - this[propertyEventListeners].set("onclose", value); - } - get oncontextmenu() { - return ElementEventAttributeUtility.getEventListener(this, "oncontextmenu"); - } - set oncontextmenu(value) { - this[propertyEventListeners].set("oncontextmenu", value); - } - get oncopy() { - return ElementEventAttributeUtility.getEventListener(this, "oncopy"); - } - set oncopy(value) { - this[propertyEventListeners].set("oncopy", value); - } - get oncuechange() { - return ElementEventAttributeUtility.getEventListener(this, "oncuechange"); - } - set oncuechange(value) { - this[propertyEventListeners].set("oncuechange", value); - } - get oncut() { - return ElementEventAttributeUtility.getEventListener(this, "oncut"); - } - set oncut(value) { - this[propertyEventListeners].set("oncut", value); - } - get ondblclick() { - return ElementEventAttributeUtility.getEventListener(this, "ondblclick"); - } - set ondblclick(value) { - this[propertyEventListeners].set("ondblclick", value); - } - get ondrag() { - return ElementEventAttributeUtility.getEventListener(this, "ondrag"); - } - set ondrag(value) { - this[propertyEventListeners].set("ondrag", value); - } - get ondragend() { - return ElementEventAttributeUtility.getEventListener(this, "ondragend"); - } - set ondragend(value) { - this[propertyEventListeners].set("ondragend", value); - } - get ondragenter() { - return ElementEventAttributeUtility.getEventListener(this, "ondragenter"); - } - set ondragenter(value) { - this[propertyEventListeners].set("ondragenter", value); - } - get ondragleave() { - return ElementEventAttributeUtility.getEventListener(this, "ondragleave"); - } - set ondragleave(value) { - this[propertyEventListeners].set("ondragleave", value); - } - get ondragover() { - return ElementEventAttributeUtility.getEventListener(this, "ondragover"); - } - set ondragover(value) { - this[propertyEventListeners].set("ondragover", value); - } - get ondragstart() { - return ElementEventAttributeUtility.getEventListener(this, "ondragstart"); - } - set ondragstart(value) { - this[propertyEventListeners].set("ondragstart", value); - } - get ondrop() { - return ElementEventAttributeUtility.getEventListener(this, "ondrop"); - } - set ondrop(value) { - this[propertyEventListeners].set("ondrop", value); - } - get ondurationchange() { - return ElementEventAttributeUtility.getEventListener(this, "ondurationchange"); - } - set ondurationchange(value) { - this[propertyEventListeners].set("ondurationchange", value); - } - get onemptied() { - return ElementEventAttributeUtility.getEventListener(this, "onemptied"); - } - set onemptied(value) { - this[propertyEventListeners].set("onemptied", value); - } - get onended() { - return ElementEventAttributeUtility.getEventListener(this, "onended"); - } - set onended(value) { - this[propertyEventListeners].set("onended", value); - } - get onerror() { - return ElementEventAttributeUtility.getEventListener(this, "onerror"); - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onfocus() { - return ElementEventAttributeUtility.getEventListener(this, "onfocus"); - } - set onfocus(value) { - this[propertyEventListeners].set("onfocus", value); - } - get onformdata() { - return ElementEventAttributeUtility.getEventListener(this, "onformdata"); - } - set onformdata(value) { - this[propertyEventListeners].set("onformdata", value); - } - get ongotpointercapture() { - return ElementEventAttributeUtility.getEventListener(this, "ongotpointercapture"); - } - set ongotpointercapture(value) { - this[propertyEventListeners].set("ongotpointercapture", value); - } - get oninput() { - return ElementEventAttributeUtility.getEventListener(this, "oninput"); - } - set oninput(value) { - this[propertyEventListeners].set("oninput", value); - } - get oninvalid() { - return ElementEventAttributeUtility.getEventListener(this, "oninvalid"); - } - set oninvalid(value) { - this[propertyEventListeners].set("oninvalid", value); - } - get onkeydown() { - return ElementEventAttributeUtility.getEventListener(this, "onkeydown"); - } - set onkeydown(value) { - this[propertyEventListeners].set("onkeydown", value); - } - get onkeypress() { - return ElementEventAttributeUtility.getEventListener(this, "onkeypress"); - } - set onkeypress(value) { - this[propertyEventListeners].set("onkeypress", value); - } - get onkeyup() { - return ElementEventAttributeUtility.getEventListener(this, "onkeyup"); - } - set onkeyup(value) { - this[propertyEventListeners].set("onkeyup", value); - } - get onload() { - return ElementEventAttributeUtility.getEventListener(this, "onload"); - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get onloadeddata() { - return ElementEventAttributeUtility.getEventListener(this, "onloadeddata"); - } - set onloadeddata(value) { - this[propertyEventListeners].set("onloadeddata", value); - } - get onloadedmetadata() { - return ElementEventAttributeUtility.getEventListener(this, "onloadedmetadata"); - } - set onloadedmetadata(value) { - this[propertyEventListeners].set("onloadedmetadata", value); - } - get onloadstart() { - return ElementEventAttributeUtility.getEventListener(this, "onloadstart"); - } - set onloadstart(value) { - this[propertyEventListeners].set("onloadstart", value); - } - get onlostpointercapture() { - return ElementEventAttributeUtility.getEventListener(this, "onlostpointercapture"); - } - set onlostpointercapture(value) { - this[propertyEventListeners].set("onlostpointercapture", value); - } - get onmousedown() { - return ElementEventAttributeUtility.getEventListener(this, "onmousedown"); - } - set onmousedown(value) { - this[propertyEventListeners].set("onmousedown", value); - } - get onmouseenter() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseenter"); - } - set onmouseenter(value) { - this[propertyEventListeners].set("onmouseenter", value); - } - get onmouseleave() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseleave"); - } - set onmouseleave(value) { - this[propertyEventListeners].set("onmouseleave", value); - } - get onmousemove() { - return ElementEventAttributeUtility.getEventListener(this, "onmousemove"); - } - set onmousemove(value) { - this[propertyEventListeners].set("onmousemove", value); - } - get onmouseout() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseout"); - } - set onmouseout(value) { - this[propertyEventListeners].set("onmouseout", value); - } - get onmouseover() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseover"); - } - set onmouseover(value) { - this[propertyEventListeners].set("onmouseover", value); - } - get onmouseup() { - return ElementEventAttributeUtility.getEventListener(this, "onmouseup"); - } - set onmouseup(value) { - this[propertyEventListeners].set("onmouseup", value); - } - get onmousewheel() { - return ElementEventAttributeUtility.getEventListener(this, "onmousewheel"); - } - set onmousewheel(value) { - this[propertyEventListeners].set("onmousewheel", value); - } - get onpaste() { - return ElementEventAttributeUtility.getEventListener(this, "onpaste"); - } - set onpaste(value) { - this[propertyEventListeners].set("onpaste", value); - } - get onpause() { - return ElementEventAttributeUtility.getEventListener(this, "onpause"); - } - set onpause(value) { - this[propertyEventListeners].set("onpause", value); - } - get onplay() { - return ElementEventAttributeUtility.getEventListener(this, "onplay"); - } - set onplay(value) { - this[propertyEventListeners].set("onplay", value); - } - get onplaying() { - return ElementEventAttributeUtility.getEventListener(this, "onplaying"); - } - set onplaying(value) { - this[propertyEventListeners].set("onplaying", value); - } - get onpointercancel() { - return ElementEventAttributeUtility.getEventListener(this, "onpointercancel"); - } - set onpointercancel(value) { - this[propertyEventListeners].set("onpointercancel", value); - } - get onpointerdown() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerdown"); - } - set onpointerdown(value) { - this[propertyEventListeners].set("onpointerdown", value); - } - get onpointerenter() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerenter"); - } - set onpointerenter(value) { - this[propertyEventListeners].set("onpointerenter", value); - } - get onpointerleave() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerleave"); - } - set onpointerleave(value) { - this[propertyEventListeners].set("onpointerleave", value); - } - get onpointermove() { - return ElementEventAttributeUtility.getEventListener(this, "onpointermove"); - } - set onpointermove(value) { - this[propertyEventListeners].set("onpointermove", value); - } - get onpointerout() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerout"); - } - set onpointerout(value) { - this[propertyEventListeners].set("onpointerout", value); - } - get onpointerover() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerover"); - } - set onpointerover(value) { - this[propertyEventListeners].set("onpointerover", value); - } - get onpointerrawupdate() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerrawupdate"); - } - set onpointerrawupdate(value) { - this[propertyEventListeners].set("onpointerrawupdate", value); - } - get onpointerup() { - return ElementEventAttributeUtility.getEventListener(this, "onpointerup"); - } - set onpointerup(value) { - this[propertyEventListeners].set("onpointerup", value); - } - get onprogress() { - return ElementEventAttributeUtility.getEventListener(this, "onprogress"); - } - set onprogress(value) { - this[propertyEventListeners].set("onprogress", value); - } - get onratechange() { - return ElementEventAttributeUtility.getEventListener(this, "onratechange"); - } - set onratechange(value) { - this[propertyEventListeners].set("onratechange", value); - } - get onreset() { - return ElementEventAttributeUtility.getEventListener(this, "onreset"); - } - set onreset(value) { - this[propertyEventListeners].set("onreset", value); - } - get onresize() { - return ElementEventAttributeUtility.getEventListener(this, "onresize"); - } - set onresize(value) { - this[propertyEventListeners].set("onresize", value); - } - get onscroll() { - return ElementEventAttributeUtility.getEventListener(this, "onscroll"); - } - set onscroll(value) { - this[propertyEventListeners].set("onscroll", value); - } - get onscrollend() { - return ElementEventAttributeUtility.getEventListener(this, "onscrollend"); - } - set onscrollend(value) { - this[propertyEventListeners].set("onscrollend", value); - } - get onscrollsnapchange() { - return ElementEventAttributeUtility.getEventListener(this, "onscrollsnapchange"); - } - set onscrollsnapchange(value) { - this[propertyEventListeners].set("onscrollsnapchange", value); - } - get onscrollsnapchanging() { - return ElementEventAttributeUtility.getEventListener(this, "onscrollsnapchanging"); - } - set onscrollsnapchanging(value) { - this[propertyEventListeners].set("onscrollsnapchanging", value); - } - get onsecuritypolicyviolation() { - return ElementEventAttributeUtility.getEventListener(this, "onsecuritypolicyviolation"); - } - set onsecuritypolicyviolation(value) { - this[propertyEventListeners].set("onsecuritypolicyviolation", value); - } - get onseeked() { - return ElementEventAttributeUtility.getEventListener(this, "onseeked"); - } - set onseeked(value) { - this[propertyEventListeners].set("onseeked", value); - } - get onseeking() { - return ElementEventAttributeUtility.getEventListener(this, "onseeking"); - } - set onseeking(value) { - this[propertyEventListeners].set("onseeking", value); - } - get onselect() { - return ElementEventAttributeUtility.getEventListener(this, "onselect"); - } - set onselect(value) { - this[propertyEventListeners].set("onselect", value); - } - get onselectionchange() { - return ElementEventAttributeUtility.getEventListener(this, "onselectionchange"); - } - set onselectionchange(value) { - this[propertyEventListeners].set("onselectionchange", value); - } - get onselectstart() { - return ElementEventAttributeUtility.getEventListener(this, "onselectstart"); - } - set onselectstart(value) { - this[propertyEventListeners].set("onselectstart", value); - } - get onslotchange() { - return ElementEventAttributeUtility.getEventListener(this, "onslotchange"); - } - set onslotchange(value) { - this[propertyEventListeners].set("onslotchange", value); - } - get onstalled() { - return ElementEventAttributeUtility.getEventListener(this, "onstalled"); - } - set onstalled(value) { - this[propertyEventListeners].set("onstalled", value); - } - get onsubmit() { - return ElementEventAttributeUtility.getEventListener(this, "onsubmit"); - } - set onsubmit(value) { - this[propertyEventListeners].set("onsubmit", value); - } - get onsuspend() { - return ElementEventAttributeUtility.getEventListener(this, "onsuspend"); - } - set onsuspend(value) { - this[propertyEventListeners].set("onsuspend", value); - } - get ontimeupdate() { - return ElementEventAttributeUtility.getEventListener(this, "ontimeupdate"); - } - set ontimeupdate(value) { - this[propertyEventListeners].set("ontimeupdate", value); - } - get ontoggle() { - return ElementEventAttributeUtility.getEventListener(this, "ontoggle"); - } - set ontoggle(value) { - this[propertyEventListeners].set("ontoggle", value); - } - get ontransitioncancel() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitioncancel"); - } - set ontransitioncancel(value) { - this[propertyEventListeners].set("ontransitioncancel", value); - } - get ontransitionend() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionend"); - } - set ontransitionend(value) { - this[propertyEventListeners].set("ontransitionend", value); - } - get ontransitionrun() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionrun"); - } - set ontransitionrun(value) { - this[propertyEventListeners].set("ontransitionrun", value); - } - get ontransitionstart() { - return ElementEventAttributeUtility.getEventListener(this, "ontransitionstart"); - } - set ontransitionstart(value) { - this[propertyEventListeners].set("ontransitionstart", value); - } - get onvolumechange() { - return ElementEventAttributeUtility.getEventListener(this, "onvolumechange"); - } - set onvolumechange(value) { - this[propertyEventListeners].set("onvolumechange", value); - } - get onwaiting() { - return ElementEventAttributeUtility.getEventListener(this, "onwaiting"); - } - set onwaiting(value) { - this[propertyEventListeners].set("onwaiting", value); - } - get onwheel() { - return ElementEventAttributeUtility.getEventListener(this, "onwheel"); - } - set onwheel(value) { - this[propertyEventListeners].set("onwheel", value); - } - get ownerSVGElement() { - let parent = this[parentNode]; - while (parent) { - if (parent[localName] === "svg") { - return parent; - } - parent = parent[parentNode]; - } - return null; - } - get viewportElement() { - return this.ownerSVGElement; - } - get dataset() { - return this.#dataset ??= new DOMStringMap(illegalConstructor, this); - } - get style() { - if (!this[style]) { - this[style] = new CSSStyleDeclaration(illegalConstructor, this[window], { element: this }); - } - return this[style]; - } - get tabIndex() { - const tabIndex = this.getAttribute("tabindex"); - return tabIndex !== null ? Number(tabIndex) : -1; - } - set tabIndex(tabIndex) { - if (tabIndex === -1) { - this.removeAttribute("tabindex"); - } else { - this.setAttribute("tabindex", String(tabIndex)); - } - } - blur() { - HTMLElementUtility.blur(this); - } - focus() { - HTMLElementUtility.focus(this); - } -} - -// node_modules/happy-dom/lib/resize-observer/ResizeObserver.js -class ResizeObserver { - observe() {} - unobserve() {} - disconnect() {} -} - -// node_modules/happy-dom/lib/screen/Screen.js -class Screen extends EventTarget { - width = 1024; - height = 768; - availWidth = 1024; - availHeight = 768; - colorDepth = 24; - pixelDepth = 24; - onchange = null; -} - -// node_modules/happy-dom/lib/screen/ScreenDetailed.js -class ScreenDetailed extends Screen { - availLeft = 0; - availTop = 0; - left = 0; - top = 0; - isPrimary = true; - isInternal = true; - devicePixelRatio = 1; - label = ""; -} - -// node_modules/happy-dom/lib/screen/ScreenDetails.js -class ScreenDetails extends EventTarget { - currentScreen; - screens; - oncurrentscreenchange = null; - onscreenschange = null; - constructor() { - super(); - const screen = new ScreenDetailed; - this.currentScreen = screen; - this.screens = [screen]; - } -} - -// node_modules/happy-dom/lib/range/RangeUtility.js -class RangeUtility { - static compareBoundaryPointsPosition(pointA, pointB) { - if (pointA.node === pointB.node) { - if (pointA.offset === pointB.offset) { - return 0; - } else if (pointA.offset < pointB.offset) { - return -1; - } - return 1; - } - if (NodeUtility.isFollowing(pointA.node, pointB.node)) { - return this.compareBoundaryPointsPosition(pointB, pointA) === -1 ? 1 : -1; - } - if (NodeUtility.isInclusiveAncestor(pointA.node, pointB.node)) { - let child = pointB.node; - while (child[parentNode] !== pointA.node) { - child = child[parentNode]; - } - if (child[parentNode][nodeArray].indexOf(child) < pointA.offset) { - return 1; - } - } - return -1; - } - static validateBoundaryPoint(point) { - if (point.node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new DOMException(`DocumentType Node can't be used as boundary point.`, DOMExceptionNameEnum_default.invalidNodeTypeError); - } - if (point.offset > NodeUtility.getNodeLength(point.node)) { - throw new DOMException(`Offset out of bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - } - static isContained(node, range) { - return this.compareBoundaryPointsPosition({ node, offset: 0 }, { node: range.startContainer, offset: range.startOffset }) === 1 && this.compareBoundaryPointsPosition({ node, offset: NodeUtility.getNodeLength(node) }, { node: range.endContainer, offset: range.endOffset }) === -1; - } - static isPartiallyContained(node, range) { - return NodeUtility.isInclusiveAncestor(node, range.startContainer) && !NodeUtility.isInclusiveAncestor(node, range.endContainer) || !NodeUtility.isInclusiveAncestor(node, range.startContainer) && NodeUtility.isInclusiveAncestor(node, range.endContainer); - } -} - -// node_modules/happy-dom/lib/selection/SelectionDirectionEnum.js -var SelectionDirectionEnum; -(function(SelectionDirectionEnum) { - SelectionDirectionEnum[SelectionDirectionEnum["forwards"] = 1] = "forwards"; - SelectionDirectionEnum[SelectionDirectionEnum["backwards"] = -1] = "backwards"; - SelectionDirectionEnum[SelectionDirectionEnum["directionless"] = 0] = "directionless"; -})(SelectionDirectionEnum || (SelectionDirectionEnum = {})); -var SelectionDirectionEnum_default = SelectionDirectionEnum; - -// node_modules/happy-dom/lib/selection/Selection.js -class Selection { - #ownerDocument; - #range = null; - #direction = SelectionDirectionEnum_default.directionless; - constructor(ownerDocument) { - this.#ownerDocument = ownerDocument; - } - get rangeCount() { - return this.#range ? 1 : 0; - } - get isCollapsed() { - return this.#range === null || this.#range.collapsed; - } - get type() { - if (!this.#range) { - return "None"; - } else if (this.#range.collapsed) { - return "Caret"; - } - return "Range"; - } - get anchorNode() { - if (!this.#range) { - return null; - } - return this.#direction === SelectionDirectionEnum_default.forwards ? this.#range.startContainer : this.#range.endContainer; - } - get anchorOffset() { - if (!this.#range) { - return 0; - } - return this.#direction === SelectionDirectionEnum_default.forwards ? this.#range.startOffset : this.#range.endOffset; - } - get baseNode() { - return this.anchorNode; - } - get baseOffset() { - return this.anchorOffset; - } - get focusNode() { - if (!this.#range) { - return null; - } - return this.#direction === SelectionDirectionEnum_default.forwards ? this.#range.endContainer : this.#range.startContainer; - } - get focusOffset() { - if (!this.#range) { - return 0; - } - return this.#direction === SelectionDirectionEnum_default.forwards ? this.#range.endOffset : this.#range.startOffset; - } - get extentNode() { - return this.focusNode; - } - get extentOffset() { - return this.focusOffset; - } - addRange(newRange) { - if (!newRange) { - throw new this.#ownerDocument[window].TypeError("Failed to execute addRange on Selection. Parameter 1 is not of type Range."); - } - if (!this.#range && newRange[ownerDocument] === this.#ownerDocument) { - this.#associateRange(newRange); - } - } - getRangeAt(index) { - if (!this.#range || index !== 0) { - throw new this.#ownerDocument[window].DOMException("Invalid range index.", DOMExceptionNameEnum_default.indexSizeError); - } - return this.#range; - } - removeRange(range) { - if (this.#range !== range) { - throw new this.#ownerDocument[window].DOMException("Invalid range.", DOMExceptionNameEnum_default.notFoundError); - } - this.#associateRange(null); - } - removeAllRanges() { - this.#associateRange(null); - } - empty() { - this.removeAllRanges(); - } - collapse(node, offset) { - if (node === null) { - this.removeAllRanges(); - return; - } - if (node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new this.#ownerDocument[window].DOMException("DocumentType Node can't be used as boundary point.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - if (offset > NodeUtility.getNodeLength(node)) { - throw new this.#ownerDocument[window].DOMException("Invalid range index.", DOMExceptionNameEnum_default.indexSizeError); - } - if (node !== this.#ownerDocument && node[ownerDocument] !== this.#ownerDocument) { - return; - } - const newRange = new this.#ownerDocument[window].Range; - newRange[start].node = node; - newRange[start].offset = offset; - newRange[end].node = node; - newRange[end].offset = offset; - this.#associateRange(newRange); - } - setPosition(node, offset) { - this.collapse(node, offset); - } - collapseToEnd() { - if (this.#range === null) { - throw new this.#ownerDocument[window].DOMException("There is no selection to collapse.", DOMExceptionNameEnum_default.invalidStateError); - } - const { node, offset } = this.#range[end]; - const newRange = new this.#ownerDocument[window].Range; - newRange[start].node = node; - newRange[start].offset = offset; - newRange[end].node = node; - newRange[end].offset = offset; - this.#associateRange(newRange); - } - collapseToStart() { - if (!this.#range) { - throw new this.#ownerDocument[window].DOMException("There is no selection to collapse.", DOMExceptionNameEnum_default.invalidStateError); - } - const { node, offset } = this.#range[start]; - const newRange = new this.#ownerDocument[window].Range; - newRange[start].node = node; - newRange[start].offset = offset; - newRange[end].node = node; - newRange[end].offset = offset; - this.#associateRange(newRange); - } - containsNode(node, allowPartialContainment = false) { - if (!this.#range || node[ownerDocument] !== this.#ownerDocument) { - return false; - } - const startIsBeforeNode = RangeUtility.compareBoundaryPointsPosition(this.#range[start], { - node, - offset: 0 - }) === -1; - const endIsAfterNode = RangeUtility.compareBoundaryPointsPosition(this.#range[end], { - node, - offset: NodeUtility.getNodeLength(node) - }) === 1; - return allowPartialContainment ? startIsBeforeNode || endIsAfterNode : startIsBeforeNode && endIsAfterNode; - } - deleteFromDocument() { - if (this.#range) { - this.#range.deleteContents(); - } - } - extend(node, offset) { - if (node !== this.#ownerDocument && node[ownerDocument] !== this.#ownerDocument) { - return; - } - if (!this.#range) { - throw new this.#ownerDocument[window].DOMException("There is no selection to extend.", DOMExceptionNameEnum_default.invalidStateError); - } - const anchorNode = this.anchorNode; - const anchorOffset = this.anchorOffset; - const newRange = new this.#ownerDocument[window].Range; - newRange[start].node = node; - newRange[start].offset = 0; - newRange[end].node = node; - newRange[end].offset = 0; - if (node[ownerDocument] !== this.#range[ownerDocument]) { - newRange[start].offset = offset; - newRange[end].offset = offset; - } else if (RangeUtility.compareBoundaryPointsPosition({ node: anchorNode, offset: anchorOffset }, { node, offset }) <= 0) { - newRange[start].node = anchorNode; - newRange[start].offset = anchorOffset; - newRange[end].node = node; - newRange[end].offset = offset; - } else { - newRange[start].node = node; - newRange[start].offset = offset; - newRange[end].node = anchorNode; - newRange[end].offset = anchorOffset; - } - this.#associateRange(newRange); - this.#direction = RangeUtility.compareBoundaryPointsPosition({ node, offset }, { node: anchorNode, offset: anchorOffset }) === -1 ? SelectionDirectionEnum_default.backwards : SelectionDirectionEnum_default.forwards; - } - selectAllChildren(node) { - if (node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new this.#ownerDocument[window].DOMException("DocumentType Node can't be used as boundary point.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - if (node !== this.#ownerDocument && node[ownerDocument] !== this.#ownerDocument) { - return; - } - const length = node[nodeArray].length; - const newRange = new this.#ownerDocument[window].Range; - newRange[start].node = node; - newRange[start].offset = 0; - newRange[end].node = node; - newRange[end].offset = length; - this.#associateRange(newRange); - } - setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset) { - if (anchorOffset > NodeUtility.getNodeLength(anchorNode) || focusOffset > NodeUtility.getNodeLength(focusNode)) { - throw new this.#ownerDocument[window].DOMException("Invalid anchor or focus offset.", DOMExceptionNameEnum_default.indexSizeError); - } - if (anchorNode !== this.#ownerDocument && anchorNode[ownerDocument] !== this.#ownerDocument || focusNode !== this.#ownerDocument && focusNode[ownerDocument] !== this.#ownerDocument) { - return; - } - const anchor = { node: anchorNode, offset: anchorOffset }; - const focus = { node: focusNode, offset: focusOffset }; - const newRange = new this.#ownerDocument[window].Range; - if (RangeUtility.compareBoundaryPointsPosition(anchor, focus) === -1) { - newRange[start] = anchor; - newRange[end] = focus; - } else { - newRange[start] = focus; - newRange[end] = anchor; - } - this.#associateRange(newRange); - this.#direction = RangeUtility.compareBoundaryPointsPosition(focus, anchor) === -1 ? SelectionDirectionEnum_default.backwards : SelectionDirectionEnum_default.forwards; - } - toString() { - return this.#range ? this.#range.toString() : ""; - } - #associateRange(range) { - const oldRange = this.#range; - this.#range = range; - this.#direction = range === null ? SelectionDirectionEnum_default.directionless : SelectionDirectionEnum_default.forwards; - if (oldRange !== this.#range) { - this.#ownerDocument.dispatchEvent(new Event("selectionchange")); - } - } -} - -// node_modules/happy-dom/lib/storage/Storage.js -class Storage { - [data] = {}; - constructor() { - const data2 = this[data]; - const methodBinder = new ClassMethodBinder(this, [Storage]); - return new Proxy(this, { - get: (target, property) => { - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - if (property in data2) { - return data2[property]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (property in target || typeof property === "symbol") { - return true; - } - data2[String(property)] = String(newValue); - return true; - }, - deleteProperty(_target, property) { - if (property in data2) { - delete data2[String(property)]; - return true; - } - return false; - }, - ownKeys() { - return Object.keys(data2); - }, - has(target, property) { - if (property in target || property in data2) { - return true; - } - return false; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - if (descriptor.value !== undefined) { - data2[String(property)] = String(descriptor.value); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target) { - return; - } - const value = data2[String(property)]; - if (value !== undefined) { - return { - value, - writable: true, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return Object.keys(this[data]).length; - } - key(index) { - const name = Object.keys(this[data])[index]; - return name !== undefined ? name : null; - } - setItem(name, item) { - this[data][name] = String(item); - } - getItem(name) { - return this[data][name] !== undefined ? this[data][name] : null; - } - removeItem(name) { - delete this[data][name]; - } - clear() { - const data2 = this[data]; - for (const key of Object.keys(data2)) { - delete data2[key]; - } - } -} - -// node_modules/happy-dom/lib/tree-walker/NodeFilter.js -var NodeFilter_default = { - FILTER_ACCEPT: 1, - FILTER_REJECT: 2, - FILTER_SKIP: 3, - SHOW_ALL: -1, - SHOW_ELEMENT: 1, - SHOW_ATTRIBUTE: 2, - SHOW_TEXT: 4, - SHOW_CDATA_SECTION: 8, - SHOW_ENTITY_REFERENCE: 16, - SHOW_ENTITY: 32, - SHOW_PROCESSING_INSTRUCTION: 64, - SHOW_COMMENT: 128, - SHOW_DOCUMENT: 256, - SHOW_DOCUMENT_TYPE: 512, - SHOW_DOCUMENT_FRAGMENT: 1024, - SHOW_NOTATION: 2048 -}; - -// node_modules/happy-dom/lib/tree-walker/NodeFilterMask.js -var NodeFilterMask_default = { - 1: NodeFilter_default.SHOW_ELEMENT, - 2: NodeFilter_default.SHOW_ATTRIBUTE, - 3: NodeFilter_default.SHOW_TEXT, - 4: NodeFilter_default.SHOW_CDATA_SECTION, - 5: NodeFilter_default.SHOW_ENTITY_REFERENCE, - 6: NodeFilter_default.SHOW_PROCESSING_INSTRUCTION, - 7: NodeFilter_default.SHOW_PROCESSING_INSTRUCTION, - 8: NodeFilter_default.SHOW_COMMENT, - 9: NodeFilter_default.SHOW_DOCUMENT, - 10: NodeFilter_default.SHOW_DOCUMENT_TYPE, - 11: NodeFilter_default.SHOW_DOCUMENT_FRAGMENT, - 12: NodeFilter_default.SHOW_NOTATION -}; - -// node_modules/happy-dom/lib/tree-walker/TreeWalker.js -var TraverseChildrenTypeEnum; -(function(TraverseChildrenTypeEnum) { - TraverseChildrenTypeEnum["first"] = "first"; - TraverseChildrenTypeEnum["last"] = "last"; -})(TraverseChildrenTypeEnum || (TraverseChildrenTypeEnum = {})); -var TraverseSiblingsTypeEnum; -(function(TraverseSiblingsTypeEnum) { - TraverseSiblingsTypeEnum["next"] = "next"; - TraverseSiblingsTypeEnum["previous"] = "previous"; -})(TraverseSiblingsTypeEnum || (TraverseSiblingsTypeEnum = {})); - -class TreeWalker { - root; - whatToShow = -1; - filter = null; - #currentNode = null; - constructor(root, whatToShow = -1, filter = null) { - if (!(root instanceof Node)) { - throw new DOMException("Parameter 1 was not of type Node."); - } - this.root = root; - this.whatToShow = whatToShow; - this.filter = filter; - this.#currentNode = root; - } - get currentNode() { - return this.#currentNode; - } - set currentNode(node) { - if (!(node instanceof Node)) { - throw new this.root[window].TypeError("Failed to set the 'currentNode' property on 'TreeWalker': Failed to convert value to 'Node'."); - } - this.#currentNode = node; - } - parentNode() { - let node = this.#currentNode; - while (node !== null && node !== this.root) { - node = node.parentNode; - if (node !== null && this[filterNode](node) === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return this.#currentNode; - } - } - return null; - } - firstChild() { - return this.#traverseChildren(TraverseChildrenTypeEnum.first); - } - lastChild() { - return this.#traverseChildren(TraverseChildrenTypeEnum.last); - } - nextSibling() { - return this.#traverseSiblings(TraverseSiblingsTypeEnum.next); - } - previousSibling() { - return this.#traverseSiblings(TraverseSiblingsTypeEnum.previous); - } - previousNode() { - let node = this.#currentNode; - while (node !== this.root) { - let sibling = node?.previousSibling || null; - while (sibling !== null) { - let node = sibling; - let result = this[filterNode](node); - while (result !== NodeFilter_default.FILTER_REJECT && node[nodeArray].length) { - node = node.lastChild; - result = this[filterNode](node); - } - if (result === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - sibling = node.previousSibling; - } - if (node === this.root || node.parentNode === null) { - return null; - } - node = node.parentNode; - if (this[filterNode](node) === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - } - return null; - } - nextNode() { - let node = this.#currentNode; - let result = NodeFilter_default.FILTER_ACCEPT; - if (node === null) { - return null; - } - while (true) { - while (result !== NodeFilter_default.FILTER_REJECT && node[nodeArray].length) { - node = node.firstChild; - result = this[filterNode](node); - if (result === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - } - while (node !== null) { - if (node === this.root) { - return null; - } - const sibling = node.nextSibling; - if (sibling !== null) { - node = sibling; - break; - } - node = node.parentNode; - } - if (node === null) { - return null; - } - result = this[filterNode](node); - if (result === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - } - } - [filterNode](node) { - const mask = NodeFilterMask_default[node.nodeType]; - if (mask && (this.whatToShow & mask) == 0) { - return NodeFilter_default.FILTER_SKIP; - } - if (typeof this.filter === "function") { - return this.filter(node); - } - if (this.filter) { - return this.filter.acceptNode(node); - } - return NodeFilter_default.FILTER_ACCEPT; - } - #traverseChildren(type) { - let node = this.#currentNode; - if (!node) { - return null; - } - node = type === TraverseChildrenTypeEnum.first ? node.firstChild : node.lastChild; - while (node !== null) { - const result = this[filterNode](node); - if (result === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - if (result === NodeFilter_default.FILTER_SKIP) { - const child = type === TraverseChildrenTypeEnum.first ? node.firstChild : node.lastChild; - if (child !== null) { - node = child; - continue; - } - } - while (node !== null) { - const sibling = type === TraverseChildrenTypeEnum.first ? node.nextSibling : node.previousSibling; - if (sibling !== null) { - node = sibling; - break; - } - const parent = node.parentNode; - if (parent === null || parent === this.root || parent === this.#currentNode) { - return null; - } - node = parent; - } - } - return null; - } - #traverseSiblings(type) { - let node = this.#currentNode; - if (!node || node === this.root) { - return null; - } - while (true) { - let sibling = type === TraverseSiblingsTypeEnum.next ? node.nextSibling : node.previousSibling; - while (sibling !== null) { - const node = sibling; - const result = this[filterNode](node); - if (result === NodeFilter_default.FILTER_ACCEPT) { - this.#currentNode = node; - return node; - } - sibling = type === TraverseSiblingsTypeEnum.next ? node.firstChild : node.lastChild; - if (result === NodeFilter_default.FILTER_REJECT || sibling === null) { - sibling = type === TraverseSiblingsTypeEnum.next ? node.nextSibling : node.previousSibling; - } - } - node = node.parentNode; - if (node === null || node === this.root) { - return null; - } - if (this[filterNode](node) === NodeFilter_default.FILTER_ACCEPT) { - return null; - } - } - } -} - -// node_modules/happy-dom/lib/tree-walker/NodeIterator.js -class NodeIterator { - #root; - #whatToShow = -1; - #filter = null; - #walker; - #atRoot = true; - constructor(root, whatToShow = -1, filter = null) { - this.#root = root; - this.#whatToShow = whatToShow; - this.#filter = filter; - this.#walker = new TreeWalker(root, whatToShow, filter); - } - get root() { - return this.#root; - } - get whatToShow() { - return this.#whatToShow; - } - get filter() { - return this.#filter; - } - nextNode() { - if (this.#atRoot) { - this.#atRoot = false; - if (this.#walker[filterNode](this.#root) !== NodeFilter_default.FILTER_ACCEPT) { - return this.#walker.nextNode(); - } - return this.#root; - } - return this.#walker.nextNode(); - } - previousNode() { - return this.#walker.previousNode(); - } -} - -// node_modules/happy-dom/lib/xml-serializer/XMLSerializer.js -class XMLSerializer { - serializeToString(root) { - return this.#serializeToString(root); - } - #serializeToString(root, inheritedDefaultNamespace = null, inheritedNamespacePrefixes = null) { - switch (root[nodeType]) { - case NodeTypeEnum_default.elementNode: - const element = root; - const localName2 = element[localName]; - let innerHTML = ""; - const namespacePrefixes = this.#getNamespacePrefixes(element, inheritedNamespacePrefixes); - const elementPrefix = element[namespaceURI] === NamespaceURI_default.html ? element[prefix] : this.#getElementPrefix(element, namespacePrefixes); - const tagName = `${elementPrefix ? elementPrefix + ":" : ""}${localName2}`; - const defaultNamespace = elementPrefix ? inheritedDefaultNamespace : element[namespaceURI] || inheritedDefaultNamespace; - const attributes = this.#getAttributes(element, elementPrefix, inheritedDefaultNamespace, inheritedNamespacePrefixes); - const childNodes = defaultNamespace === NamespaceURI_default.html && localName2 === "template" ? root.content[nodeArray] : root[nodeArray]; - for (const node of childNodes) { - innerHTML += this.#serializeToString(node, defaultNamespace, namespacePrefixes); - } - if (!innerHTML && defaultNamespace === NamespaceURI_default.html && HTMLElementConfig_default[localName2.toLowerCase()]?.contentModel === HTMLElementConfigContentModelEnum_default.noDescendants) { - return `<${tagName}${attributes} />`; - } - if (!innerHTML && defaultNamespace !== NamespaceURI_default.html) { - return `<${tagName}${attributes}/>`; - } - return `<${tagName}${attributes}>${innerHTML}`; - case Node.DOCUMENT_FRAGMENT_NODE: - case Node.DOCUMENT_NODE: - let html = ""; - if (root[xmlProcessingInstruction]) { - html += this.#serializeToString(root[xmlProcessingInstruction], inheritedDefaultNamespace, new Map(inheritedNamespacePrefixes)); - } - for (const node of root[nodeArray]) { - html += this.#serializeToString(node, inheritedDefaultNamespace, new Map(inheritedNamespacePrefixes)); - } - return html; - case NodeTypeEnum_default.commentNode: - return ``; - case NodeTypeEnum_default.processingInstructionNode: - return ``; - case NodeTypeEnum_default.textNode: - const parentElement = root.parentElement; - if (parentElement) { - const parentConfig = HTMLElementConfig_default[parentElement[localName]]; - if (parentConfig?.contentModel === HTMLElementConfigContentModelEnum_default.rawText) { - return root.textContent; - } - } - return XMLEncodeUtility.encodeTextContent(root.textContent); - case NodeTypeEnum_default.documentTypeNode: - const doctype = root; - const identifier = doctype.publicId ? " PUBLIC" : doctype.systemId ? " SYSTEM" : ""; - const publicId = doctype.publicId ? ` "${doctype.publicId}"` : ""; - const systemId = doctype.systemId ? ` "${doctype.systemId}"` : ""; - return ``; - } - return ""; - } - #getNamespacePrefixes(element, inheritedNamespacePrefixes) { - const namespacePrefixes = new Map(inheritedNamespacePrefixes); - for (const attribute of element[attributes][items].values()) { - if (attribute[namespaceURI] === NamespaceURI_default.xmlns && attribute[prefix]) { - namespacePrefixes.set(attribute[value], attribute[localName]); - } - } - return namespacePrefixes; - } - #getElementPrefix(element, namespacePrefixes) { - if (element[prefix] && !element[namespaceURI]) { - throw new Error("Element has a prefix but no namespace."); - } - if (!element[prefix] || !namespacePrefixes) { - return null; - } - const elementPrefix = namespacePrefixes.get(element[namespaceURI]); - if (elementPrefix) { - return elementPrefix; - } - const existingPrefixes = new Set(namespacePrefixes.values()); - if (existingPrefixes.has(element[prefix])) { - let i = 1; - while (existingPrefixes.has("n" + i)) { - i++; - } - namespacePrefixes.set(element[namespaceURI], "n" + i); - return "n" + i; - } - namespacePrefixes.set(element[namespaceURI], element[prefix]); - return element[prefix]; - } - #getAttributes(element, elementPrefix, inheritedDefaultNamespace, inheritedNamespacePrefixes) { - let attributeString = ""; - let namespaceString = ""; - const handledNamespaces = new Set; - for (const attribute of element[attributes][items].values()) { - if (attribute[namespaceURI] === NamespaceURI_default.xmlns) { - if (elementPrefix && attribute[localName] === elementPrefix && element[namespaceURI]) { - namespaceString += ` xmlns:${elementPrefix}="${XMLEncodeUtility.encodeXMLAttributeValue(element[namespaceURI])}"`; - handledNamespaces.add(element[namespaceURI]); - } else if (!elementPrefix && attribute[name] === "xmlns" && element[namespaceURI]) { - namespaceString += ` xmlns="${XMLEncodeUtility.encodeXMLAttributeValue(element[namespaceURI])}"`; - handledNamespaces.add(element[namespaceURI]); - } else { - namespaceString += ` ${attribute[name]}="${XMLEncodeUtility.encodeXMLAttributeValue(attribute[value])}"`; - handledNamespaces.add(attribute[value]); - } - } else { - attributeString += ` ${attribute[name]}="${XMLEncodeUtility.encodeXMLAttributeValue(attribute[value])}"`; - } - } - if (element[namespaceURI] && inheritedDefaultNamespace !== element[namespaceURI] && !handledNamespaces.has(element[namespaceURI])) { - if (elementPrefix && !inheritedNamespacePrefixes?.has(element[namespaceURI])) { - namespaceString += ` xmlns:${elementPrefix}="${XMLEncodeUtility.encodeXMLAttributeValue(element[namespaceURI])}"`; - } else if (!elementPrefix && inheritedDefaultNamespace !== element[namespaceURI]) { - namespaceString += ` xmlns="${XMLEncodeUtility.encodeXMLAttributeValue(element[namespaceURI])}"`; - } - } - return namespaceString + attributeString; - } -} - -// node_modules/happy-dom/lib/window/VMGlobalPropertyScript.js -import { Script } from "vm"; -var VMGlobalPropertyScript_default = new Script(` -this.ArrayBuffer = globalThis.ArrayBuffer; -this.Boolean = globalThis.Boolean; -this.DataView = globalThis.DataView; -this.Date = globalThis.Date; -this.Error = globalThis.Error; -this.EvalError = globalThis.EvalError; -this.Float32Array = globalThis.Float32Array; -this.Float64Array = globalThis.Float64Array; -this.GLOBAL = globalThis.GLOBAL; -this.Infinity = globalThis.Infinity; -this.Int16Array = globalThis.Int16Array; -this.Int32Array = globalThis.Int32Array; -this.Int8Array = globalThis.Int8Array; -this.Intl = globalThis.Intl; -this.JSON = globalThis.JSON; -this.Map = globalThis.Map; -this.Math = globalThis.Math; -this.NaN = globalThis.NaN; -this.Number = globalThis.Number; -this.Promise = globalThis.Promise; -this.RangeError = globalThis.RangeError; -this.ReferenceError = globalThis.ReferenceError; -this.RegExp = globalThis.RegExp; -this.Reflect = globalThis.Reflect; -this.Set = globalThis.Set; -this.Symbol = globalThis.Symbol; -this.SyntaxError = globalThis.SyntaxError; -this.String = globalThis.String; -this.TypeError = globalThis.TypeError; -this.URIError = globalThis.URIError; -this.Uint16Array = globalThis.Uint16Array; -this.Uint32Array = globalThis.Uint32Array; -this.Uint8Array = globalThis.Uint8Array; -this.Uint8ClampedArray = globalThis.Uint8ClampedArray; -this.WeakMap = globalThis.WeakMap; -this.WeakSet = globalThis.WeakSet; -this.decodeURI = globalThis.decodeURI; -this.decodeURIComponent = globalThis.decodeURIComponent; -this.encodeURI = globalThis.encodeURI; -this.encodeURIComponent = globalThis.encodeURIComponent; -this.eval = globalThis.eval; -this.escape = globalThis.escape; -this.global = globalThis.global; -this.isFinite = globalThis.isFinite; -this.isNaN = globalThis.isNaN; -this.parseFloat = globalThis.parseFloat; -this.parseInt = globalThis.parseInt; -this.root = globalThis.root; -this.undefined = globalThis.undefined; -this.unescape = globalThis.unescape; -this.AbortController = globalThis.AbortController; -this.AbortSignal = globalThis.AbortSignal; -this.Array = globalThis.Array; -this.Object = globalThis.Object; -this.Function = globalThis.Function; -`); - -// node_modules/happy-dom/lib/window/WindowPageOpenUtility.js -import { URL as URL12 } from "url"; -class WindowPageOpenUtility { - static openPage(browserFrame, options) { - const features = this.getWindowFeatures(options?.features || ""); - const target = options?.target !== undefined ? String(options.target) : null; - const originURL = new URL12(browserFrame.window.location.href); - const targetURL = BrowserFrameURL.getRelativeURL(browserFrame, options?.url); - const oldWindow = browserFrame.window; - let targetFrame; - if (browserFrame.window !== oldWindow) { - return null; - } - switch (target) { - case "_self": - targetFrame = browserFrame; - break; - case "_top": - targetFrame = browserFrame.page.mainFrame; - break; - case "_parent": - targetFrame = browserFrame.parentFrame ?? browserFrame; - break; - case "_blank": - default: - const newPage = browserFrame.page.context.newPage(); - targetFrame = newPage.mainFrame; - targetFrame[openerFrame] = browserFrame; - break; - } - targetFrame.goto(targetURL.href, { - referrer: features.noreferrer ? undefined : browserFrame.window.location.origin, - referrerPolicy: features.noreferrer ? "no-referrer" : undefined - }).catch((error) => { - targetFrame.page.console.error(error); - }); - if (targetURL.protocol === "javascript:") { - return targetFrame.window; - } - if (targetFrame === browserFrame && browserFrame.window === oldWindow) { - return null; - } - if (features.popup && target !== "_self" && target !== "_top" && target !== "_parent") { - targetFrame[popup] = true; - if (features?.width || features?.height) { - targetFrame.page.setViewport({ - width: features?.width, - height: features?.height - }); - } - if (features?.left) { - targetFrame.window.screenLeft = features.left; - targetFrame.window.screenX = features.left; - } - if (features?.top) { - targetFrame.window.screenTop = features.top; - targetFrame.window.screenY = features.top; - } - } - if (target && target !== "_self" && target !== "_top" && target !== "_parent" && target !== "_blank") { - targetFrame.window.name = target; - } - const isCORS = FetchCORSUtility.isCORS(originURL, targetFrame.url); - if (!features.noopener && !features.noreferrer && browserFrame.window && targetFrame[openerFrame] && targetFrame.window !== browserFrame.window) { - targetFrame[openerWindow] = isCORS ? new CrossOriginBrowserWindow(browserFrame.window) : browserFrame.window; - } - if (features.noopener || features.noreferrer) { - return null; - } - if (isCORS) { - return new CrossOriginBrowserWindow(targetFrame.window, browserFrame.window); - } - return targetFrame.window; - } - static getWindowFeatures(features) { - const parts = features.split(","); - const result = { - popup: false, - width: 0, - height: 0, - left: 0, - top: 0, - noopener: false, - noreferrer: false - }; - for (const part of parts) { - const [key, value] = part.split("="); - switch (key) { - case "popup": - result.popup = !value || value === "yes" || value === "1" || value === "true"; - break; - case "width": - case "innerWidth": - result.width = parseInt(value, 10); - break; - case "height": - case "innerHeight": - result.height = parseInt(value, 10); - break; - case "left": - case "screenX": - result.left = parseInt(value, 10); - break; - case "top": - case "screenY": - result.top = parseInt(value, 10); - break; - case "noopener": - result.noopener = true; - break; - case "noreferrer": - result.noreferrer = true; - break; - } - } - return result; - } -} - -// node_modules/happy-dom/lib/window/BrowserWindow.js -import { PerformanceObserver, PerformanceEntry } from "perf_hooks"; - -// node_modules/happy-dom/lib/dom-implementation/DOMImplementation.js -class DOMImplementation { - #document; - constructor(document) { - this.#document = document; - } - createDocument(_namespaceURI, qualifiedName, _docType) { - if (arguments.length < 2) { - throw new this.#document[window].TypeError(`Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only ${arguments.length} present.`); - } - qualifiedName = qualifiedName === null ? "" : String(qualifiedName); - switch (qualifiedName.split(":").pop()) { - case "svg": - case "xml": - return new this.#document[window].XMLDocument; - default: - return new this.#document[window].HTMLDocument; - } - } - createHTMLDocument() { - return new this.#document[window].HTMLDocument; - } - createDocumentType(qualifiedName, publicId2, systemId2) { - const documentType = NodeFactory.createNode(this.#document, DocumentType); - documentType[name] = qualifiedName; - documentType[publicId] = publicId2; - documentType[systemId] = systemId2; - return documentType; - } -} - -// node_modules/happy-dom/lib/nodes/document/VisibilityStateEnum.js -var VisibilityStateEnum; -(function(VisibilityStateEnum) { - VisibilityStateEnum["hidden"] = "hidden"; - VisibilityStateEnum["visible"] = "visible"; - VisibilityStateEnum["prerender"] = "prerender"; -})(VisibilityStateEnum || (VisibilityStateEnum = {})); -var VisibilityStateEnum_default = VisibilityStateEnum; - -// node_modules/happy-dom/lib/nodes/document/Document.js -var PROCESSING_INSTRUCTION_TARGET_REGEXP = /^[a-z][a-z0-9-]+$/; - -class Document extends Node { - [children] = null; - [activeElement] = null; - [nextActiveElement] = null; - [currentScript] = null; - [rootNode] = this; - [isFirstWrite] = true; - [isFirstWriteAfterOpen] = false; - [nodeType] = NodeTypeEnum_default.documentNode; - [isConnected] = true; - [adoptedStyleSheets] = []; - [implementation] = new DOMImplementation(this); - [readyState] = DocumentReadyStateEnum_default.interactive; - [referrer] = ""; - [defaultView] = null; - [forms] = null; - [links] = null; - [affectsComputedStyleCache] = []; - [ownerDocument] = null; - [elementIdMap] = new Map; - [contentType] = "text/html"; - [xmlProcessingInstruction] = null; - [preloads] = new Map; - [propertyEventListeners] = new Map; - [selection] = null; - get onreadystatechange() { - return this[propertyEventListeners].get("onreadystatechange") ?? null; - } - set onreadystatechange(value) { - this[propertyEventListeners].set("onreadystatechange", value); - } - get onpointerlockchange() { - return this[propertyEventListeners].get("onpointerlockchange") ?? null; - } - set onpointerlockchange(value) { - this[propertyEventListeners].set("onpointerlockchange", value); - } - get onpointerlockerror() { - return this[propertyEventListeners].get("onpointerlockerror") ?? null; - } - set onpointerlockerror(value) { - this[propertyEventListeners].set("onpointerlockerror", value); - } - get onbeforecopy() { - return this[propertyEventListeners].get("onbeforecopy") ?? null; - } - set onbeforecopy(value) { - this[propertyEventListeners].set("onbeforecopy", value); - } - get onbeforecut() { - return this[propertyEventListeners].get("onbeforecut") ?? null; - } - set onbeforecut(value) { - this[propertyEventListeners].set("onbeforecut", value); - } - get onbeforepaste() { - return this[propertyEventListeners].get("onbeforepaste") ?? null; - } - set onbeforepaste(value) { - this[propertyEventListeners].set("onbeforepaste", value); - } - get onfreeze() { - return this[propertyEventListeners].get("onfreeze") ?? null; - } - set onfreeze(value) { - this[propertyEventListeners].set("onfreeze", value); - } - get onprerenderingchange() { - return this[propertyEventListeners].get("onprerenderingchange") ?? null; - } - set onprerenderingchange(value) { - this[propertyEventListeners].set("onprerenderingchange", value); - } - get onresume() { - return this[propertyEventListeners].get("onresume") ?? null; - } - set onresume(value) { - this[propertyEventListeners].set("onresume", value); - } - get onsearch() { - return this[propertyEventListeners].get("onsearch") ?? null; - } - set onsearch(value) { - this[propertyEventListeners].set("onsearch", value); - } - get onvisibilitychange() { - return this[propertyEventListeners].get("onvisibilitychange") ?? null; - } - set onvisibilitychange(value) { - this[propertyEventListeners].set("onvisibilitychange", value); - } - get onfullscreenchange() { - return this[propertyEventListeners].get("onfullscreenchange") ?? null; - } - set onfullscreenchange(value) { - this[propertyEventListeners].set("onfullscreenchange", value); - } - get onfullscreenerror() { - return this[propertyEventListeners].get("onfullscreenerror") ?? null; - } - set onfullscreenerror(value) { - this[propertyEventListeners].set("onfullscreenerror", value); - } - get onwebkitfullscreenchange() { - return this[propertyEventListeners].get("onwebkitfullscreenchange") ?? null; - } - set onwebkitfullscreenchange(value) { - this[propertyEventListeners].set("onwebkitfullscreenchange", value); - } - get onwebkitfullscreenerror() { - return this[propertyEventListeners].get("onwebkitfullscreenerror") ?? null; - } - set onwebkitfullscreenerror(value) { - this[propertyEventListeners].set("onwebkitfullscreenerror", value); - } - get onbeforexrselect() { - return this[propertyEventListeners].get("onbeforexrselect") ?? null; - } - set onbeforexrselect(value) { - this[propertyEventListeners].set("onbeforexrselect", value); - } - get onabort() { - return this[propertyEventListeners].get("onabort") ?? null; - } - set onabort(value) { - this[propertyEventListeners].set("onabort", value); - } - get onbeforeinput() { - return this[propertyEventListeners].get("onbeforeinput") ?? null; - } - set onbeforeinput(value) { - this[propertyEventListeners].set("onbeforeinput", value); - } - get onbeforematch() { - return this[propertyEventListeners].get("onbeforematch") ?? null; - } - set onbeforematch(value) { - this[propertyEventListeners].set("onbeforematch", value); - } - get onbeforetoggle() { - return this[propertyEventListeners].get("onbeforetoggle") ?? null; - } - set onbeforetoggle(value) { - this[propertyEventListeners].set("onbeforetoggle", value); - } - get onblur() { - return this[propertyEventListeners].get("onblur") ?? null; - } - set onblur(value) { - this[propertyEventListeners].set("onblur", value); - } - get oncancel() { - return this[propertyEventListeners].get("oncancel") ?? null; - } - set oncancel(value) { - this[propertyEventListeners].set("oncancel", value); - } - get oncanplay() { - return this[propertyEventListeners].get("oncanplay") ?? null; - } - set oncanplay(value) { - this[propertyEventListeners].set("oncanplay", value); - } - get oncanplaythrough() { - return this[propertyEventListeners].get("oncanplaythrough") ?? null; - } - set oncanplaythrough(value) { - this[propertyEventListeners].set("oncanplaythrough", value); - } - get onchange() { - return this[propertyEventListeners].get("onchange") ?? null; - } - set onchange(value) { - this[propertyEventListeners].set("onchange", value); - } - get onclick() { - return this[propertyEventListeners].get("onclick") ?? null; - } - set onclick(value) { - this[propertyEventListeners].set("onclick", value); - } - get onclose() { - return this[propertyEventListeners].get("onclose") ?? null; - } - set onclose(value) { - this[propertyEventListeners].set("onclose", value); - } - get oncontentvisibilityautostatechange() { - return this[propertyEventListeners].get("oncontentvisibilityautostatechange") ?? null; - } - set oncontentvisibilityautostatechange(value) { - this[propertyEventListeners].set("oncontentvisibilityautostatechange", value); - } - get oncontextlost() { - return this[propertyEventListeners].get("oncontextlost") ?? null; - } - set oncontextlost(value) { - this[propertyEventListeners].set("oncontextlost", value); - } - get oncontextmenu() { - return this[propertyEventListeners].get("oncontextmenu") ?? null; - } - set oncontextmenu(value) { - this[propertyEventListeners].set("oncontextmenu", value); - } - get oncontextrestored() { - return this[propertyEventListeners].get("oncontextrestored") ?? null; - } - set oncontextrestored(value) { - this[propertyEventListeners].set("oncontextrestored", value); - } - get oncuechange() { - return this[propertyEventListeners].get("oncuechange") ?? null; - } - set oncuechange(value) { - this[propertyEventListeners].set("oncuechange", value); - } - get ondblclick() { - return this[propertyEventListeners].get("ondblclick") ?? null; - } - set ondblclick(value) { - this[propertyEventListeners].set("ondblclick", value); - } - get ondrag() { - return this[propertyEventListeners].get("ondrag") ?? null; - } - set ondrag(value) { - this[propertyEventListeners].set("ondrag", value); - } - get ondragend() { - return this[propertyEventListeners].get("ondragend") ?? null; - } - set ondragend(value) { - this[propertyEventListeners].set("ondragend", value); - } - get ondragenter() { - return this[propertyEventListeners].get("ondragenter") ?? null; - } - set ondragenter(value) { - this[propertyEventListeners].set("ondragenter", value); - } - get ondragleave() { - return this[propertyEventListeners].get("ondragleave") ?? null; - } - set ondragleave(value) { - this[propertyEventListeners].set("ondragleave", value); - } - get ondragover() { - return this[propertyEventListeners].get("ondragover") ?? null; - } - set ondragover(value) { - this[propertyEventListeners].set("ondragover", value); - } - get ondragstart() { - return this[propertyEventListeners].get("ondragstart") ?? null; - } - set ondragstart(value) { - this[propertyEventListeners].set("ondragstart", value); - } - get ondrop() { - return this[propertyEventListeners].get("ondrop") ?? null; - } - set ondrop(value) { - this[propertyEventListeners].set("ondrop", value); - } - get ondurationchange() { - return this[propertyEventListeners].get("ondurationchange") ?? null; - } - set ondurationchange(value) { - this[propertyEventListeners].set("ondurationchange", value); - } - get onemptied() { - return this[propertyEventListeners].get("onemptied") ?? null; - } - set onemptied(value) { - this[propertyEventListeners].set("onemptied", value); - } - get onended() { - return this[propertyEventListeners].get("onended") ?? null; - } - set onended(value) { - this[propertyEventListeners].set("onended", value); - } - get onerror() { - return this[propertyEventListeners].get("onerror") ?? null; - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onfocus() { - return this[propertyEventListeners].get("onfocus") ?? null; - } - set onfocus(value) { - this[propertyEventListeners].set("onfocus", value); - } - get onformdata() { - return this[propertyEventListeners].get("onformdata") ?? null; - } - set onformdata(value) { - this[propertyEventListeners].set("onformdata", value); - } - get oninput() { - return this[propertyEventListeners].get("oninput") ?? null; - } - set oninput(value) { - this[propertyEventListeners].set("oninput", value); - } - get oninvalid() { - return this[propertyEventListeners].get("oninvalid") ?? null; - } - set oninvalid(value) { - this[propertyEventListeners].set("oninvalid", value); - } - get onkeydown() { - return this[propertyEventListeners].get("onkeydown") ?? null; - } - set onkeydown(value) { - this[propertyEventListeners].set("onkeydown", value); - } - get onkeypress() { - return this[propertyEventListeners].get("onkeypress") ?? null; - } - set onkeypress(value) { - this[propertyEventListeners].set("onkeypress", value); - } - get onkeyup() { - return this[propertyEventListeners].get("onkeyup") ?? null; - } - set onkeyup(value) { - this[propertyEventListeners].set("onkeyup", value); - } - get onload() { - return this[propertyEventListeners].get("onload") ?? null; - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get onloadeddata() { - return this[propertyEventListeners].get("onloadeddata") ?? null; - } - set onloadeddata(value) { - this[propertyEventListeners].set("onloadeddata", value); - } - get onloadedmetadata() { - return this[propertyEventListeners].get("onloadedmetadata") ?? null; - } - set onloadedmetadata(value) { - this[propertyEventListeners].set("onloadedmetadata", value); - } - get onloadstart() { - return this[propertyEventListeners].get("onloadstart") ?? null; - } - set onloadstart(value) { - this[propertyEventListeners].set("onloadstart", value); - } - get onmousedown() { - return this[propertyEventListeners].get("onmousedown") ?? null; - } - set onmousedown(value) { - this[propertyEventListeners].set("onmousedown", value); - } - get onmouseenter() { - return this[propertyEventListeners].get("onmouseenter") ?? null; - } - set onmouseenter(value) { - this[propertyEventListeners].set("onmouseenter", value); - } - get onmouseleave() { - return this[propertyEventListeners].get("onmouseleave") ?? null; - } - set onmouseleave(value) { - this[propertyEventListeners].set("onmouseleave", value); - } - get onmousemove() { - return this[propertyEventListeners].get("onmousemove") ?? null; - } - set onmousemove(value) { - this[propertyEventListeners].set("onmousemove", value); - } - get onmouseout() { - return this[propertyEventListeners].get("onmouseout") ?? null; - } - set onmouseout(value) { - this[propertyEventListeners].set("onmouseout", value); - } - get onmouseover() { - return this[propertyEventListeners].get("onmouseover") ?? null; - } - set onmouseover(value) { - this[propertyEventListeners].set("onmouseover", value); - } - get onmouseup() { - return this[propertyEventListeners].get("onmouseup") ?? null; - } - set onmouseup(value) { - this[propertyEventListeners].set("onmouseup", value); - } - get onmousewheel() { - return this[propertyEventListeners].get("onmousewheel") ?? null; - } - set onmousewheel(value) { - this[propertyEventListeners].set("onmousewheel", value); - } - get onpause() { - return this[propertyEventListeners].get("onpause") ?? null; - } - set onpause(value) { - this[propertyEventListeners].set("onpause", value); - } - get onplay() { - return this[propertyEventListeners].get("onplay") ?? null; - } - set onplay(value) { - this[propertyEventListeners].set("onplay", value); - } - get onplaying() { - return this[propertyEventListeners].get("onplaying") ?? null; - } - set onplaying(value) { - this[propertyEventListeners].set("onplaying", value); - } - get onprogress() { - return this[propertyEventListeners].get("onprogress") ?? null; - } - set onprogress(value) { - this[propertyEventListeners].set("onprogress", value); - } - get onratechange() { - return this[propertyEventListeners].get("onratechange") ?? null; - } - set onratechange(value) { - this[propertyEventListeners].set("onratechange", value); - } - get onreset() { - return this[propertyEventListeners].get("onreset") ?? null; - } - set onreset(value) { - this[propertyEventListeners].set("onreset", value); - } - get onresize() { - return this[propertyEventListeners].get("onresize") ?? null; - } - set onresize(value) { - this[propertyEventListeners].set("onresize", value); - } - get onscroll() { - return this[propertyEventListeners].get("onscroll") ?? null; - } - set onscroll(value) { - this[propertyEventListeners].set("onscroll", value); - } - get onsecuritypolicyviolation() { - return this[propertyEventListeners].get("onsecuritypolicyviolation") ?? null; - } - set onsecuritypolicyviolation(value) { - this[propertyEventListeners].set("onsecuritypolicyviolation", value); - } - get onseeked() { - return this[propertyEventListeners].get("onseeked") ?? null; - } - set onseeked(value) { - this[propertyEventListeners].set("onseeked", value); - } - get onseeking() { - return this[propertyEventListeners].get("onseeking") ?? null; - } - set onseeking(value) { - this[propertyEventListeners].set("onseeking", value); - } - get onselect() { - return this[propertyEventListeners].get("onselect") ?? null; - } - set onselect(value) { - this[propertyEventListeners].set("onselect", value); - } - get onslotchange() { - return this[propertyEventListeners].get("onslotchange") ?? null; - } - set onslotchange(value) { - this[propertyEventListeners].set("onslotchange", value); - } - get onstalled() { - return this[propertyEventListeners].get("onstalled") ?? null; - } - set onstalled(value) { - this[propertyEventListeners].set("onstalled", value); - } - get onsubmit() { - return this[propertyEventListeners].get("onsubmit") ?? null; - } - set onsubmit(value) { - this[propertyEventListeners].set("onsubmit", value); - } - get onsuspend() { - return this[propertyEventListeners].get("onsuspend") ?? null; - } - set onsuspend(value) { - this[propertyEventListeners].set("onsuspend", value); - } - get ontimeupdate() { - return this[propertyEventListeners].get("ontimeupdate") ?? null; - } - set ontimeupdate(value) { - this[propertyEventListeners].set("ontimeupdate", value); - } - get ontoggle() { - return this[propertyEventListeners].get("ontoggle") ?? null; - } - set ontoggle(value) { - this[propertyEventListeners].set("ontoggle", value); - } - get onvolumechange() { - return this[propertyEventListeners].get("onvolumechange") ?? null; - } - set onvolumechange(value) { - this[propertyEventListeners].set("onvolumechange", value); - } - get onwaiting() { - return this[propertyEventListeners].get("onwaiting") ?? null; - } - set onwaiting(value) { - this[propertyEventListeners].set("onwaiting", value); - } - get onwebkitanimationend() { - return this[propertyEventListeners].get("onwebkitanimationend") ?? null; - } - set onwebkitanimationend(value) { - this[propertyEventListeners].set("onwebkitanimationend", value); - } - get onwebkitanimationiteration() { - return this[propertyEventListeners].get("onwebkitanimationiteration") ?? null; - } - set onwebkitanimationiteration(value) { - this[propertyEventListeners].set("onwebkitanimationiteration", value); - } - get onwebkitanimationstart() { - return this[propertyEventListeners].get("onwebkitanimationstart") ?? null; - } - set onwebkitanimationstart(value) { - this[propertyEventListeners].set("onwebkitanimationstart", value); - } - get onwebkittransitionend() { - return this[propertyEventListeners].get("onwebkittransitionend") ?? null; - } - set onwebkittransitionend(value) { - this[propertyEventListeners].set("onwebkittransitionend", value); - } - get onwheel() { - return this[propertyEventListeners].get("onwheel") ?? null; - } - set onwheel(value) { - this[propertyEventListeners].set("onwheel", value); - } - get onauxclick() { - return this[propertyEventListeners].get("onauxclick") ?? null; - } - set onauxclick(value) { - this[propertyEventListeners].set("onauxclick", value); - } - get ongotpointercapture() { - return this[propertyEventListeners].get("ongotpointercapture") ?? null; - } - set ongotpointercapture(value) { - this[propertyEventListeners].set("ongotpointercapture", value); - } - get onlostpointercapture() { - return this[propertyEventListeners].get("onlostpointercapture") ?? null; - } - set onlostpointercapture(value) { - this[propertyEventListeners].set("onlostpointercapture", value); - } - get onpointerdown() { - return this[propertyEventListeners].get("onpointerdown") ?? null; - } - set onpointerdown(value) { - this[propertyEventListeners].set("onpointerdown", value); - } - get onpointermove() { - return this[propertyEventListeners].get("onpointermove") ?? null; - } - set onpointermove(value) { - this[propertyEventListeners].set("onpointermove", value); - } - get onpointerrawupdate() { - return this[propertyEventListeners].get("onpointerrawupdate") ?? null; - } - set onpointerrawupdate(value) { - this[propertyEventListeners].set("onpointerrawupdate", value); - } - get onpointerup() { - return this[propertyEventListeners].get("onpointerup") ?? null; - } - set onpointerup(value) { - this[propertyEventListeners].set("onpointerup", value); - } - get onpointercancel() { - return this[propertyEventListeners].get("onpointercancel") ?? null; - } - set onpointercancel(value) { - this[propertyEventListeners].set("onpointercancel", value); - } - get onpointerover() { - return this[propertyEventListeners].get("onpointerover") ?? null; - } - set onpointerover(value) { - this[propertyEventListeners].set("onpointerover", value); - } - get onpointerout() { - return this[propertyEventListeners].get("onpointerout") ?? null; - } - set onpointerout(value) { - this[propertyEventListeners].set("onpointerout", value); - } - get onpointerenter() { - return this[propertyEventListeners].get("onpointerenter") ?? null; - } - set onpointerenter(value) { - this[propertyEventListeners].set("onpointerenter", value); - } - get onpointerleave() { - return this[propertyEventListeners].get("onpointerleave") ?? null; - } - set onpointerleave(value) { - this[propertyEventListeners].set("onpointerleave", value); - } - get onselectstart() { - return this[propertyEventListeners].get("onselectstart") ?? null; - } - set onselectstart(value) { - this[propertyEventListeners].set("onselectstart", value); - } - get onselectionchange() { - return this[propertyEventListeners].get("onselectionchange") ?? null; - } - set onselectionchange(value) { - this[propertyEventListeners].set("onselectionchange", value); - } - get onanimationend() { - return this[propertyEventListeners].get("onanimationend") ?? null; - } - set onanimationend(value) { - this[propertyEventListeners].set("onanimationend", value); - } - get onanimationiteration() { - return this[propertyEventListeners].get("onanimationiteration") ?? null; - } - set onanimationiteration(value) { - this[propertyEventListeners].set("onanimationiteration", value); - } - get onanimationstart() { - return this[propertyEventListeners].get("onanimationstart") ?? null; - } - set onanimationstart(value) { - this[propertyEventListeners].set("onanimationstart", value); - } - get ontransitionrun() { - return this[propertyEventListeners].get("ontransitionrun") ?? null; - } - set ontransitionrun(value) { - this[propertyEventListeners].set("ontransitionrun", value); - } - get ontransitionstart() { - return this[propertyEventListeners].get("ontransitionstart") ?? null; - } - set ontransitionstart(value) { - this[propertyEventListeners].set("ontransitionstart", value); - } - get ontransitionend() { - return this[propertyEventListeners].get("ontransitionend") ?? null; - } - set ontransitionend(value) { - this[propertyEventListeners].set("ontransitionend", value); - } - get ontransitioncancel() { - return this[propertyEventListeners].get("ontransitioncancel") ?? null; - } - set ontransitioncancel(value) { - this[propertyEventListeners].set("ontransitioncancel", value); - } - get oncopy() { - return this[propertyEventListeners].get("oncopy") ?? null; - } - set oncopy(value) { - this[propertyEventListeners].set("oncopy", value); - } - get oncut() { - return this[propertyEventListeners].get("oncut") ?? null; - } - set oncut(value) { - this[propertyEventListeners].set("oncut", value); - } - get onpaste() { - return this[propertyEventListeners].get("onpaste") ?? null; - } - set onpaste(value) { - this[propertyEventListeners].set("onpaste", value); - } - get onscrollend() { - return this[propertyEventListeners].get("onscrollend") ?? null; - } - set onscrollend(value) { - this[propertyEventListeners].set("onscrollend", value); - } - get onscrollsnapchange() { - return this[propertyEventListeners].get("onscrollsnapchange") ?? null; - } - set onscrollsnapchange(value) { - this[propertyEventListeners].set("onscrollsnapchange", value); - } - get onscrollsnapchanging() { - return this[propertyEventListeners].get("onscrollsnapchanging") ?? null; - } - set onscrollsnapchanging(value) { - this[propertyEventListeners].set("onscrollsnapchanging", value); - } - get adoptedStyleSheets() { - return this[adoptedStyleSheets]; - } - set adoptedStyleSheets(value) { - this[adoptedStyleSheets] = value; - } - get implementation() { - return this[implementation]; - } - get readyState() { - return this[readyState]; - } - get referrer() { - return this[referrer]; - } - get defaultView() { - return this[defaultView]; - } - get children() { - if (!this[children]) { - const elements = this[elementArray]; - this[children] = new HTMLCollection(illegalConstructor, () => elements); - } - return this[children]; - } - get charset() { - return this.characterSet; - } - get characterSet() { - const charset = QuerySelector.querySelector(this, "meta[charset]")?.getAttributeNS(null, "charset"); - return charset ? charset : "UTF-8"; - } - get title() { - const element = ParentNodeUtility.getElementByTagName(this, "title"); - if (element) { - return element.text.trim(); - } - return ""; - } - set title(title) { - const element = ParentNodeUtility.getElementByTagName(this, "title"); - if (element) { - element.textContent = title; - } else { - const newElement = this.createElement("title"); - newElement.textContent = title; - this.head.appendChild(newElement); - } - } - get links() { - if (!this[links]) { - this[links] = new HTMLCollection(illegalConstructor, () => QuerySelector.querySelectorAll(this, "a[href],area[href]")[items]); - } - return this[links]; - } - get forms() { - if (!this[forms]) { - this[forms] = ParentNodeUtility.getElementsByTagName(this, "form"); - } - return this[forms]; - } - get childElementCount() { - return this[elementArray].length; - } - get firstElementChild() { - return this[elementArray][0] ?? null; - } - get lastElementChild() { - const children2 = this[elementArray]; - return children2[children2.length - 1] ?? null; - } - get cookie() { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - return ""; - } - return CookieStringUtility.cookiesToString(browserFrame.page.context.cookieContainer.getCookies(this[window].location, true)); - } - set cookie(value) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame) { - return; - } - const cookie = CookieStringUtility.stringToCookie(this[window].location, value); - if (cookie) { - browserFrame.page.context.cookieContainer.addCookies([cookie]); - } - } - get nodeName() { - return "#document"; - } - get documentElement() { - return this[elementArray][0] ?? null; - } - get doctype() { - for (const node of this[nodeArray]) { - if (node instanceof DocumentType) { - return node; - } - } - return null; - } - get body() { - const documentElement = this.documentElement; - return documentElement ? ParentNodeUtility.getElementByTagName(documentElement, "body") : null; - } - get head() { - const documentElement = this.documentElement; - return documentElement ? ParentNodeUtility.getElementByTagName(documentElement, "head") : null; - } - get styleSheets() { - const styles = QuerySelector.querySelectorAll(this, 'link[rel="stylesheet"][href],style'); - const styleSheets = []; - for (const style of styles) { - const sheet = style.sheet; - if (sheet) { - styleSheets.push(sheet); - } - } - return styleSheets; - } - get activeElement() { - if (this[activeElement] && !this[activeElement][isConnected]) { - this[activeElement] = null; - } - if (this[activeElement]) { - let rootNode2 = this[activeElement].getRootNode(); - let activeElement2 = this[activeElement]; - while (rootNode2 !== this) { - activeElement2 = rootNode2.host; - rootNode2 = activeElement2 ? activeElement2.getRootNode() : this; - } - return activeElement2; - } - return this[activeElement] || this.body || this.documentElement || null; - } - get scrollingElement() { - return this.documentElement; - } - get location() { - return this[window].location; - } - get scripts() { - return this.getElementsByTagName("script"); - } - get baseURI() { - const element = ParentNodeUtility.getElementByTagName(this, "base"); - if (element) { - return element.href; - } - return this[window].location.href; - } - get URL() { - return this[window].location.href; - } - get documentURI() { - return this.URL; - } - get domain() { - return this[window].location.hostname; - } - get visibilityState() { - if (this.defaultView) { - return VisibilityStateEnum_default.visible; - } - return VisibilityStateEnum_default.hidden; - } - get hidden() { - if (this.defaultView) { - return false; - } - return true; - } - get currentScript() { - return this[currentScript]; - } - get contentType() { - return this[contentType]; - } - append(...nodes) { - ParentNodeUtility.append(this, ...nodes); - } - prepend(...nodes) { - ParentNodeUtility.prepend(this, ...nodes); - } - replaceChildren(...nodes) { - ParentNodeUtility.replaceChildren(this, ...nodes); - } - querySelectorAll(selector) { - return QuerySelector.querySelectorAll(this, selector); - } - querySelector(selector) { - return QuerySelector.querySelector(this, selector); - } - queryCommandSupported(_) { - if (!arguments.length) { - throw new this[window].TypeError("Failed to execute 'queryCommandSupported' on 'Document': 1 argument required, but only 0 present."); - } - return true; - } - getElementsByClassName(className) { - return ParentNodeUtility.getElementsByClassName(this, className); - } - getElementsByTagName(tagName) { - return ParentNodeUtility.getElementsByTagName(this, tagName); - } - getElementsByTagNameNS(namespaceURI, tagName) { - return ParentNodeUtility.getElementsByTagNameNS(this, namespaceURI, tagName); - } - getElementById(id) { - return ParentNodeUtility.getElementById(this, id); - } - getElementsByName(name) { - return QuerySelector.querySelectorAll(this, `[name="${name}"]`); - } - write(html) { - if (this[isFirstWrite] || this[isFirstWriteAfterOpen]) { - if (this[isFirstWrite]) { - if (!this[isFirstWriteAfterOpen]) { - this.open(); - } - this[isFirstWrite] = false; - } - const { documentElement, head, body } = this; - if (!documentElement || !head || !body) { - this.open(); - } - this[isFirstWrite] = false; - this[isFirstWriteAfterOpen] = false; - new HTMLParser(this[window], { - evaluateScripts: true - }).parse(html, this); - } else { - new HTMLParser(this[window], { - evaluateScripts: true - }).parse(html, this.body); - } - } - open() { - this[isFirstWriteAfterOpen] = true; - for (const eventType of this[listeners].bubbling.keys()) { - const listeners2 = this[listeners].bubbling.get(eventType); - if (listeners2) { - for (const listener of listeners2) { - this.removeEventListener(eventType, listener); - } - } - } - for (const eventType of this[listeners].capturing.keys()) { - const listeners2 = this[listeners].capturing.get(eventType); - if (listeners2) { - for (const listener of listeners2) { - this.removeEventListener(eventType, listener); - } - } - } - const childNodes = this[nodeArray]; - while (childNodes.length) { - this.removeChild(childNodes[0]); - } - const doctype = this[implementation].createDocumentType("html", "", ""); - const documentElement = this.createElement("html"); - const bodyElement = this.createElement("body"); - const headElement = this.createElement("head"); - this.appendChild(doctype); - this.appendChild(documentElement); - documentElement.appendChild(headElement); - documentElement.appendChild(bodyElement); - return this; - } - close() {} - createElement(qualifiedName, options) { - return this.createElementNS(NamespaceURI_default.html, StringUtility.asciiLowerCase(String(qualifiedName)), options); - } - createElementNS(namespaceURI2, qualifiedName, options) { - const window2 = this[window]; - qualifiedName = String(qualifiedName); - if (!qualifiedName) { - throw new window2.DOMException("Failed to execute 'createElementNS' on 'Document': The qualified name provided is empty."); - } - const parts = qualifiedName.split(":"); - const localName2 = parts[1] ?? parts[0]; - const prefix2 = parts[1] ? parts[0] : null; - switch (namespaceURI2) { - case NamespaceURI_default.svg: - const config = SVGElementConfig_default[qualifiedName.toLowerCase()]; - const svgElementClass = config && config.localName === qualifiedName ? window2[config.className] : window2.SVGElement; - const svgElement = NodeFactory.createNode(this, svgElementClass); - svgElement[tagName] = qualifiedName; - svgElement[localName] = localName2; - svgElement[prefix] = prefix2; - svgElement[namespaceURI] = namespaceURI2; - svgElement[isValue] = options && options.is ? String(options.is) : null; - return svgElement; - case NamespaceURI_default.html: - const customElementDefinition = window2.customElements[registry]?.get(options && options.is ? String(options.is) : qualifiedName); - if (customElementDefinition) { - const element = new customElementDefinition.elementClass; - element[tagName] = StringUtility.asciiUpperCase(qualifiedName); - element[localName] = localName2; - element[prefix] = prefix2; - element[namespaceURI] = namespaceURI2; - element[isValue] = options && options.is ? String(options.is) : null; - return element; - } - const elementClass = HTMLElementConfig_default[qualifiedName] ? window2[HTMLElementConfig_default[qualifiedName].className] : null; - if (elementClass) { - const element = NodeFactory.createNode(this, elementClass); - element[tagName] = StringUtility.asciiUpperCase(qualifiedName); - element[localName] = localName2; - element[prefix] = prefix2; - element[namespaceURI] = namespaceURI2; - element[isValue] = options && options.is ? String(options.is) : null; - return element; - } - const unknownElementClass = qualifiedName.includes("-") ? window2.HTMLElement : window2.HTMLUnknownElement; - const unknownElement = NodeFactory.createNode(this, unknownElementClass); - unknownElement[tagName] = StringUtility.asciiUpperCase(qualifiedName); - unknownElement[localName] = localName2; - unknownElement[prefix] = prefix2; - unknownElement[namespaceURI] = namespaceURI2; - unknownElement[isValue] = options && options.is ? String(options.is) : null; - return unknownElement; - default: - const element = NodeFactory.createNode(this, Element); - element[tagName] = qualifiedName; - element[localName] = localName2; - element[prefix] = prefix2; - element[namespaceURI] = namespaceURI2; - element[isValue] = options && options.is ? String(options.is) : null; - return element; - } - } - createTextNode(data) { - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'createTextNode' on 'Document': 1 argument required, but only ${arguments.length} present.`); - } - return NodeFactory.createNode(this, this[window].Text, String(data)); - } - createComment(data) { - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'createComment' on 'Document': 1 argument required, but only ${arguments.length} present.`); - } - return NodeFactory.createNode(this, this[window].Comment, String(data)); - } - createDocumentFragment() { - return NodeFactory.createNode(this, this[window].DocumentFragment); - } - createNodeIterator(root, whatToShow = -1, filter = null) { - return new NodeIterator(root, whatToShow, filter); - } - createTreeWalker(root, whatToShow = -1, filter = null) { - return new TreeWalker(root, whatToShow, filter); - } - createEvent(type) { - if (typeof this[window][type] === "function") { - return new this[window][type]("init"); - } - return new Event("init"); - } - createAttribute(qualifiedName) { - const attribute = NodeFactory.createNode(this, this[window].Attr); - const name2 = StringUtility.asciiLowerCase(qualifiedName); - const parts = name2.split(":"); - attribute[name] = name2; - attribute[localName] = parts[1] ?? name2; - attribute[prefix] = parts[1] ? parts[0] : null; - return attribute; - } - createAttributeNS(namespaceURI2, qualifiedName) { - const attribute = NodeFactory.createNode(this, this[window].Attr); - const parts = qualifiedName.split(":"); - attribute[namespaceURI] = namespaceURI2; - attribute[name] = qualifiedName; - attribute[localName] = parts[1] ?? qualifiedName; - attribute[prefix] = parts[1] ? parts[0] : null; - if (!namespaceURI2 && attribute[prefix]) { - throw new this[window].DOMException(`Failed to execute 'createAttributeNS' on 'Document': The namespace URI provided ('${namespaceURI2 || ""}') is not valid for the qualified name provided ('${qualifiedName}').`, DOMExceptionNameEnum_default.namespaceError); - } - return attribute; - } - importNode(node, deep = false) { - if (!(node instanceof Node)) { - throw new this[window].DOMException("Parameter 1 was not of type Node."); - } - const clone = node.cloneNode(deep); - this.#importNode(clone); - return clone; - } - createRange() { - return new this[window].Range; - } - adoptNode(node) { - if (!(node instanceof Node)) { - throw new this[window].DOMException("Parameter 1 was not of type Node."); - } - const adopted = node[parentNode] ? node[parentNode].removeChild(node) : node; - const document = this; - Object.defineProperty(adopted, "ownerDocument", { value: document }); - return adopted; - } - getSelection() { - if (!this[selection]) { - this[selection] = new Selection(this); - } - return this[selection]; - } - hasFocus() { - return !!this.activeElement; - } - createProcessingInstruction(target2, data2) { - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'createProcessingInstruction' on 'Document': 2 arguments required, but only ${arguments.length} present.`); - } - target2 = String(target2); - data2 = String(data2); - if (!target2 || !PROCESSING_INSTRUCTION_TARGET_REGEXP.test(target2)) { - throw new this[window].DOMException(`Failed to execute 'createProcessingInstruction' on 'Document': The target provided ('${target2}') is not a valid name.`); - } - if (data2.includes("?>")) { - throw new this[window].DOMException(`Failed to execute 'createProcessingInstruction' on 'Document': The data provided ('?>') contains '?>'`); - } - const element = NodeFactory.createNode(this, this[window].ProcessingInstruction); - element[data] = data2; - element[target] = target2; - return element; - } - elementFromPoint(_x, _y) { - return null; - } - [destroy]() { - super[destroy](); - this[children] = null; - this[activeElement] = null; - this[nextActiveElement] = null; - this[currentScript] = null; - this[defaultView] = null; - this[adoptedStyleSheets] = []; - this[forms] = null; - this[links] = null; - this[affectsComputedStyleCache] = []; - this[elementIdMap].clear(); - this[xmlProcessingInstruction] = null; - this[preloads].clear(); - this[propertyEventListeners].clear(); - this[selection] = null; - } - #importNode(node) { - node[ownerDocument] = this; - for (const child of node[nodeArray]) { - this.#importNode(child); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-document/HTMLDocument.js -class HTMLDocument extends Document { - constructor() { - super(); - const documentElement = this.createElement("html"); - const bodyElement = this.createElement("body"); - const headElement = this.createElement("head"); - this.appendChild(documentElement); - documentElement.appendChild(headElement); - documentElement.appendChild(bodyElement); - } - [appendChild](node, disableValidations = false) { - if (node[nodeType] === NodeTypeEnum_default.textNode) { - throw new this[window].Error(`Failed to execute 'appendChild' on 'Node': Nodes of type '#text' may not be inserted inside nodes of type '#document'.`); - } - if (node[nodeType] === NodeTypeEnum_default.documentFragmentNode) { - return node; - } - if (node[nodeType] === NodeTypeEnum_default.elementNode && this[elementArray].length !== 0) { - throw new this[window].Error(`Failed to execute 'appendChild' on 'Node': Only one element on document allowed.`); - } - return super[appendChild](node, disableValidations); - } - [insertBefore](newNode, referenceNode, disableValidations = false) { - if (newNode[nodeType] === NodeTypeEnum_default.textNode) { - throw new this[window].Error(`Failed to execute 'insertBefore' on 'Node': Nodes of type '#text' may not be inserted inside nodes of type '#document'.`); - } - if (newNode[nodeType] === NodeTypeEnum_default.documentFragmentNode) { - return newNode; - } - if (newNode[nodeType] === NodeTypeEnum_default.elementNode && this[elementArray].length !== 0) { - throw new this[window].Error(`Failed to execute 'insertBefore' on 'Node': Only one element on document allowed.`); - } - return super[insertBefore](newNode, referenceNode, disableValidations); - } -} - -// node_modules/happy-dom/lib/nodes/xml-document/XMLDocument.js -class XMLDocument extends Document { - [contentType] = "application/xml"; -} - -// node_modules/happy-dom/lib/nodes/text/Text.js -class Text extends CharacterData { - [nodeType] = NodeTypeEnum_default.textNode; - [textAreaNode] = null; - [styleNode] = null; - get nodeName() { - return "#text"; - } - get wholeText() { - if (!this[parentNode]) { - return this[data]; - } - let text = ""; - for (let node = this.previousSibling;NodeUtility.isTextNode(node); node = node.previousSibling) { - text = node.data + text; - } - text += this[data]; - for (let node = this.nextSibling;NodeUtility.isTextNode(node); node = node.nextSibling) { - text += node.data; - } - return text; - } - get data() { - return this[data]; - } - set data(data) { - super.data = data; - if (this[textAreaNode]) { - this[textAreaNode][resetSelection](); - } - if (this[styleNode]) { - this[styleNode][updateSheet](); - } - } - splitText(offset) { - const length = this[data].length; - if (offset < 0 || offset > length) { - throw new this[window].DOMException("The index is not in the allowed range.", DOMExceptionNameEnum_default.indexSizeError); - } - const count = length - offset; - const newData = this.substringData(offset, count); - const newNode = this[ownerDocument].createTextNode(newData); - if (this[parentNode] !== null) { - this[parentNode].insertBefore(newNode, this.nextSibling); - } - this.replaceData(offset, count, ""); - return newNode; - } - toString() { - return "[object Text]"; - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } - [connectedToNode]() { - super[connectedToNode](); - if (this[textAreaNode]) { - this[textAreaNode][resetSelection](); - } - if (this[styleNode] && this[data]) { - this[styleNode][updateSheet](); - } - } - [disconnectedFromNode]() { - if (this[textAreaNode]) { - this[textAreaNode][resetSelection](); - } - if (this[styleNode] && this[data]) { - this[styleNode][updateSheet](); - } - super[disconnectedFromNode](); - } -} - -// node_modules/happy-dom/lib/nodes/comment/Comment.js -class Comment extends CharacterData { - [nodeType] = NodeTypeEnum_default.commentNode; - get nodeName() { - return "#comment"; - } - toString() { - return "[object Comment]"; - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } -} - -// node_modules/happy-dom/lib/nodes/html-image-element/Image.js -class Image extends HTMLImageElement { - [tagName] = "IMG"; - [localName] = "img"; - [namespaceURI] = NamespaceURI_default.html; - constructor(width = null, height = null) { - super(); - if (width !== null) { - this.width = width; - } - if (height !== null) { - this.height = height; - } - } -} - -// node_modules/happy-dom/lib/nodes/html-audio-element/Audio.js -class Audio extends HTMLAudioElement { - [tagName] = "AUDIO"; - [localName] = "audio"; - [namespaceURI] = NamespaceURI_default.html; - constructor(url = null) { - super(); - if (url !== null) { - this.src = url; - } - } -} - -// node_modules/happy-dom/lib/mutation-observer/MutationObserverListener.js -class MutationObserverListener { - target; - options; - mutationListener; - #window; - #observer; - #callback; - #records = []; - #destroyed = false; - #microtaskQueued = false; - #listenerCallback; - constructor(init) { - this.options = init.options; - this.target = init.target; - this.#listenerCallback = (record) => this.report(record); - this.mutationListener = { - options: init.options, - callback: new WeakRef(this.#listenerCallback) - }; - this.#window = init.window; - this.#observer = init.observer; - this.#callback = init.callback; - } - report(record) { - if (this.#destroyed) { - return; - } - this.#records.push(record); - if (this.#microtaskQueued) { - return; - } - this.#window.queueMicrotask(() => { - if (this.#destroyed) { - return; - } - this.#microtaskQueued = false; - const records = this.#records; - if (records?.length > 0) { - this.#records = []; - this.#callback(records, this.#observer); - } - }); - this.#microtaskQueued = true; - } - takeRecords() { - if (this.#destroyed) { - return []; - } - const records = this.#records; - this.#records = []; - return records; - } - destroy() { - if (this.#destroyed) { - return; - } - this.#destroyed = true; - this.options = null; - this.target = null; - this.#listenerCallback = null; - this.mutationListener = null; - this.#window = null; - this.#observer = null; - this.#callback = null; - this.#records = null; - } -} - -// node_modules/happy-dom/lib/mutation-observer/MutationObserver.js -class MutationObserver { - #callback; - #listeners = []; - #destroyed = false; - constructor(callback) { - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - this.#callback = callback; - } - observe(target, options) { - if (this.#destroyed) { - return; - } - if (!target) { - throw new this[window].TypeError(`Failed to execute 'observe' on 'MutationObserver': The first parameter "target" should be of type "Node".`); - } - if (options && (options.attributeFilter || options.attributeOldValue)) { - if (options.attributes === undefined) { - options = Object.assign({}, options, { - attributes: true, - attributeFilter: options.attributeFilter, - attributeOldValue: options.attributeOldValue - }); - } - if (!options.attributes && options.attributeOldValue) { - throw new this[window].TypeError(`Failed to execute 'observe' on 'MutationObserver': The options object may only set 'attributeOldValue' to true when 'attributes' is true or not present.`); - } - if (!options.attributes && options.attributeFilter) { - throw new this[window].TypeError(`Failed to execute 'observe' on 'MutationObserver': The options object may only set 'attributeFilter' when 'attributes' is true or not present.`); - } - } - if (options && options.characterDataOldValue) { - if (options.characterData === undefined) { - options = Object.assign({}, options, { - characterData: true, - characterDataOldValue: options.characterDataOldValue - }); - } - if (!options.characterData && options.characterDataOldValue) { - throw new this[window].TypeError(`Failed to execute 'observe' on 'MutationObserver': The options object may only set 'characterDataOldValue' to true when 'characterData' is true or not present.`); - } - } - if (!options || !options.childList && !options.attributes && !options.characterData) { - throw new this[window].TypeError(`Failed to execute 'observe' on 'MutationObserver': The options object must set at least one of 'attributes', 'characterData', or 'childList' to true.`); - } - options = Object.assign({}, options, { - attributeFilter: options.attributeFilter ? options.attributeFilter.map((name) => name.toLowerCase()) : null - }); - for (const listener of this.#listeners) { - if (listener.target === target) { - listener.options = options; - return; - } - } - const listener = new MutationObserverListener({ - window: this[window], - options, - callback: this.#callback.bind(this), - observer: this, - target - }); - this.#listeners.push(listener); - if (!this[window][mutationObservers].includes(this)) { - this[window][mutationObservers].push(this); - } - target[observeMutations](listener.mutationListener); - } - disconnect() { - if (this.#listeners.length === 0) { - return; - } - for (const listener of this.#listeners) { - listener.target[unobserveMutations](listener.mutationListener); - listener.destroy(); - } - this.#listeners = []; - const mutationObservers2 = this[window][mutationObservers]; - const index = mutationObservers2.indexOf(this); - if (index !== -1) { - mutationObservers2.splice(index, 1); - } - } - takeRecords() { - let records = []; - for (const listener of this.#listeners) { - records = records.concat(listener.takeRecords()); - } - return records; - } - [destroy]() { - this.#destroyed = true; - this.disconnect(); - } -} - -// node_modules/happy-dom/lib/event/MessagePort.js -class MessagePort extends EventTarget { - postMessage(_message, _transerList) {} - start() {} - close() {} -} - -// node_modules/happy-dom/lib/css/utilities/CSSParser.js -var COMMENT_REGEXP = /\/\*[\s\S]*?\*\//gm; - -class CSSParser { - #parentStyleSheet; - constructor(parentStyleSheet) { - this.#parentStyleSheet = parentStyleSheet; - } - parseFromString(cssText2) { - const parentStyleSheet2 = this.#parentStyleSheet; - const window2 = parentStyleSheet2[window]; - const css = cssText2.replace(COMMENT_REGEXP, ""); - const cssRules = []; - const regExp = /{|}/gm; - const stack = []; - let parentRule2 = null; - let lastIndex = 0; - let match; - while (match = regExp.exec(css)) { - if (match[0] === "{") { - const selectorText2 = css.substring(lastIndex, match.index).trim(); - if (selectorText2[0] === "@") { - const ruleParts = selectorText2.split(" "); - const ruleType = ruleParts[0]; - const ruleParameters = ruleParts.slice(1).join(" ").trim(); - switch (ruleType) { - case "@keyframes": - case "@-webkit-keyframes": - const keyframesRule = new CSSKeyframesRule(illegalConstructor, window2, this); - keyframesRule[rulePrefix] = ruleType === "@-webkit-keyframes" ? "-webkit-" : ""; - keyframesRule[name] = ruleParameters; - keyframesRule[parentStyleSheet] = parentStyleSheet2; - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(keyframesRule); - } - } else { - cssRules.push(keyframesRule); - } - parentRule2 = keyframesRule; - break; - case "@media": - const mediums = ruleParameters.split(","); - const mediaRule = new CSSMediaRule(illegalConstructor, window2, this); - for (const medium of mediums) { - mediaRule.media.appendMedium(medium.trim()); - } - mediaRule[parentStyleSheet] = parentStyleSheet2; - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(mediaRule); - } - } else { - cssRules.push(mediaRule); - } - parentRule2 = mediaRule; - break; - case "@container": - case "@-webkit-container": - const containerRule = new CSSContainerRule(illegalConstructor, window2, this); - containerRule[rulePrefix] = ruleType === "@-webkit-container" ? "-webkit-" : ""; - containerRule[conditionText] = ruleParameters; - containerRule[parentStyleSheet] = parentStyleSheet2; - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(containerRule); - } - } else { - cssRules.push(containerRule); - } - parentRule2 = containerRule; - break; - case "@supports": - case "@-webkit-supports": - const supportsRule = new CSSSupportsRule(illegalConstructor, window2, this); - supportsRule[rulePrefix] = ruleType === "@-webkit-supports" ? "-webkit-" : ""; - supportsRule[conditionText] = ruleParameters; - supportsRule[parentStyleSheet] = parentStyleSheet2; - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(supportsRule); - } - } else { - cssRules.push(supportsRule); - } - parentRule2 = supportsRule; - break; - case "@font-face": - const fontFaceRule = new CSSFontFaceRule(illegalConstructor, window2, this); - fontFaceRule[cssText] = ruleParameters; - fontFaceRule[parentStyleSheet] = parentStyleSheet2; - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(fontFaceRule); - } - } else { - cssRules.push(fontFaceRule); - } - parentRule2 = fontFaceRule; - break; - case "@scope": - case "@-webkit-scope": - const scopeRule = new CSSScopeRule(illegalConstructor, window2, this); - scopeRule[rulePrefix] = ruleType === "@-webkit-scope" ? "-webkit-" : ""; - scopeRule[parentStyleSheet] = parentStyleSheet2; - if (ruleParameters) { - const scopeRuleParts = ruleParameters.split(/\s+to\s+/); - if (scopeRuleParts[0] && scopeRuleParts[0][0] === "(" && scopeRuleParts[0][scopeRuleParts[0].length - 1] === ")") { - scopeRule[start] = scopeRuleParts[0].slice(1, -1); - } - if (scopeRuleParts[1] && scopeRuleParts[1][0] === "(" && scopeRuleParts[1][scopeRuleParts[1].length - 1] === ")") { - scopeRule[end] = scopeRuleParts[1].slice(1, -1); - } - } - if (parentRule2) { - if (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule) { - parentRule2.cssRules.push(scopeRule); - } - } else { - cssRules.push(scopeRule); - } - parentRule2 = scopeRule; - break; - default: - const newRule = new CSSStyleRule(illegalConstructor, window2, this); - newRule[parentStyleSheet] = parentStyleSheet2; - parentRule2 = newRule; - break; - } - } else if (parentRule2 && parentRule2.type === CSSRuleTypeEnum_default.keyframesRule) { - const newRule = new CSSKeyframeRule(illegalConstructor, window2, this); - let keyText2 = selectorText2.trim(); - if (keyText2 === "from") { - keyText2 = "0%"; - } else if (keyText2 === "to") { - keyText2 = "100%"; - } - newRule[keyText] = keyText2; - newRule[parentStyleSheet] = parentStyleSheet2; - newRule[parentRule] = parentRule2; - parentRule2.cssRules.push(newRule); - parentRule2 = newRule; - } else if (parentRule2 && (parentRule2.type === CSSRuleTypeEnum_default.mediaRule || parentRule2.type === CSSRuleTypeEnum_default.containerRule || parentRule2.type === CSSRuleTypeEnum_default.supportsRule)) { - if (this.validateSelectorText(selectorText2)) { - const newRule = new CSSStyleRule(illegalConstructor, window2, this); - newRule[selectorText] = selectorText2; - newRule[parentStyleSheet] = parentStyleSheet2; - newRule[parentRule] = parentRule2; - parentRule2.cssRules.push(newRule); - parentRule2 = newRule; - } - } else { - if (this.validateSelectorText(selectorText2)) { - const newRule = new CSSStyleRule(illegalConstructor, window2, this); - newRule[selectorText] = selectorText2; - newRule[parentStyleSheet] = parentStyleSheet2; - newRule[parentRule] = parentRule2; - if (!parentRule2) { - cssRules.push(newRule); - } - parentRule2 = newRule; - } - } - if (parentRule2) { - stack.push(parentRule2); - } - } else { - if (parentRule2) { - const cssText2 = css.substring(lastIndex, match.index).trim().replace(/([^;])$/, "$1;"); - switch (parentRule2.type) { - case CSSRuleTypeEnum_default.fontFaceRule: - case CSSRuleTypeEnum_default.keyframeRule: - case CSSRuleTypeEnum_default.styleRule: - parentRule2[cssText] = cssText2; - break; - } - } - stack.pop(); - parentRule2 = stack[stack.length - 1] || null; - } - lastIndex = match.index + 1; - } - return cssRules; - } - validateSelectorText(selectorText) { - const window2 = this.#parentStyleSheet[window]; - return new SelectorParser({ window: window2, scope: window2.document, ignoreErrors: true }).getSelectorGroups(selectorText).length > 0; - } -} - -// node_modules/happy-dom/lib/css/CSSStyleSheet.js -class CSSStyleSheet { - cssRules = []; - media; - title; - alternate; - disabled; - #currentText = null; - constructor(options) { - this.media = options && options.media ? options.media : ""; - this.title = options && options.title ? options.title : ""; - this.alternate = options && options.alternate ? options.alternate : false; - this.disabled = options && options.disabled ? options.disabled : false; - } - insertRule(rule, index) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'insertRule' on 'CSSStyleSheet': 1 argument required, but only 0 present.`); - } - const parser = new CSSParser(this); - const rules = parser.parseFromString(rule); - if (rules.length === 0 || rules.length > 1) { - throw new this[window].DOMException(`Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '${rule}'.`, DOMExceptionNameEnum_default.syntaxError); - } - if (index !== undefined) { - if (index > this.cssRules.length) { - throw new this[window].DOMException(`Failed to execute 'insertRule' on 'CSSStyleSheet': The index provided (${index}) is larger than the maximum index (${this.cssRules.length - 1}).`, DOMExceptionNameEnum_default.indexSizeError); - } - this.cssRules.splice(index, 0, rules[0]); - return index; - } - const newIndex = this.cssRules.length; - this.cssRules.push(rules[0]); - return newIndex; - } - deleteRule(index) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'deleteRule' on 'CSSStyleSheet': 1 argument required, but only 0 present.`); - } - this.cssRules.splice(index, 1); - } - async replace(text) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'replace' on 'CSSStyleSheet': 1 argument required, but only 0 present.`); - } - this.replaceSync(text); - } - replaceSync(text) { - if (arguments.length === 0) { - throw new this[window].TypeError(`Failed to execute 'replaceSync' on 'CSSStyleSheet': 1 argument required, but only 0 present.`); - } - if (this.#currentText !== text) { - this.#currentText = text; - this.cssRules = new CSSParser(this).parseFromString(text); - } - } -} - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpRequestEventTarget.js -class XMLHttpRequestEventTarget extends EventTarget { - [propertyEventListeners] = new Map; - get onloadstart() { - return this[propertyEventListeners].get("onloadstart") ?? null; - } - set onloadstart(value) { - this[propertyEventListeners].set("onloadstart", value); - } - get onprogress() { - return this[propertyEventListeners].get("onprogress") ?? null; - } - set onprogress(value) { - this[propertyEventListeners].set("onprogress", value); - } - get onabort() { - return this[propertyEventListeners].get("onabort") ?? null; - } - set onabort(value) { - this[propertyEventListeners].set("onabort", value); - } - get onerror() { - return this[propertyEventListeners].get("onerror") ?? null; - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onload() { - return this[propertyEventListeners].get("onload") ?? null; - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get ontimeout() { - return this[propertyEventListeners].get("ontimeout") ?? null; - } - set ontimeout(value) { - this[propertyEventListeners].set("ontimeout", value); - } - get onloadend() { - return this[propertyEventListeners].get("onloadend") ?? null; - } - set onloadend(value) { - this[propertyEventListeners].set("onloadend", value); - } -} - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpRequestUpload.js -class XMLHttpRequestUpload extends XMLHttpRequestEventTarget { -} - -// node_modules/happy-dom/lib/fetch/AbortController.js -class AbortController { - signal = new this[window].AbortSignal; - abort(reason) { - this.signal[abort](reason); - } -} - -// node_modules/happy-dom/lib/fetch/AbortSignal.js -class AbortSignal extends EventTarget { - [aborted] = false; - [reason] = undefined; - onabort = null; - constructor() { - super(); - if (!this[window]) { - throw new TypeError(`Failed to construct 'AbortSignal': Illegal constructor`); - } - } - get [Symbol.toStringTag]() { - return "AbortSignal"; - } - get aborted() { - return this[aborted]; - } - set aborted(_value) {} - get reason() { - return this[reason]; - } - set reason(_value) {} - [abort](reason2) { - if (this.aborted) { - return; - } - this[reason] = reason2 !== undefined ? reason2 : new this[window].DOMException("signal is aborted without reason", DOMExceptionNameEnum_default.abortError); - this[aborted] = true; - this.dispatchEvent(new Event("abort")); - } - throwIfAborted() { - if (this.aborted) { - throw this.reason; - } - } - static abort(reason2) { - const signal = new this; - signal[reason] = reason2 !== undefined ? reason2 : new this[window].DOMException("signal is aborted without reason", DOMExceptionNameEnum_default.abortError); - signal[aborted] = true; - return signal; - } - static timeout(time) { - const window2 = this[window]; - const signal = new this; - window2.setTimeout(() => { - signal[abort](new window2.DOMException("signal timed out", DOMExceptionNameEnum_default.timeoutError)); - }, time); - return signal; - } - static any(signals) { - for (const signal of signals) { - if (signal[aborted]) { - return this.abort(signal[reason]); - } - } - const anySignal = new this; - const handlers = new Map; - const stopListening = () => { - for (const signal of signals) { - signal.removeEventListener("abort", handlers.get(signal)); - } - }; - for (const signal of signals) { - const handler = () => { - stopListening(); - anySignal[abort](signal[reason]); - }; - handlers.set(signal, handler); - signal.addEventListener("abort", handler); - } - return anySignal; - } -} - -// node_modules/happy-dom/lib/permissions/PermissionStatus.js -class PermissionStatus extends EventTarget { - state; - onchange = null; - constructor(state = "granted") { - super(); - this.state = state; - } -} - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpRequestReadyStateEnum.js -var XMLHttpRequestReadyStateEnum; -(function(XMLHttpRequestReadyStateEnum) { - XMLHttpRequestReadyStateEnum[XMLHttpRequestReadyStateEnum["unsent"] = 0] = "unsent"; - XMLHttpRequestReadyStateEnum[XMLHttpRequestReadyStateEnum["opened"] = 1] = "opened"; - XMLHttpRequestReadyStateEnum[XMLHttpRequestReadyStateEnum["headersReceived"] = 2] = "headersReceived"; - XMLHttpRequestReadyStateEnum[XMLHttpRequestReadyStateEnum["loading"] = 3] = "loading"; - XMLHttpRequestReadyStateEnum[XMLHttpRequestReadyStateEnum["done"] = 4] = "done"; -})(XMLHttpRequestReadyStateEnum || (XMLHttpRequestReadyStateEnum = {})); -var XMLHttpRequestReadyStateEnum_default = XMLHttpRequestReadyStateEnum; - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpResponseTypeEnum.js -var XMLHttpResponseTypeEnum; -(function(XMLHttpResponseTypeEnum) { - XMLHttpResponseTypeEnum["arraybuffer"] = "arraybuffer"; - XMLHttpResponseTypeEnum["blob"] = "blob"; - XMLHttpResponseTypeEnum["document"] = "document"; - XMLHttpResponseTypeEnum["json"] = "json"; - XMLHttpResponseTypeEnum["text"] = "text"; -})(XMLHttpResponseTypeEnum || (XMLHttpResponseTypeEnum = {})); -var XMLHttpResponseTypeEnum_default = XMLHttpResponseTypeEnum; - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpRequestResponseDataParser.js -class XMLHttpRequestResponseDataParser { - static parse(options) { - if (!options.data) { - return ""; - } - switch (options.responseType) { - case XMLHttpResponseTypeEnum_default.arraybuffer: - const newAB = new ArrayBuffer(options.data.length); - const view = new Uint8Array(newAB); - view.set(options.data); - return view; - case XMLHttpResponseTypeEnum_default.blob: - try { - return new options.window.Blob([new Uint8Array(options.data)], { - type: options.contentType || "" - }); - } catch (e) {} - return null; - case XMLHttpResponseTypeEnum_default.document: - const window = options.window; - const domParser = new window.DOMParser; - try { - return domParser.parseFromString(options.data.toString(), "application/xml"); - } catch (e) {} - return null; - case XMLHttpResponseTypeEnum_default.json: - try { - return JSON.parse(options.data.toString()); - } catch (e) {} - return null; - case XMLHttpResponseTypeEnum_default.text: - case "": - default: - return options.data.toString(); - } - } -} - -// node_modules/happy-dom/lib/xml-http-request/XMLHttpRequest.js -class XMLHttpRequest extends XMLHttpRequestEventTarget { - static UNSENT = XMLHttpRequestReadyStateEnum_default.unsent; - static OPENED = XMLHttpRequestReadyStateEnum_default.opened; - static HEADERS_RECEIVED = XMLHttpRequestReadyStateEnum_default.headersReceived; - static LOADING = XMLHttpRequestReadyStateEnum_default.loading; - static DONE = XMLHttpRequestReadyStateEnum_default.done; - upload = new this[window].XMLHttpRequestUpload; - withCredentials = false; - #async = true; - #abortController = null; - #aborted = false; - #request = null; - #response = null; - #responseType = ""; - #responseBody = null; - #accumulatedData = Buffer.from([]); - #readyState = XMLHttpRequestReadyStateEnum_default.unsent; - #overriddenMimeType = null; - constructor() { - super(); - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - } - get status() { - return this.#response?.status || 0; - } - get statusText() { - return this.#response?.statusText || ""; - } - get response() { - if (!this.#response) { - return ""; - } - return this.#responseBody; - } - get responseText() { - if (this.responseType !== XMLHttpResponseTypeEnum_default.text && this.responseType !== "") { - throw new this[window].DOMException(`Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was '${this.responseType}').`, DOMExceptionNameEnum_default.invalidStateError); - } - if (this.#responseBody !== null) { - return this.#responseBody; - } - if (this.readyState === XMLHttpRequestReadyStateEnum_default.headersReceived || this.readyState === XMLHttpRequestReadyStateEnum_default.loading) { - return this.#accumulatedData.toString() ?? ""; - } - return ""; - } - get responseXML() { - if (this.responseType !== XMLHttpResponseTypeEnum_default.document && this.responseType !== "") { - throw new this[window].DOMException(`Failed to read the 'responseXML' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'document' (was '${this.responseType}').`, DOMExceptionNameEnum_default.invalidStateError); - } - return this.responseType === "" ? null : this.#responseBody; - } - get responseURL() { - return this.#response?.url || ""; - } - get readyState() { - return this.#readyState; - } - set responseType(type) { - if (this.readyState !== XMLHttpRequestReadyStateEnum_default.opened && this.readyState !== XMLHttpRequestReadyStateEnum_default.unsent) { - throw new this[window].DOMException(`Failed to set the 'responseType' property on 'XMLHttpRequest': The object's state must be OPENED or UNSENT.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (!this.#async) { - throw new this[window].DOMException(`Failed to set the 'responseType' property on 'XMLHttpRequest': The response type cannot be changed for synchronous requests made from a document.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.#responseType = type; - } - get responseType() { - return this.#responseType; - } - open(method, url, async = true, user, password) { - const window2 = this[window]; - if (!async && !!this.responseType && this.responseType !== XMLHttpResponseTypeEnum_default.text) { - throw new window2.DOMException(`Failed to execute 'open' on 'XMLHttpRequest': Synchronous requests from a document must not set a response type.`, DOMExceptionNameEnum_default.invalidAccessError); - } - const headers = new this[window].Headers; - if (user) { - const authBuffer = Buffer.from(`${user}:${password || ""}`); - headers.set("Authorization", "Basic " + authBuffer.toString("base64")); - } - this.#async = async; - this.#aborted = false; - this.#response = null; - this.#responseBody = null; - this.#accumulatedData = Buffer.from([]); - this.#abortController = new window2.AbortController; - this.#request = new window2.Request(url, { - method, - headers, - signal: this.#abortController.signal, - credentials: this.withCredentials ? "include" : "same-origin" - }); - this.#readyState = XMLHttpRequestReadyStateEnum_default.opened; - } - setRequestHeader(name, value) { - if (this.readyState !== XMLHttpRequestReadyStateEnum_default.opened) { - throw new this[window].DOMException(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (FetchRequestHeaderUtility.isHeaderForbidden(name)) { - return false; - } - this.#request.headers.set(name, value); - return true; - } - getResponseHeader(header) { - return this.#response?.headers.get(header) ?? null; - } - getAllResponseHeaders() { - if (!this.#response) { - return ""; - } - const result = []; - for (const [name, value] of this.#response?.headers) { - const lowerName = name.toLowerCase(); - if (lowerName !== "set-cookie" && lowerName !== "set-cookie2") { - result.push(`${name}: ${value}`); - } - } - return result.join(`\r -`); - } - send(body) { - const window2 = this[window]; - if (this.readyState != XMLHttpRequestReadyStateEnum_default.opened) { - throw new this[window].DOMException(`Failed to execute 'send' on 'XMLHttpRequest': Connection must be opened before send() is called.`, DOMExceptionNameEnum_default.invalidStateError); - } - if (typeof body === "object" && body !== null && body[nodeType] === NodeTypeEnum_default.documentNode) { - body = new window2.XMLSerializer().serializeToString(body); - } - if (this.#async) { - this.#sendAsync(body).catch((error) => { - throw error; - }); - } else { - this.#sendSync(body); - } - } - abort() { - if (this.#aborted) { - return; - } - this.#aborted = true; - this.#abortController.abort(); - } - overrideMimeType(mimeType) { - if (this.readyState === XMLHttpRequestReadyStateEnum_default.loading || this.readyState === XMLHttpRequestReadyStateEnum_default.done) { - throw new this[window].DOMException(`Failed to execute 'overrideMimeType' on 'XMLHttpRequest': MIME type cannot be overridden when the request state is LOADING or DONE.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.#overriddenMimeType = mimeType; - } - async#sendAsync(body) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return; - } - const asyncTaskManager2 = browserFrame[asyncTaskManager]; - const taskID = asyncTaskManager2.startTask(() => this.abort()); - this.#readyState = XMLHttpRequestReadyStateEnum_default.loading; - this.#dispatchEvent(new Event("readystatechange")); - this.#dispatchEvent(new Event("loadstart")); - if (body) { - this.#request = new window2.Request(this.#request.url, { - method: this.#request.method, - headers: this.#request.headers, - signal: this.#abortController.signal, - credentials: this.#request.credentials, - body - }); - } - this.#abortController.signal.addEventListener("abort", () => { - this.#aborted = true; - this.#readyState = XMLHttpRequestReadyStateEnum_default.unsent; - this.#dispatchEvent(new Event("abort")); - this.#dispatchEvent(new Event("loadend")); - this.#dispatchEvent(new Event("readystatechange")); - asyncTaskManager2.endTask(taskID); - }); - const onError = (error) => { - if (error instanceof DOMException && error.name === DOMExceptionNameEnum_default.abortError) { - if (this.#aborted) { - return; - } - this.#readyState = XMLHttpRequestReadyStateEnum_default.unsent; - this.#dispatchEvent(new Event("abort")); - } else { - this.#readyState = XMLHttpRequestReadyStateEnum_default.done; - this.#dispatchEvent(new ErrorEvent("error", { error, message: error.message })); - } - this.#dispatchEvent(new Event("loadend")); - this.#dispatchEvent(new Event("readystatechange")); - asyncTaskManager2.endTask(taskID); - }; - const fetch2 = new Fetch({ - browserFrame, - window: window2, - url: this.#request.url, - init: this.#request - }); - try { - this.#response = await fetch2.send(); - } catch (error) { - onError(error); - return; - } - this.#readyState = XMLHttpRequestReadyStateEnum_default.headersReceived; - this.#dispatchEvent(new Event("readystatechange")); - const contentLength = this.#response.headers.get("Content-Length"); - const contentLengthNumber = contentLength !== null && !isNaN(Number(contentLength)) ? Number(contentLength) : null; - let loaded = 0; - if (this.#response.body) { - let eventError; - try { - for await (const chunk of this.#response.body) { - const chunkBuffer = typeof chunk === "string" ? Buffer.from(chunk) : chunk; - this.#accumulatedData = Buffer.concat([this.#accumulatedData, chunkBuffer]); - loaded += chunk.length; - try { - this.#dispatchEvent(new ProgressEvent("progress", { - lengthComputable: contentLengthNumber !== null, - loaded, - total: contentLengthNumber !== null ? contentLengthNumber : 0 - })); - } catch (error) { - eventError = error; - throw error; - } - } - } catch (error) { - if (error === eventError) { - throw error; - } - onError(error); - return; - } - } - this.#responseBody = XMLHttpRequestResponseDataParser.parse({ - window: window2, - responseType: this.#responseType, - data: this.#accumulatedData, - contentType: this.#overriddenMimeType || this.#response.headers.get("Content-Type") || this.#request.headers.get("Content-Type") - }); - this.#readyState = XMLHttpRequestReadyStateEnum_default.done; - this.#accumulatedData = Buffer.from([]); - asyncTaskManager2.endTask(taskID); - this.#dispatchEvent(new Event("readystatechange")); - this.#dispatchEvent(new Event("load")); - this.#dispatchEvent(new Event("loadend")); - } - #sendSync(body) { - const window2 = this[window]; - const browserFrame = new WindowBrowserContext(window2).getBrowserFrame(); - if (!browserFrame) { - return; - } - if (body) { - this.#request = new window2.Request(this.#request.url, { - method: this.#request.method, - headers: this.#request.headers, - signal: this.#abortController.signal, - credentials: this.#request.credentials, - body - }); - } - this.#readyState = XMLHttpRequestReadyStateEnum_default.loading; - const fetch2 = new SyncFetch({ - browserFrame, - window: window2, - url: this.#request.url, - init: this.#request - }); - try { - this.#response = fetch2.send(); - } catch (error) { - this.#readyState = XMLHttpRequestReadyStateEnum_default.done; - this.#dispatchEvent(new ErrorEvent("error", { error, message: error.message })); - this.#dispatchEvent(new Event("loadend")); - this.#dispatchEvent(new Event("readystatechange")); - return; - } - this.#readyState = XMLHttpRequestReadyStateEnum_default.headersReceived; - this.#responseBody = XMLHttpRequestResponseDataParser.parse({ - window: window2, - responseType: this.#responseType, - data: this.#response.body, - contentType: this.#overriddenMimeType || this.#response.headers.get("Content-Type") || this.#request.headers.get("Content-Type") - }); - this.#readyState = XMLHttpRequestReadyStateEnum_default.done; - this.#dispatchEvent(new Event("readystatechange")); - this.#dispatchEvent(new Event("load")); - this.#dispatchEvent(new Event("loadend")); - } - #dispatchEvent(event) { - const browserFrame = new WindowBrowserContext(this[window]).getBrowserFrame(); - if (!browserFrame?.page?.context?.browser?.settings?.errorCapture) { - return; - } - const settings = browserFrame.page.context.browser.settings; - const errorCapture = settings.errorCapture; - settings.errorCapture = BrowserErrorCaptureEnum_default.tryAndCatch; - this.dispatchEvent(event); - settings.errorCapture = errorCapture; - } -} - -// node_modules/happy-dom/lib/xml-parser/XMLParser.js -var MARKUP_REGEXP2 = /<([^\s/!>?]+)|<\/([^\s/!>?]+)\s*>|()|()|(>)/gm; -var ATTRIBUTE_REGEXP2 = /\s*([a-zA-Z0-9-_:]+)\s*=\s*"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:]+)\s*=\s*'([^']*)('{0,1})/gm; -var ATTRIBUTE_WITHOUT_VALUE_REGEXP = /^\s*([a-zA-Z0-9-_:]+)$/; -var XML_PROCESSING_INSTRUCTION_VERSION_REGEXP = /version="[^"]+"/; -var DOCUMENT_TYPE_ATTRIBUTE_REGEXP2 = /"([^"]+)"/gm; -var SPACE_REGEXP3 = /\s+/; -var NEW_LINE_REGEXP = /\n/g; -var MarkupReadStateEnum2; -(function(MarkupReadStateEnum) { - MarkupReadStateEnum["any"] = "any"; - MarkupReadStateEnum["startTag"] = "startTag"; - MarkupReadStateEnum["comment"] = "comment"; - MarkupReadStateEnum["documentType"] = "documentType"; - MarkupReadStateEnum["processingInstruction"] = "processingInstruction"; - MarkupReadStateEnum["error"] = "error"; -})(MarkupReadStateEnum2 || (MarkupReadStateEnum2 = {})); -var NAMESPACE_URIS = Object.values(NamespaceURI_default); - -class XMLParser { - window; - rootNode = null; - nodeStack = []; - tagNameStack = []; - defaultNamespaceStack = null; - namespacePrefixStack = null; - startTagIndex = 0; - markupRegExp = null; - lastIndex = 0; - errorIndex = 0; - nextElement = null; - nextTagName = null; - currentNode = null; - readState = MarkupReadStateEnum2.any; - errorMessage = null; - constructor(window) { - this.window = window; - } - parse(xml) { - this.rootNode = new this.window.XMLDocument; - this.nodeStack = [this.rootNode]; - this.tagNameStack = [null]; - this.currentNode = this.rootNode; - this.readState = MarkupReadStateEnum2.any; - this.defaultNamespaceStack = [null]; - this.namespacePrefixStack = [null]; - this.startTagIndex = 0; - this.errorIndex = 0; - this.errorMessage = null; - this.markupRegExp = new RegExp(MARKUP_REGEXP2, "gm"); - this.lastIndex = 0; - let match; - this.rootNode[defaultView] = this.window; - xml = String(xml); - while (match = this.markupRegExp.exec(xml)) { - switch (this.readState) { - case MarkupReadStateEnum2.any: - if (match.index !== this.lastIndex && (match[1] || match[2] || match[3] || match[4] || match[5] !== undefined || match[6])) { - this.parsePlainText(xml.substring(this.lastIndex, match.index)); - } - if (match[1]) { - this.parseStartTag(match[1]); - } else if (match[2]) { - if (!this.parseEndTag(match[2])) { - this.errorMessage = `Opening and ending tag mismatch: ${this.tagNameStack[this.tagNameStack.length - 1]} line ${xml.substring(0, this.startTagIndex).split(` -`).length} and ${match[2]} -`; - this.errorIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum2.error; - this.removeOverflowingTextNodes(); - } - } else if (match[3]) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum2.comment; - } else if (match[5] !== undefined) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum2.documentType; - } else if (match[6]) { - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum2.processingInstruction; - } else { - this.parsePlainText(xml.substring(this.lastIndex, this.markupRegExp.lastIndex)); - } - break; - case MarkupReadStateEnum2.startTag: - if (match[7] || match[8]) { - const attributeString = xml.substring(this.startTagIndex, match[2] ? this.markupRegExp.lastIndex - 1 : match.index); - const isSelfClosed = !!match[7]; - this.parseEndOfStartTag(attributeString, isSelfClosed); - } else { - this.errorMessage = match[2] && this.lastIndex !== this.startTagIndex ? `Unescaped '<' not allowed in attributes values -` : `error parsing attribute name -`; - this.errorIndex = match.index; - this.readState = MarkupReadStateEnum2.error; - this.removeOverflowingTextNodes(); - } - break; - case MarkupReadStateEnum2.comment: - if (match[4]) { - this.parseComment(xml.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum2.documentType: - if (match[7] || match[8]) { - this.parseDocumentType(xml.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum2.processingInstruction: - if (match[7] || match[8]) { - this.parseProcessingInstruction(xml.substring(this.startTagIndex, match.index)); - } - break; - case MarkupReadStateEnum2.error: - this.parseError(xml.slice(0, this.errorIndex), this.errorMessage); - return this.rootNode; - } - this.lastIndex = this.markupRegExp.lastIndex; - } - if (this.readState === MarkupReadStateEnum2.error) { - this.parseError(xml.slice(0, this.errorIndex), this.errorMessage); - return this.rootNode; - } - if (this.readState === MarkupReadStateEnum2.comment) { - this.parseError(xml, `Comment not terminated -`); - this.removeOverflowingTextNodes(); - return this.rootNode; - } - if (this.rootNode[elementArray].length === 0) { - this.parseError("", `Start tag expected, '<' not found`); - return this.rootNode; - } - if (this.lastIndex !== xml.length && this.currentNode) { - this.parsePlainText(xml.substring(this.lastIndex)); - } - if (this.nodeStack.length !== 1) { - this.parseError(xml, this.nextElement ? `attributes construct error -` : `Premature end of data in tag article line 1 -`); - return this.rootNode; - } - return this.rootNode; - } - parsePlainText(text) { - if (this.currentNode === this.rootNode) { - const xmlText = text.replace(SPACE_REGEXP3, ""); - if (xmlText) { - this.errorMessage = `Extra content at the end of the document -`; - this.errorIndex = this.lastIndex; - this.readState = MarkupReadStateEnum2.error; - } - } else if (text.includes(" ")) { - this.errorMessage = `Entity 'nbsp' not defined -`; - this.errorIndex = this.lastIndex + text.indexOf(" ") + 6; - this.readState = MarkupReadStateEnum2.error; - } else { - this.currentNode[appendChild](this.rootNode.createTextNode(XMLEncodeUtility.decodeXMLEntities(text)), true); - } - } - parseProcessingInstruction(text) { - const markupRegExp = this.markupRegExp; - const parts = text.split(SPACE_REGEXP3); - const endsWithQuestionMark = text[text.length - 1] === "?"; - if (parts[0] === "xml") { - if (this.currentNode !== this.rootNode || this.rootNode[nodeArray].length !== 0 || parts.length === 1) { - this.errorMessage = `XML declaration allowed only at the start of the document -`; - this.errorIndex = markupRegExp.lastIndex - text.length + 2; - this.readState = MarkupReadStateEnum2.error; - this.removeOverflowingTextNodes(); - } else if (!XML_PROCESSING_INSTRUCTION_VERSION_REGEXP.test(parts[1])) { - this.errorMessage = `Malformed declaration expecting version -`; - this.errorIndex = markupRegExp.lastIndex - text.length + 3; - this.readState = MarkupReadStateEnum2.error; - } else if (!endsWithQuestionMark) { - this.errorMessage = `Blank needed here -`; - this.errorIndex = markupRegExp.lastIndex - 1; - this.readState = MarkupReadStateEnum2.error; - } else { - const name = parts[0]; - const content = parts.slice(1).join(" ").slice(0, -1); - this.rootNode[xmlProcessingInstruction] = this.rootNode.createProcessingInstruction(name, content); - this.readState = MarkupReadStateEnum2.any; - } - } else { - if (parts.length === 1 && !endsWithQuestionMark) { - this.errorMessage = `ParsePI: PI processing-instruction space expected -`; - this.errorIndex = markupRegExp.lastIndex - 1; - this.readState = MarkupReadStateEnum2.error; - } else if (parts.length > 1 && !endsWithQuestionMark) { - this.errorMessage = `ParsePI: PI processing-instruction never end ... -`; - this.errorIndex = markupRegExp.lastIndex - 1; - this.readState = MarkupReadStateEnum2.error; - } else { - const name = parts[0]; - const content = parts.slice(1).join(" ").slice(0, -1); - this.currentNode[appendChild](this.rootNode.createProcessingInstruction(name, content), true); - this.readState = MarkupReadStateEnum2.any; - } - } - } - parseComment(comment) { - if (this.currentNode !== this.rootNode) { - this.currentNode[appendChild](this.rootNode.createComment(XMLEncodeUtility.decodeXMLEntities(comment)), true); - } - this.readState = MarkupReadStateEnum2.any; - } - parseDocumentType(text) { - const markupRegExp = this.markupRegExp; - if (this.currentNode === this.rootNode && this.rootNode[nodeArray].length === 0) { - const documentType = this.getDocumentType(XMLEncodeUtility.decodeXMLEntities(text)); - if (documentType?.name) { - this.rootNode[appendChild](this.window.document.implementation.createDocumentType(documentType.name, documentType.publicId, documentType.systemId), true); - this.readState = MarkupReadStateEnum2.any; - } else if (documentType) { - this.errorMessage = `xmlParseDocTypeDecl : no DOCTYPE name -`; - this.errorIndex = markupRegExp.lastIndex - text.length - 2; - this.readState = MarkupReadStateEnum2.error; - } else { - this.errorMessage = `StartTag: invalid element name -`; - this.errorIndex = markupRegExp.lastIndex - text.length - 2; - this.readState = MarkupReadStateEnum2.error; - } - } else if (this.currentNode === this.rootNode && this.rootNode[elementArray].length === 1) { - this.errorMessage = `Extra content at the end of the document -`; - this.errorIndex = markupRegExp.lastIndex - text.length - 2; - this.readState = MarkupReadStateEnum2.error; - } else { - this.errorMessage = `StartTag: invalid element name -`; - this.errorIndex = markupRegExp.lastIndex - text.length - 2; - this.readState = MarkupReadStateEnum2.error; - } - } - parseStartTag(tagName) { - const parts = tagName.split(":"); - const namespacePrefixStack = this.namespacePrefixStack; - const defaultNamespaceStack = this.defaultNamespaceStack; - if (parts.length > 1) { - this.nextElement = this.rootNode.createElementNS(namespacePrefixStack[namespacePrefixStack.length - 1]?.get(parts[0]) || null, tagName); - } else { - this.nextElement = this.rootNode.createElementNS(defaultNamespaceStack[defaultNamespaceStack.length - 1] || null, tagName); - } - namespacePrefixStack.push(new Map(namespacePrefixStack[namespacePrefixStack.length - 1])); - this.nextTagName = tagName; - this.startTagIndex = this.markupRegExp.lastIndex; - this.readState = MarkupReadStateEnum2.startTag; - } - parseEndOfStartTag(attributeString, isSelfClosed) { - const namespacePrefix = this.namespacePrefixStack[this.namespacePrefixStack.length - 1]; - if (attributeString) { - const attributeRegexp = new RegExp(ATTRIBUTE_REGEXP2, "gm"); - let attributeMatch; - let lastIndex = 0; - while (attributeMatch = attributeRegexp.exec(attributeString)) { - const textBetweenAttributes = attributeString.substring(lastIndex, attributeMatch.index).replace(SPACE_REGEXP3, ""); - if (textBetweenAttributes.length) { - const match = textBetweenAttributes.match(ATTRIBUTE_WITHOUT_VALUE_REGEXP); - this.errorMessage = match ? `Specification mandates value for attribute ${match[1]} -` : `attributes construct error -`; - this.errorIndex = this.startTagIndex; - this.readState = MarkupReadStateEnum2.error; - this.removeOverflowingTextNodes(); - return; - } - if (attributeMatch[1] && attributeMatch[3] === '"' || attributeMatch[4] && attributeMatch[6] === "'") { - const name2 = attributeMatch[1] ?? attributeMatch[4]; - const rawValue = attributeMatch[2] ?? attributeMatch[5]; - const value2 = rawValue ? XMLEncodeUtility.decodeXMLAttributeValue(rawValue.replace(NEW_LINE_REGEXP, " ")) : ""; - const attributes2 = this.nextElement[attributes]; - const nameParts = name2.split(":"); - if (nameParts.length > 2 || nameParts.length === 2 && (!nameParts[0] || !nameParts[1])) { - this.errorMessage = `Failed to parse QName '${name2}' -`; - this.errorIndex = this.startTagIndex + attributeMatch.index + attributeMatch[0].split("=")[0].length; - this.readState = MarkupReadStateEnum2.error; - return; - } - let namespaceURI2 = null; - switch (nameParts[0]) { - case "xmlns": - namespaceURI2 = NamespaceURI_default.xmlns; - break; - case "xlink": - namespaceURI2 = NamespaceURI_default.xlink; - break; - } - if (!attributes2.getNamedItemNS(namespaceURI2, nameParts[1] ?? name2)) { - const attribute = NodeFactory.createNode(this.rootNode, this.window.Attr); - attribute[namespaceURI] = namespaceURI2; - attribute[name] = name2; - attribute[localName] = namespaceURI2 && nameParts[1] ? nameParts[1] : name2; - attribute[prefix] = namespaceURI2 && nameParts[1] ? nameParts[0] : null; - attribute[value] = value2; - attributes2[setNamedItem](attribute); - if (attribute[prefix] === "xmlns") { - namespacePrefix.set(attribute[localName], value2); - if (this.nextElement[prefix] === attribute[localName]) { - this.nextElement[namespaceURI] = value2; - } - } else if (name2 === "xmlns" && !this.nextElement[prefix]) { - if (NAMESPACE_URIS.includes(value2)) { - this.nextElement = this.rootNode.createElementNS(value2, this.nextElement[tagName]); - this.nextElement[attributes] = attributes2; - attributes2[ownerElement] = this.nextElement; - for (const item of attributes2[items].values()) { - item[ownerElement] = this.nextElement; - } - } else { - this.nextElement[namespaceURI] = value2; - } - } - } else { - this.errorMessage = `Attribute ${name2} redefined -`; - this.errorIndex = this.startTagIndex; - this.readState = MarkupReadStateEnum2.error; - } - this.startTagIndex += attributeMatch[0].length; - } else if (attributeMatch[1] && attributeMatch[3] !== '"' || attributeMatch[4] && attributeMatch[6] !== "'") { - return; - } - lastIndex = attributeRegexp.lastIndex; - } - const attributeStringEnd = attributeString.substring(lastIndex).replace(SPACE_REGEXP3, ""); - if (attributeStringEnd.length) { - const match = attributeStringEnd.match(ATTRIBUTE_WITHOUT_VALUE_REGEXP); - if (match) { - this.errorMessage = `Specification mandates value for attribute ${match[1]} -`; - this.errorIndex = this.markupRegExp.lastIndex - 2; - } else { - this.errorMessage = `attributes construct error -`; - this.errorIndex = this.startTagIndex; - } - this.readState = MarkupReadStateEnum2.error; - this.removeOverflowingTextNodes(); - return; - } - } - if (this.nextElement[prefix] && !this.nextElement[namespaceURI]) { - this.errorMessage = `Namespace prefix ${this.nextElement[prefix]} on name is not defined -`; - this.errorIndex = this.lastIndex; - this.readState = MarkupReadStateEnum2.error; - return; - } - if (this.currentNode === this.rootNode && this.rootNode[elementArray].length !== 0) { - this.errorMessage = `Extra content at the end of the document -`; - this.errorIndex = this.lastIndex - this.nextElement[tagName].length - 1; - this.readState = MarkupReadStateEnum2.error; - return; - } - this.currentNode[appendChild](this.nextElement, true); - if (!isSelfClosed) { - this.currentNode = this.nextElement; - this.nodeStack.push(this.currentNode); - this.tagNameStack.push(this.nextTagName); - if (this.currentNode[namespaceURI] && !this.currentNode[prefix]) { - this.defaultNamespaceStack.push(this.currentNode[namespaceURI]); - } else { - this.defaultNamespaceStack.push(this.defaultNamespaceStack[this.defaultNamespaceStack.length - 1]); - } - } - this.nextElement = null; - this.nextTagName = null; - this.readState = MarkupReadStateEnum2.any; - this.startTagIndex = this.markupRegExp.lastIndex; - } - parseEndTag(tagName) { - if (this.tagNameStack[this.tagNameStack.length - 1] === tagName) { - this.nodeStack.pop(); - this.tagNameStack.pop(); - this.namespacePrefixStack.pop(); - this.defaultNamespaceStack.pop(); - this.currentNode = this.nodeStack[this.nodeStack.length - 1] || this.rootNode; - return true; - } - return false; - } - parseError(readXML, errorMessage) { - let errorRoot = this.rootNode.documentElement; - if (!errorRoot) { - const documentElement = this.rootNode.createElementNS(NamespaceURI_default.html, "html"); - const body = this.rootNode.createElementNS(NamespaceURI_default.html, "body"); - documentElement.appendChild(body); - errorRoot = body; - this.rootNode[appendChild](documentElement, true); - } - const rows = readXML.split(` -`); - const column = rows[rows.length - 1].length + 1; - const error = `error on line ${rows.length} at column ${column}: ${errorMessage || "Unknown error"}`; - const errorElement = this.rootNode.createElementNS(NamespaceURI_default.html, "parsererror"); - errorElement.setAttribute("style", "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"); - errorElement.innerHTML = `

This page contains the following errors:

${error}

Below is a rendering of the page up to the first error.

`; - errorRoot.insertBefore(errorElement, errorRoot.firstChild); - } - removeOverflowingTextNodes() { - if (this.currentNode && this.currentNode !== this.rootNode) { - while (this.currentNode.lastChild?.[nodeType] === Node.TEXT_NODE) { - this.currentNode.removeChild(this.currentNode.lastChild); - } - } - } - getDocumentType(value) { - if (!value.toUpperCase().startsWith("DOCTYPE")) { - return null; - } - const docTypeSplit = value.split(SPACE_REGEXP3); - if (docTypeSplit.length <= 1) { - return null; - } - const docTypeString = docTypeSplit.slice(1).join(" "); - const attributes = []; - const attributeRegExp = new RegExp(DOCUMENT_TYPE_ATTRIBUTE_REGEXP2, "gm"); - const isPublic = docTypeString.toUpperCase().includes("PUBLIC"); - let attributeMatch; - while (attributeMatch = attributeRegExp.exec(docTypeString)) { - attributes.push(attributeMatch[1]); - } - const publicId = isPublic ? attributes[0] || "" : ""; - const systemId = isPublic ? attributes[1] || "" : attributes[0] || ""; - return { - name: docTypeSplit[1].toLowerCase(), - publicId, - systemId - }; - } -} - -// node_modules/happy-dom/lib/dom-parser/DOMParser.js -class DOMParser { - parseFromString(string, mimeType) { - if (!mimeType) { - throw new this[window].DOMException('Second parameter "mimeType" is mandatory.'); - } - const window2 = this[window]; - switch (mimeType) { - case "text/html": - const newDocument = new window2.HTMLDocument; - newDocument[defaultView] = window2; - return new HTMLParser(this[window]).parse(string, newDocument); - case "image/svg+xml": - case "text/xml": - case "application/xml": - case "application/xhtml+xml": - return new XMLParser(this[window]).parse(string); - default: - throw new window2.DOMException(`Unknown mime type "${mimeType}".`); - } - } -} - -// node_modules/happy-dom/lib/range/RangeHowEnum.js -var RangeHowEnum; -(function(RangeHowEnum) { - RangeHowEnum[RangeHowEnum["endToEnd"] = 2] = "endToEnd"; - RangeHowEnum[RangeHowEnum["endToStart"] = 3] = "endToStart"; - RangeHowEnum[RangeHowEnum["startToEnd"] = 1] = "startToEnd"; - RangeHowEnum[RangeHowEnum["startToStart"] = 0] = "startToStart"; -})(RangeHowEnum || (RangeHowEnum = {})); -var RangeHowEnum_default = RangeHowEnum; - -// node_modules/happy-dom/lib/range/Range.js -class Range { - static END_TO_END = RangeHowEnum_default.endToEnd; - static END_TO_START = RangeHowEnum_default.endToStart; - static START_TO_END = RangeHowEnum_default.startToEnd; - static START_TO_START = RangeHowEnum_default.startToStart; - END_TO_END = RangeHowEnum_default.endToEnd; - END_TO_START = RangeHowEnum_default.endToStart; - START_TO_END = RangeHowEnum_default.startToEnd; - START_TO_START = RangeHowEnum_default.startToStart; - [start]; - [end]; - [ownerDocument]; - constructor() { - const window2 = this[window]; - if (!window2) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - this[ownerDocument] = window2.document; - this[start] = { node: window2.document, offset: 0 }; - this[end] = { node: window2.document, offset: 0 }; - } - get startContainer() { - return this[start].node; - } - get endContainer() { - return this[end].node; - } - get startOffset() { - if (this[start].offset > 0) { - const length = NodeUtility.getNodeLength(this[start].node); - if (this[start].offset > length) { - this[start].offset = length; - } - } - return this[start].offset; - } - get endOffset() { - if (this[end].offset > 0) { - const length = NodeUtility.getNodeLength(this[end].node); - if (this[end].offset > length) { - this[end].offset = length; - } - } - return this[end].offset; - } - get collapsed() { - return this[start].node === this[end].node && this.startOffset === this.endOffset; - } - get commonAncestorContainer() { - let container = this[start].node; - while (container) { - if (NodeUtility.isInclusiveAncestor(container, this[end].node)) { - return container; - } - container = container[parentNode]; - } - return null; - } - collapse(toStart = false) { - if (toStart) { - this[end] = Object.assign({}, this[start]); - } else { - this[start] = Object.assign({}, this[end]); - } - } - compareBoundaryPoints(how, sourceRange) { - if (how !== RangeHowEnum_default.startToStart && how !== RangeHowEnum_default.startToEnd && how !== RangeHowEnum_default.endToEnd && how !== RangeHowEnum_default.endToStart) { - throw new this[window].DOMException(`The comparison method provided must be one of '${RangeHowEnum_default.startToStart}', '${RangeHowEnum_default.startToEnd}', '${RangeHowEnum_default.endToEnd}' or '${RangeHowEnum_default.endToStart}'.`, DOMExceptionNameEnum_default.notSupportedError); - } - if (this[ownerDocument] !== sourceRange[ownerDocument]) { - throw new this[window].DOMException(`The two Ranges are not in the same tree.`, DOMExceptionNameEnum_default.wrongDocumentError); - } - const thisPoint = { - node: null, - offset: 0 - }; - const sourcePoint = { - node: null, - offset: 0 - }; - switch (how) { - case RangeHowEnum_default.startToStart: - thisPoint.node = this[start].node; - thisPoint.offset = this.startOffset; - sourcePoint.node = sourceRange[start].node; - sourcePoint.offset = sourceRange.startOffset; - break; - case RangeHowEnum_default.startToEnd: - thisPoint.node = this[end].node; - thisPoint.offset = this.endOffset; - sourcePoint.node = sourceRange[start].node; - sourcePoint.offset = sourceRange.startOffset; - break; - case RangeHowEnum_default.endToEnd: - thisPoint.node = this[end].node; - thisPoint.offset = this.endOffset; - sourcePoint.node = sourceRange[end].node; - sourcePoint.offset = sourceRange.endOffset; - break; - case RangeHowEnum_default.endToStart: - thisPoint.node = this[start].node; - thisPoint.offset = this.startOffset; - sourcePoint.node = sourceRange[end].node; - sourcePoint.offset = sourceRange.endOffset; - break; - } - return RangeUtility.compareBoundaryPointsPosition(thisPoint, sourcePoint); - } - comparePoint(node, offset) { - if (node[ownerDocument] !== this[ownerDocument]) { - throw new this[window].DOMException(`The two Ranges are not in the same tree.`, DOMExceptionNameEnum_default.wrongDocumentError); - } - RangeUtility.validateBoundaryPoint({ node, offset }); - const boundaryPoint = { node, offset }; - if (RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[start].node, - offset: this.startOffset - }) === -1) { - return -1; - } else if (RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[end].node, - offset: this.endOffset - }) === 1) { - return 1; - } - return 0; - } - cloneContents() { - const window2 = this[window]; - const fragment = this[ownerDocument].createDocumentFragment(); - const startOffset = this.startOffset; - const endOffset = this.endOffset; - if (this.collapsed) { - return fragment; - } - if (this[start].node === this[end].node && (this[start].node[nodeType] === NodeTypeEnum_default.textNode || this[start].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[start].node[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[start].node.cloneNode(false); - clone[data] = clone.substringData(startOffset, endOffset - startOffset); - fragment.appendChild(clone); - return fragment; - } - let commonAncestor = this[start].node; - while (!NodeUtility.isInclusiveAncestor(commonAncestor, this[end].node)) { - commonAncestor = commonAncestor[parentNode]; - } - let firstPartialContainedChild = null; - if (!NodeUtility.isInclusiveAncestor(this[start].node, this[end].node)) { - let candidate = commonAncestor.firstChild; - while (!firstPartialContainedChild) { - if (RangeUtility.isPartiallyContained(candidate, this)) { - firstPartialContainedChild = candidate; - } - candidate = candidate.nextSibling; - } - } - let lastPartiallyContainedChild = null; - if (!NodeUtility.isInclusiveAncestor(this[end].node, this[start].node)) { - let candidate = commonAncestor.lastChild; - while (!lastPartiallyContainedChild) { - if (RangeUtility.isPartiallyContained(candidate, this)) { - lastPartiallyContainedChild = candidate; - } - candidate = candidate.previousSibling; - } - } - const containedChildren = []; - for (const node of commonAncestor[nodeArray]) { - if (RangeUtility.isContained(node, this)) { - if (node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new window2.DOMException("Invalid document type element.", DOMExceptionNameEnum_default.hierarchyRequestError); - } - containedChildren.push(node); - } - } - if (firstPartialContainedChild !== null && (firstPartialContainedChild[nodeType] === NodeTypeEnum_default.textNode || firstPartialContainedChild[nodeType] === NodeTypeEnum_default.processingInstructionNode || firstPartialContainedChild[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[start].node.cloneNode(false); - clone[data] = clone.substringData(startOffset, NodeUtility.getNodeLength(this[start].node) - startOffset); - fragment.appendChild(clone); - } else if (firstPartialContainedChild !== null) { - const clone = firstPartialContainedChild.cloneNode(); - fragment.appendChild(clone); - const subRange = new window2.Range; - subRange[start].node = this[start].node; - subRange[start].offset = startOffset; - subRange[end].node = firstPartialContainedChild; - subRange[end].offset = NodeUtility.getNodeLength(firstPartialContainedChild); - const subDocumentFragment = subRange.cloneContents(); - clone.appendChild(subDocumentFragment); - } - for (const containedChild of containedChildren) { - const clone = containedChild.cloneNode(true); - fragment.appendChild(clone); - } - if (lastPartiallyContainedChild !== null && (lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.textNode || lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.processingInstructionNode || lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[end].node.cloneNode(false); - clone[data] = clone.substringData(0, endOffset); - fragment.appendChild(clone); - } else if (lastPartiallyContainedChild !== null) { - const clone = lastPartiallyContainedChild.cloneNode(false); - fragment.appendChild(clone); - const subRange = new window2.Range; - subRange[start].node = lastPartiallyContainedChild; - subRange[start].offset = 0; - subRange[end].node = this[end].node; - subRange[end].offset = endOffset; - const subFragment = subRange.cloneContents(); - clone.appendChild(subFragment); - } - return fragment; - } - cloneRange() { - const clone = new this[window].Range; - clone[start].node = this[start].node; - clone[start].offset = this[start].offset; - clone[end].node = this[end].node; - clone[end].offset = this[end].offset; - return clone; - } - createContextualFragment(tagString) { - return new HTMLParser(this[window]).parse(tagString); - } - deleteContents() { - const startOffset = this.startOffset; - const endOffset = this.endOffset; - if (this.collapsed) { - return; - } - if (this[start].node === this[end].node && (this[start].node[nodeType] === NodeTypeEnum_default.textNode || this[start].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[start].node[nodeType] === NodeTypeEnum_default.commentNode)) { - this[start].node.replaceData(startOffset, endOffset - startOffset, ""); - return; - } - const nodesToRemove = []; - let currentNode = this[start].node; - const endNode = NodeUtility.nextDescendantNode(this[end].node); - while (currentNode && currentNode !== endNode) { - if (RangeUtility.isContained(currentNode, this) && !RangeUtility.isContained(currentNode[parentNode], this)) { - nodesToRemove.push(currentNode); - } - currentNode = NodeUtility.following(currentNode); - } - let newNode; - let newOffset; - if (NodeUtility.isInclusiveAncestor(this[start].node, this[end].node)) { - newNode = this[start].node; - newOffset = startOffset; - } else { - let referenceNode = this[start].node; - while (referenceNode && !NodeUtility.isInclusiveAncestor(referenceNode[parentNode], this[end].node)) { - referenceNode = referenceNode[parentNode]; - } - newNode = referenceNode[parentNode]; - newOffset = referenceNode[parentNode][nodeArray].indexOf(referenceNode) + 1; - } - if (this[start].node[nodeType] === NodeTypeEnum_default.textNode || this[start].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[start].node[nodeType] === NodeTypeEnum_default.commentNode) { - this[start].node.replaceData(this.startOffset, NodeUtility.getNodeLength(this[start].node) - this.startOffset, ""); - } - for (const node of nodesToRemove) { - const parent = node[parentNode]; - parent.removeChild(node); - } - if (this[end].node[nodeType] === NodeTypeEnum_default.textNode || this[end].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[end].node[nodeType] === NodeTypeEnum_default.commentNode) { - this[end].node.replaceData(0, endOffset, ""); - } - this[start].node = newNode; - this[start].offset = newOffset; - this[end].node = newNode; - this[end].offset = newOffset; - } - detach() {} - extractContents() { - const window2 = this[window]; - const fragment = this[ownerDocument].createDocumentFragment(); - const startOffset = this.startOffset; - const endOffset = this.endOffset; - if (this.collapsed) { - return fragment; - } - if (this[start].node === this[end].node && (this[start].node[nodeType] === NodeTypeEnum_default.textNode || this[start].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[start].node[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[start].node.cloneNode(false); - clone[data] = clone.substringData(startOffset, endOffset - startOffset); - fragment.appendChild(clone); - this[start].node.replaceData(startOffset, endOffset - startOffset, ""); - return fragment; - } - let commonAncestor = this[start].node; - while (!NodeUtility.isInclusiveAncestor(commonAncestor, this[end].node)) { - commonAncestor = commonAncestor[parentNode]; - } - let firstPartialContainedChild = null; - if (!NodeUtility.isInclusiveAncestor(this[start].node, this[end].node)) { - let candidate = commonAncestor.firstChild; - while (!firstPartialContainedChild) { - if (RangeUtility.isPartiallyContained(candidate, this)) { - firstPartialContainedChild = candidate; - } - candidate = candidate.nextSibling; - } - } - let lastPartiallyContainedChild = null; - if (!NodeUtility.isInclusiveAncestor(this[end].node, this[start].node)) { - let candidate = commonAncestor.lastChild; - while (!lastPartiallyContainedChild) { - if (RangeUtility.isPartiallyContained(candidate, this)) { - lastPartiallyContainedChild = candidate; - } - candidate = candidate.previousSibling; - } - } - const containedChildren = []; - for (const node of commonAncestor[nodeArray]) { - if (RangeUtility.isContained(node, this)) { - if (node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new this[window].DOMException("Invalid document type element.", DOMExceptionNameEnum_default.hierarchyRequestError); - } - containedChildren.push(node); - } - } - let newNode; - let newOffset; - if (NodeUtility.isInclusiveAncestor(this[start].node, this[end].node)) { - newNode = this[start].node; - newOffset = startOffset; - } else { - let referenceNode = this[start].node; - while (referenceNode && !NodeUtility.isInclusiveAncestor(referenceNode[parentNode], this[end].node)) { - referenceNode = referenceNode[parentNode]; - } - newNode = referenceNode[parentNode]; - newOffset = referenceNode[parentNode][nodeArray].indexOf(referenceNode) + 1; - } - if (firstPartialContainedChild !== null && (firstPartialContainedChild[nodeType] === NodeTypeEnum_default.textNode || firstPartialContainedChild[nodeType] === NodeTypeEnum_default.processingInstructionNode || firstPartialContainedChild[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[start].node.cloneNode(false); - clone[data] = clone.substringData(startOffset, NodeUtility.getNodeLength(this[start].node) - startOffset); - fragment.appendChild(clone); - this[start].node.replaceData(startOffset, NodeUtility.getNodeLength(this[start].node) - startOffset, ""); - } else if (firstPartialContainedChild !== null) { - const clone = firstPartialContainedChild.cloneNode(false); - fragment.appendChild(clone); - const subRange = new window2.Range; - subRange[start].node = this[start].node; - subRange[start].offset = startOffset; - subRange[end].node = firstPartialContainedChild; - subRange[end].offset = NodeUtility.getNodeLength(firstPartialContainedChild); - const subFragment = subRange.extractContents(); - clone.appendChild(subFragment); - } - for (const containedChild of containedChildren) { - fragment.appendChild(containedChild); - } - if (lastPartiallyContainedChild !== null && (lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.textNode || lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.processingInstructionNode || lastPartiallyContainedChild[nodeType] === NodeTypeEnum_default.commentNode)) { - const clone = this[end].node.cloneNode(false); - clone[data] = clone.substringData(0, endOffset); - fragment.appendChild(clone); - this[end].node.replaceData(0, endOffset, ""); - } else if (lastPartiallyContainedChild !== null) { - const clone = lastPartiallyContainedChild.cloneNode(false); - fragment.appendChild(clone); - const subRange = new window2.Range; - subRange[start].node = lastPartiallyContainedChild; - subRange[start].offset = 0; - subRange[end].node = this[end].node; - subRange[end].offset = endOffset; - const subFragment = subRange.extractContents(); - clone.appendChild(subFragment); - } - this[start].node = newNode; - this[start].offset = newOffset; - this[end].node = newNode; - this[end].offset = newOffset; - return fragment; - } - getBoundingClientRect() { - return new DOMRect; - } - getClientRects() { - return new DOMRectList(illegalConstructor); - } - isPointInRange(node, offset = 0) { - if (node[ownerDocument] !== this[ownerDocument]) { - return false; - } - const boundaryPoint = { node, offset }; - RangeUtility.validateBoundaryPoint(boundaryPoint); - if (RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[start].node, - offset: this.startOffset - }) === -1 || RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[end].node, - offset: this.endOffset - }) === 1) { - return false; - } - return true; - } - insertNode(newNode) { - if (this[start].node[nodeType] === NodeTypeEnum_default.processingInstructionNode || this[start].node[nodeType] === NodeTypeEnum_default.commentNode || this[start].node[nodeType] === NodeTypeEnum_default.textNode && !this[start].node[parentNode] || newNode === this[start].node) { - throw new this[window].DOMException("Invalid start node.", DOMExceptionNameEnum_default.hierarchyRequestError); - } - let referenceNode = this[start].node[nodeType] === NodeTypeEnum_default.textNode ? this[start].node : this[start].node[nodeArray][this.startOffset] || null; - const parent = !referenceNode ? this[start].node : referenceNode[parentNode]; - if (this[start].node[nodeType] === NodeTypeEnum_default.textNode) { - referenceNode = this[start].node.splitText(this.startOffset); - } - if (newNode === referenceNode) { - referenceNode = referenceNode.nextSibling; - } - const nodeParent = newNode[parentNode]; - if (nodeParent) { - nodeParent.removeChild(newNode); - } - let newOffset = !referenceNode ? NodeUtility.getNodeLength(parent) : referenceNode[parentNode][nodeArray].indexOf(referenceNode); - newOffset += newNode[nodeType] === NodeTypeEnum_default.documentFragmentNode ? NodeUtility.getNodeLength(newNode) : 1; - parent.insertBefore(newNode, referenceNode); - if (this.collapsed) { - this[end].node = parent; - this[end].offset = newOffset; - } - } - intersectsNode(node) { - if (node[ownerDocument] !== this[ownerDocument]) { - return false; - } - const parent = node[parentNode]; - if (!parent) { - return true; - } - const offset = parent[nodeArray].indexOf(node); - return RangeUtility.compareBoundaryPointsPosition({ node: parent, offset }, { node: this[end].node, offset: this.endOffset }) === -1 && RangeUtility.compareBoundaryPointsPosition({ node: parent, offset: offset + 1 }, { node: this[start].node, offset: this.startOffset }) === 1; - } - selectNode(node) { - if (!node[parentNode]) { - throw new this[window].DOMException(`The given Node has no parent.`, DOMExceptionNameEnum_default.invalidNodeTypeError); - } - const index = node[parentNode][nodeArray].indexOf(node); - this[start].node = node[parentNode]; - this[start].offset = index; - this[end].node = node[parentNode]; - this[end].offset = index + 1; - } - selectNodeContents(node) { - if (node[nodeType] === NodeTypeEnum_default.documentTypeNode) { - throw new this[window].DOMException("DocumentType Node can't be used as boundary point.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - this[start].node = node; - this[start].offset = 0; - this[end].node = node; - this[end].offset = NodeUtility.getNodeLength(node); - } - setEnd(node, offset = 0) { - RangeUtility.validateBoundaryPoint({ node, offset }); - const boundaryPoint = { node, offset }; - if (node[ownerDocument] !== this[ownerDocument] || RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[start].node, - offset: this.startOffset - }) === -1) { - this[start].node = node; - this[start].offset = offset; - } - this[end].node = node; - this[end].offset = offset; - } - setStart(node, offset = 0) { - RangeUtility.validateBoundaryPoint({ node, offset }); - const boundaryPoint = { node, offset }; - if (node[ownerDocument] !== this[ownerDocument] || RangeUtility.compareBoundaryPointsPosition(boundaryPoint, { - node: this[end].node, - offset: this.endOffset - }) === 1) { - this[end].node = node; - this[end].offset = offset; - } - this[start].node = node; - this[start].offset = offset; - } - setEndAfter(node) { - if (!node[parentNode]) { - throw new this[window].DOMException("The given Node has no parent.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - this.setEnd(node[parentNode], node[parentNode][nodeArray].indexOf(node) + 1); - } - setEndBefore(node) { - if (!node[parentNode]) { - throw new this[window].DOMException("The given Node has no parent.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - this.setEnd(node[parentNode], node[parentNode][nodeArray].indexOf(node)); - } - setStartAfter(node) { - if (!node[parentNode]) { - throw new this[window].DOMException("The given Node has no parent.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - this.setStart(node[parentNode], node[parentNode][nodeArray].indexOf(node) + 1); - } - setStartBefore(node) { - if (!node[parentNode]) { - throw new this[window].DOMException("The given Node has no parent.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - this.setStart(node[parentNode], node[parentNode][nodeArray].indexOf(node)); - } - surroundContents(newParent) { - let node = this.commonAncestorContainer; - if (!node) { - return; - } - const endNode = NodeUtility.nextDescendantNode(node); - while (node && node !== endNode) { - if (node[nodeType] !== NodeTypeEnum_default.textNode && RangeUtility.isPartiallyContained(node, this)) { - throw new this[window].DOMException("The Range has partially contains a non-Text node.", DOMExceptionNameEnum_default.invalidStateError); - } - node = NodeUtility.following(node); - } - if (newParent[nodeType] === NodeTypeEnum_default.documentNode || newParent[nodeType] === NodeTypeEnum_default.documentTypeNode || newParent[nodeType] === NodeTypeEnum_default.documentFragmentNode) { - throw new this[window].DOMException("Invalid element type.", DOMExceptionNameEnum_default.invalidNodeTypeError); - } - const fragment = this.extractContents(); - while (newParent.firstChild) { - newParent.removeChild(newParent.firstChild); - } - this.insertNode(newParent); - newParent.appendChild(fragment); - this.selectNode(newParent); - } - toString() { - const startOffset = this.startOffset; - const endOffset = this.endOffset; - let string = ""; - if (this[start].node === this[end].node && this[start].node[nodeType] === NodeTypeEnum_default.textNode) { - return this[start].node.data.slice(startOffset, endOffset); - } - if (this[start].node[nodeType] === NodeTypeEnum_default.textNode) { - string += this[start].node.data.slice(startOffset); - } - const endNode = NodeUtility.nextDescendantNode(this[end].node); - let currentNode = this[start].node; - while (currentNode && currentNode !== endNode) { - if (currentNode[nodeType] === NodeTypeEnum_default.textNode && RangeUtility.isContained(currentNode, this)) { - string += currentNode.data; - } - currentNode = NodeUtility.following(currentNode); - } - if (this[end].node[nodeType] === NodeTypeEnum_default.textNode) { - string += this[end].node.data.slice(0, endOffset); - } - return string; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TextTrackCue.js -class TextTrackCue extends EventTarget { - id = ""; - startTime = 0; - endTime = 0; - pauseOnExit = false; - [track] = null; - onenter = null; - onexit = null; - constructor(illegalConstructorSymbol) { - super(); - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - } - get track() { - return this[track]; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/VTTCue.js -class VTTCue extends TextTrackCue { - region = null; - vertical = ""; - snapToLines = true; - line = 0; - lineAlign = ""; - position = "auto"; - positionAlign = "auto"; - size = 100; - align = ""; - text = ""; - constructor(startTime, endTime, text) { - super(illegalConstructor); - const window2 = this[window]; - let argumentCount = 0; - if (startTime !== undefined) { - argumentCount++; - } - if (endTime !== undefined) { - argumentCount++; - } - if (text !== undefined) { - argumentCount++; - } - if (argumentCount < 3) { - throw new window2.TypeError(`Failed to construct 'VTTCue': 3 arguments required, but only ${argumentCount} present.`); - } - startTime = Number(startTime); - endTime = Number(endTime); - if (isNaN(startTime) || isNaN(endTime)) { - throw new window2.TypeError(`Failed to construct 'VTTCue': The provided double value is non-finite.`); - } - this.startTime = startTime; - this.endTime = endTime; - this.text = String(text); - } - getCueAsHTML() { - const window2 = this[window]; - const fragment = window2.document.createDocumentFragment(); - fragment.appendChild(window2.document.createTextNode(this.text)); - return fragment; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TextTrack.js -class TextTrack extends EventTarget { - [kind] = TextTrackKindEnum_default.subtitles; - [label] = ""; - [language] = ""; - [id] = ""; - [mode] = "disabled"; - [cues] = new TextTrackCueList(illegalConstructor); - [activeCues] = new TextTrackCueList(illegalConstructor); - oncuechange = null; - constructor(illegalConstructorSymbol) { - super(); - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - } - get kind() { - return this[kind]; - } - get label() { - return this[label]; - } - get language() { - return this[language]; - } - get id() { - return this[id]; - } - get mode() { - return this[mode]; - } - set mode(mode2) { - if (mode2 !== "disabled" && mode2 !== "showing") { - return; - } - this[mode] = mode2; - } - get cues() { - if (this[mode] === "disabled") { - return null; - } - return this[cues]; - } - get activeCues() { - if (this[mode] === "disabled") { - return null; - } - return this[activeCues]; - } - addCue(cue) { - if (this[cues].includes(cue)) { - return; - } - cue[track] = this; - this[cues].push(cue); - } - removeCue(cue) { - const index = this[cues].indexOf(cue); - if (index !== -1) { - cue[track] = null; - this[cues].splice(index, 1); - } - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/TextTrackList.js -class TextTrackList extends EventTarget { - [items] = []; - onaddtrack = null; - onchange = null; - onremovetrack = null; - constructor(illegalConstructorSymbol, items2) { - super(); - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[items] = items2; - const methodBinder = new ClassMethodBinder(this, [TextTrackList, EventTarget]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length") { - return items2.length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return items2[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys() { - return Object.keys(items2); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < items2.length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - if (!isNaN(index) && items2[index]) { - return { - value: items2[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[items].length; - } - get [Symbol.toStringTag]() { - return "TextTrackList"; - } - toLocaleString() { - return "[object TextTrackList]"; - } - toString() { - return "[object TextTrackList]"; - } - [Symbol.iterator]() { - const items2 = this[items]; - return items2[Symbol.iterator](); - } - getTrackById(id) { - for (const cue of this[items]) { - if (cue.id === id) { - return cue; - } - } - return null; - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/RemotePlayback.js -class RemotePlayback extends EventTarget { - [state] = "disconnected"; - onconnecting = null; - onconnect = null; - ondisconnect = null; - get state() { - return this[state]; - } - async watchAvailability() {} - cancelWatchAvailability() {} - prompt() {} -} - -// node_modules/happy-dom/lib/file/FileReader.js -var import_whatwg_mimetype = __toESM(require_mime_type(), 1); - -// node_modules/happy-dom/lib/file/FileReaderReadyStateEnum.js -var FileReaderReadyStateEnum; -(function(FileReaderReadyStateEnum) { - FileReaderReadyStateEnum[FileReaderReadyStateEnum["empty"] = 0] = "empty"; - FileReaderReadyStateEnum[FileReaderReadyStateEnum["loading"] = 1] = "loading"; - FileReaderReadyStateEnum[FileReaderReadyStateEnum["done"] = 2] = "done"; -})(FileReaderReadyStateEnum || (FileReaderReadyStateEnum = {})); -var FileReaderReadyStateEnum_default = FileReaderReadyStateEnum; - -// node_modules/happy-dom/lib/file/FileReaderFormatEnum.js -var FileReaderFormatEnum; -(function(FileReaderFormatEnum) { - FileReaderFormatEnum["buffer"] = "buffer"; - FileReaderFormatEnum["binaryString"] = "binaryString"; - FileReaderFormatEnum["dataURL"] = "dataURL"; - FileReaderFormatEnum["text"] = "text"; -})(FileReaderFormatEnum || (FileReaderFormatEnum = {})); -var FileReaderFormatEnum_default = FileReaderFormatEnum; - -// node_modules/happy-dom/lib/file/FileReaderEventTypeEnum.js -var FileReaderEventTypeEnum; -(function(FileReaderEventTypeEnum) { - FileReaderEventTypeEnum["abort"] = "abort"; - FileReaderEventTypeEnum["error"] = "error"; - FileReaderEventTypeEnum["load"] = "load"; - FileReaderEventTypeEnum["loadstart"] = "loadstart"; - FileReaderEventTypeEnum["loadend"] = "loadend"; - FileReaderEventTypeEnum["progress"] = "progress"; -})(FileReaderEventTypeEnum || (FileReaderEventTypeEnum = {})); -var FileReaderEventTypeEnum_default = FileReaderEventTypeEnum; - -// node_modules/happy-dom/lib/file/FileReader.js -import { Buffer as Buffer7 } from "buffer"; - -class FileReader extends EventTarget { - error = null; - result = null; - readyState = FileReaderReadyStateEnum_default.empty; - onabort = null; - onerror = null; - onload = null; - onloadstart = null; - onloadend = null; - onprogress = null; - #isTerminated = false; - #loadTimeout = null; - #parseTimeout = null; - constructor() { - super(); - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - } - readAsArrayBuffer(blob) { - if (!(blob instanceof Blob)) { - throw new this[window].TypeError(`Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.`); - } - this.#readFile(blob, FileReaderFormatEnum_default.buffer); - } - readAsBinaryString(blob) { - if (!(blob instanceof Blob)) { - throw new this[window].TypeError(`Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1 is not of type 'Blob'.`); - } - this.#readFile(blob, FileReaderFormatEnum_default.binaryString); - } - readAsDataURL(blob) { - if (!(blob instanceof Blob)) { - throw new this[window].TypeError(`Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.`); - } - this.#readFile(blob, FileReaderFormatEnum_default.dataURL); - } - readAsText(blob, encoding = null) { - if (!(blob instanceof Blob)) { - throw new this[window].TypeError(`Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'.`); - } - this.#readFile(blob, FileReaderFormatEnum_default.text, encoding || "UTF-8"); - } - abort() { - const window2 = this[window]; - if (this.#loadTimeout) { - window2.clearTimeout(this.#loadTimeout); - } - if (this.#parseTimeout) { - window2.clearTimeout(this.#parseTimeout); - } - if (this.readyState === FileReaderReadyStateEnum_default.empty || this.readyState === FileReaderReadyStateEnum_default.done) { - this.result = null; - return; - } - if (this.readyState === FileReaderReadyStateEnum_default.loading) { - this.readyState = FileReaderReadyStateEnum_default.done; - this.result = null; - } - this.#isTerminated = true; - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.abort)); - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.loadend)); - } - #readFile(blob, format, encoding = null) { - const window2 = this[window]; - if (this.readyState === FileReaderReadyStateEnum_default.loading) { - throw new window2.DOMException("The object is in an invalid state.", DOMExceptionNameEnum_default.invalidStateError); - } - this.readyState = FileReaderReadyStateEnum_default.loading; - this.#loadTimeout = window2.setTimeout(() => { - if (this.#isTerminated) { - this.#isTerminated = false; - return; - } - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.loadstart)); - let data = blob[buffer]; - if (!data) { - data = Buffer7.alloc(0); - } - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.loadstart, { - lengthComputable: !isNaN(blob.size), - total: blob.size, - loaded: data.length - })); - this.#parseTimeout = window2.setTimeout(() => { - if (this.#isTerminated) { - this.#isTerminated = false; - return; - } - switch (format) { - default: - case FileReaderFormatEnum_default.buffer: { - this.result = new Uint8Array(data).buffer; - break; - } - case FileReaderFormatEnum_default.binaryString: { - this.result = data.toString("binary"); - break; - } - case FileReaderFormatEnum_default.dataURL: { - const contentType = import_whatwg_mimetype.default.parse(blob.type) || "application/octet-stream"; - this.result = `data:${contentType};base64,${data.toString("base64")}`; - break; - } - case FileReaderFormatEnum_default.text: { - this.result = new TextDecoder(encoding || "UTF-8").decode(data); - break; - } - } - this.readyState = FileReaderReadyStateEnum_default.done; - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.load)); - this.dispatchEvent(new ProgressEvent(FileReaderEventTypeEnum_default.loadend)); - }); - }); - } -} - -// node_modules/happy-dom/lib/nodes/html-media-element/MediaStreamTrack.js -import Crypto3 from "crypto"; -var CAPABILITIES = { - aspectRatio: { - max: 300, - min: 0.006666666666666667 - }, - deviceId: "", - facingMode: [], - frameRate: { - max: 60, - min: 0 - }, - height: { - max: 150, - min: 1 - }, - resizeMode: ["none", "crop-and-scale"], - width: { - max: 300, - min: 1 - } -}; -var SETTINGS = { - deviceId: "", - frameRate: 60, - resizeMode: "none" -}; - -class MediaStreamTrack extends EventTarget { - contentHint = ""; - enabled = true; - id = Crypto3.randomUUID(); - muted = false; - readyState = "live"; - label = ""; - [label] = ""; - [kind] = "video"; - [constraints] = {}; - [capabilities] = JSON.parse(JSON.stringify(CAPABILITIES)); - [settings] = JSON.parse(JSON.stringify(SETTINGS)); - onended = null; - onmute = null; - onunmute = null; - constructor(illegalConstructorSymbol) { - super(); - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - if (!this[window]) { - throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`); - } - } - get kind() { - return this[kind]; - } - async applyConstraints(constraints2) { - this.#mergeConstraints(this[constraints], constraints2); - } - getConstraints() { - return this[constraints]; - } - getCapabilities() { - return this[capabilities]; - } - getSettings() { - return this[settings]; - } - clone() { - const clone = new this.constructor(illegalConstructor); - clone[kind] = this[kind]; - clone[constraints] = this[constraints]; - clone[capabilities] = this[capabilities]; - clone[settings] = this[settings]; - clone.contentHint = this.contentHint; - clone.enabled = this.enabled; - clone.label = this.label; - clone.muted = this.muted; - clone.readyState = this.readyState; - return clone; - } - stop() { - this.readyState = "ended"; - } - #mergeConstraints(source, target) { - for (const key in target) { - if (target[key] !== null && typeof target[key] === "object" && !Array.isArray(target[key])) { - if (typeof source[key] !== "object") { - source[key] = {}; - } - this.#mergeConstraints(source[key], target[key]); - } else { - source[key] = target[key]; - } - } - } -} - -// node_modules/happy-dom/lib/nodes/html-canvas-element/CanvasCaptureMediaStreamTrack.js -class CanvasCaptureMediaStreamTrack extends MediaStreamTrack { - [canvas]; - constructor(illegalConstructorSymbol, canvas2) { - super(illegalConstructorSymbol); - this[canvas] = canvas2; - } - get canvas() { - return this[canvas]; - } - requestFrame() {} - clone() { - const clone = super.clone(); - clone[canvas] = this.canvas; - return clone; - } -} - -// node_modules/happy-dom/lib/web-socket/WebSocketReadyStateEnum.js -var WebSocketReadyStateEnum; -(function(WebSocketReadyStateEnum) { - WebSocketReadyStateEnum[WebSocketReadyStateEnum["connecting"] = 0] = "connecting"; - WebSocketReadyStateEnum[WebSocketReadyStateEnum["open"] = 1] = "open"; - WebSocketReadyStateEnum[WebSocketReadyStateEnum["closing"] = 2] = "closing"; - WebSocketReadyStateEnum[WebSocketReadyStateEnum["closed"] = 3] = "closed"; -})(WebSocketReadyStateEnum || (WebSocketReadyStateEnum = {})); -var WebSocketReadyStateEnum_default = WebSocketReadyStateEnum; - -// node_modules/happy-dom/lib/web-socket/WebSocket.js -import WS from "ws"; -var SECURE_PROTOCOL_REGEXP = /^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/; - -class WebSocket extends EventTarget { - static CONNECTING = WebSocketReadyStateEnum_default.connecting; - static OPEN = WebSocketReadyStateEnum_default.open; - static CLOSING = WebSocketReadyStateEnum_default.closing; - static CLOSED = WebSocketReadyStateEnum_default.closed; - #readyState = WebSocketReadyStateEnum_default.closed; - #extensions = ""; - #binaryType = "blob"; - #error = null; - #url; - [webSocket] = null; - constructor(url, protocols) { - super(); - const window2 = this[window]; - let parsedURL; - try { - parsedURL = new URL(url); - } catch { - throw new window2.DOMException(`The URL '${url}' is invalid.`, DOMExceptionNameEnum_default.syntaxError); - } - if (parsedURL.protocol !== "ws:" && parsedURL.protocol !== "wss:") { - throw new window2.DOMException(`The URL's protocol must be either 'ws' or 'wss'. '${parsedURL.protocol}' is not allowed.`, DOMExceptionNameEnum_default.syntaxError); - } - if (parsedURL.hash) { - parsedURL.hash = ""; - } - const protocolSet = new Set; - const protocolList = protocols !== undefined ? Array.isArray(protocols) ? protocols : [protocols] : []; - for (const protocol of protocolList) { - if (!this.#validateSecureProtocol(protocol)) { - throw new window2.DOMException(`The subprotocol '${protocol}' is invalid.`, DOMExceptionNameEnum_default.syntaxError); - } - if (protocolSet.has(protocol)) { - throw new window2.DOMException(`The subprotocol '${protocol}' is duplicated.`, DOMExceptionNameEnum_default.syntaxError); - } - protocolSet.add(protocol); - } - this.#url = parsedURL; - this.#connect(parsedURL, protocolList); - } - get readyState() { - return this.#readyState; - } - get extensions() { - return this.#extensions; - } - get binaryType() { - return this.#binaryType; - } - set binaryType(value) { - if (value !== "blob" && value !== "arraybuffer") { - return; - } - this.#binaryType = value; - } - get protocol() { - return this[webSocket]?.protocol || ""; - } - get url() { - return this.#url.href; - } - close(code, reason) { - const window2 = this[window]; - if (code !== undefined && code !== 1000 && !(code >= 3000 && code <= 4999)) { - throw new window2.DOMException(`The code must be either 1000, or between 3000 and 4999. ${code} is neither.`, DOMExceptionNameEnum_default.invalidAccessError); - } - if (reason !== undefined && Buffer.byteLength(reason, "utf8") > 123) { - throw new window2.DOMException(`The message must not be greater than 123 bytes.`, DOMExceptionNameEnum_default.syntaxError); - } - this.#close(code, reason ? Buffer.from(reason) : undefined); - } - send(data) { - const window2 = this[window]; - if (this.#readyState === WebSocketReadyStateEnum_default.connecting) { - throw new window2.DOMException("Still in CONNECTING state.", DOMExceptionNameEnum_default.invalidStateError); - } - if (this.#readyState !== WebSocketReadyStateEnum_default.open) { - return; - } - if (typeof data === "string") { - this[webSocket]?.send(data, { binary: false }); - return; - } - let buffer2; - if (data instanceof ArrayBuffer) { - buffer2 = Buffer.from(new Uint8Array(data)); - } else if (data instanceof Blob) { - buffer2 = data[buffer]; - } else if (data instanceof Buffer) { - buffer2 = data; - } else if (ArrayBuffer.isView(data)) { - buffer2 = Buffer.from(new Uint8Array(data.buffer, data.byteOffset, data.byteLength)); - } else { - buffer2 = Buffer.from(String(data)); - } - this[webSocket]?.send(buffer2, { binary: true }); - } - [destroy]() { - super[destroy](); - this.#close(1001); - } - #connect(url, protocols) { - const window2 = this[window]; - const browserContext = new WindowBrowserContext(window2).getBrowserContext(); - if (!browserContext) { - return; - } - const originURL = new URL(window2.location.href); - const cookies = browserContext.cookieContainer.getCookies(originURL, false); - this.#readyState = WebSocketReadyStateEnum_default.connecting; - this[webSocket] = new WS(url, protocols, { - headers: { - "user-agent": window2.navigator.userAgent, - cookie: CookieStringUtility.cookiesToString(cookies), - origin: originURL.origin - }, - rejectUnauthorized: !browserContext.browser.settings.fetch.disableStrictSSL - }); - this[webSocket].once("open", () => { - this.#onConnectionEstablished(); - }); - this[webSocket].on("message", this.#onMessageReceived.bind(this)); - this[webSocket].once("close", (code, reason) => { - this.#onConnectionClosed(code, reason); - }); - this[webSocket].once("upgrade", ({ headers }) => { - if (headers["set-cookie"] !== undefined) { - const cookieStrings = Array.isArray(headers["set-cookie"]) ? headers["set-cookie"] : [headers["set-cookie"]]; - for (const cookieString of cookieStrings) { - const cookie = CookieStringUtility.stringToCookie(originURL, cookieString); - if (cookie) { - browserContext.cookieContainer.addCookies([cookie]); - } - } - } - }); - this[webSocket].once("error", (error) => { - this.#error = error; - }); - window2[openWebSockets].push(this); - } - #close(code, reason) { - if (this.readyState === WebSocketReadyStateEnum_default.connecting) { - if (this[webSocket]) { - this[webSocket].terminate(); - } else { - this.#readyState = WebSocketReadyStateEnum_default.closing; - } - } else if (this[webSocket] && this.readyState === WebSocketReadyStateEnum_default.open) { - this[webSocket].close(code, reason); - } - this[webSocket] = null; - } - #onConnectionEstablished() { - if (this[webSocket]?.extensions) { - this.#extensions = Object.keys(this[webSocket].extensions).join(", "); - } - this.#readyState = WebSocketReadyStateEnum_default.open; - this.dispatchEvent(new this[window].Event("open")); - } - #onConnectionClosed(code, reason) { - const window2 = this[window]; - const index = window2[openWebSockets].indexOf(this); - if (index !== -1) { - window2[openWebSockets].splice(index, 1); - } - this.#readyState = WebSocketReadyStateEnum_default.closed; - this.dispatchEvent(new this[window].CloseEvent("close", { - wasClean: this.#error === null, - code, - reason: reason.toString() - })); - } - #onMessageReceived(data, isBinary) { - if (this.#readyState !== WebSocketReadyStateEnum_default.open) { - return; - } - const window2 = this[window]; - let dataForEvent; - if (isBinary) { - switch (this.binaryType) { - case "arraybuffer": - if (data instanceof window2.ArrayBuffer) { - dataForEvent = data; - } else if (Array.isArray(data)) { - dataForEvent = this.#convertToArrayBuffer(Buffer.concat(data)); - } else { - dataForEvent = this.#convertToArrayBuffer(data); - } - break; - case "blob": - default: - if (!Array.isArray(data)) { - data = [data]; - } - dataForEvent = new window2.Blob(data); - break; - } - } else { - dataForEvent = String(data); - } - this.dispatchEvent(new window2.MessageEvent("message", { - data: dataForEvent, - origin: this.#url.origin - })); - } - #convertToArrayBuffer(buffer) { - const window2 = this[window]; - const arrayBuffer = new window2.ArrayBuffer(buffer.byteLength); - const view = new Uint8Array(arrayBuffer); - view.set(buffer); - return arrayBuffer; - } - #validateSecureProtocol(protocol) { - return SECURE_PROTOCOL_REGEXP.test(protocol); - } -} - -// node_modules/happy-dom/lib/canvas/ImageData.js -class ImageData { - [data]; - [width]; - [height]; - constructor(dataArray, width2, height2) { - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to construct 'ImageData': 2 arguments required, but only ${arguments.length} present.`); - } - if (dataArray instanceof Uint8ClampedArray) { - if (typeof width2 !== "number") { - throw new this[window].TypeError(`Failed to construct 'ImageData': The width argument must be a number.`); - } - if (height2 !== undefined && typeof height2 !== "number") { - throw new this[window].TypeError(`Failed to construct 'ImageData': The height argument must be a number.`); - } - this[data] = dataArray; - this[width] = width2; - this[height] = height2 !== undefined ? height2 : dataArray.length / (width2 * 4); - } else { - if (typeof width2 !== "number") { - throw new this[window].TypeError(`Failed to construct 'ImageData': The height argument must be a number.`); - } - this[data] = new Uint8ClampedArray(new Array(dataArray * width2 * 4).fill(0)); - this[width] = dataArray; - this[height] = width2; - } - } - get data() { - return this[data]; - } - get width() { - return this[width]; - } - get height() { - return this[height]; - } -} - -// node_modules/happy-dom/lib/dom/dom-matrix/DOMMatrixReadOnly.js -var DEFAULT_MATRIX_JSON = { - a: 1, - b: 0, - c: 0, - d: 1, - e: 0, - f: 0, - m11: 1, - m12: 0, - m13: 0, - m14: 0, - m21: 0, - m22: 1, - m23: 0, - m24: 0, - m31: 0, - m32: 0, - m33: 1, - m34: 0, - m41: 0, - m42: 0, - m43: 0, - m44: 1, - is2D: true, - isIdentity: true -}; -var TRANSFORM_REGEXP = /([a-zA-Z0-9]+)\(([^)]+)\)/gm; -var TRANSFORM_PARAMETER_SPLIT_REGEXP = /[\s,]+/; - -class DOMMatrixReadOnly { - [m11] = 1; - [m12] = 0; - [m13] = 0; - [m14] = 0; - [m21] = 0; - [m22] = 1; - [m23] = 0; - [m24] = 0; - [m31] = 0; - [m32] = 0; - [m33] = 1; - [m34] = 0; - [m41] = 0; - [m42] = 0; - [m43] = 0; - [m44] = 1; - constructor(init) { - if (init) { - this[setMatrixValue](init); - } - } - get a() { - return this[m11]; - } - get b() { - return this[m12]; - } - get c() { - return this[m21]; - } - get d() { - return this[m22]; - } - get e() { - return this[m41]; - } - get f() { - return this[m42]; - } - get m11() { - return this[m11]; - } - get m12() { - return this[m12]; - } - get m13() { - return this[m13]; - } - get m14() { - return this[m14]; - } - get m21() { - return this[m21]; - } - get m22() { - return this[m22]; - } - get m23() { - return this[m23]; - } - get m24() { - return this[m24]; - } - get m31() { - return this[m31]; - } - get m32() { - return this[m32]; - } - get m33() { - return this[m33]; - } - get m34() { - return this[m34]; - } - get m41() { - return this[m41]; - } - get m42() { - return this[m42]; - } - get m43() { - return this[m43]; - } - get m44() { - return this[m44]; - } - get isIdentity() { - return this[m11] === 1 && this[m12] === 0 && this[m13] === 0 && this[m14] === 0 && this[m21] === 0 && this[m22] === 1 && this[m23] === 0 && this[m24] === 0 && this[m31] === 0 && this[m32] === 0 && this[m33] === 1 && this[m34] === 0 && this[m41] === 0 && this[m42] === 0 && this[m43] === 0 && this[m44] === 1; - } - get is2D() { - return this[m31] === 0 && this[m32] === 0 && this[m33] === 1 && this[m34] === 0 && this[m43] === 0 && this[m44] === 1; - } - toFloat32Array(is2D) { - return Float32Array.from(this[toArray](is2D)); - } - toFloat64Array(is2D) { - return Float64Array.from(this[toArray](is2D)); - } - toString() { - const is2D = this.is2D; - const values = this[toArray](is2D).join(", "); - const type = is2D ? "matrix" : "matrix3d"; - return `${type}(${values})`; - } - toJSON() { - const { is2D, isIdentity } = this; - return { - m11: this[m11], - m12: this[m12], - m13: this[m13], - m14: this[m14], - m21: this[m21], - m22: this[m22], - m23: this[m23], - m24: this[m24], - m31: this[m31], - m32: this[m32], - m33: this[m33], - m34: this[m34], - m41: this[m41], - m42: this[m42], - m43: this[m43], - m44: this[m44], - a: this[m11], - b: this[m12], - c: this[m21], - d: this[m22], - e: this[m41], - f: this[m42], - is2D, - isIdentity - }; - } - multiply(secondMatrix) { - const matrix = new this.constructor(this); - if (secondMatrix) { - matrix[multiplySelf](secondMatrix); - } - return matrix; - } - translate(x = 0, y = 0, z = 0) { - const matrix = new this.constructor(this); - matrix[translateSelf](x, y, z); - return matrix; - } - scale(scaleX, scaleY, scaleZ = 1, originX = 0, originY = 0, originZ = 0) { - const matrix = new this.constructor(this); - matrix[scaleSelf](scaleX, scaleY, scaleZ, originX, originY, originZ); - return matrix; - } - scale3d(scale = 1, originX = 0, originY = 0, originZ = 0) { - const matrix = new this.constructor(this); - matrix[scale3dSelf](scale, originX, originY, originZ); - return matrix; - } - scaleNonUniform(scaleX = 1, scaleY = 1) { - const matrix = new this.constructor(this); - matrix[scaleNonUniformSelf](scaleX, scaleY); - return matrix; - } - rotateAxisAngle(x = 0, y = 0, z = 0, angle = 0) { - const matrix = new this.constructor(this); - matrix[rotateAxisAngleSelf](x, y, z, angle); - return matrix; - } - rotate(x = 0, y, z) { - const matrix = new this.constructor(this); - matrix[rotateSelf](x, y, z); - return matrix; - } - rotateFromVector(x = 0, y = 0) { - const matrix = new this.constructor(this); - matrix[rotateFromVectorSelf](x, y); - return matrix; - } - skewX(angle) { - const matrix = new this.constructor(this); - matrix[skewXSelf](angle); - return matrix; - } - skewY(angle) { - const matrix = new this.constructor(this); - matrix[skewYSelf](angle); - return matrix; - } - flipX() { - const matrix = new this.constructor(this); - matrix[flipXSelf](); - return matrix; - } - flipY() { - const matrix = new this.constructor(this); - matrix[flipYSelf](); - return matrix; - } - inverse() { - const matrix = new this.constructor(this); - matrix[invertSelf](); - return matrix; - } - transformPoint(domPoint) { - const xPoint = domPoint?.x ?? 0; - const yPoint = domPoint?.y ?? 0; - const zPoint = domPoint?.z ?? 0; - const wPoint = domPoint?.w ?? 1; - const x = this[m11] * xPoint + this[m21] * yPoint + this[m31] * zPoint + this[m41] * wPoint; - const y = this[m12] * xPoint + this[m22] * yPoint + this[m32] * zPoint + this[m42] * wPoint; - const z = this[m13] * xPoint + this[m23] * yPoint + this[m33] * zPoint + this[m43] * wPoint; - const w = this[m14] * xPoint + this[m24] * yPoint + this[m34] * zPoint + this[m44] * wPoint; - return new this[window].DOMPoint(x, y, z, w); - } - [setMatrixValue](source) { - let matrix = null; - if (typeof source === "string" && source.length && source !== "none") { - matrix = this.constructor[fromString](source); - } else if (Array.isArray(source) || source instanceof Float64Array || source instanceof Float32Array) { - matrix = this.constructor[fromArray](source); - } else if (typeof source === "object") { - matrix = this.constructor.fromMatrix(source); - } else { - return; - } - this[m11] = matrix[m11]; - this[m12] = matrix[m12]; - this[m13] = matrix[m13]; - this[m14] = matrix[m14]; - this[m21] = matrix[m21]; - this[m22] = matrix[m22]; - this[m23] = matrix[m23]; - this[m24] = matrix[m24]; - this[m31] = matrix[m31]; - this[m32] = matrix[m32]; - this[m33] = matrix[m33]; - this[m34] = matrix[m34]; - this[m41] = matrix[m41]; - this[m42] = matrix[m42]; - this[m43] = matrix[m43]; - this[m44] = matrix[m44]; - } - [multiplySelf](matrixCompatibleObject) { - if (!matrixCompatibleObject) { - return; - } - let matrix = matrixCompatibleObject; - if (!(matrix instanceof DOMMatrixReadOnly)) { - if (matrix?.m11 === undefined && matrix?.a !== undefined) { - matrix = Object.assign({}, DEFAULT_MATRIX_JSON, matrix); - matrix.m11 = matrix.a; - matrix.m12 = matrix.b; - matrix.m21 = matrix.c; - matrix.m22 = matrix.d; - matrix.m41 = matrix.e; - matrix.m42 = matrix.f; - } else { - matrix = Object.assign({}, DEFAULT_MATRIX_JSON, matrix); - } - } - const m112 = this[m11] * matrix.m11 + this[m21] * matrix.m12 + this[m31] * matrix.m13 + this[m41] * matrix.m14; - const m212 = this[m11] * matrix.m21 + this[m21] * matrix.m22 + this[m31] * matrix.m23 + this[m41] * matrix.m24; - const m312 = this[m11] * matrix.m31 + this[m21] * matrix.m32 + this[m31] * matrix.m33 + this[m41] * matrix.m34; - const m412 = this[m11] * matrix.m41 + this[m21] * matrix.m42 + this[m31] * matrix.m43 + this[m41] * matrix.m44; - const m122 = this[m12] * matrix.m11 + this[m22] * matrix.m12 + this[m32] * matrix.m13 + this[m42] * matrix.m14; - const m222 = this[m12] * matrix.m21 + this[m22] * matrix.m22 + this[m32] * matrix.m23 + this[m42] * matrix.m24; - const m322 = this[m12] * matrix.m31 + this[m22] * matrix.m32 + this[m32] * matrix.m33 + this[m42] * matrix.m34; - const m422 = this[m12] * matrix.m41 + this[m22] * matrix.m42 + this[m32] * matrix.m43 + this[m42] * matrix.m44; - const m132 = this[m13] * matrix.m11 + this[m23] * matrix.m12 + this[m33] * matrix.m13 + this[m43] * matrix.m14; - const m232 = this[m13] * matrix.m21 + this[m23] * matrix.m22 + this[m33] * matrix.m23 + this[m43] * matrix.m24; - const m332 = this[m13] * matrix.m31 + this[m23] * matrix.m32 + this[m33] * matrix.m33 + this[m43] * matrix.m34; - const m432 = this[m13] * matrix.m41 + this[m23] * matrix.m42 + this[m33] * matrix.m43 + this[m43] * matrix.m44; - const m142 = this[m14] * matrix.m11 + this[m24] * matrix.m12 + this[m34] * matrix.m13 + this[m44] * matrix.m14; - const m242 = this[m14] * matrix.m21 + this[m24] * matrix.m22 + this[m34] * matrix.m23 + this[m44] * matrix.m24; - const m342 = this[m14] * matrix.m31 + this[m24] * matrix.m32 + this[m34] * matrix.m33 + this[m44] * matrix.m34; - const m442 = this[m14] * matrix.m41 + this[m24] * matrix.m42 + this[m34] * matrix.m43 + this[m44] * matrix.m44; - this[m11] = m112; - this[m12] = m122; - this[m13] = m132; - this[m14] = m142; - this[m21] = m212; - this[m22] = m222; - this[m23] = m232; - this[m24] = m242; - this[m31] = m312; - this[m32] = m322; - this[m33] = m332; - this[m34] = m342; - this[m41] = m412; - this[m42] = m422; - this[m43] = m432; - this[m44] = m442; - } - [translateSelf](x = 0, y = 0, z = 0) { - const translationMatrix = this.constructor[fromArray]([ - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - x, - y, - z, - 1 - ]); - this[multiplySelf](translationMatrix); - } - [scaleSelf](scaleX, scaleY, scaleZ = 1, originX = 0, originY = 0, originZ = 0) { - scaleX = scaleX === undefined ? 1 : Number(scaleX); - scaleY = scaleY === undefined ? scaleX : Number(scaleY); - if (originX !== 0 || originY !== 0 || originZ !== 0) { - this[translateSelf](originX, originY, originZ); - } - if (scaleX !== 1 || scaleY !== 1 || scaleZ !== 1) { - this[multiplySelf](this.constructor[fromArray]([ - scaleX, - 0, - 0, - 0, - 0, - scaleY, - 0, - 0, - 0, - 0, - scaleZ, - 0, - 0, - 0, - 0, - 1 - ])); - } - if (originX !== 0 || originY !== 0 || originZ !== 0) { - this[translateSelf](-originX, -originY, -originZ); - } - } - [scale3dSelf](scale = 1, originX = 0, originY = 0, originZ = 0) { - if (originX !== 0 || originY !== 0 || originZ !== 0) { - this[translateSelf](originX, originY, originZ); - } - if (scale !== 1) { - this[multiplySelf](this.constructor[fromArray]([ - scale, - 0, - 0, - 0, - 0, - scale, - 0, - 0, - 0, - 0, - scale, - 0, - 0, - 0, - 0, - 1 - ])); - } - if (originX !== 0 || originY !== 0 || originZ !== 0) { - this[translateSelf](-originX, -originY, -originZ); - } - } - [scaleNonUniformSelf](scaleX = 1, scaleY = 1) { - if (scaleX === 1 && scaleY === 1) { - return; - } - this[multiplySelf](this.constructor[fromArray]([ - scaleX, - 0, - 0, - 0, - 0, - scaleY, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ])); - } - [rotateAxisAngleSelf](x = 0, y = 0, z = 0, angle = 0) { - x = Number(x); - y = Number(y); - z = Number(z); - angle = Number(angle); - if (isNaN(x) || isNaN(y) || isNaN(z) || isNaN(angle)) { - throw new this[window].TypeError(`Failed to execute 'rotateAxisAngleSelf' on 'DOMMatrix': The arguments must be numbers.`); - } - const length = Math.hypot(x, y, z); - if (length === 0) { - return; - } - if (length !== 1) { - x /= length; - y /= length; - z /= length; - } - const alpha = -(angle * Math.PI / 360); - const round = this.#round; - const sc = Math.sin(alpha) * Math.cos(alpha); - const sq = Math.sin(alpha) * Math.sin(alpha); - const m112 = round(1 - 2 * (y * y + z * z) * sq); - const m122 = round(2 * (x * y * sq + z * sc)); - const m132 = round(2 * (x * z * sq - y * sc)); - const m212 = round(2 * (x * y * sq - z * sc)); - const m222 = round(1 - 2 * (x * x + z * z) * sq); - const m232 = round(2 * (y * z * sq + x * sc)); - const m312 = round(2 * (x * z * sq + y * sc)); - const m322 = round(2 * (y * z * sq - x * sc)); - const m332 = round(1 - 2 * (x * x + y * y) * sq); - const matrix = this.constructor[fromArray]([ - m112, - m212, - m312, - 0, - m122, - m222, - m322, - 0, - m132, - m232, - m332, - 0, - 0, - 0, - 0, - 1 - ]); - this[multiplySelf](matrix); - } - [rotateSelf](x = 0, y, z) { - if (y === undefined && z === undefined) { - z = x; - x = 0; - y = 0; - } - if (y === undefined) { - y = 0; - } - if (z === undefined) { - z = 0; - } - x = Number(x); - y = Number(y); - z = Number(z); - if (isNaN(x) || isNaN(y) || isNaN(z)) { - throw new this[window].TypeError(`Failed to execute 'rotateSelf' on 'DOMMatrix': The arguments must be numbers.`); - } - if (z !== 0) { - this[rotateAxisAngleSelf](0, 0, 1, z); - } - if (y !== 0) { - this[rotateAxisAngleSelf](0, 1, 0, y); - } - if (x !== 0) { - this[rotateAxisAngleSelf](1, 0, 0, x); - } - } - [rotateFromVectorSelf](x = 0, y = 0) { - if (x === 0 && y === 0) { - return; - } - this[rotateSelf](Math.atan2(y, x) * 180 / Math.PI); - } - [skewXSelf](angle) { - const matrix = Object.assign({}, DEFAULT_MATRIX_JSON); - const value = Math.tan(angle * Math.PI / 180); - matrix.m21 = value; - matrix.c = value; - this[multiplySelf](matrix); - } - [skewYSelf](angle) { - const matrix = Object.assign({}, DEFAULT_MATRIX_JSON); - const value = Math.tan(angle * Math.PI / 180); - matrix.m12 = value; - matrix.b = value; - this[multiplySelf](matrix); - } - [flipXSelf]() { - const matrix = this.constructor[fromArray]([ - -1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ]); - this[multiplySelf](matrix); - } - [flipYSelf]() { - const matrix = this.constructor[fromArray]([ - 1, - 0, - 0, - 0, - 0, - -1, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 1 - ]); - this[multiplySelf](matrix); - } - [invertSelf]() { - const m112 = this[m22] * this[m33] * this[m44] - this[m22] * this[m34] * this[m43] - this[m32] * this[m23] * this[m44] + this[m32] * this[m24] * this[m43] + this[m42] * this[m23] * this[m34] - this[m42] * this[m24] * this[m33]; - const m122 = -this[m12] * this[m33] * this[m44] + this[m12] * this[m34] * this[m43] + this[m32] * this[m13] * this[m44] - this[m32] * this[m14] * this[m43] - this[m42] * this[m13] * this[m34] + this[m42] * this[m14] * this[m33]; - const m132 = this[m12] * this[m23] * this[m44] - this[m12] * this[m24] * this[m43] - this[m22] * this[m13] * this[m44] + this[m22] * this[m14] * this[m43] + this[m42] * this[m13] * this[m24] - this[m42] * this[m14] * this[m23]; - const m142 = -this[m12] * this[m23] * this[m34] + this[m12] * this[m24] * this[m33] + this[m22] * this[m13] * this[m34] - this[m22] * this[m14] * this[m33] - this[m32] * this[m13] * this[m24] + this[m32] * this[m14] * this[m23]; - const det = this[m11] * m112 + this[m21] * m122 + this[m31] * m132 + this[m41] * m142; - if (det === 0) { - this[m11] = NaN; - this[m12] = NaN; - this[m13] = NaN; - this[m14] = NaN; - this[m21] = NaN; - this[m22] = NaN; - this[m23] = NaN; - this[m24] = NaN; - this[m31] = NaN; - this[m32] = NaN; - this[m33] = NaN; - this[m34] = NaN; - this[m41] = NaN; - this[m42] = NaN; - this[m43] = NaN; - this[m44] = NaN; - return; - } - const m212 = -this[m21] * this[m33] * this[m44] + this[m21] * this[m34] * this[m43] + this[m31] * this[m23] * this[m44] - this[m31] * this[m24] * this[m43] - this[m41] * this[m23] * this[m34] + this[m41] * this[m24] * this[m33]; - const m222 = this[m11] * this[m33] * this[m44] - this[m11] * this[m34] * this[m43] - this[m31] * this[m13] * this[m44] + this[m31] * this[m14] * this[m43] + this[m41] * this[m13] * this[m34] - this[m41] * this[m14] * this[m33]; - const m232 = -this[m11] * this[m23] * this[m44] + this[m11] * this[m24] * this[m43] + this[m21] * this[m13] * this[m44] - this[m21] * this[m14] * this[m43] - this[m41] * this[m13] * this[m24] + this[m41] * this[m14] * this[m23]; - const m242 = this[m11] * this[m23] * this[m34] - this[m11] * this[m24] * this[m33] - this[m21] * this[m13] * this[m34] + this[m21] * this[m14] * this[m33] + this[m31] * this[m13] * this[m24] - this[m31] * this[m14] * this[m23]; - const m312 = this[m21] * this[m32] * this[m44] - this[m21] * this[m34] * this[m42] - this[m31] * this[m22] * this[m44] + this[m31] * this[m24] * this[m42] + this[m41] * this[m22] * this[m34] - this[m41] * this[m24] * this[m32]; - const m322 = -this[m11] * this[m32] * this[m44] + this[m11] * this[m34] * this[m42] + this[m31] * this[m12] * this[m44] - this[m31] * this[m14] * this[m42] - this[m41] * this[m12] * this[m34] + this[m41] * this[m14] * this[m32]; - const m332 = this[m11] * this[m22] * this[m44] - this[m11] * this[m24] * this[m42] - this[m21] * this[m12] * this[m44] + this[m21] * this[m14] * this[m42] + this[m41] * this[m12] * this[m24] - this[m41] * this[m14] * this[m22]; - const m342 = -this[m11] * this[m22] * this[m34] + this[m11] * this[m24] * this[m32] + this[m21] * this[m12] * this[m34] - this[m21] * this[m14] * this[m32] - this[m31] * this[m12] * this[m24] + this[m31] * this[m14] * this[m22]; - const m412 = -this[m21] * this[m32] * this[m43] + this[m21] * this[m33] * this[m42] + this[m31] * this[m22] * this[m43] - this[m31] * this[m23] * this[m42] - this[m41] * this[m22] * this[m33] + this[m41] * this[m23] * this[m32]; - const m422 = this[m11] * this[m32] * this[m43] - this[m11] * this[m33] * this[m42] - this[m31] * this[m12] * this[m43] + this[m31] * this[m13] * this[m42] + this[m41] * this[m12] * this[m33] - this[m41] * this[m13] * this[m32]; - const m432 = -this[m11] * this[m22] * this[m43] + this[m11] * this[m23] * this[m42] + this[m21] * this[m12] * this[m43] - this[m21] * this[m13] * this[m42] - this[m41] * this[m12] * this[m23] + this[m41] * this[m13] * this[m22]; - const m442 = this[m11] * this[m22] * this[m33] - this[m11] * this[m23] * this[m32] - this[m21] * this[m12] * this[m33] + this[m21] * this[m13] * this[m32] + this[m31] * this[m12] * this[m23] - this[m31] * this[m13] * this[m22]; - this[m11] = m112 / det || 0; - this[m12] = m122 / det || 0; - this[m13] = m132 / det || 0; - this[m14] = m142 / det || 0; - this[m21] = m212 / det || 0; - this[m22] = m222 / det || 0; - this[m23] = m232 / det || 0; - this[m24] = m242 / det || 0; - this[m31] = m312 / det || 0; - this[m32] = m322 / det || 0; - this[m33] = m332 / det || 0; - this[m34] = m342 / det || 0; - this[m41] = m412 / det || 0; - this[m42] = m422 / det || 0; - this[m43] = m432 / det || 0; - this[m44] = m442 / det || 0; - } - [toArray](is2D = false) { - if (is2D) { - return [ - this[m11], - this[m12], - this[m21], - this[m22], - this[m41], - this[m42] - ]; - } - return [ - this[m11], - this[m12], - this[m13], - this[m14], - this[m21], - this[m22], - this[m23], - this[m24], - this[m31], - this[m32], - this[m33], - this[m34], - this[m41], - this[m42], - this[m43], - this[m44] - ]; - } - #round(value, decimals = 1000000000000000) { - return Math.round(value * decimals) / decimals; - } - static fromMatrix(matrix) { - if (!(matrix instanceof DOMMatrixReadOnly)) { - if (matrix?.m11 === undefined && matrix?.a !== undefined) { - matrix = Object.assign({}, DEFAULT_MATRIX_JSON, matrix); - matrix.m11 = matrix.a; - matrix.m12 = matrix.b; - matrix.m21 = matrix.c; - matrix.m22 = matrix.d; - matrix.m41 = matrix.e; - matrix.m42 = matrix.f; - } else { - matrix = Object.assign({}, DEFAULT_MATRIX_JSON, matrix); - } - } - return this[fromArray]([ - matrix.m11, - matrix.m12, - matrix.m13, - matrix.m14, - matrix.m21, - matrix.m22, - matrix.m23, - matrix.m24, - matrix.m31, - matrix.m32, - matrix.m33, - matrix.m34, - matrix.m41, - matrix.m42, - matrix.m43, - matrix.m44 - ]); - } - static fromFloat32Array(array) { - return this[fromArray](array); - } - static fromFloat64Array(array) { - return this[fromArray](array); - } - static [fromArray](array) { - if (!(array instanceof Float64Array || array instanceof Float32Array || Array.isArray(array)) || array.length !== 6 && array.length !== 16) { - throw TypeError(`Failed to execute 'fromArray' on '${this.name}': '${String(array)}' is not a compatible array.`); - } - const matrix = new this; - if (array.length === 16) { - const [m112, m122, m132, m142, m212, m222, m232, m242, m312, m322, m332, m342, m412, m422, m432, m442] = array; - matrix[m11] = m112; - matrix[m12] = m122; - matrix[m13] = m132; - matrix[m14] = m142; - matrix[m21] = m212; - matrix[m22] = m222; - matrix[m23] = m232; - matrix[m24] = m242; - matrix[m31] = m312; - matrix[m32] = m322; - matrix[m33] = m332; - matrix[m34] = m342; - matrix[m41] = m412; - matrix[m42] = m422; - matrix[m43] = m432; - matrix[m44] = m442; - } else if (array.length === 6) { - const [m112, m122, m212, m222, m412, m422] = array; - matrix[m11] = m112; - matrix[m12] = m122; - matrix[m21] = m212; - matrix[m22] = m222; - matrix[m41] = m412; - matrix[m42] = m422; - } - return matrix; - } - static [fromString](source) { - if (typeof source !== "string") { - throw TypeError(`Failed to execute 'setMatrixValue' on '${this.name}': Expected '${String(source)}' to be a string.`); - } - const domMatrix = new this; - const regexp = new RegExp(TRANSFORM_REGEXP); - let match; - while (match = regexp.exec(source)) { - const name = match[1]; - const parameters = match[2].split(TRANSFORM_PARAMETER_SPLIT_REGEXP); - for (let i = 0, max = parameters.length;i < max; i++) { - parameters[i] = this[getLength](parameters[i]); - } - const [x, y, z, a] = parameters; - switch (name) { - case "perspective": - if (!isNaN(x) && x !== 0 && y === undefined && z === undefined) { - domMatrix[m34] = -1 / x; - } - break; - case "translate": - if (!isNaN(x) && z === undefined) { - domMatrix[translateSelf](x, y || 0, 0); - } - break; - case "translate3d": - if (!isNaN(x) && !isNaN(y) && !isNaN(z)) { - domMatrix[translateSelf](x, y, z); - } - break; - case "translateX": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[translateSelf](x); - } - break; - case "translateY": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[translateSelf](0, x); - } - break; - case "translateZ": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[translateSelf](0, 0, x); - } - break; - case "matrix": - case "matrix3d": - if (parameters.length === 6 || parameters.length === 16) { - domMatrix[setMatrixValue](this[fromArray](parameters)); - } - break; - case "rotate": - case "rotateZ": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[rotateSelf](0, 0, x); - } - break; - case "rotateX": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[rotateSelf](x, 0, 0); - } - break; - case "rotateY": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[rotateSelf](0, x, 0); - } - case "rotate3d": - if (!isNaN(x) && !isNaN(y) && !isNaN(z) && !isNaN(a)) { - domMatrix[rotateAxisAngleSelf](x, y, z, a); - } - break; - case "scale": - if (!isNaN(x) && x !== 1 && z === undefined) { - domMatrix[scaleSelf](x, isNaN(y) ? x : y); - } - break; - case "scale3d": - if (!isNaN(x) && !isNaN(y) && !isNaN(z)) { - domMatrix[scaleSelf](x, y, z); - } - break; - case "scaleX": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[scaleSelf](x, 1, 1); - } - break; - case "scaleY": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[scaleSelf](1, x, 1); - } - break; - case "scaleZ": - if (!isNaN(x) && y === undefined && z === undefined) { - domMatrix[scaleSelf](1, 1, x); - } - break; - case "skew": - if (!isNaN(x)) { - domMatrix[skewXSelf](x); - } - if (!isNaN(y)) { - domMatrix[skewYSelf](y); - } - break; - case "skewX": - if (!isNaN(x) && y === undefined) { - domMatrix[skewXSelf](x); - } - break; - case "skewY": - if (!isNaN(x) && y === undefined) { - domMatrix[skewYSelf](x); - } - break; - default: - throw TypeError(`Failed to execute 'setMatrixValue' on '${this.name}': Unknown transform function '${match[1]}'.`); - } - } - return domMatrix; - } - static [getLength](length) { - const value = parseFloat(length); - const unit = length.replace(value.toString(), ""); - switch (unit) { - case "rem": - case "em": - case "vw": - case "vh": - case "%": - case "vmin": - case "vmax": - throw new SyntaxError(`Failed to construct '${this.name}': Lengths must be absolute, not relative`); - case "rad": - return value * (180 / Math.PI); - case "turn": - return value * 360; - case "px": - return value; - case "cm": - return value * 37.7812; - case "mm": - return value * 3.7781; - case "in": - return value * 96; - case "pt": - return value * 1.3281; - case "pc": - return value * 16; - case "Q": - return value * 0.945; - default: - return value; - } - } -} - -// node_modules/happy-dom/lib/dom/dom-matrix/DOMMatrix.js -class DOMMatrix extends DOMMatrixReadOnly { - get a() { - return this[m11]; - } - set a(value) { - this[m11] = value; - } - get b() { - return this[m12]; - } - set b(value) { - this[m12] = value; - } - get c() { - return this[m21]; - } - set c(value) { - this[m21] = value; - } - get d() { - return this[m22]; - } - set d(value) { - this[m22] = value; - } - get e() { - return this[m41]; - } - set e(value) { - this[m41] = value; - } - get f() { - return this[m42]; - } - set f(value) { - this[m42] = value; - } - get m11() { - return this[m11]; - } - set m11(value) { - this[m11] = value; - } - get m12() { - return this[m12]; - } - set m12(value) { - this[m12] = value; - } - get m13() { - return this[m13]; - } - set m13(value) { - this[m13] = value; - } - get m14() { - return this[m14]; - } - set m14(value) { - this[m14] = value; - } - get m21() { - return this[m21]; - } - set m21(value) { - this[m21] = value; - } - get m22() { - return this[m22]; - } - set m22(value) { - this[m22] = value; - } - get m23() { - return this[m23]; - } - set m23(value) { - this[m23] = value; - } - get m24() { - return this[m24]; - } - set m24(value) { - this[m24] = value; - } - get m31() { - return this[m31]; - } - set m31(value) { - this[m31] = value; - } - get m32() { - return this[m32]; - } - set m32(value) { - this[m32] = value; - } - get m33() { - return this[m33]; - } - set m33(value) { - this[m33] = value; - } - get m34() { - return this[m34]; - } - set m34(value) { - this[m34] = value; - } - get m41() { - return this[m41]; - } - set m41(value) { - this[m41] = value; - } - get m42() { - return this[m42]; - } - set m42(value) { - this[m42] = value; - } - get m43() { - return this[m43]; - } - set m43(value) { - this[m43] = value; - } - get m44() { - return this[m44]; - } - set m44(value) { - this[m44] = value; - } - setMatrixValue(source) { - this[setMatrixValue](source); - return this; - } - multiplySelf(secondMatrix) { - this[multiplySelf](secondMatrix); - return this; - } - translateSelf(x = 0, y = 0, z = 0) { - this[translateSelf](x, y, z); - return this; - } - scaleSelf(scaleX, scaleY, scaleZ = 1, originX = 0, originY = 0, originZ = 0) { - this[scaleSelf](scaleX, scaleY, scaleZ, originX, originY, originZ); - return this; - } - scale3dSelf(scale = 1, originX = 0, originY = 0, originZ = 0) { - this[scale3dSelf](scale, originX, originY, originZ); - return this; - } - scaleNonUniformSelf(scaleX = 1, scaleY = 1) { - this[scaleNonUniformSelf](scaleX, scaleY); - return this; - } - rotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0) { - this[rotateAxisAngleSelf](x, y, z, angle); - return this; - } - rotateSelf(x = 0, y, z) { - this[rotateSelf](x, y, z); - return this; - } - rotateFromVectorSelf(x = 0, y = 0) { - this[rotateFromVectorSelf](x, y); - return this; - } - skewXSelf(angle) { - this[skewXSelf](angle); - return this; - } - skewYSelf(angle) { - this[skewYSelf](angle); - return this; - } - flipXSelf() { - this[flipXSelf](); - return this; - } - flipYSelf() { - this[flipYSelf](); - return this; - } - invertSelf() { - this[invertSelf](); - return this; - } - preMultiplySelf(otherMatrix) { - this[multiplySelf](otherMatrix); - return this; - } -} - -// node_modules/happy-dom/lib/dom/DOMPointReadOnly.js -class DOMPointReadOnly { - [x] = 0; - [y] = 0; - [z] = 0; - [w] = 1; - constructor(x2, y2, z2, w2) { - this[x] = x2 !== undefined && x2 !== null ? Number(x2) : 0; - this[y] = y2 !== undefined && y2 !== null ? Number(y2) : 0; - this[z] = z2 !== undefined && z2 !== null ? Number(z2) : 0; - this[w] = w2 !== undefined && w2 !== null ? Number(w2) : 1; - } - get x() { - return this[x]; - } - get y() { - return this[y]; - } - get z() { - return this[z]; - } - get w() { - return this[w]; - } - toJSON() { - return { - x: this.x, - y: this.y, - z: this.z, - w: this.w - }; - } - static fromPoint(otherPoint) { - if (!otherPoint) { - return new this; - } - return new this(otherPoint.x ?? null, otherPoint.y ?? null, otherPoint.z ?? null, otherPoint.w ?? null); - } - matrixTransform(init) { - const matrix = new this[window].DOMMatrixReadOnly(init); - const x2 = this.x * matrix.m11 + this.y * matrix.m21 + this.z * matrix.m31 + this.w * matrix.m41; - const y2 = this.x * matrix.m12 + this.y * matrix.m22 + this.z * matrix.m32 + this.w * matrix.m42; - const z2 = this.x * matrix.m13 + this.y * matrix.m23 + this.z * matrix.m33 + this.w * matrix.m43; - const w2 = this.x * matrix.m14 + this.y * matrix.m24 + this.z * matrix.m34 + this.w * matrix.m44; - return new this.constructor(x2, y2, z2, w2); - } -} - -// node_modules/happy-dom/lib/dom/DOMPoint.js -class DOMPoint extends DOMPointReadOnly { - set x(value) { - this[x] = value; - } - get x() { - return this[x]; - } - set y(value) { - this[y] = value; - } - get y() { - return this[y]; - } - set z(value) { - this[z] = value; - } - get z() { - return this[z]; - } - set w(value) { - this[w] = value; - } - get w() { - return this[w]; - } -} - -// node_modules/happy-dom/lib/window/WindowContextClassExtender.js -class WindowContextClassExtender { - static extendClasses(window2) { - class Document2 extends Document { - } - Document2.prototype[window] = window2; - window2.Document = Document2; - - class HTMLDocument2 extends HTMLDocument { - } - HTMLDocument2.prototype[window] = window2; - window2.HTMLDocument = HTMLDocument2; - - class XMLDocument2 extends XMLDocument { - } - XMLDocument2.prototype[window] = window2; - window2.XMLDocument = XMLDocument2; - - class DocumentFragment2 extends DocumentFragment { - } - DocumentFragment2.prototype[window] = window2; - window2.DocumentFragment = DocumentFragment2; - - class Text2 extends Text { - } - Text2.prototype[window] = window2; - window2.Text = Text2; - - class Comment2 extends Comment { - } - Comment2.prototype[window] = window2; - window2.Comment = Comment2; - - class Image2 extends Image { - } - Image2.prototype[window] = window2; - window2.Image = Image2; - - class Audio2 extends Audio { - } - Audio2.prototype[window] = window2; - window2.Audio = Audio2; - - class MutationObserver2 extends MutationObserver { - } - MutationObserver2.prototype[window] = window2; - window2.MutationObserver = MutationObserver2; - - class MessagePort2 extends MessagePort { - } - MessagePort2.prototype[window] = window2; - window2.MessagePort = MessagePort2; - - class CSSStyleSheet2 extends CSSStyleSheet { - } - CSSStyleSheet2.prototype[window] = window2; - window2.CSSStyleSheet = CSSStyleSheet2; - - class DOMException2 extends DOMException { - } - window2.DOMException = DOMException2; - - class Headers2 extends Headers { - } - Headers2.prototype[window] = window2; - window2.Headers = Headers2; - - class Request2 extends Request { - } - Request2.prototype[window] = window2; - window2.Request = Request2; - - class Response2 extends Response { - } - Response2.prototype[window] = window2; - Response2[window] = window2; - window2.Response = Response2; - - class EventTarget2 extends EventTarget { - } - EventTarget2.prototype[window] = window2; - window2.EventTarget = EventTarget2; - - class XMLHttpRequestUpload2 extends XMLHttpRequestUpload { - } - XMLHttpRequestUpload2.prototype[window] = window2; - window2.XMLHttpRequestUpload = XMLHttpRequestUpload2; - - class XMLHttpRequestEventTarget2 extends XMLHttpRequestEventTarget { - } - XMLHttpRequestEventTarget2.prototype[window] = window2; - window2.XMLHttpRequestEventTarget = XMLHttpRequestEventTarget2; - - class AbortController2 extends AbortController { - } - AbortController2.prototype[window] = window2; - window2.AbortController = AbortController2; - - class AbortSignal2 extends AbortSignal { - } - AbortSignal2.prototype[window] = window2; - AbortSignal2[window] = window2; - window2.AbortSignal = AbortSignal2; - - class FormData2 extends FormData { - } - FormData2.prototype[window] = window2; - window2.FormData = FormData2; - - class PermissionStatus2 extends PermissionStatus { - } - PermissionStatus2.prototype[window] = window2; - window2.PermissionStatus = PermissionStatus2; - - class XMLHttpRequest2 extends XMLHttpRequest { - } - XMLHttpRequest2.prototype[window] = window2; - window2.XMLHttpRequest = XMLHttpRequest2; - - class DOMParser2 extends DOMParser { - } - DOMParser2.prototype[window] = window2; - window2.DOMParser = DOMParser2; - - class Range2 extends Range { - } - Range2.prototype[window] = window2; - window2.Range = Range2; - - class VTTCue2 extends VTTCue { - } - VTTCue2.prototype[window] = window2; - window2.VTTCue = VTTCue2; - - class TextTrack2 extends TextTrack { - } - TextTrack2.prototype[window] = window2; - window2.TextTrack = TextTrack2; - - class TextTrackList2 extends TextTrackList { - } - TextTrackList2.prototype[window] = window2; - window2.TextTrackList = TextTrackList2; - - class TextTrackCue2 extends TextTrackCue { - } - TextTrackCue2.prototype[window] = window2; - window2.TextTrackCue = TextTrackCue2; - - class RemotePlayback2 extends RemotePlayback { - } - RemotePlayback2.prototype[window] = window2; - window2.RemotePlayback = RemotePlayback2; - - class FileReader2 extends FileReader { - } - FileReader2.prototype[window] = window2; - window2.FileReader = FileReader2; - - class MediaStream2 extends MediaStream { - } - MediaStream2.prototype[window] = window2; - window2.MediaStream = MediaStream2; - - class MediaStreamTrack2 extends MediaStreamTrack { - } - MediaStreamTrack2.prototype[window] = window2; - window2.MediaStreamTrack = MediaStreamTrack2; - - class CanvasCaptureMediaStreamTrack2 extends CanvasCaptureMediaStreamTrack { - } - CanvasCaptureMediaStreamTrack2.prototype[window] = window2; - window2.CanvasCaptureMediaStreamTrack = CanvasCaptureMediaStreamTrack2; - - class URL3 extends URL2 { - } - URL3.prototype[window] = window2; - window2.URL = URL3; - - class WebSocket2 extends WebSocket { - } - WebSocket2.prototype[window] = window2; - window2.WebSocket = WebSocket2; - - class ImageData2 extends ImageData { - } - ImageData2.prototype[window] = window2; - window2.ImageData = ImageData2; - - class OffscreenCanvas2 extends OffscreenCanvas { - } - OffscreenCanvas2.prototype[window] = window2; - window2.OffscreenCanvas = OffscreenCanvas2; - - class DOMMatrixReadOnly2 extends DOMMatrixReadOnly { - } - DOMMatrixReadOnly2.prototype[window] = window2; - window2.DOMMatrixReadOnly = DOMMatrixReadOnly2; - - class DOMMatrix2 extends DOMMatrix { - } - DOMMatrix2.prototype[window] = window2; - window2.DOMMatrix = DOMMatrix2; - - class DOMPointReadOnly2 extends DOMPointReadOnly { - } - DOMPointReadOnly2.prototype[window] = window2; - window2.DOMPointReadOnly = DOMPointReadOnly2; - - class DOMPoint2 extends DOMPoint { - } - DOMPoint2.prototype[window] = window2; - window2.DOMPoint = DOMPoint2; - } -} - -// node_modules/happy-dom/lib/svg/SVGStringList.js -var ATTRIBUTE_SPLIT_REGEXP2 = /[\t\f\n\r ,]+/; - -class SVGStringList { - [window]; - [getAttribute]; - [setAttribute]; - [readOnly] = false; - [cache] = { - items: [], - attributeValue: "" - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - const methodBinder = new ClassMethodBinder(this, [SVGStringList]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length" || property === "numberOfItems") { - return target[getItemList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get numberOfItems() { - return this[getItemList]().length; - } - [Symbol.iterator]() { - return this[getItemList]().values(); - } - clear() { - this[cache].attributeValue = ""; - this[cache].items = []; - this[setAttribute](""); - } - initialize(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGStringList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGStringList': 1 arguments required, but only ${arguments.length} present.`); - } - newItem = String(newItem); - if (!newItem) { - this.clear(); - return; - } - this[setAttribute](newItem); - return newItem; - } - getItem(index) { - const items = this[getItemList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - insertItemBefore(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGStringList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.`); - } - newItem = String(newItem); - if (!newItem) { - return newItem; - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index > items.length) { - index = items.length; - } - items.splice(index, 0, newItem); - this[setAttribute](items.join(" ")); - return newItem; - } - replaceItem(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGStringList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.`); - } - newItem = String(newItem); - if (!newItem) { - return this.removeItem(index); - } - const items = this[getItemList](); - if (index < 0) { - index = 0; - } else if (index >= items.length) { - index = items.length - 1; - } - const replacedItem = items[index]; - items[index] = newItem; - this[setAttribute](items.join(" ")); - return replacedItem; - } - removeItem(index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGStringList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - index = Number(index); - if (isNaN(index)) { - index = 0; - } - if (index >= items.length) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGStringList': The index provided (${index}) is greater than the maximum bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index < 0) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGStringList': The index provided (${index}) is negative.`, DOMExceptionNameEnum_default.indexSizeError); - } - const removedItem = items[index]; - items.splice(index, 1); - this[setAttribute](items.join(" ")); - return removedItem; - } - appendItem(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGStringList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.`); - } - newItem = String(newItem); - if (!newItem) { - return newItem; - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - items.push(newItem); - this[setAttribute](items.join(" ")); - return newItem; - } - [getItemList]() { - const attributeValue = this[getAttribute]() ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue) { - return cache2.items; - } - const items = []; - const trimmed = attributeValue.trim(); - if (trimmed) { - for (const item of trimmed.split(ATTRIBUTE_SPLIT_REGEXP2)) { - if (!items.includes(item)) { - items.push(item); - } - } - } - cache2.attributeValue = attributeValue; - cache2.items = items; - return items; - } -} - -// node_modules/happy-dom/lib/svg/SVGMatrix.js -var TRANSFORM_REGEXP2 = /([a-zA-Z0-9]+)\(([^)]+)\)/; -var TRANSFORM_PARAMETER_SPLIT_REGEXP2 = /[\s,]+/; - -class SVGMatrix { - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get a() { - return this[getDOMMatrix]().a; - } - set a(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.a = value; - this[setDOMMatrix](domMatrix); - } - get b() { - return this[getDOMMatrix]().b; - } - set b(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.b = value; - this[setDOMMatrix](domMatrix); - } - get c() { - return this[getDOMMatrix]().c; - } - set c(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.c = value; - this[setDOMMatrix](domMatrix); - } - get d() { - return this[getDOMMatrix]().d; - } - set d(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.d = value; - this[setDOMMatrix](domMatrix); - } - get e() { - return this[getDOMMatrix]().e; - } - set e(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.e = value; - this[setDOMMatrix](domMatrix); - } - get f() { - return this[getDOMMatrix]().f; - } - set f(value) { - if (this[readOnly]) { - return; - } - const domMatrix = this[getDOMMatrix](); - domMatrix.f = value; - this[setDOMMatrix](domMatrix); - } - multiply(secondMatrix) { - if (!(secondMatrix instanceof SVGMatrix)) { - throw new this[window].TypeError("Failed to execute 'multiply' on 'SVGMatrix': parameter 1 is not of type 'SVGMatrix'."); - } - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.multiplySelf(secondMatrix[getDOMMatrix]()); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - translate(x = 0, y = 0) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.translateSelf(x, y); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - scale(scale) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.scaleSelf(scale); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - scaleNonUniform(scaleX = 1, scaleY = 1) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.scaleNonUniformSelf(scaleX, scaleY); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - rotate(angle) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.rotateSelf(angle); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - rotateFromVector(x = 0, y = 0) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.rotateFromVectorSelf(x, y); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - skewX(angle) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.skewXSelf(angle); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - skewY(angle) { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.skewYSelf(angle); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - flipX() { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.flipXSelf(); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - flipY() { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.flipYSelf(); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - inverse() { - const domMatrix = this[getDOMMatrix](); - const svgMatrix = new SVGMatrix(illegalConstructor, this[window]); - domMatrix.invertSelf(); - svgMatrix[setDOMMatrix](domMatrix); - return svgMatrix; - } - [getDOMMatrix]() { - const attribute = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const window2 = this[window]; - if (!attribute) { - return new window2.DOMMatrix; - } - const match = attribute.match(TRANSFORM_REGEXP2); - if (!match) { - return new window2.DOMMatrix; - } - const parameters = []; - for (const parameter of match[2].trim().split(TRANSFORM_PARAMETER_SPLIT_REGEXP2)) { - const value = Number(parameter); - if (isNaN(value)) { - throw new window2.TypeError(`Failed to parse transform attribute: Expected number, but got "${parameter}" in "${attribute}".`); - } - parameters.push(value); - } - switch (match[1]) { - case "matrix": - if (parameters.length !== 6) { - throw new window2.TypeError(`Failed to parse transform attribute: Expected 6 parameters in "${attribute}".`); - } - return DOMMatrix[fromString](attribute); - case "scale": - case "translate": - if (parameters.length !== 1 && parameters.length !== 2) { - throw new window2.TypeError(`Failed to parse transform attribute: Expected 1 or 2 parameters in "${attribute}".`); - } - return DOMMatrix[fromString](attribute); - case "skewY": - case "skewX": - if (parameters.length !== 1) { - throw new window2.TypeError(`Failed to parse transform attribute: Expected 1 parameter in "${attribute}".`); - } - return DOMMatrix[fromString](attribute); - case "rotate": - const domMatrix = new window2.DOMMatrix; - if (parameters.length !== 1 && parameters.length !== 3) { - throw new window2.TypeError(`Failed to parse transform attribute: Expected 1 or 3 parameters in "${attribute}".`); - } - const [angle, x, y] = parameters; - if (x || y) { - domMatrix.translateSelf(x, y); - } - const radian = angle * Math.PI / 180; - domMatrix.multiplySelf(new window2.DOMMatrix([ - Math.cos(radian), - Math.sin(radian), - -Math.sin(radian), - Math.cos(radian), - 0, - 0 - ])); - if (x || y) { - domMatrix.translateSelf(-x, -y); - } - return domMatrix; - default: - throw new this[window].TypeError(`Failed to parse transform attribute: Unknown transformation "${attribute}".`); - } - } - [setDOMMatrix](domMatrix) { - this[attributeValue] = domMatrix.toString().replace(/, /g, " "); - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGTransformTypeEnum.js -var SVGTransformTypeEnum; -(function(SVGTransformTypeEnum) { - SVGTransformTypeEnum[SVGTransformTypeEnum["unknown"] = 0] = "unknown"; - SVGTransformTypeEnum[SVGTransformTypeEnum["matrix"] = 1] = "matrix"; - SVGTransformTypeEnum[SVGTransformTypeEnum["translate"] = 2] = "translate"; - SVGTransformTypeEnum[SVGTransformTypeEnum["scale"] = 3] = "scale"; - SVGTransformTypeEnum[SVGTransformTypeEnum["rotate"] = 4] = "rotate"; - SVGTransformTypeEnum[SVGTransformTypeEnum["skewX"] = 5] = "skewX"; - SVGTransformTypeEnum[SVGTransformTypeEnum["skewY"] = 6] = "skewY"; -})(SVGTransformTypeEnum || (SVGTransformTypeEnum = {})); -var SVGTransformTypeEnum_default = SVGTransformTypeEnum; - -// node_modules/happy-dom/lib/svg/SVGTransform.js -var TRANSFORM_REGEXP3 = /([a-zA-Z0-9]+)\(([^)]+)\)/; -var TRANSFORM_PARAMETER_SPLIT_REGEXP3 = /[\s,]+/; - -class SVGTransform { - static SVG_TRANSFORM_UNKNOWN = SVGTransformTypeEnum_default.unknown; - static SVG_TRANSFORM_MATRIX = SVGTransformTypeEnum_default.matrix; - static SVG_TRANSFORM_TRANSLATE = SVGTransformTypeEnum_default.translate; - static SVG_TRANSFORM_SCALE = SVGTransformTypeEnum_default.scale; - static SVG_TRANSFORM_ROTATE = SVGTransformTypeEnum_default.rotate; - static SVG_TRANSFORM_SKEWX = SVGTransformTypeEnum_default.skewX; - static SVG_TRANSFORM_SKEWY = SVGTransformTypeEnum_default.skewY; - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - [matrix] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get type() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const match = attributeValue2?.match(TRANSFORM_REGEXP3); - if (!match) { - return SVGTransformTypeEnum_default.unknown; - } - switch (match[1]) { - case "matrix": - return SVGTransformTypeEnum_default.matrix; - case "translate": - return SVGTransformTypeEnum_default.translate; - case "rotate": - return SVGTransformTypeEnum_default.rotate; - case "scale": - return SVGTransformTypeEnum_default.scale; - case "skewX": - return SVGTransformTypeEnum_default.skewX; - case "skewY": - return SVGTransformTypeEnum_default.skewY; - } - return 0; - } - get angle() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const match = attributeValue2?.match(TRANSFORM_REGEXP3); - if (!match) { - return 0; - } - const angle = parseFloat(match[2].trim().split(TRANSFORM_PARAMETER_SPLIT_REGEXP3)[0]); - if (isNaN(angle)) { - return 0; - } - switch (match[1]) { - case "rotate": - case "skewX": - case "skewY": - return angle; - } - return 0; - } - get matrix() { - if (!this[matrix]) { - this[matrix] = new SVGMatrix(illegalConstructor, this[window], { - readOnly: this[readOnly], - getAttribute: () => { - if (this[getAttribute]) { - return this[getAttribute](); - } - return this[attributeValue]; - }, - setAttribute: (value) => { - this[attributeValue] = value; - if (this[setAttribute]) { - this[setAttribute](value); - return; - } - } - }); - } - return this[matrix]; - } - setMatrix(matrix2) { - if (!(matrix2 instanceof SVGMatrix)) { - throw new TypeError('Failed to set the "matrix" property on "SVGTransform": The provided value is not of type "SVGMatrix".'); - } - if (this[readOnly]) { - return; - } - if (this[matrix]) { - this[matrix][getAttribute] = null; - this[matrix][setAttribute] = null; - } - matrix2[getAttribute] = () => { - if (this[getAttribute]) { - return this[getAttribute](); - } - return this[attributeValue]; - }; - matrix2[setAttribute] = (value) => { - this[attributeValue] = value; - if (this[setAttribute]) { - this[setAttribute](value); - return; - } - }; - this[matrix] = matrix2; - if (matrix2[attributeValue] !== this[attributeValue]) { - this[attributeValue] = matrix2[attributeValue]; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue] || ""); - } - } - } - setTranslate(x, y) { - if (arguments.length < 2) { - throw new TypeError(`Failed to execute 'setTranslate' on 'SVGTransform': 2 arguments required, but only ${arguments.length} present.`); - } - x = Number(x); - y = Number(y); - if (isNaN(x) || isNaN(y)) { - throw new TypeError(`Failed to execute 'setTranslate' on 'SVGTransform': The provided float value is non-finite.`); - } - if (this[readOnly]) { - return; - } - this[attributeValue] = `translate(${x} ${y})`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - setScale(x, y) { - if (arguments.length < 2) { - throw new TypeError(`Failed to execute 'setScale' on 'SVGTransform': 2 arguments required, but only ${arguments.length} present.`); - } - x = Number(x); - y = Number(y); - if (isNaN(x) || isNaN(y)) { - throw new TypeError(`Failed to execute 'setScale' on 'SVGTransform': The provided float value is non-finite.`); - } - if (this[readOnly]) { - return; - } - this[attributeValue] = `scale(${x} ${y})`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - setRotate(angle, x, y) { - if (arguments.length < 3) { - throw new TypeError(`Failed to execute 'setRotate' on 'SVGTransform': 3 arguments required, but only ${arguments.length} present.`); - } - angle = Number(angle); - x = Number(x); - y = Number(y); - if (isNaN(angle) || isNaN(x) || isNaN(y)) { - throw new TypeError(`Failed to execute 'setRotate' on 'SVGTransform': The provided float value is non-finite.`); - } - if (this[readOnly]) { - return; - } - this[attributeValue] = `rotate(${angle} ${x} ${y})`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - setSkewX(angle) { - if (arguments.length < 1) { - throw new TypeError(`Failed to execute 'setSkewX' on 'SVGTransform': 1 arguments required, but only ${arguments.length} present.`); - } - angle = Number(angle); - if (isNaN(angle)) { - throw new TypeError(`Failed to execute 'setSkewX' on 'SVGTransform': The provided float value is non-finite.`); - } - if (this[readOnly]) { - return; - } - this[attributeValue] = `skewX(${angle})`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - setSkewY(angle) { - if (arguments.length < 1) { - throw new TypeError(`Failed to execute 'setSkewY' on 'SVGTransform': 1 arguments required, but only ${arguments.length} present.`); - } - angle = Number(angle); - if (isNaN(angle)) { - throw new TypeError(`Failed to execute 'setSkewY' on 'SVGTransform': The provided float value is non-finite.`); - } - if (this[readOnly]) { - return; - } - this[attributeValue] = `skewY(${angle})`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGTransformList.js -var TRANSFORM_REGEXP4 = /([a-zA-Z0-9]+)\(([^)]+)\)/gm; -var EMPTY_MATRIX = "matrix(1 0 0 1 0 0)"; - -class SVGTransformList { - [window]; - [getAttribute]; - [setAttribute]; - [readOnly] = false; - [cache] = { - items: [], - attributeValue: "" - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - const methodBinder = new ClassMethodBinder(this, [SVGTransformList]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length" || property === "numberOfItems") { - return target[getItemList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get numberOfItems() { - return this[getItemList]().length; - } - [Symbol.iterator]() { - return this[getItemList]().values(); - } - clear() { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'clear' on 'SVGTransformList': The object is read-only.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - this[cache].items = []; - this[cache].attributeValue = ""; - this[setAttribute](""); - } - initialize(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGTransformList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGTransformList': 1 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGTransform)) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGTransformList': parameter 1 is not of type 'SVGTransform'.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].items = [newItem]; - this[cache].attributeValue = newItem[attributeValue]; - this[setAttribute](newItem[attributeValue] || ""); - return newItem; - } - getItem(index) { - const items = this[getItemList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - insertItemBefore(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGTransformList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGTransformList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGTransform)) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGTransformList': parameter 1 is not of type 'SVGTransform'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index > items.length) { - index = items.length; - } - items.splice(index, 0, newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - replaceItem(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGTransformList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGTransformList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGTransform)) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGTransformList': parameter 1 is not of type 'SVGTransform'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex === index) { - return newItem; - } - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index >= items.length) { - index = items.length - 1; - } - if (items[index]) { - items[index][getAttribute] = null; - items[index][setAttribute] = null; - } - const replacedItem = items[index]; - items[index] = newItem; - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - return replacedItem; - } - removeItem(index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGTransformList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGTransformList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - index = Number(index); - if (isNaN(index)) { - index = 0; - } - if (index >= items.length) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGTransformList': The index provided (${index}) is greater than the maximum bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index < 0) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGTransformList': The index provided (${index}) is negative.`, DOMExceptionNameEnum_default.indexSizeError); - } - const removedItem = items[index]; - if (removedItem) { - removedItem[getAttribute] = null; - removedItem[setAttribute] = null; - } - items.splice(index, 1); - this[cache].attributeValue = items.map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - return removedItem; - } - appendItem(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGTransformList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGTransformList': 1 argument required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGTransform)) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGTransformList': parameter 1 is not of type 'SVGTransform'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - items.push(newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - [getItemList]() { - const attributeValue2 = this[getAttribute]() ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue2) { - return cache2.items; - } - if (cache2.items.length) { - for (const item of cache2.items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - } - const items = []; - const trimmed = attributeValue2.trim(); - if (trimmed) { - const regexp = new RegExp(TRANSFORM_REGEXP4); - let match; - while (match = regexp.exec(trimmed)) { - const item = new SVGTransform(illegalConstructor, this[window], { - readOnly: this[readOnly], - getAttribute: () => item[attributeValue], - setAttribute: () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || EMPTY_MATRIX).join(" "); - this[setAttribute](this[cache].attributeValue); - } - }); - item[attributeValue] = `${match[1]}(${match[2]})`; - items.push(item); - } - } - cache2.attributeValue = attributeValue2; - cache2.items = items; - return items; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedTransformList.js -class SVGAnimatedTransformList { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGTransformList(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute], - setAttribute: () => {} - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGTransformList(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/nodes/svg-graphics-element/SVGGraphicsElement.js -class SVGGraphicsElement extends SVGElement { - [requiredExtensions] = null; - [systemLanguage] = null; - [transform] = null; - get oncopy() { - return ElementEventAttributeUtility.getEventListener(this, "oncopy"); - } - set oncopy(value) { - this[propertyEventListeners].set("oncopy", value); - } - get oncut() { - return ElementEventAttributeUtility.getEventListener(this, "oncut"); - } - set oncut(value) { - this[propertyEventListeners].set("oncut", value); - } - get onpaste() { - return ElementEventAttributeUtility.getEventListener(this, "onpaste"); - } - set onpaste(value) { - this[propertyEventListeners].set("onpaste", value); - } - get requiredExtensions() { - if (!this[requiredExtensions]) { - this[requiredExtensions] = new SVGStringList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("requiredExtensions"), - setAttribute: (value) => this.setAttribute("requiredExtensions", value) - }); - } - return this[requiredExtensions]; - } - get systemLanguage() { - if (!this[systemLanguage]) { - this[systemLanguage] = new SVGStringList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("systemLanguage"), - setAttribute: (value) => this.setAttribute("systemLanguage", value) - }); - } - return this[systemLanguage]; - } - get transform() { - if (!this[transform]) { - this[transform] = new SVGAnimatedTransformList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("transform"), - setAttribute: (value) => this.setAttribute("transform", value) - }); - } - return this[transform]; - } - getBBox() { - return new DOMRect; - } - getCTM() { - return new this[window].DOMMatrix; - } - getScreenCTM() { - return new this[window].DOMMatrix; - } -} - -// node_modules/happy-dom/lib/svg/SVGRect.js -class SVGRect { - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get x() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return 0; - } - const parts = attributeValue2.split(/\s+/); - const value = Number(parts[0]); - return isNaN(value) ? 0 : value; - } - set x(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'x' property on 'SVGRect': The object is read-only.`); - } - this[attributeValue] = `${String(typeof value === "number" ? value : parseFloat(value))} ${this.y} ${this.width} ${this.height}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get y() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return 0; - } - const parts = attributeValue2.split(/\s+/); - const value = Number(parts[1]); - return isNaN(value) ? 0 : value; - } - set y(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'y' property on 'SVGRect': The object is read-only.`); - } - this[attributeValue] = `${this.x} ${String(typeof value === "number" ? value : parseFloat(value))} ${this.width} ${this.height}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get width() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return 0; - } - const parts = attributeValue2.split(/\s+/); - const value = Number(parts[2]); - return isNaN(value) ? 0 : value; - } - set width(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'width' property on 'SVGRect': The object is read-only.`); - } - this[attributeValue] = `${this.x} ${this.y} ${String(typeof value === "number" ? value : parseFloat(value))} ${this.height}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get height() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return 0; - } - const parts = attributeValue2.split(/\s+/); - const value = Number(parts[3]); - return isNaN(value) ? 0 : value; - } - set height(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'height' property on 'SVGRect': The object is read-only.`); - } - this[attributeValue] = `${this.x} ${this.y} ${this.width} ${String(typeof value === "number" ? value : parseFloat(value))}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGPoint.js -var ATTRIBUTE_SEPARATOR_REGEXP = /[\t\f\n\r, ]+/; - -class SVGPoint { - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get x() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const parts = (attributeValue2 || "").split(ATTRIBUTE_SEPARATOR_REGEXP); - return parts[0] ? parseFloat(parts[0]) : 0; - } - set x(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'x' property on 'SVGPoint': The object is read-only.`); - } - this[attributeValue] = `${value} ${this.y}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get y() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const parts = (attributeValue2 || "").split(ATTRIBUTE_SEPARATOR_REGEXP); - return parts[1] ? parseFloat(parts[1]) : 0; - } - set y(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'y' property on 'SVGPoint': The object is read-only.`); - } - this[attributeValue] = `${this.x} ${value}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGLengthTypeEnum.js -var SVGLengthTypeEnum; -(function(SVGLengthTypeEnum) { - SVGLengthTypeEnum[SVGLengthTypeEnum["unknown"] = 0] = "unknown"; - SVGLengthTypeEnum[SVGLengthTypeEnum["number"] = 1] = "number"; - SVGLengthTypeEnum[SVGLengthTypeEnum["percentage"] = 2] = "percentage"; - SVGLengthTypeEnum[SVGLengthTypeEnum["ems"] = 3] = "ems"; - SVGLengthTypeEnum[SVGLengthTypeEnum["exs"] = 4] = "exs"; - SVGLengthTypeEnum[SVGLengthTypeEnum["px"] = 5] = "px"; - SVGLengthTypeEnum[SVGLengthTypeEnum["cm"] = 6] = "cm"; - SVGLengthTypeEnum[SVGLengthTypeEnum["mm"] = 7] = "mm"; - SVGLengthTypeEnum[SVGLengthTypeEnum["in"] = 8] = "in"; - SVGLengthTypeEnum[SVGLengthTypeEnum["pt"] = 9] = "pt"; - SVGLengthTypeEnum[SVGLengthTypeEnum["pc"] = 10] = "pc"; -})(SVGLengthTypeEnum || (SVGLengthTypeEnum = {})); -var SVGLengthTypeEnum_default = SVGLengthTypeEnum; - -// node_modules/happy-dom/lib/svg/SVGLength.js -var ATTRIBUTE_REGEXP3 = /^(\d+|\d+\.\d+)(px|em|ex|cm|mm|in|pt|pc|%|)$/; - -class SVGLength { - static SVG_LENGTHTYPE_UNKNOWN = SVGLengthTypeEnum_default.unknown; - static SVG_LENGTHTYPE_NUMBER = SVGLengthTypeEnum_default.number; - static SVG_LENGTHTYPE_PERCENTAGE = SVGLengthTypeEnum_default.percentage; - static SVG_LENGTHTYPE_EMS = SVGLengthTypeEnum_default.ems; - static SVG_LENGTHTYPE_EXS = SVGLengthTypeEnum_default.exs; - static SVG_LENGTHTYPE_PX = SVGLengthTypeEnum_default.px; - static SVG_LENGTHTYPE_CM = SVGLengthTypeEnum_default.cm; - static SVG_LENGTHTYPE_MM = SVGLengthTypeEnum_default.mm; - static SVG_LENGTHTYPE_IN = SVGLengthTypeEnum_default.in; - static SVG_LENGTHTYPE_PT = SVGLengthTypeEnum_default.pt; - static SVG_LENGTHTYPE_PC = SVGLengthTypeEnum_default.pc; - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get unitType() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() || "" : this[attributeValue] || ""; - const match = attributeValue2.match(ATTRIBUTE_REGEXP3); - if (!match) { - return SVGLengthTypeEnum_default.unknown; - } - if (isNaN(parseFloat(match[1]))) { - return SVGLengthTypeEnum_default.unknown; - } - switch (match[2]) { - case "": - return SVGLengthTypeEnum_default.number; - case "px": - return SVGLengthTypeEnum_default.px; - case "cm": - return SVGLengthTypeEnum_default.cm; - case "mm": - return SVGLengthTypeEnum_default.mm; - case "in": - return SVGLengthTypeEnum_default.in; - case "pt": - return SVGLengthTypeEnum_default.pt; - case "pc": - return SVGLengthTypeEnum_default.pc; - case "em": - case "ex": - case "%": - throw new this[window].TypeError(`Failed to execute 'value' on 'SVGLength': Could not resolve relative length.`); - default: - return SVGLengthTypeEnum_default.unknown; - } - } - get value() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() || "" : this[attributeValue] || ""; - const match = attributeValue2.match(ATTRIBUTE_REGEXP3); - if (!match) { - return 0; - } - const parsedValue = parseFloat(match[1]); - if (isNaN(parsedValue)) { - return 0; - } - switch (match[2]) { - case "": - return parsedValue; - case "px": - return parsedValue; - case "cm": - return parsedValue / 2.54 * 96; - case "mm": - return parsedValue / 25.4 * 96; - case "in": - return parsedValue * 96; - case "pt": - return parsedValue * 72; - case "pc": - return parsedValue * 6; - case "em": - case "ex": - case "%": - throw new this[window].TypeError(`Failed to execute 'value' on 'SVGLength': Could not resolve relative length.`); - default: - return 0; - } - } - set value(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'value' property on 'SVGLength': The object is read-only.`); - } - value = typeof value !== "number" ? parseFloat(String(value)) : value; - if (isNaN(value)) { - throw new this[window].TypeError(`Failed to set the 'value' property on 'SVGLength': The provided float value is non-finite.`); - } - let unitType = ""; - let valueInSpecifiedUnits = value; - switch (this.unitType) { - case SVGLengthTypeEnum_default.number: - valueInSpecifiedUnits = value; - unitType = ""; - break; - case SVGLengthTypeEnum_default.px: - valueInSpecifiedUnits = value; - unitType = "px"; - break; - case SVGLengthTypeEnum_default.cm: - valueInSpecifiedUnits = value / 96 * 2.54; - unitType = "cm"; - break; - case SVGLengthTypeEnum_default.mm: - valueInSpecifiedUnits = value / 96 * 25.4; - unitType = "mm"; - break; - case SVGLengthTypeEnum_default.in: - valueInSpecifiedUnits = value / 96; - unitType = "in"; - break; - case SVGLengthTypeEnum_default.pt: - valueInSpecifiedUnits = value / 72; - unitType = "pt"; - break; - case SVGLengthTypeEnum_default.pc: - valueInSpecifiedUnits = value / 6; - unitType = "pc"; - break; - case SVGLengthTypeEnum_default.percentage: - case SVGLengthTypeEnum_default.ems: - case SVGLengthTypeEnum_default.exs: - throw new this[window].TypeError(`Failed to set the 'value' property on 'SVGLength': Could not resolve relative length.`); - default: - break; - } - this[attributeValue] = String(valueInSpecifiedUnits) + unitType; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get valueAsString() { - return this[getAttribute] ? this[getAttribute]() || "0" : this[attributeValue] || "0"; - } - get valueInSpecifiedUnits() { - const attributeValue2 = this.valueAsString; - return parseFloat(attributeValue2) || 0; - } - newValueSpecifiedUnits(unitType, value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGLength': The object is read-only.`); - } - if (typeof unitType !== "number") { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGLength': parameter 1 ('unitType') is not of type 'number'.`); - } - value = typeof value !== "number" ? parseFloat(String(value)) : value; - if (isNaN(value)) { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGLength': The provided float value is non-finite.`); - } - let unit = ""; - switch (unitType) { - case SVGLengthTypeEnum_default.number: - unit = ""; - break; - case SVGLengthTypeEnum_default.px: - unit = "px"; - break; - case SVGLengthTypeEnum_default.cm: - unit = "cm"; - break; - case SVGLengthTypeEnum_default.mm: - unit = "mm"; - break; - case SVGLengthTypeEnum_default.in: - unit = "in"; - break; - case SVGLengthTypeEnum_default.pt: - unit = "pt"; - break; - case SVGLengthTypeEnum_default.pc: - unit = "pc"; - break; - case SVGLengthTypeEnum_default.ems: - case SVGLengthTypeEnum_default.exs: - case SVGLengthTypeEnum_default.percentage: - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGLength': Could not resolve relative length.`); - default: - break; - } - this[attributeValue] = String(value) + unit; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - convertToSpecifiedUnits(unitType) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'convertToSpecifiedUnits' on 'SVGLength': The object is read-only.`); - } - if (typeof unitType !== "number") { - throw new this[window].TypeError(`Failed to execute 'convertToSpecifiedUnits' on 'SVGLength': parameter 1 ('unitType') is not of type 'number'.`); - } - let value = this.value; - let unit = ""; - switch (unitType) { - case SVGLengthTypeEnum_default.number: - unit = ""; - break; - case SVGLengthTypeEnum_default.px: - unit = "px"; - break; - case SVGLengthTypeEnum_default.cm: - value = value / 96 * 2.54; - unit = "cm"; - break; - case SVGLengthTypeEnum_default.mm: - value = value / 96 * 25.4; - unit = "mm"; - break; - case SVGLengthTypeEnum_default.in: - value = value / 96; - unit = "in"; - break; - case SVGLengthTypeEnum_default.pt: - value = value / 72; - unit = "pt"; - break; - case SVGLengthTypeEnum_default.pc: - value = value / 6; - unit = "pc"; - break; - case SVGLengthTypeEnum_default.percentage: - case SVGLengthTypeEnum_default.ems: - case SVGLengthTypeEnum_default.exs: - throw new this[window].TypeError(`Failed to execute 'convertToSpecifiedUnits' on 'SVGLength': Could not resolve relative length.`); - default: - break; - } - this[attributeValue] = String(value) + unit; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGAngleTypeEnum.js -var SVGAngleTypeEnum; -(function(SVGAngleTypeEnum) { - SVGAngleTypeEnum[SVGAngleTypeEnum["unknown"] = 0] = "unknown"; - SVGAngleTypeEnum[SVGAngleTypeEnum["unspecified"] = 1] = "unspecified"; - SVGAngleTypeEnum[SVGAngleTypeEnum["deg"] = 2] = "deg"; - SVGAngleTypeEnum[SVGAngleTypeEnum["rad"] = 3] = "rad"; - SVGAngleTypeEnum[SVGAngleTypeEnum["grad"] = 4] = "grad"; -})(SVGAngleTypeEnum || (SVGAngleTypeEnum = {})); -var SVGAngleTypeEnum_default = SVGAngleTypeEnum; - -// node_modules/happy-dom/lib/svg/SVGAngle.js -var ATTRIBUTE_REGEXP4 = /^(\d+|\d+\.\d+)(deg|rad|grad|turn|)$/; - -class SVGAngle { - static SVG_ANGLETYPE_UNKNOWN = SVGAngleTypeEnum_default.unknown; - static SVG_ANGLETYPE_UNSPECIFIED = SVGAngleTypeEnum_default.unspecified; - static SVG_ANGLETYPE_DEG = SVGAngleTypeEnum_default.deg; - static SVG_ANGLETYPE_RAD = SVGAngleTypeEnum_default.rad; - static SVG_ANGLETYPE_GRAD = SVGAngleTypeEnum_default.grad; - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = ""; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get unitType() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const match = attributeValue2?.match(ATTRIBUTE_REGEXP4); - if (!match) { - return SVGAngleTypeEnum_default.unknown; - } - if (isNaN(parseFloat(match[1]))) { - return SVGAngleTypeEnum_default.unknown; - } - switch (match[2]) { - case "": - return SVGAngleTypeEnum_default.unspecified; - case "deg": - return SVGAngleTypeEnum_default.deg; - case "rad": - return SVGAngleTypeEnum_default.rad; - case "grad": - return SVGAngleTypeEnum_default.grad; - case "turn": - return SVGAngleTypeEnum_default.unknown; - default: - return SVGAngleTypeEnum_default.unspecified; - } - } - get value() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - const match = attributeValue2?.match(ATTRIBUTE_REGEXP4); - if (!match) { - return 0; - } - const parsedValue = parseFloat(match[1]); - if (isNaN(parsedValue)) { - return 0; - } - switch (match[2]) { - case "": - return parsedValue; - case "deg": - return parsedValue; - case "rad": - return parsedValue * (180 / Math.PI); - case "grad": - return parsedValue * (180 / 200); - case "turn": - return parsedValue * 360; - default: - return parsedValue; - } - } - set value(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'value' property on 'SVGAngle': The object is read-only.`); - } - value = typeof value !== "number" ? parseFloat(String(value)) : value; - if (isNaN(value)) { - throw new this[window].TypeError(`Failed to set the 'value' property on 'SVGAngle': The provided float value is non-finite.`); - } - let unitType = ""; - let valueInSpecifiedUnits = value; - switch (this.unitType) { - case SVGAngleTypeEnum_default.unspecified: - valueInSpecifiedUnits = value; - unitType = ""; - break; - case SVGAngleTypeEnum_default.deg: - valueInSpecifiedUnits = value; - unitType = "deg"; - break; - case SVGAngleTypeEnum_default.rad: - valueInSpecifiedUnits = value / (180 / Math.PI); - unitType = "rad"; - break; - case SVGAngleTypeEnum_default.grad: - valueInSpecifiedUnits = value / (180 / 200); - unitType = "grad"; - break; - case SVGAngleTypeEnum_default.unknown: - valueInSpecifiedUnits = value / 360; - unitType = "turn"; - default: - break; - } - this[attributeValue] = String(valueInSpecifiedUnits) + unitType; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get valueAsString() { - return this[getAttribute] ? this[getAttribute]() || "0" : this[attributeValue] || "0"; - } - get valueInSpecifiedUnits() { - const attributeValue2 = this.valueAsString; - return parseFloat(attributeValue2) || 0; - } - newValueSpecifiedUnits(unitType, value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGAngle': The object is read-only.`); - } - if (typeof unitType !== "number") { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGAngle': parameter 1 ('unitType') is not of type 'number'.`); - } - value = typeof value !== "number" ? parseFloat(value) : value; - if (isNaN(value)) { - throw new this[window].TypeError(`Failed to execute 'newValueSpecifiedUnits' on 'SVGAngle': The provided float value is non-finite.`); - } - let unit = ""; - switch (unitType) { - case SVGAngleTypeEnum_default.unspecified: - unit = ""; - break; - case SVGAngleTypeEnum_default.deg: - unit = "deg"; - break; - case SVGAngleTypeEnum_default.rad: - unit = "rad"; - break; - case SVGAngleTypeEnum_default.grad: - unit = "grad"; - break; - case SVGAngleTypeEnum_default.unknown: - unit = "turn"; - break; - default: - break; - } - this[attributeValue] = String(value) + unit; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - convertToSpecifiedUnits(unitType) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'convertToSpecifiedUnits' on 'SVGAngle': The object is read-only.`); - } - if (typeof unitType !== "number") { - throw new this[window].TypeError(`Failed to execute 'convertToSpecifiedUnits' on 'SVGAngle': parameter 1 ('unitType') is not of type 'number'.`); - } - let value = this.value; - let unit = ""; - switch (unitType) { - case SVGAngleTypeEnum_default.unspecified: - unit = ""; - break; - case SVGAngleTypeEnum_default.deg: - unit = "deg"; - break; - case SVGAngleTypeEnum_default.rad: - unit = "rad"; - value = value / (180 / Math.PI); - break; - case SVGAngleTypeEnum_default.grad: - unit = "grad"; - value = value / (180 / 200); - break; - case SVGAngleTypeEnum_default.unknown: - unit = "turn"; - value = value / 360; - break; - default: - break; - } - this[attributeValue] = String(value) + unit; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGNumber.js -class SVGNumber { - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get value() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - return parseFloat(attributeValue2 || "0"); - } - set value(value) { - if (this[readOnly]) { - throw new TypeError(`Failed to set the 'value' property on 'SVGNumber': The object is read-only.`); - } - const parsedValue = typeof value !== "number" ? parseFloat(String(value)) : value; - if (isNaN(parsedValue)) { - throw new TypeError(`Failed to set the 'value' property on 'SVGNumber': The provided value is not a number.`); - } - this[attributeValue] = String(value); - if (this[setAttribute]) { - this[setAttribute](this[attributeValue] || ""); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedRect.js -class SVGAnimatedRect { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGRect(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute] - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGRect(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/svg/SVGPreserveAspectRatioMeetOrSliceEnum.js -var SVGPreserveAspectRatioMeetOrSliceEnum; -(function(SVGPreserveAspectRatioMeetOrSliceEnum) { - SVGPreserveAspectRatioMeetOrSliceEnum[SVGPreserveAspectRatioMeetOrSliceEnum["unknown"] = 0] = "unknown"; - SVGPreserveAspectRatioMeetOrSliceEnum[SVGPreserveAspectRatioMeetOrSliceEnum["meet"] = 1] = "meet"; - SVGPreserveAspectRatioMeetOrSliceEnum[SVGPreserveAspectRatioMeetOrSliceEnum["slice"] = 2] = "slice"; -})(SVGPreserveAspectRatioMeetOrSliceEnum || (SVGPreserveAspectRatioMeetOrSliceEnum = {})); -var SVGPreserveAspectRatioMeetOrSliceEnum_default = SVGPreserveAspectRatioMeetOrSliceEnum; - -// node_modules/happy-dom/lib/svg/SVGPreserveAspectRatioAlignEnum.js -var SVGPreserveAspectRatioAlignEnum; -(function(SVGPreserveAspectRatioAlignEnum) { - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["unknown"] = 0] = "unknown"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["none"] = 1] = "none"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMinYMin"] = 2] = "xMinYMin"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMidYMin"] = 3] = "xMidYMin"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMaxYMin"] = 4] = "xMaxYMin"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMinYMid"] = 5] = "xMinYMid"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMidYMid"] = 6] = "xMidYMid"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMaxYMid"] = 7] = "xMaxYMid"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMinYMax"] = 8] = "xMinYMax"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMidYMax"] = 9] = "xMidYMax"; - SVGPreserveAspectRatioAlignEnum[SVGPreserveAspectRatioAlignEnum["xMaxYMax"] = 10] = "xMaxYMax"; -})(SVGPreserveAspectRatioAlignEnum || (SVGPreserveAspectRatioAlignEnum = {})); -var SVGPreserveAspectRatioAlignEnum_default = SVGPreserveAspectRatioAlignEnum; - -// node_modules/happy-dom/lib/svg/SVGPreserveAspectRatio.js -var ALIGN_KEYS = Object.values(SVGPreserveAspectRatioAlignEnum_default); -ALIGN_KEYS.length = ALIGN_KEYS.indexOf(0); -var MEET_OR_SLICE_KEYS = Object.values(SVGPreserveAspectRatioMeetOrSliceEnum_default); -MEET_OR_SLICE_KEYS.length = MEET_OR_SLICE_KEYS.indexOf(0); - -class SVGPreserveAspectRatio { - static SVG_MEETORSLICE_UNKNOWN = SVGPreserveAspectRatioMeetOrSliceEnum_default.unknown; - static SVG_MEETORSLICE_MEET = SVGPreserveAspectRatioMeetOrSliceEnum_default.meet; - static SVG_MEETORSLICE_SLICE = SVGPreserveAspectRatioMeetOrSliceEnum_default.slice; - static SVG_PRESERVEASPECTRATIO_UNKNOWN = SVGPreserveAspectRatioAlignEnum_default.unknown; - static SVG_PRESERVEASPECTRATIO_NONE = SVGPreserveAspectRatioAlignEnum_default.none; - static SVG_PRESERVEASPECTRATIO_XMINYMIN = SVGPreserveAspectRatioAlignEnum_default.xMinYMin; - static SVG_PRESERVEASPECTRATIO_XMIDYMIN = SVGPreserveAspectRatioAlignEnum_default.xMidYMin; - static SVG_PRESERVEASPECTRATIO_XMAXYMIN = SVGPreserveAspectRatioAlignEnum_default.xMaxYMin; - static SVG_PRESERVEASPECTRATIO_XMINYMID = SVGPreserveAspectRatioAlignEnum_default.xMinYMid; - static SVG_PRESERVEASPECTRATIO_XMIDYMID = SVGPreserveAspectRatioAlignEnum_default.xMidYMid; - static SVG_PRESERVEASPECTRATIO_XMAXYMID = SVGPreserveAspectRatioAlignEnum_default.xMaxYMid; - static SVG_PRESERVEASPECTRATIO_XMINYMAX = SVGPreserveAspectRatioAlignEnum_default.xMinYMax; - static SVG_PRESERVEASPECTRATIO_XMIDYMAX = SVGPreserveAspectRatioAlignEnum_default.xMidYMax; - static SVG_PRESERVEASPECTRATIO_XMAXYMAX = SVGPreserveAspectRatioAlignEnum_default.xMaxYMax; - [window]; - [getAttribute] = null; - [setAttribute] = null; - [attributeValue] = null; - [readOnly] = false; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - if (options) { - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute || null; - this[setAttribute] = options.setAttribute || null; - } - } - get align() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return SVGPreserveAspectRatioAlignEnum_default.xMidYMid; - } - const align = attributeValue2.split(/\s+/)[0]; - if (SVGPreserveAspectRatioAlignEnum_default[align] === undefined) { - return SVGPreserveAspectRatioAlignEnum_default.xMidYMid; - } - return SVGPreserveAspectRatioAlignEnum_default[align]; - } - set align(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'align' property on 'SVGPreserveAspectRatio': The object is read-only.`); - } - const parsedValue = Number(value); - if (isNaN(parsedValue) || parsedValue < 1 || parsedValue > ALIGN_KEYS.length) { - throw new this[window].TypeError(`Failed to set the 'align' property on 'SVGPreserveAspectRatio': The alignment provided is invalid.`); - } - this[attributeValue] = `${ALIGN_KEYS[parsedValue]} ${MEET_OR_SLICE_KEYS[this.meetOrSlice]}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } - get meetOrSlice() { - const attributeValue2 = this[getAttribute] ? this[getAttribute]() : this[attributeValue]; - if (!attributeValue2) { - return SVGPreserveAspectRatioMeetOrSliceEnum_default.meet; - } - const meetOrSlice = attributeValue2.split(/\s+/)[1]; - if (!meetOrSlice || SVGPreserveAspectRatioMeetOrSliceEnum_default[meetOrSlice] === undefined) { - return SVGPreserveAspectRatioMeetOrSliceEnum_default.meet; - } - return SVGPreserveAspectRatioMeetOrSliceEnum_default[meetOrSlice]; - } - set meetOrSlice(value) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to set the 'meetOrSlice' property on 'SVGPreserveAspectRatio': The object is read-only.`); - } - const parsedValue = Number(value); - if (isNaN(parsedValue) || parsedValue < 1 || parsedValue > 2) { - throw new this[window].TypeError(`Failed to set the 'meetOrSlice' property on 'SVGPreserveAspectRatio': The meetOrSlice provided is invalid.`); - } - this[attributeValue] = `${ALIGN_KEYS[this.align]} ${MEET_OR_SLICE_KEYS[parsedValue]}`; - if (this[setAttribute]) { - this[setAttribute](this[attributeValue]); - } - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedPreserveAspectRatio.js -class SVGAnimatedPreserveAspectRatio { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGPreserveAspectRatio(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute] - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGPreserveAspectRatio(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedLength.js -class SVGAnimatedLength { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGLength(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute] - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGLength(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/nodes/svg-svg-element/SVGSVGElement.js -class SVGSVGElement extends SVGGraphicsElement { - [preserveAspectRatio] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - [currentScale] = 1; - [viewBox] = null; - get onafterprint() { - return ElementEventAttributeUtility.getEventListener(this, "onafterprint"); - } - set onafterprint(value) { - this[propertyEventListeners].set("onafterprint", value); - } - get onbeforeprint() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforeprint"); - } - set onbeforeprint(value) { - this[propertyEventListeners].set("onbeforeprint", value); - } - get onbeforeunload() { - return ElementEventAttributeUtility.getEventListener(this, "onbeforeunload"); - } - set onbeforeunload(value) { - this[propertyEventListeners].set("onbeforeunload", value); - } - get ongamepadconnected() { - return ElementEventAttributeUtility.getEventListener(this, "ongamepadconnected"); - } - set ongamepadconnected(value) { - this[propertyEventListeners].set("ongamepadconnected", value); - } - get ongamepaddisconnected() { - return ElementEventAttributeUtility.getEventListener(this, "ongamepaddisconnected"); - } - set ongamepaddisconnected(value) { - this[propertyEventListeners].set("ongamepaddisconnected", value); - } - get onhashchange() { - return ElementEventAttributeUtility.getEventListener(this, "onhashchange"); - } - set onhashchange(value) { - this[propertyEventListeners].set("onhashchange", value); - } - get onlanguagechange() { - return ElementEventAttributeUtility.getEventListener(this, "onlanguagechange"); - } - set onlanguagechange(value) { - this[propertyEventListeners].set("onlanguagechange", value); - } - get onmessage() { - return ElementEventAttributeUtility.getEventListener(this, "onmessage"); - } - set onmessage(value) { - this[propertyEventListeners].set("onmessage", value); - } - get onmessageerror() { - return ElementEventAttributeUtility.getEventListener(this, "onmessageerror"); - } - set onmessageerror(value) { - this[propertyEventListeners].set("onmessageerror", value); - } - get onoffline() { - return ElementEventAttributeUtility.getEventListener(this, "onoffline"); - } - set onoffline(value) { - this[propertyEventListeners].set("onoffline", value); - } - get ononline() { - return ElementEventAttributeUtility.getEventListener(this, "ononline"); - } - set ononline(value) { - this[propertyEventListeners].set("ononline", value); - } - get onpagehide() { - return ElementEventAttributeUtility.getEventListener(this, "onpagehide"); - } - set onpagehide(value) { - this[propertyEventListeners].set("onpagehide", value); - } - get onpageshow() { - return ElementEventAttributeUtility.getEventListener(this, "onpageshow"); - } - set onpageshow(value) { - this[propertyEventListeners].set("onpageshow", value); - } - get onpopstate() { - return ElementEventAttributeUtility.getEventListener(this, "onpopstate"); - } - set onpopstate(value) { - this[propertyEventListeners].set("onpopstate", value); - } - get onrejectionhandled() { - return ElementEventAttributeUtility.getEventListener(this, "onrejectionhandled"); - } - set onrejectionhandled(value) { - this[propertyEventListeners].set("onrejectionhandled", value); - } - get onstorage() { - return ElementEventAttributeUtility.getEventListener(this, "onstorage"); - } - set onstorage(value) { - this[propertyEventListeners].set("onstorage", value); - } - get onunhandledrejection() { - return ElementEventAttributeUtility.getEventListener(this, "onunhandledrejection"); - } - set onunhandledrejection(value) { - this[propertyEventListeners].set("onunhandledrejection", value); - } - get onunload() { - return ElementEventAttributeUtility.getEventListener(this, "onunload"); - } - set onunload(value) { - this[propertyEventListeners].set("onunload", value); - } - get preserveAspectRatio() { - if (!this[preserveAspectRatio]) { - this[preserveAspectRatio] = new SVGAnimatedPreserveAspectRatio(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("preserveAspectRatio"), - setAttribute: (value) => this.setAttribute("preserveAspectRatio", value) - }); - } - return this[preserveAspectRatio]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get currentScale() { - return this[currentScale]; - } - set currentScale(currentScale2) { - const parsed = typeof currentScale2 !== "number" ? parseFloat(String(currentScale2)) : currentScale2; - if (isNaN(parsed)) { - throw this[window].TypeError(`Failed to set the 'currentScale' property on 'SVGSVGElement': The provided float value is non-finite.`); - } - if (parsed < 1) { - return; - } - this[currentScale] = parsed; - } - get currentTranslate() { - return new SVGPoint(illegalConstructor, this[window]); - } - get viewBox() { - if (!this[viewBox]) { - this[viewBox] = new SVGAnimatedRect(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("viewBox"), - setAttribute: (value) => this.setAttribute("viewBox", value) - }); - } - return this[viewBox]; - } - pauseAnimations() {} - unpauseAnimations() {} - animationsPaused() { - return false; - } - getCurrentTime() { - return 0; - } - setCurrentTime(_seconds) {} - getIntersectionList(_rect, _element) { - return new NodeList_default(illegalConstructor, []); - } - getEnclosureList(_rect, _element) { - return new NodeList_default(illegalConstructor, []); - } - checkIntersection(_element, _rect) { - return false; - } - checkEnclosure(_element, _rect) { - return false; - } - deselectAll() {} - createSVGNumber() { - return new SVGNumber(illegalConstructor, this[window]); - } - createSVGLength() { - return new SVGLength(illegalConstructor, this[window]); - } - createSVGAngle() { - return new SVGAngle(illegalConstructor, this[window]); - } - createSVGPoint() { - return new SVGPoint(illegalConstructor, this[window]); - } - createSVGMatrix() { - return new SVGMatrix(illegalConstructor, this[window]); - } - createSVGRect() { - return new SVGRect(illegalConstructor, this[window]); - } - createSVGTransform() { - return new SVGTransform(illegalConstructor, this[window]); - } - createSVGTransformFromMatrix(matrix) { - const transform = new SVGTransform(illegalConstructor, this[window]); - transform.setMatrix(matrix); - return transform; - } - getElementsByClassName(className) { - return ParentNodeUtility.getElementsByClassName(this, className); - } - getElementsByTagName(tagName) { - return ParentNodeUtility.getElementsByTagName(this, tagName); - } - getElementsByTagNameNS(namespaceURI, tagName) { - return ParentNodeUtility.getElementsByTagNameNS(this, namespaceURI, tagName); - } - getElementById(id) { - return ParentNodeUtility.getElementById(this, id); - } - [cloneNode](deep = false) { - return super[cloneNode](deep); - } -} - -// node_modules/happy-dom/lib/nodes/svg-animation-element/SVGAnimationElement.js -class SVGAnimationElement extends SVGElement { - [requiredExtensions] = null; - [systemLanguage] = null; - get onbegin() { - return ElementEventAttributeUtility.getEventListener(this, "onbegin"); - } - set onbegin(value) { - this[propertyEventListeners].set("onbegin", value); - } - get onend() { - return ElementEventAttributeUtility.getEventListener(this, "onend"); - } - set onend(value) { - this[propertyEventListeners].set("onend", value); - } - get onrepeat() { - return ElementEventAttributeUtility.getEventListener(this, "onrepeat"); - } - set onrepeat(value) { - this[propertyEventListeners].set("onrepeat", value); - } - get requiredExtensions() { - if (!this[requiredExtensions]) { - this[requiredExtensions] = new SVGStringList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("requiredExtensions"), - setAttribute: (value) => this.setAttribute("requiredExtensions", value) - }); - } - return this[requiredExtensions]; - } - get systemLanguage() { - if (!this[systemLanguage]) { - this[systemLanguage] = new SVGStringList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("systemLanguage"), - setAttribute: (value) => this.setAttribute("systemLanguage", value) - }); - } - return this[systemLanguage]; - } - get targetElement() { - return null; - } -} - -// node_modules/happy-dom/lib/nodes/svg-animate-element/SVGAnimateElement.js -class SVGAnimateElement extends SVGAnimationElement { -} - -// node_modules/happy-dom/lib/nodes/svg-animate-motion-element/SVGAnimateMotionElement.js -class SVGAnimateMotionElement extends SVGAnimationElement { -} - -// node_modules/happy-dom/lib/nodes/svg-animate-transform-element/SVGAnimateTransformElement.js -class SVGAnimateTransformElement extends SVGAnimationElement { -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedNumber.js -class SVGAnimatedNumber { - [window]; - [getAttribute]; - [setAttribute]; - [defaultValue] = 0; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - this[defaultValue] = options.defaultValue || 0; - } - get animVal() { - return this.baseVal; - } - set animVal(_value) {} - get baseVal() { - const attributeValue = this[getAttribute](); - if (!attributeValue) { - return this[defaultValue]; - } - const value = parseFloat(attributeValue); - if (isNaN(value)) { - return this[defaultValue]; - } - return value; - } - set baseVal(value) { - const parsedValue = typeof value !== "number" ? parseFloat(value) : value; - if (isNaN(parsedValue)) { - throw new this[window].TypeError(`TypeError: Failed to set the 'baseVal' property on 'SVGAnimatedNumber': The provided float value is non-finite.`); - } - this[setAttribute](String(parsedValue)); - } -} - -// node_modules/happy-dom/lib/nodes/svg-geometry-element/SVGGeometryElement.js -class SVGGeometryElement extends SVGGraphicsElement { - [pathLength] = null; - get pathLength() { - if (!this[pathLength]) { - this[pathLength] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("pathLength"), - setAttribute: (value) => this.setAttribute("pathLength", value) - }); - } - return this[pathLength]; - } - isPointInFill(point) { - if (!(point instanceof SVGPoint)) { - throw new TypeError(`Failed to execute 'isPointInFill' on 'SVGGeometryElement': parameter 1 is not of type 'SVGPoint'.`); - } - return false; - } - isPointInStroke(point) { - if (!(point instanceof SVGPoint)) { - throw new TypeError(`Failed to execute 'isPointInFill' on 'SVGGeometryElement': parameter 1 is not of type 'SVGPoint'.`); - } - return false; - } - getTotalLength() { - return 0; - } - getPointAtLength(_distance) { - return new SVGPoint(illegalConstructor, this[window]); - } -} - -// node_modules/happy-dom/lib/nodes/svg-circle-element/SVGCircleElement.js -class SVGCircleElement extends SVGGeometryElement { - [cx] = null; - [cy] = null; - [r] = null; - get cx() { - if (!this[cx]) { - this[cx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cx"), - setAttribute: (value) => this.setAttribute("cx", value) - }); - } - return this[cx]; - } - get cy() { - if (!this[cy]) { - this[cy] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cy"), - setAttribute: (value) => this.setAttribute("cy", value) - }); - } - return this[cy]; - } - get r() { - if (!this[r]) { - this[r] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("r"), - setAttribute: (value) => this.setAttribute("r", value) - }); - } - return this[r]; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedEnumeration.js -class SVGAnimatedEnumeration { - [window]; - [getAttribute]; - [setAttribute]; - [values]; - [defaultValue]; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - this[values] = options.values; - this[defaultValue] = options.defaultValue; - } - get animVal() { - return this.baseVal; - } - set animVal(_value) {} - get baseVal() { - const value = this[getAttribute](); - if (!value) { - return this[values].indexOf(this[defaultValue]) + 1; - } - const index = this[values].indexOf(value); - if (index === -1) { - const anyValueIndex = this[values].indexOf(null); - return anyValueIndex !== -1 ? anyValueIndex + 1 : 0; - } - return index + 1; - } - set baseVal(value) { - let parsedValue = Number(value); - if (isNaN(parsedValue)) { - parsedValue = 0; - } - if (parsedValue < 1) { - throw new TypeError(`Failed to set the 'baseVal' property on 'SVGAnimatedEnumeration': The enumeration value provided is ${parsedValue}, which is not settable.`); - } - if (parsedValue > this[values].length) { - throw new TypeError(`Failed to set the 'baseVal' property on 'SVGAnimatedEnumeration': The enumeration value provided (${parsedValue}) is larger than the largest allowed value (${this[values].length}).`); - } - const currentValue = this[getAttribute](); - const isAnyValue = this[values][parsedValue - 1] === null; - const newValue = isAnyValue ? "0" : this[values][parsedValue - 1]; - if (!currentValue || isAnyValue && this[values].includes(currentValue) || !isAnyValue && currentValue !== newValue) { - this[setAttribute](newValue || ""); - } - } -} - -// node_modules/happy-dom/lib/nodes/svg-clip-path-element/SVGClipPathElement.js -class SVGClipPathElement extends SVGElement { - [clipPathUnits] = null; - get clipPathUnits() { - if (!this[clipPathUnits]) { - this[clipPathUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("clipPathUnits"), - setAttribute: (value) => this.setAttribute("clipPathUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[clipPathUnits]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-defs-element/SVGDefsElement.js -class SVGDefsElement extends SVGGraphicsElement { -} - -// node_modules/happy-dom/lib/nodes/svg-desc-element/SVGDescElement.js -class SVGDescElement extends SVGElement { -} - -// node_modules/happy-dom/lib/nodes/svg-ellipse-element/SVGEllipseElement.js -class SVGEllipseElement extends SVGGeometryElement { - [cx] = null; - [cy] = null; - [rx] = null; - [ry] = null; - get cx() { - if (!this[cx]) { - this[cx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cx"), - setAttribute: (value) => this.setAttribute("cx", value) - }); - } - return this[cx]; - } - get cy() { - if (!this[cy]) { - this[cy] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cy"), - setAttribute: (value) => this.setAttribute("cy", value) - }); - } - return this[cy]; - } - get rx() { - if (!this[rx]) { - this[rx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("rx"), - setAttribute: (value) => this.setAttribute("rx", value) - }); - } - return this[rx]; - } - get ry() { - if (!this[ry]) { - this[ry] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("ry"), - setAttribute: (value) => this.setAttribute("ry", value) - }); - } - return this[ry]; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedString.js -class SVGAnimatedString { - [window]; - [getAttribute]; - [setAttribute]; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - return this.baseVal; - } - set animVal(_value) {} - get baseVal() { - const attributeValue = this[getAttribute](); - if (!attributeValue) { - return ""; - } - return attributeValue; - } - set baseVal(value) { - this[setAttribute](String(value)); - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-blend-element/SVGFEBlendElement.js -class SVGFEBlendElement extends SVGElement { - static SVG_FEBLEND_MODE_UNKNOWN = 0; - static SVG_FEBLEND_MODE_NORMAL = 1; - static SVG_FEBLEND_MODE_MULTIPLY = 2; - static SVG_FEBLEND_MODE_SCREEN = 3; - static SVG_FEBLEND_MODE_DARKEN = 4; - static SVG_FEBLEND_MODE_LIGHTEN = 5; - static SVG_FEBLEND_MODE_OVERLAY = 6; - static SVG_FEBLEND_MODE_COLOR_DODGE = 7; - static SVG_FEBLEND_MODE_COLOR_BURN = 8; - static SVG_FEBLEND_MODE_HARD_LIGHT = 9; - static SVG_FEBLEND_MODE_SOFT_LIGHT = 10; - static SVG_FEBLEND_MODE_DIFFERENCE = 11; - static SVG_FEBLEND_MODE_EXCLUSION = 12; - static SVG_FEBLEND_MODE_HUE = 13; - static SVG_FEBLEND_MODE_SATURATION = 14; - static SVG_FEBLEND_MODE_COLOR = 15; - static SVG_FEBLEND_MODE_LUMINOSITY = 16; - [height] = null; - [in1] = null; - [in2] = null; - [mode] = null; - [x] = null; - [y] = null; - [width] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get in2() { - if (!this[in2]) { - this[in2] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in2"), - setAttribute: (value) => this.setAttribute("in2", value) - }); - } - return this[in2]; - } - get mode() { - if (!this[mode]) { - this[mode] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("mode"), - setAttribute: (value) => this.setAttribute("mode", value), - values: [ - "normal", - "multiply", - "screen", - "darken", - "lighten", - "overlay", - "color-dodge", - "color-burn", - "hard-light", - "soft-light", - "difference", - "exclusion", - "hue", - "saturation", - "color", - "luminosity" - ], - defaultValue: "normal" - }); - } - return this[mode]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/svg/SVGNumberList.js -var ATTRIBUTE_SEPARATOR_REGEXP2 = /[\t\f\n\r, ]+/; - -class SVGNumberList { - [window]; - [getAttribute]; - [setAttribute]; - [readOnly] = false; - [cache] = { - items: [], - attributeValue: "" - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - const methodBinder = new ClassMethodBinder(this, [SVGNumberList]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length" || property === "numberOfItems") { - return target[getItemList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get numberOfItems() { - return this[getItemList]().length; - } - [Symbol.iterator]() { - return this[getItemList]().values(); - } - clear() { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'clear' on 'SVGNumberList': The object is read-only.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - this[cache].items = []; - this[cache].attributeValue = ""; - this[setAttribute](""); - } - initialize(newItem) { - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGNumberList': 1 arguments required, but only ${arguments.length} present.`); - } - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGNumberList': The object is read-only.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].items = [newItem]; - this[cache].attributeValue = newItem[attributeValue]; - this[setAttribute](newItem[attributeValue] || ""); - return newItem; - } - getItem(index) { - const items = this[getItemList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - insertItemBefore(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGNumberList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGNumberList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGNumber)) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGNumberList': parameter 1 is not of type 'SVGNumber'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index > items.length) { - index = items.length; - } - items.splice(index, 0, newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - replaceItem(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGNumberList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGNumberList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGNumber)) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGNumberList': parameter 1 is not of type 'SVGNumber'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex === index) { - return newItem; - } - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index >= items.length) { - index = items.length - 1; - } - if (items[index]) { - items[index][getAttribute] = null; - items[index][setAttribute] = null; - } - const replacedItem = items[index]; - items[index] = newItem; - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return replacedItem; - } - removeItem(index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGNumberList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGNumberList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - index = Number(index); - if (isNaN(index)) { - index = 0; - } - if (index >= items.length) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGNumberList': The index provided (${index}) is greater than the maximum bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index < 0) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGNumberList': The index provided (${index}) is negative.`, DOMExceptionNameEnum_default.indexSizeError); - } - const removedItem = items[index]; - if (removedItem) { - removedItem[getAttribute] = null; - removedItem[setAttribute] = null; - } - items.splice(index, 1); - this[setAttribute](items.map((item) => item[attributeValue] || "0").join(" ")); - return removedItem; - } - appendItem(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGNumberList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGNumberList': 1 argument required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGNumber)) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGNumberList': parameter 1 is not of type 'SVGNumber'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - items.push(newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - [getItemList]() { - const attributeValue2 = this[getAttribute]() ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue2) { - return cache2.items; - } - if (cache2.items.length) { - for (const item of cache2.items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - } - const items = []; - const trimmed = attributeValue2.trim(); - if (trimmed) { - const parts = trimmed.split(ATTRIBUTE_SEPARATOR_REGEXP2); - for (let i = 0, max = parts.length;i < max; i++) { - const item = new SVGNumber(illegalConstructor, this[window], { - readOnly: this[readOnly], - getAttribute: () => item[attributeValue], - setAttribute: () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0").join(" "); - this[setAttribute](this[cache].attributeValue); - } - }); - item[attributeValue] = String(parseFloat(parts[i])); - items.push(item); - } - } - cache2.attributeValue = attributeValue2; - cache2.items = items; - return items; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedNumberList.js -class SVGAnimatedNumberList { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGNumberList(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute], - setAttribute: () => {} - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGNumberList(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/nodes/svg-fe-color-matrix-element/SVGFEColorMatrixElement.js -class SVGFEColorMatrixElement extends SVGElement { - static SVG_FEBLEND_TYPE_UNKNOWN = 0; - static SVG_FEBLEND_TYPE_MATRIX = 1; - static SVG_FEBLEND_TYPE_SATURATE = 2; - static SVG_FEBLEND_TYPE_HUEROTATE = 3; - static SVG_FEBLEND_TYPE_LUMINANCETOALPHA = 4; - [height] = null; - [in1] = null; - [in2] = null; - [result] = null; - [type] = null; - [values] = null; - [x] = null; - [y] = null; - [width] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get in2() { - if (!this[in2]) { - this[in2] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in2"), - setAttribute: (value) => this.setAttribute("in2", value) - }); - } - return this[in2]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get type() { - if (!this[type]) { - this[type] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("type"), - setAttribute: (value) => this.setAttribute("type", value), - values: ["matrix", "saturate", "huerotate", "luminancetoalpha"], - defaultValue: "matrix" - }); - } - return this[type]; - } - get values() { - if (!this[values]) { - this[values] = new SVGAnimatedNumberList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("values"), - setAttribute: (value) => this.setAttribute("values", value) - }); - } - return this[values]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-component-transfer-element/SVGFEComponentTransferElement.js -class SVGFEComponentTransferElement extends SVGElement { - [height] = null; - [in1] = null; - [result] = null; - [x] = null; - [y] = null; - [width] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-composite-element/SVGFECompositeElement.js -class SVGFECompositeElement extends SVGElement { - static SVG_FECOMPOSITE_OPERATOR_UNKNOWN = 0; - static SVG_FECOMPOSITE_OPERATOR_OVER = 1; - static SVG_FECOMPOSITE_OPERATOR_IN = 2; - static SVG_FECOMPOSITE_OPERATOR_OUT = 3; - static SVG_FECOMPOSITE_OPERATOR_ATOP = 4; - static SVG_FECOMPOSITE_OPERATOR_XOR = 5; - static SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6; - [height] = null; - [in1] = null; - [result] = null; - [type] = null; - [values] = null; - [x] = null; - [y] = null; - [width] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get type() { - if (!this[type]) { - this[type] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("type"), - setAttribute: (value) => this.setAttribute("type", value), - values: ["over", "in", "out", "atop", "xor", "arithmetic"], - defaultValue: "over" - }); - } - return this[type]; - } - get values() { - if (!this[values]) { - this[values] = new SVGAnimatedNumberList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("values"), - setAttribute: (value) => this.setAttribute("values", value) - }); - } - return this[values]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedBoolean.js -class SVGAnimatedBoolean { - [window]; - [getAttribute]; - [setAttribute]; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - return this.baseVal; - } - set animVal(_value) {} - get baseVal() { - const attributeValue = this[getAttribute](); - return attributeValue === "true"; - } - set baseVal(value) { - this[setAttribute](typeof value !== "boolean" ? String(Boolean(value)) : String(value)); - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedInteger.js -class SVGAnimatedInteger { - [window]; - [getAttribute]; - [setAttribute]; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - return this.baseVal; - } - set animVal(_value) {} - get baseVal() { - const attributeValue = this[getAttribute](); - if (!attributeValue) { - return 0; - } - const value = parseInt(attributeValue); - if (isNaN(value)) { - return 0; - } - return value; - } - set baseVal(value) { - const parsedValue = parseInt(String(value)); - if (isNaN(parsedValue)) { - throw new this[window].TypeError(`TypeError: Failed to set the 'baseVal' property on 'SVGAnimatedInteger': The provided float value is non-finite.`); - } - this[setAttribute](String(parsedValue)); - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-convolve-matrix-element/SVGFEConvolveMatrixElement.js -class SVGFEConvolveMatrixElement extends SVGElement { - static SVG_EDGEMODE_UNKNOWN = 0; - static SVG_EDGEMODE_DUPLICATE = 1; - static SVG_EDGEMODE_WRAP = 2; - static SVG_EDGEMODE_NONE = 3; - [bias] = null; - [divisor] = null; - [edgeMode] = null; - [height] = null; - [in1] = null; - [kernelMatrix] = null; - [kernelUnitLengthX] = null; - [kernelUnitLengthY] = null; - [orderX] = null; - [orderY] = null; - [preserveAlpha] = null; - [result] = null; - [targetX] = null; - [targetY] = null; - [width] = null; - [x] = null; - [y] = null; - get bias() { - if (!this[bias]) { - this[bias] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("bias"), - setAttribute: (value) => this.setAttribute("bias", value) - }); - } - return this[bias]; - } - get divisor() { - if (!this[divisor]) { - this[divisor] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("divisor"), - setAttribute: (value) => this.setAttribute("divisor", value) - }); - } - return this[divisor]; - } - get edgeMode() { - if (!this[edgeMode]) { - this[edgeMode] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("edgeMode"), - setAttribute: (value) => this.setAttribute("edgeMode", value), - values: ["duplicate", "wrap", "none"], - defaultValue: "duplicate" - }); - } - return this[edgeMode]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get kernelMatrix() { - if (!this[kernelMatrix]) { - this[kernelMatrix] = new SVGAnimatedNumberList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelMatrix"), - setAttribute: (value) => this.setAttribute("kernelMatrix", value) - }); - } - return this[kernelMatrix]; - } - get kernelUnitLengthX() { - if (!this[kernelUnitLengthX]) { - this[kernelUnitLengthX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthX"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthX", value) - }); - } - return this[kernelUnitLengthX]; - } - get kernelUnitLengthY() { - if (!this[kernelUnitLengthY]) { - this[kernelUnitLengthY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthY"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthY", value) - }); - } - return this[kernelUnitLengthY]; - } - get orderX() { - if (!this[orderX]) { - this[orderX] = new SVGAnimatedInteger(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("orderX"), - setAttribute: (value) => this.setAttribute("orderX", value) - }); - } - return this[orderX]; - } - get orderY() { - if (!this[orderY]) { - this[orderY] = new SVGAnimatedInteger(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("orderY"), - setAttribute: (value) => this.setAttribute("orderY", value) - }); - } - return this[orderY]; - } - get preserveAlpha() { - if (!this[preserveAlpha]) { - this[preserveAlpha] = new SVGAnimatedBoolean(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("preserveAlpha"), - setAttribute: (value) => this.setAttribute("preserveAlpha", value) - }); - } - return this[preserveAlpha]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get targetX() { - if (!this[targetX]) { - this[targetX] = new SVGAnimatedInteger(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("targetX"), - setAttribute: (value) => this.setAttribute("targetX", value) - }); - } - return this[targetX]; - } - get targetY() { - if (!this[targetY]) { - this[targetY] = new SVGAnimatedInteger(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("targetY"), - setAttribute: (value) => this.setAttribute("targetY", value) - }); - } - return this[targetY]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-diffuse-lighting-element/SVGFEDiffuseLightingElement.js -class SVGFEDiffuseLightingElement extends SVGElement { - [diffuseConstant] = null; - [height] = null; - [in1] = null; - [kernelUnitLengthX] = null; - [kernelUnitLengthY] = null; - [result] = null; - [surfaceScale] = null; - [width] = null; - [x] = null; - [y] = null; - get diffuseConstant() { - if (!this[diffuseConstant]) { - this[diffuseConstant] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("diffuseConstant"), - setAttribute: (value) => this.setAttribute("diffuseConstant", value) - }); - } - return this[diffuseConstant]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get kernelUnitLengthX() { - if (!this[kernelUnitLengthX]) { - this[kernelUnitLengthX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthX"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthX", value) - }); - } - return this[kernelUnitLengthX]; - } - get kernelUnitLengthY() { - if (!this[kernelUnitLengthY]) { - this[kernelUnitLengthY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthY"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthY", value) - }); - } - return this[kernelUnitLengthY]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get surfaceScale() { - if (!this[surfaceScale]) { - this[surfaceScale] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("surfaceScale"), - setAttribute: (value) => this.setAttribute("surfaceScale", value) - }); - } - return this[surfaceScale]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-displacement-map-element/SVGFEDisplacementMapElement.js -class SVGFEDisplacementMapElement extends SVGElement { - static SVG_CHANNEL_UNKNOWN = 0; - static SVG_CHANNEL_R = 1; - static SVG_CHANNEL_G = 2; - static SVG_CHANNEL_B = 3; - static SVG_CHANNEL_A = 4; - [height] = null; - [in1] = null; - [in2] = null; - [result] = null; - [scale] = null; - [width] = null; - [x] = null; - [xChannelSelector] = null; - [y] = null; - [yChannelSelector] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get in2() { - if (!this[in2]) { - this[in2] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in2"), - setAttribute: (value) => this.setAttribute("in2", value) - }); - } - return this[in2]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get scale() { - if (!this[scale]) { - this[scale] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("scale"), - setAttribute: (value) => this.setAttribute("scale", value) - }); - } - return this[scale]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get xChannelSelector() { - if (!this[xChannelSelector]) { - this[xChannelSelector] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("xChannelSelector"), - setAttribute: (value) => this.setAttribute("xChannelSelector", value), - values: ["r", "g", "b", "a"], - defaultValue: "r" - }); - } - return this[xChannelSelector]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get yChannelSelector() { - if (!this[yChannelSelector]) { - this[yChannelSelector] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("yChannelSelector"), - setAttribute: (value) => this.setAttribute("yChannelSelector", value), - values: ["r", "g", "b", "a"], - defaultValue: "r" - }); - } - return this[yChannelSelector]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-distant-light-element/SVGFEDistantLightElement.js -class SVGFEDistantLightElement extends SVGElement { - [azimuth] = null; - [elevation] = null; - get azimuth() { - if (!this[azimuth]) { - this[azimuth] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("azimuth"), - setAttribute: (value) => this.setAttribute("azimuth", value) - }); - } - return this[azimuth]; - } - get elevation() { - if (!this[elevation]) { - this[elevation] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("elevation"), - setAttribute: (value) => this.setAttribute("elevation", value) - }); - } - return this[elevation]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-drop-shadow-element/SVGFEDropShadowElement.js -class SVGFEDropShadowElement extends SVGElement { - [dx] = null; - [dy] = null; - [height] = null; - [in1] = null; - [result] = null; - [stdDeviationX] = null; - [stdDeviationY] = null; - [width] = null; - [x] = null; - [y] = null; - get dx() { - if (!this[dx]) { - this[dx] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dx"), - setAttribute: (value) => this.setAttribute("dx", value) - }); - } - return this[dx]; - } - get dy() { - if (!this[dy]) { - this[dy] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dy"), - setAttribute: (value) => this.setAttribute("dy", value) - }); - } - return this[dy]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get stdDeviationX() { - if (!this[stdDeviationX]) { - this[stdDeviationX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("stdDeviationX"), - setAttribute: (value) => this.setAttribute("stdDeviationX", value), - defaultValue: 2 - }); - } - return this[stdDeviationX]; - } - get stdDeviationY() { - if (!this[stdDeviationY]) { - this[stdDeviationY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("stdDeviationY"), - setAttribute: (value) => this.setAttribute("stdDeviationY", value), - defaultValue: 2 - }); - } - return this[stdDeviationY]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - setStdDeviation(x2, y2) { - this.stdDeviationX.baseVal = x2; - this.stdDeviationY.baseVal = y2; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-flood-element/SVGFEFloodElement.js -class SVGFEFloodElement extends SVGElement { - [height] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js -class SVGComponentTransferFunctionElement extends SVGElement { - static SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0; - static SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1; - static SVG_FECOMPONENTTRANSFER_TYPE_TABLE = 2; - static SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3; - static SVG_FECOMPONENTTRANSFER_TYPE_LINEAR = 4; - static SVG_FECOMPONENTTRANSFER_TYPE_GAMMA = 5; - [type] = null; - [tableValues] = null; - [slope] = null; - [intercept] = null; - [amplitude] = null; - [exponent] = null; - [offset] = null; - get type() { - if (!this[type]) { - this[type] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("type"), - setAttribute: (value) => this.setAttribute("type", value), - values: ["identity", "table", "discrete", "linear", "gamma"], - defaultValue: "identity" - }); - } - return this[type]; - } - get tableValues() { - if (!this[tableValues]) { - this[tableValues] = new SVGAnimatedNumberList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("tableValues"), - setAttribute: (value) => this.setAttribute("tableValues", value) - }); - } - return this[tableValues]; - } - get slope() { - if (!this[slope]) { - this[slope] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("slope"), - setAttribute: (value) => this.setAttribute("slope", value), - defaultValue: 1 - }); - } - return this[slope]; - } - get intercept() { - if (!this[intercept]) { - this[intercept] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("intercept"), - setAttribute: (value) => this.setAttribute("intercept", value) - }); - } - return this[intercept]; - } - get amplitude() { - if (!this[amplitude]) { - this[amplitude] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("amplitude"), - setAttribute: (value) => this.setAttribute("amplitude", value), - defaultValue: 1 - }); - } - return this[amplitude]; - } - get exponent() { - if (!this[exponent]) { - this[exponent] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("exponent"), - setAttribute: (value) => this.setAttribute("exponent", value), - defaultValue: 1 - }); - } - return this[exponent]; - } - get offset() { - if (!this[offset]) { - this[offset] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("offset"), - setAttribute: (value) => this.setAttribute("offset", value) - }); - } - return this[offset]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-func-a-element/SVGFEFuncAElement.js -class SVGFEFuncAElement extends SVGComponentTransferFunctionElement { -} - -// node_modules/happy-dom/lib/nodes/svg-fe-func-b-element/SVGFEFuncBElement.js -class SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} - -// node_modules/happy-dom/lib/nodes/svg-fe-func-g-element/SVGFEFuncGElement.js -class SVGFEFuncGElement extends SVGComponentTransferFunctionElement { -} - -// node_modules/happy-dom/lib/nodes/svg-fe-func-r-element/SVGFEFuncRElement.js -class SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} - -// node_modules/happy-dom/lib/nodes/svg-fe-gaussian-blur-element/SVGFEGaussianBlurElement.js -class SVGFEGaussianBlurElement extends SVGElement { - static SVG_EDGEMODE_UNKNOWN = 0; - static SVG_EDGEMODE_DUPLICATE = 1; - static SVG_EDGEMODE_WRAP = 2; - static SVG_EDGEMODE_NONE = 3; - [edgeMode] = null; - [height] = null; - [in1] = null; - [result] = null; - [stdDeviationX] = null; - [stdDeviationY] = null; - [width] = null; - [x] = null; - [y] = null; - get edgeMode() { - if (!this[edgeMode]) { - this[edgeMode] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("edgeMode"), - setAttribute: (value) => this.setAttribute("edgeMode", value), - values: ["duplicate", "wrap", "none"], - defaultValue: "duplicate" - }); - } - return this[edgeMode]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get stdDeviationX() { - if (!this[stdDeviationX]) { - this[stdDeviationX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("stdDeviationX") || "2", - setAttribute: (value) => this.setAttribute("stdDeviationX", value) - }); - } - return this[stdDeviationX]; - } - get stdDeviationY() { - if (!this[stdDeviationY]) { - this[stdDeviationY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("stdDeviationY") || "2", - setAttribute: (value) => this.setAttribute("stdDeviationY", value) - }); - } - return this[stdDeviationY]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - setStdDeviation(x2, y2) { - this.stdDeviationX.baseVal = x2; - this.stdDeviationY.baseVal = y2; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-image-element/SVGFEImageElement.js -class SVGFEImageElement extends SVGElement { - [crossOrigin] = null; - [height] = null; - [href] = null; - [preserveAspectRatio] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get crossOrigin() { - return this.getAttribute("crossorigin"); - } - set crossOrigin(value) { - this.setAttribute("crossorigin", value); - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get preserveAspectRatio() { - if (!this[preserveAspectRatio]) { - this[preserveAspectRatio] = new SVGAnimatedPreserveAspectRatio(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("preserveAspectRatio"), - setAttribute: (value) => this.setAttribute("preserveAspectRatio", value) - }); - } - return this[preserveAspectRatio]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-merge-element/SVGFEMergeElement.js -class SVGFEMergeElement extends SVGElement { - [height] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-merge-node-element/SVGFEMergeNodeElement.js -class SVGFEMergeNodeElement extends SVGElement { - [in1] = null; - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-morphology-element/SVGFEMorphologyElement.js -class SVGFEMorphologyElement extends SVGElement { - static SVG_MORPHOLOGY_OPERATOR_UNKNOWN = 0; - static SVG_MORPHOLOGY_OPERATOR_ERODE = 1; - static SVG_MORPHOLOGY_OPERATOR_DILATE = 2; - [height] = null; - [in1] = null; - [operator] = null; - [radiusX] = null; - [radiusY] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get operator() { - if (!this[operator]) { - this[operator] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("operator"), - setAttribute: (value) => this.setAttribute("operator", value), - values: ["erode", "dilate"], - defaultValue: "erode" - }); - } - return this[operator]; - } - get radiusX() { - if (!this[radiusX]) { - this[radiusX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("radiusX"), - setAttribute: (value) => this.setAttribute("radiusX", value) - }); - } - return this[radiusX]; - } - get radiusY() { - if (!this[radiusY]) { - this[radiusY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("radiusY"), - setAttribute: (value) => this.setAttribute("radiusY", value) - }); - } - return this[radiusY]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-offset-element/SVGFEOffsetElement.js -class SVGFEOffsetElement extends SVGElement { - [height] = null; - [in1] = null; - [dx] = null; - [dy] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get dx() { - if (!this[dx]) { - this[dx] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dx"), - setAttribute: (value) => this.setAttribute("dx", value) - }); - } - return this[dx]; - } - get dy() { - if (!this[dy]) { - this[dy] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dy"), - setAttribute: (value) => this.setAttribute("dy", value) - }); - } - return this[dy]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-point-light-element/SVGFEPointLightElement.js -class SVGFEPointLightElement extends SVGElement { - [x] = null; - [y] = null; - [z] = null; - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get z() { - if (!this[z]) { - this[z] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("z"), - setAttribute: (value) => this.setAttribute("z", value) - }); - } - return this[z]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-specular-lighting-element/SVGFESpecularLightingElement.js -class SVGFESpecularLightingElement extends SVGElement { - [height] = null; - [in1] = null; - [kernelUnitLengthX] = null; - [kernelUnitLengthY] = null; - [result] = null; - [specularConstant] = null; - [specularExponent] = null; - [surfaceScale] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get kernelUnitLengthX() { - if (!this[kernelUnitLengthX]) { - this[kernelUnitLengthX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthX"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthX", value) - }); - } - return this[kernelUnitLengthX]; - } - get kernelUnitLengthY() { - if (!this[kernelUnitLengthY]) { - this[kernelUnitLengthY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("kernelUnitLengthY"), - setAttribute: (value) => this.setAttribute("kernelUnitLengthY", value) - }); - } - return this[kernelUnitLengthY]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get specularConstant() { - if (!this[specularConstant]) { - this[specularConstant] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("specularConstant"), - setAttribute: (value) => this.setAttribute("specularConstant", value), - defaultValue: 1 - }); - } - return this[specularConstant]; - } - get specularExponent() { - if (!this[specularExponent]) { - this[specularExponent] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("specularExponent"), - setAttribute: (value) => this.setAttribute("specularExponent", value), - defaultValue: 1 - }); - } - return this[specularExponent]; - } - get surfaceScale() { - if (!this[surfaceScale]) { - this[surfaceScale] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("surfaceScale"), - setAttribute: (value) => this.setAttribute("surfaceScale", value), - defaultValue: 1 - }); - } - return this[surfaceScale]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-spot-light-element/SVGFESpotLightElement.js -class SVGFESpotLightElement extends SVGElement { - [x] = null; - [y] = null; - [z] = null; - [pointsAtX] = null; - [pointsAtY] = null; - [pointsAtZ] = null; - [specularExponent] = null; - [limitingConeAngle] = null; - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get z() { - if (!this[z]) { - this[z] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("z"), - setAttribute: (value) => this.setAttribute("z", value) - }); - } - return this[z]; - } - get pointsAtX() { - if (!this[pointsAtX]) { - this[pointsAtX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("pointsAtX"), - setAttribute: (value) => this.setAttribute("pointsAtX", value) - }); - } - return this[pointsAtX]; - } - get pointsAtY() { - if (!this[pointsAtY]) { - this[pointsAtY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("pointsAtY"), - setAttribute: (value) => this.setAttribute("pointsAtY", value) - }); - } - return this[pointsAtY]; - } - get pointsAtZ() { - if (!this[pointsAtZ]) { - this[pointsAtZ] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("pointsAtZ"), - setAttribute: (value) => this.setAttribute("pointsAtZ", value) - }); - } - return this[pointsAtZ]; - } - get specularExponent() { - if (!this[specularExponent]) { - this[specularExponent] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("specularExponent"), - setAttribute: (value) => this.setAttribute("specularExponent", value), - defaultValue: 1 - }); - } - return this[specularExponent]; - } - get limitingConeAngle() { - if (!this[limitingConeAngle]) { - this[limitingConeAngle] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("limitingConeAngle"), - setAttribute: (value) => this.setAttribute("limitingConeAngle", value) - }); - } - return this[limitingConeAngle]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-tile-element/SVGFETileElement.js -class SVGFETileElement extends SVGElement { - [height] = null; - [in1] = null; - [result] = null; - [width] = null; - [x] = null; - [y] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get in1() { - if (!this[in1]) { - this[in1] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("in"), - setAttribute: (value) => this.setAttribute("in", value) - }); - } - return this[in1]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-fe-turbulence-element/SVGFETurbulenceElement.js -class SVGFETurbulenceElement extends SVGElement { - static SVG_TURBULENCE_TYPE_UNKNOWN = 0; - static SVG_TURBULENCE_TYPE_FRACTALNOISE = 1; - static SVG_TURBULENCE_TYPE_TURBULENCE = 2; - static SVG_STITCHTYPE_UNKNOWN = 0; - static SVG_STITCHTYPE_STITCH = 1; - static SVG_STITCHTYPE_NOSTITCH = 2; - [baseFrequencyX] = null; - [baseFrequencyY] = null; - [height] = null; - [numOctaves] = null; - [result] = null; - [seed] = null; - [stitchTiles] = null; - [type] = null; - [width] = null; - [x] = null; - [y] = null; - get baseFrequencyX() { - if (!this[baseFrequencyX]) { - this[baseFrequencyX] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("baseFrequencyX"), - setAttribute: (value) => this.setAttribute("baseFrequencyX", value) - }); - } - return this[baseFrequencyX]; - } - get baseFrequencyY() { - if (!this[baseFrequencyY]) { - this[baseFrequencyY] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("baseFrequencyY"), - setAttribute: (value) => this.setAttribute("baseFrequencyY", value) - }); - } - return this[baseFrequencyY]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get numOctaves() { - if (!this[numOctaves]) { - this[numOctaves] = new SVGAnimatedInteger(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("numOctaves"), - setAttribute: (value) => this.setAttribute("numOctaves", value) - }); - } - return this[numOctaves]; - } - get result() { - if (!this[result]) { - this[result] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("result"), - setAttribute: (value) => this.setAttribute("result", value) - }); - } - return this[result]; - } - get seed() { - if (!this[seed]) { - this[seed] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("seed"), - setAttribute: (value) => this.setAttribute("seed", value) - }); - } - return this[seed]; - } - get stitchTiles() { - if (!this[stitchTiles]) { - this[stitchTiles] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("stitchTiles"), - setAttribute: (value) => this.setAttribute("stitchTiles", value), - values: ["stitch", "noStitch"], - defaultValue: "stitch" - }); - } - return this[stitchTiles]; - } - get type() { - if (!this[type]) { - this[type] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("type"), - setAttribute: (value) => this.setAttribute("type", value), - values: ["fractalNoise", "turbulence"], - defaultValue: "turbulence" - }); - } - return this[type]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-filter-element/SVGFilterElement.js -class SVGFilterElement extends SVGElement { - [href] = null; - [filterUnits] = null; - [primitiveUnits] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get filterUnits() { - if (!this[filterUnits]) { - this[filterUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("filterUnits"), - setAttribute: (value) => this.setAttribute("filterUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[filterUnits]; - } - get primitiveUnits() { - if (!this[primitiveUnits]) { - this[primitiveUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("primitiveUnits"), - setAttribute: (value) => this.setAttribute("primitiveUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[primitiveUnits]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-foreign-object-element/SVGForeignObjectElement.js -class SVGForeignObjectElement extends SVGGraphicsElement { - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-g-element/SVGGElement.js -class SVGGElement extends SVGGraphicsElement { -} - -// node_modules/happy-dom/lib/nodes/svg-image-element/SVGImageElement.js -class SVGImageElement extends SVGGraphicsElement { - [href] = null; - [preserveAspectRatio] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get crossOrigin() { - return this.getAttribute("crossorigin"); - } - set crossOrigin(value) { - this.setAttribute("crossorigin", value); - } - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get decoding() { - const value = this.getAttribute("decoding"); - switch (value) { - case "sync": - case "async": - case "auto": - return value; - default: - return "auto"; - } - } - set decoding(value) { - this.setAttribute("decoding", value); - } - get preserveAspectRatio() { - if (!this[preserveAspectRatio]) { - this[preserveAspectRatio] = new SVGAnimatedPreserveAspectRatio(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("preserveAspectRatio"), - setAttribute: (value) => this.setAttribute("preserveAspectRatio", value) - }); - } - return this[preserveAspectRatio]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - decode() { - return Promise.resolve(); - } -} - -// node_modules/happy-dom/lib/nodes/svg-line-element/SVGLineElement.js -class SVGLineElement extends SVGGeometryElement { - [x1] = null; - [y1] = null; - [x2] = null; - [y2] = null; - get x1() { - if (!this[x1]) { - this[x1] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x1"), - setAttribute: (value) => this.setAttribute("x1", value) - }); - } - return this[x1]; - } - get y1() { - if (!this[y1]) { - this[y1] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y1"), - setAttribute: (value) => this.setAttribute("y1", value) - }); - } - return this[y1]; - } - get x2() { - if (!this[x2]) { - this[x2] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x2"), - setAttribute: (value) => this.setAttribute("x2", value) - }); - } - return this[x2]; - } - get y2() { - if (!this[y2]) { - this[y2] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y2"), - setAttribute: (value) => this.setAttribute("y2", value) - }); - } - return this[y2]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-gradient-element/SVGGradientElement.js -class SVGGradientElement extends SVGGraphicsElement { - static SVG_SPREADMETHOD_UNKNOWN = 0; - static SVG_SPREADMETHOD_PAD = 1; - static SVG_SPREADMETHOD_REFLECT = 2; - static SVG_SPREADMETHOD_REPEAT = 3; - [href] = null; - [gradientUnits] = null; - [gradientTransform] = null; - [spreadMethod] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get gradientUnits() { - if (!this[gradientUnits]) { - this[gradientUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("gradientUnits"), - setAttribute: (value) => this.setAttribute("gradientUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "objectBoundingBox" - }); - } - return this[gradientUnits]; - } - get gradientTransform() { - if (!this[gradientTransform]) { - this[gradientTransform] = new SVGAnimatedTransformList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("gradientTransform"), - setAttribute: (value) => this.setAttribute("gradientTransform", value) - }); - } - return this[gradientTransform]; - } - get spreadMethod() { - if (!this[spreadMethod]) { - this[spreadMethod] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("spreadMethod"), - setAttribute: (value) => this.setAttribute("spreadMethod", value), - values: ["pad", "reflect", "repeat"], - defaultValue: "pad" - }); - } - return this[spreadMethod]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-linear-gradient-element/SVGLinearGradientElement.js -class SVGLinearGradientElement extends SVGGradientElement { - [x1] = null; - [y1] = null; - [x2] = null; - [y2] = null; - get x1() { - if (!this[x1]) { - this[x1] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x1"), - setAttribute: (value) => this.setAttribute("x1", value) - }); - } - return this[x1]; - } - get y1() { - if (!this[y1]) { - this[y1] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y1"), - setAttribute: (value) => this.setAttribute("y1", value) - }); - } - return this[y1]; - } - get x2() { - if (!this[x2]) { - this[x2] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x2"), - setAttribute: (value) => this.setAttribute("x2", value) - }); - } - return this[x2]; - } - get y2() { - if (!this[y2]) { - this[y2] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y2"), - setAttribute: (value) => this.setAttribute("y2", value) - }); - } - return this[y2]; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedAngle.js -class SVGAnimatedAngle { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGAngle(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute] - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGAngle(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/nodes/svg-marker-element/SVGMarkerElement.js -class SVGMarkerElement extends SVGElement { - static SVG_MARKER_ORIENT_UNKNOWN = 0; - static SVG_MARKER_ORIENT_AUTO = 1; - static SVG_MARKER_ORIENT_ANGLE = 2; - static SVG_MARKERUNITS_UNKNOWN = 0; - static SVG_MARKERUNITS_USERSPACEONUSE = 1; - static SVG_MARKERUNITS_STROKEWIDTH = 2; - SVG_MARKER_ORIENT_UNKNOWN = 0; - SVG_MARKER_ORIENT_AUTO = 1; - SVG_MARKER_ORIENT_ANGLE = 2; - [markerUnits] = null; - [markerWidth] = null; - [markerHeight] = null; - [orientType] = null; - [orientAngle] = null; - [refX] = null; - [refY] = null; - [viewBox] = null; - [preserveAspectRatio] = null; - get markerUnits() { - if (!this[markerUnits]) { - this[markerUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("markerUnits"), - setAttribute: (value) => this.setAttribute("markerUnits", value), - values: ["userSpaceOnUse", "strokeWidth"], - defaultValue: "strokeWidth" - }); - } - return this[markerUnits]; - } - get markerWidth() { - if (!this[markerWidth]) { - this[markerWidth] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("markerWidth"), - setAttribute: (value) => this.setAttribute("markerWidth", value) - }); - } - return this[markerWidth]; - } - get markerHeight() { - if (!this[markerHeight]) { - this[markerHeight] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("markerHeight"), - setAttribute: (value) => this.setAttribute("markerHeight", value) - }); - } - return this[markerHeight]; - } - get orientType() { - if (!this[orientType]) { - this[orientType] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("orient"), - setAttribute: (value) => this.setAttribute("orient", value), - values: ["auto", null], - defaultValue: "auto" - }); - } - return this[orientType]; - } - get orientAngle() { - if (!this[orientAngle]) { - this[orientAngle] = new SVGAnimatedAngle(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("orient"), - setAttribute: (value) => this.setAttribute("orient", value) - }); - } - return this[orientAngle]; - } - get refX() { - if (!this[refX]) { - this[refX] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("refX"), - setAttribute: (value) => this.setAttribute("refX", value) - }); - } - return this[refX]; - } - get refY() { - if (!this[refY]) { - this[refY] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("refY"), - setAttribute: (value) => this.setAttribute("refY", value) - }); - } - return this[refY]; - } - get viewBox() { - if (!this[viewBox]) { - this[viewBox] = new SVGAnimatedRect(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("viewBox"), - setAttribute: (value) => this.setAttribute("viewBox", value) - }); - } - return this[viewBox]; - } - get preserveAspectRatio() { - if (!this[preserveAspectRatio]) { - this[preserveAspectRatio] = new SVGAnimatedPreserveAspectRatio(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("preserveAspectRatio"), - setAttribute: (value) => this.setAttribute("preserveAspectRatio", value) - }); - } - return this[preserveAspectRatio]; - } - setOrientToAuto() { - this.setAttribute("orient", "auto"); - } - setOrientToAngle(angle) { - this.setAttribute("orient", angle.valueAsString); - } -} - -// node_modules/happy-dom/lib/nodes/svg-mask-element/SVGMaskElement.js -class SVGMaskElement extends SVGElement { - [maskUnits] = null; - [maskContentUnits] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get maskUnits() { - if (!this[maskUnits]) { - this[maskUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("maskUnits"), - setAttribute: (value) => this.setAttribute("maskUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[maskUnits]; - } - get maskContentUnits() { - if (!this[maskContentUnits]) { - this[maskContentUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("maskContentUnits"), - setAttribute: (value) => this.setAttribute("maskContentUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[maskContentUnits]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-metadata-element/SVGMetadataElement.js -class SVGMetadataElement extends SVGElement { -} - -// node_modules/happy-dom/lib/nodes/svg-m-path-element/SVGMPathElement.js -class SVGMPathElement extends SVGElement { - [href] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-path-element/SVGPathElement.js -class SVGPathElement extends SVGGeometryElement { -} - -// node_modules/happy-dom/lib/nodes/svg-pattern-element/SVGPatternElement.js -class SVGPatternElement extends SVGElement { - [href] = null; - [patternUnits] = null; - [patternContentUnits] = null; - [patternTransform] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get patternUnits() { - if (!this[patternUnits]) { - this[patternUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("patternUnits"), - setAttribute: (value) => this.setAttribute("patternUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "objectBoundingBox" - }); - } - return this[patternUnits]; - } - get patternContentUnits() { - if (!this[patternContentUnits]) { - this[patternContentUnits] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("patternContentUnits"), - setAttribute: (value) => this.setAttribute("patternContentUnits", value), - values: ["userSpaceOnUse", "objectBoundingBox"], - defaultValue: "userSpaceOnUse" - }); - } - return this[patternContentUnits]; - } - get patternTransform() { - if (!this[patternTransform]) { - this[patternTransform] = new SVGAnimatedTransformList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("patternTransform"), - setAttribute: (value) => this.setAttribute("patternTransform", value) - }); - } - return this[patternTransform]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } -} - -// node_modules/happy-dom/lib/svg/SVGPointList.js -var ATTRIBUTE_SEPARATOR_REGEXP3 = /[\t\f\n\r, ]+/; - -class SVGPointList { - [window]; - [getAttribute]; - [setAttribute]; - [readOnly] = false; - [cache] = { - items: [], - attributeValue: "" - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - const methodBinder = new ClassMethodBinder(this, [SVGPointList]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length" || property === "numberOfItems") { - return target[getItemList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get numberOfItems() { - return this[getItemList]().length; - } - [Symbol.iterator]() { - return this[getItemList]().values(); - } - clear() { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'clear' on 'SVGPointList': The object is read-only.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - this[cache].items = []; - this[cache].attributeValue = ""; - this[setAttribute](""); - } - initialize(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGPointList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGPointList': 1 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGPoint)) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGPointList': parameter 1 is not of type 'SVGPoint'.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].items = [newItem]; - this[cache].attributeValue = newItem[attributeValue]; - this[setAttribute](newItem[attributeValue] || ""); - return newItem; - } - getItem(index) { - const items = this[getItemList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - insertItemBefore(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGPointList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGPointList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGPoint)) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGPointList': parameter 1 is not of type 'SVGPoint'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index > items.length) { - index = items.length; - } - items.splice(index, 0, newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - replaceItem(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGPointList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGPointList': 2 arguments required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGPoint)) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGPointList': parameter 1 is not of type 'SVGPoint'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex === index) { - return newItem; - } - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index >= items.length) { - index = items.length - 1; - } - if (items[index]) { - items[index][getAttribute] = null; - items[index][setAttribute] = null; - } - const replacedItem = items[index]; - items[index] = newItem; - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - return replacedItem; - } - removeItem(index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGPointList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGPointList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - index = Number(index); - if (isNaN(index)) { - index = 0; - } - if (index >= items.length) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGPointList': The index provided (${index}) is greater than the maximum bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index < 0) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGPointList': The index provided (${index}) is negative.`, DOMExceptionNameEnum_default.indexSizeError); - } - const removedItem = items[index]; - if (removedItem) { - removedItem[getAttribute] = null; - removedItem[setAttribute] = null; - } - items.splice(index, 1); - this[setAttribute](items.map((item) => item[attributeValue] || "0 0").join(" ")); - return removedItem; - } - appendItem(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGPointList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGPointList': 1 argument required, but only ${arguments.length} present.`); - } - if (!(newItem instanceof SVGPoint)) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGPointList': parameter 1 is not of type 'SVGPoint'.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - items.push(newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - [getItemList]() { - const attributeValue2 = this[getAttribute]() ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue2) { - return cache2.items; - } - if (cache2.items.length) { - for (const item of cache2.items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - } - const items = []; - const trimmed = attributeValue2.trim(); - if (trimmed) { - const parts = trimmed.split(ATTRIBUTE_SEPARATOR_REGEXP3); - for (let i = 0, max = parts.length;i < max; i += 2) { - const x = parseFloat(parts[i]); - const y = parts[i + 1] !== undefined ? " " + parseFloat(parts[i + 1]) : ""; - const item = new SVGPoint(illegalConstructor, this[window], { - readOnly: this[readOnly], - getAttribute: () => item[attributeValue], - setAttribute: () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] || "0 0").join(" "); - this[setAttribute](this[cache].attributeValue); - } - }); - item[attributeValue] = `${x}${y}`; - items.push(item); - } - } - cache2.attributeValue = attributeValue2; - cache2.items = items; - return items; - } -} - -// node_modules/happy-dom/lib/nodes/svg-polygon-element/SVGPolygonElement.js -class SVGPolygonElement extends SVGGeometryElement { - [animatedPoints] = null; - [points] = null; - get animatedPoints() { - if (!this[animatedPoints]) { - this[animatedPoints] = new SVGPointList(illegalConstructor, this[window], { - readOnly: true, - getAttribute: () => this.getAttribute("points"), - setAttribute: () => {} - }); - } - return this[animatedPoints]; - } - get points() { - if (!this[points]) { - this[points] = new SVGPointList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("points"), - setAttribute: (value) => this.setAttribute("points", value) - }); - } - return this[points]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-polyline-element/SVGPolylineElement.js -class SVGPolylineElement extends SVGGeometryElement { - [animatedPoints] = null; - [points] = null; - get animatedPoints() { - if (!this[animatedPoints]) { - this[animatedPoints] = new SVGPointList(illegalConstructor, this[window], { - readOnly: true, - getAttribute: () => this.getAttribute("points"), - setAttribute: () => {} - }); - } - return this[animatedPoints]; - } - get points() { - if (!this[points]) { - this[points] = new SVGPointList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("points"), - setAttribute: (value) => this.setAttribute("points", value) - }); - } - return this[points]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-radial-gradient-element/SVGRadialGradientElement.js -class SVGRadialGradientElement extends SVGGradientElement { - [cx] = null; - [cy] = null; - [r] = null; - [fx] = null; - [fy] = null; - get cx() { - if (!this[cx]) { - this[cx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cx"), - setAttribute: (value) => this.setAttribute("cx", value) - }); - } - return this[cx]; - } - get cy() { - if (!this[cy]) { - this[cy] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("cy"), - setAttribute: (value) => this.setAttribute("cy", value) - }); - } - return this[cy]; - } - get r() { - if (!this[r]) { - this[r] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("r"), - setAttribute: (value) => this.setAttribute("r", value) - }); - } - return this[r]; - } - get fx() { - if (!this[fx]) { - this[fx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("fx"), - setAttribute: (value) => this.setAttribute("fx", value) - }); - } - return this[fx]; - } - get fy() { - if (!this[fy]) { - this[fy] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("fy"), - setAttribute: (value) => this.setAttribute("fy", value) - }); - } - return this[fy]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-rect-element/SVGRectElement.js -class SVGRectElement extends SVGGeometryElement { - [x] = null; - [y] = null; - [width] = null; - [height] = null; - [rx] = null; - [ry] = null; - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get rx() { - if (!this[rx]) { - this[rx] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("rx"), - setAttribute: (value) => this.setAttribute("rx", value) - }); - } - return this[rx]; - } - get ry() { - if (!this[ry]) { - this[ry] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("ry"), - setAttribute: (value) => this.setAttribute("ry", value) - }); - } - return this[ry]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-script-element/SVGScriptElement.js -class SVGScriptElement extends SVGGraphicsElement { - [href] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get type() { - return this.getAttribute("type") || ""; - } - set type(value) { - this.setAttribute("type", value); - } -} - -// node_modules/happy-dom/lib/nodes/svg-set-element/SVGSetElement.js -class SVGSetElement extends SVGAnimationElement { -} - -// node_modules/happy-dom/lib/nodes/svg-stop-element/SVGStopElement.js -class SVGStopElement extends SVGElement { - [offset] = null; - get offset() { - if (!this[offset]) { - this[offset] = new SVGAnimatedNumber(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("offset"), - setAttribute: (value) => this.setAttribute("offset", value) - }); - } - return this[offset]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-style-element/SVGStyleElement.js -class SVGStyleElement extends SVGElement { - [sheet] = null; - [styleNode] = this; - [disabled] = false; - get media() { - return this.getAttribute("media") || "all"; - } - set media(media) { - this.setAttribute("media", media); - } - get type() { - return this.getAttribute("type") || "text/css"; - } - set type(type) { - this.setAttribute("type", type); - } - get title() { - return this.getAttribute("title") || ""; - } - set title(title) { - this.setAttribute("title", title); - } - get disabled() { - return this[disabled]; - } - set disabled(disabled2) { - this[disabled] = Boolean(disabled2); - } - get sheet() { - if (!this[isConnected]) { - return null; - } - if (!this[sheet]) { - this[sheet] = new this[ownerDocument][window].CSSStyleSheet; - this[sheet].replaceSync(this.textContent); - } - return this[sheet]; - } - [disconnectedFromDocument]() { - super[disconnectedFromDocument](); - this[sheet] = null; - } - [destroy]() { - super[destroy](); - this[sheet] = null; - } - [updateSheet]() { - if (this[sheet]) { - this[sheet].replaceSync(this.textContent); - } - } -} - -// node_modules/happy-dom/lib/nodes/svg-switch-element/SVGSwitchElement.js -class SVGSwitchElement extends SVGGraphicsElement { -} - -// node_modules/happy-dom/lib/nodes/svg-symbol-element/SVGSymbolElement.js -class SVGSymbolElement extends SVGGraphicsElement { -} - -// node_modules/happy-dom/lib/nodes/svg-text-content-element/SVGTextContentElement.js -class SVGTextContentElement extends SVGGraphicsElement { - static LENGTHADJUST_UNKNOWN = 0; - static LENGTHADJUST_SPACING = 1; - static LENGTHADJUST_SPACINGANDGLYPHS = 2; - [textLength] = null; - [lengthAdjust] = null; - get textLength() { - if (!this[textLength]) { - this[textLength] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("textLength"), - setAttribute: (value) => this.setAttribute("textLength", value) - }); - } - return this[textLength]; - } - get lengthAdjust() { - if (!this[lengthAdjust]) { - this[lengthAdjust] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("lengthAdjust"), - setAttribute: (value) => this.setAttribute("lengthAdjust", value), - values: ["spacing", "spacingAndGlyphs"], - defaultValue: "spacing" - }); - } - return this[lengthAdjust]; - } - getNumberOfChars() { - return 0; - } - getComputedTextLength() { - return 0; - } - getSubStringLength(_charnum, _nchars) { - return 0; - } - getStartPositionOfChar(_charnum) { - return new SVGPoint(illegalConstructor, this[window]); - } - getEndPositionOfChar(_charnum) { - return new SVGPoint(illegalConstructor, this[window]); - } - getExtentOfChar(_charnum) { - return new SVGRect(illegalConstructor, this[window]); - } - getRotationOfChar(_charnum) { - return 0; - } - getCharNumAtPosition(_point) { - return 0; - } -} - -// node_modules/happy-dom/lib/svg/SVGLengthList.js -var ATTRIBUTE_SEPARATOR_REGEXP4 = /[\t\f\n\r, ]+/; - -class SVGLengthList { - [window]; - [getAttribute]; - [setAttribute]; - [readOnly] = false; - [cache] = { - items: [], - attributeValue: "" - }; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[readOnly] = !!options.readOnly; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - const methodBinder = new ClassMethodBinder(this, [SVGLengthList]); - return new Proxy(this, { - get: (target, property) => { - if (property === "length" || property === "numberOfItems") { - return target[getItemList]().length; - } - if (property in target || typeof property === "symbol") { - methodBinder.bind(property); - return target[property]; - } - const index = Number(property); - if (!isNaN(index)) { - return target[getItemList]()[index]; - } - }, - set(target, property, newValue) { - methodBinder.bind(property); - if (typeof property === "symbol") { - target[property] = newValue; - return true; - } - const index = Number(property); - if (isNaN(index)) { - target[property] = newValue; - } - return true; - }, - deleteProperty(target, property) { - if (typeof property === "symbol") { - delete target[property]; - return true; - } - const index = Number(property); - if (isNaN(index)) { - delete target[property]; - } - return true; - }, - ownKeys(target) { - return Object.keys(target[getItemList]()); - }, - has(target, property) { - if (property in target) { - return true; - } - if (typeof property === "symbol") { - return false; - } - const index = Number(property); - return !isNaN(index) && index >= 0 && index < target[getItemList]().length; - }, - defineProperty(target, property, descriptor) { - methodBinder.preventBinding(property); - if (property in target) { - Object.defineProperty(target, property, descriptor); - return true; - } - return false; - }, - getOwnPropertyDescriptor(target, property) { - if (property in target || typeof property === "symbol") { - return; - } - const index = Number(property); - const items = target[getItemList](); - if (!isNaN(index) && items[index]) { - return { - value: items[index], - writable: false, - enumerable: true, - configurable: true - }; - } - } - }); - } - get length() { - return this[getItemList]().length; - } - get numberOfItems() { - return this[getItemList]().length; - } - [Symbol.iterator]() { - return this[getItemList]().values(); - } - clear() { - this[setAttribute](""); - } - initialize(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGLengthList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'initialize' on 'SVGLengthList': 1 arguments required, but only ${arguments.length} present.`); - } - for (const item of this[cache].items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].items = [newItem]; - this[cache].attributeValue = newItem[attributeValue]; - this[setAttribute](newItem[attributeValue] || ""); - return newItem; - } - getItem(index) { - const items = this[getItemList](); - if (typeof index === "number") { - return items[index] ? items[index] : null; - } - index = Number(index); - index = isNaN(index) ? 0 : index; - return items[index] ? items[index] : null; - } - insertItemBefore(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGLengthList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'insertItemBefore' on 'SVGLengthList': 2 arguments required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index > items.length) { - index = items.length; - } - items.splice(index, 0, newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - replaceItem(newItem, index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGLengthList': The object is read-only.`); - } - if (arguments.length < 2) { - throw new this[window].TypeError(`Failed to execute 'replaceItem' on 'SVGLengthList': 2 arguments required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex === index) { - return newItem; - } - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - if (index < 0) { - index = 0; - } else if (index >= items.length) { - index = items.length - 1; - } - if (items[index]) { - items[index][getAttribute] = null; - items[index][setAttribute] = null; - } - const replacedItem = items[index]; - items[index] = newItem; - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return replacedItem; - } - removeItem(index) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGLengthList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'removeItem' on 'SVGLengthList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - index = Number(index); - if (isNaN(index)) { - index = 0; - } - if (index >= items.length) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGLengthList': The index provided (${index}) is greater than the maximum bound.`, DOMExceptionNameEnum_default.indexSizeError); - } - if (index < 0) { - throw new this[window].DOMException(`Failed to execute 'removeItem' on 'SVGLengthList': The index provided (${index}) is negative.`, DOMExceptionNameEnum_default.indexSizeError); - } - const removedItem = items[index]; - if (removedItem) { - removedItem[getAttribute] = null; - removedItem[setAttribute] = null; - } - items.splice(index, 1); - this[setAttribute](items.map((item) => item[attributeValue] ?? "0").join(" ")); - return removedItem; - } - appendItem(newItem) { - if (this[readOnly]) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGLengthList': The object is read-only.`); - } - if (arguments.length < 1) { - throw new this[window].TypeError(`Failed to execute 'appendItem' on 'SVGLengthList': 1 argument required, but only ${arguments.length} present.`); - } - const items = this[getItemList](); - const existingIndex = items.indexOf(newItem); - if (existingIndex !== -1) { - items.splice(existingIndex, 1); - } - items.push(newItem); - newItem[getAttribute] = () => newItem[attributeValue]; - newItem[setAttribute] = () => { - this[cache].attributeValue = this[getItemList]().map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - }; - this[cache].attributeValue = items.map((item) => item[attributeValue] ?? "0").join(" "); - this[setAttribute](this[cache].attributeValue); - return newItem; - } - [getItemList]() { - const attributeValue2 = this[getAttribute]() ?? ""; - const cache2 = this[cache]; - if (cache2.attributeValue === attributeValue2) { - return cache2.items; - } - if (cache2.items.length) { - for (const item of cache2.items) { - item[getAttribute] = null; - item[setAttribute] = null; - } - } - const items = []; - const trimmed = attributeValue2.trim(); - if (trimmed) { - const parts = trimmed.split(ATTRIBUTE_SEPARATOR_REGEXP4); - for (let i = 0, max = parts.length;i < max; i++) { - const item = new SVGLength(illegalConstructor, this[window], { - readOnly: this[readOnly], - getAttribute: () => item[attributeValue], - setAttribute: (value) => { - item[attributeValue] = value; - const newAttributeValue = items.map((item) => item[attributeValue] ?? "0").join(" "); - cache2.attributeValue = newAttributeValue; - this[setAttribute](newAttributeValue); - } - }); - item[attributeValue] = parts[i]; - items.push(item); - } - } - cache2.attributeValue = attributeValue2; - cache2.items = items; - return items; - } -} - -// node_modules/happy-dom/lib/svg/SVGAnimatedLengthList.js -class SVGAnimatedLengthList { - [window]; - [getAttribute]; - [setAttribute]; - [baseVal] = null; - [animVal] = null; - constructor(illegalConstructorSymbol, window2, options) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - this[window] = window2; - this[getAttribute] = options.getAttribute; - this[setAttribute] = options.setAttribute; - } - get animVal() { - if (!this[animVal]) { - this[animVal] = new SVGLengthList(illegalConstructor, this[window], { - readOnly: true, - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[animVal]; - } - set animVal(_value) {} - get baseVal() { - if (!this[baseVal]) { - this[baseVal] = new SVGLengthList(illegalConstructor, this[window], { - getAttribute: this[getAttribute], - setAttribute: this[setAttribute] - }); - } - return this[baseVal]; - } - set baseVal(_value) {} -} - -// node_modules/happy-dom/lib/nodes/svg-text-positioning-element/SVGTextPositioningElement.js -class SVGTextPositioningElement extends SVGTextContentElement { - [x] = null; - [y] = null; - [dx] = null; - [dy] = null; - [rotate] = null; - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLengthList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLengthList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get dx() { - if (!this[dx]) { - this[dx] = new SVGAnimatedLengthList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dx"), - setAttribute: (value) => this.setAttribute("dx", value) - }); - } - return this[dx]; - } - get dy() { - if (!this[dy]) { - this[dy] = new SVGAnimatedLengthList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("dy"), - setAttribute: (value) => this.setAttribute("dy", value) - }); - } - return this[dy]; - } - get rotate() { - if (!this[rotate]) { - this[rotate] = new SVGAnimatedNumberList(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("rotate"), - setAttribute: (value) => this.setAttribute("rotate", value) - }); - } - return this[rotate]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-text-element/SVGTextElement.js -class SVGTextElement extends SVGTextPositioningElement { -} - -// node_modules/happy-dom/lib/nodes/svg-text-path-element/SVGTextPathElement.js -class SVGTextPathElement extends SVGTextContentElement { - static TEXTPATH_METHODTYPE_UNKNOWN = 0; - static TEXTPATH_METHODTYPE_ALIGN = 1; - static TEXTPATH_METHODTYPE_STRETCH = 2; - static TEXTPATH_SPACINGTYPE_UNKNOWN = 0; - static TEXTPATH_SPACINGTYPE_AUTO = 1; - static TEXTPATH_SPACINGTYPE_EXACT = 2; - [href] = null; - [startOffset] = null; - [method] = null; - [spacing] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get startOffset() { - if (!this[startOffset]) { - this[startOffset] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("startOffset"), - setAttribute: (value) => this.setAttribute("startOffset", value) - }); - } - return this[startOffset]; - } - get method() { - if (!this[method]) { - this[method] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("method"), - setAttribute: (value) => this.setAttribute("method", value), - values: ["align", "stretch"], - defaultValue: "align" - }); - } - return this[method]; - } - get spacing() { - if (!this[spacing]) { - this[spacing] = new SVGAnimatedEnumeration(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("spacing"), - setAttribute: (value) => this.setAttribute("spacing", value), - values: ["auto", "exact"], - defaultValue: "exact" - }); - } - return this[spacing]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-title-element/SVGTitleElement.js -class SVGTitleElement extends SVGElement { -} - -// node_modules/happy-dom/lib/nodes/svg-t-span-element/SVGTSpanElement.js -class SVGTSpanElement extends SVGTextPositioningElement { -} - -// node_modules/happy-dom/lib/nodes/svg-use-element/SVGUseElement.js -class SVGUseElement extends SVGGraphicsElement { - [href] = null; - [x] = null; - [y] = null; - [width] = null; - [height] = null; - get href() { - if (!this[href]) { - this[href] = new SVGAnimatedString(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("href"), - setAttribute: (value) => this.setAttribute("href", value) - }); - } - return this[href]; - } - get x() { - if (!this[x]) { - this[x] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("x"), - setAttribute: (value) => this.setAttribute("x", value) - }); - } - return this[x]; - } - get y() { - if (!this[y]) { - this[y] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("y"), - setAttribute: (value) => this.setAttribute("y", value) - }); - } - return this[y]; - } - get width() { - if (!this[width]) { - this[width] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("width"), - setAttribute: (value) => this.setAttribute("width", value) - }); - } - return this[width]; - } - get height() { - if (!this[height]) { - this[height] = new SVGAnimatedLength(illegalConstructor, this[window], { - getAttribute: () => this.getAttribute("height"), - setAttribute: (value) => this.setAttribute("height", value) - }); - } - return this[height]; - } -} - -// node_modules/happy-dom/lib/nodes/svg-view-element/SVGViewElement.js -class SVGViewElement extends SVGElement { -} - -// node_modules/happy-dom/lib/svg/SVGUnitTypes.js -class SVGUnitTypes { - static SVG_UNIT_TYPE_UNKNOWN = 0; - static SVG_UNIT_TYPE_USERSPACEONUSE = 1; - static SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; - SVG_UNIT_TYPE_UNKNOWN = 0; - SVG_UNIT_TYPE_USERSPACEONUSE = 1; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; - constructor(illegalConstructorSymbol) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - } -} - -// node_modules/happy-dom/lib/custom-element/CustomElementReactionStack.js -class CustomElementReactionStack { - window; - constructor(window) { - this.window = window; - } - enqueueReaction(element, callbackName, args) { - const definition = this.window.customElements[registry]?.get(element.localName); - if (!definition) { - return; - } - if (element[ownerDocument] !== this.window.document) { - return; - } - switch (callbackName) { - case "connectedCallback": - if (definition.lifecycleCallbacks.connectedCallback) { - const returnValue = definition.lifecycleCallbacks.connectedCallback?.call(element); - if (returnValue instanceof Promise) { - const asyncTaskManager = new WindowBrowserContext(this.window).getAsyncTaskManager(); - if (asyncTaskManager) { - const taskID = asyncTaskManager.startTask(); - returnValue.then(() => asyncTaskManager.endTask(taskID)).catch(() => asyncTaskManager.endTask(taskID)); - } - } - } - break; - case "disconnectedCallback": - if (definition.lifecycleCallbacks.disconnectedCallback) { - definition.lifecycleCallbacks.disconnectedCallback.call(element); - } - break; - case "attributeChangedCallback": - if (definition.lifecycleCallbacks.attributeChangedCallback && args?.length && definition.observedAttributes.has(args[0])) { - definition.lifecycleCallbacks.attributeChangedCallback.apply(element, args); - } - break; - } - } -} - -// node_modules/happy-dom/lib/event/events/PopStateEvent.js -class PopStateEvent extends Event { - state; - hasUAVisualTransition; - constructor(type, eventInit = null) { - super(type); - this.state = eventInit?.state ?? null; - this.hasUAVisualTransition = eventInit?.hasUAVisualTransition ?? false; - } -} - -// node_modules/happy-dom/lib/event/events/CloseEvent.js -class CloseEvent extends Event { - code; - reason; - wasClean; - constructor(type, eventInit = null) { - super(type, eventInit); - this.code = eventInit?.code ?? 0; - this.reason = eventInit?.reason ?? ""; - this.wasClean = eventInit?.wasClean ?? false; - } -} - -// node_modules/happy-dom/lib/canvas/ImageBitmap.js -class ImageBitmap { - [canvas] = null; - [width] = 0; - [height] = 0; - [options] = null; - constructor(illegalConstructorSymbol, window, source, sx, sy, sw, sh, options2) { - if (illegalConstructorSymbol !== illegalConstructor) { - throw new TypeError("Illegal constructor"); - } - let validSource = null; - if (source instanceof ImageBitmap) { - if (source[canvas] === null) { - throw new window.DOMException("Failed to execute 'createImageBitmap' on 'Window': The image source is not usable.", DOMExceptionNameEnum_default.invalidStateError); - } - validSource = source; - } - if (source instanceof HTMLImageElement) { - if (!source[buffer]) { - throw new window.DOMException("Failed to execute 'createImageBitmap' on 'Window': The image source is not usable.", DOMExceptionNameEnum_default.invalidStateError); - } - validSource = source; - } else if (source instanceof HTMLVideoElement) { - throw new window.DOMException("Failed to execute 'createImageBitmap' on 'Window': HTMLVideoElement is not supported as an image source yet in Happy DOM.", DOMExceptionNameEnum_default.invalidStateError); - } else if (source instanceof HTMLCanvasElement || source instanceof OffscreenCanvas) { - validSource = source; - } - if (validSource === null) { - throw new window.TypeError(`Failed to execute 'createImageBitmap' on 'Window': The provided value is not of type '(Blob or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or ImageData or OffscreenCanvas or SVGImageElement or VideoFrame)'.`); - } - this[width] = validSource.width; - this[height] = validSource.height; - let x = 0; - let y = 0; - if (typeof sx === "number" && typeof sy === "number" && typeof sw === "number" && typeof sh === "number") { - x = sx; - y = sy; - this[width] = sw; - this[height] = sh; - if (options2 !== undefined && typeof options2 !== "object") { - throw new window.TypeError(`The provided value is not of type 'ImageBitmapOptions'.`); - } - this[options] = options2 || null; - } else if (typeof sx === "number" && typeof sy === "number") { - this[width] = sx; - this[height] = sy; - if (sw !== undefined && typeof sw !== "object") { - throw new window.TypeError(`The provided value is not of type 'ImageBitmapOptions'.`); - } - this[options] = sw || null; - } else if (typeof sx === "object") { - this[options] = sx; - } else if (sx !== undefined) { - throw new window.TypeError(`Failed to execute 'createImageBitmap' on 'Window': Overload resolution failed.`); - } - const settings = new WindowBrowserContext(window).getSettings(); - const canvas2 = new window.OffscreenCanvas(this[width], this[height]); - if (settings?.canvasAdapter) { - const context = canvas2.getContext("2d"); - context.drawImage(validSource, -x, -y, validSource.width, validSource.height); - this[canvas] = canvas2; - } - } - get width() { - return this[width]; - } - get height() { - return this[height]; - } - close() { - this[canvas] = null; - this[options] = null; - this[width] = 0; - this[height] = 0; - } -} - -// node_modules/happy-dom/lib/window/BrowserWindow.js -var TIMER2 = { - setTimeout: globalThis.setTimeout.bind(globalThis), - clearTimeout: globalThis.clearTimeout.bind(globalThis), - setInterval: globalThis.setInterval.bind(globalThis), - clearInterval: globalThis.clearInterval.bind(globalThis), - queueMicrotask: globalThis.queueMicrotask.bind(globalThis), - setImmediate: globalThis.setImmediate.bind(globalThis), - clearImmediate: globalThis.clearImmediate.bind(globalThis) -}; -var IS_NODE_JS_TIMEOUT_ENVIRONMENT = setTimeout.toString().includes("new Timeout"); -var IS_CODE_GENERATION_FROM_STRINGS_ENVIRONMENT = (() => { - try { - new Function("return true;")(); - return true; - } catch { - return false; - } -})(); -var IS_UNFROZEN_INTRINSICS_ENVIRONMENT = (() => { - try { - globalThis.Function["$UNFROZEN$"] = true; - delete globalThis.Function["$UNFROZEN$"]; - return true; - } catch { - return false; - } -})(); - -class PerformanceObserverEntryList { - constructor() { - throw new TypeError("Illegal constructor"); - } -} - -class Timeout { - callback; - constructor(callback) { - this.callback = callback; - } -} - -class BrowserWindow extends EventTarget { - Node = Node; - Attr = Attr; - ShadowRoot = ShadowRoot; - ProcessingInstruction = ProcessingInstruction; - Element = Element; - CharacterData = CharacterData; - DocumentType = DocumentType; - HTMLAnchorElement = HTMLAnchorElement; - HTMLButtonElement = HTMLButtonElement; - HTMLOptGroupElement = HTMLOptGroupElement; - HTMLOptionElement = HTMLOptionElement; - HTMLElement = HTMLElement; - HTMLUnknownElement = HTMLUnknownElement; - HTMLTemplateElement = HTMLTemplateElement; - HTMLInputElement = HTMLInputElement; - HTMLSelectElement = HTMLSelectElement; - HTMLTextAreaElement = HTMLTextAreaElement; - HTMLImageElement = HTMLImageElement; - HTMLStyleElement = HTMLStyleElement; - HTMLLabelElement = HTMLLabelElement; - HTMLSlotElement = HTMLSlotElement_default; - HTMLMetaElement = HTMLMetaElement; - HTMLMediaElement = HTMLMediaElement; - HTMLAudioElement = HTMLAudioElement; - HTMLVideoElement = HTMLVideoElement; - HTMLBaseElement = HTMLBaseElement; - HTMLDialogElement = HTMLDialogElement; - HTMLScriptElement = HTMLScriptElement; - HTMLLinkElement = HTMLLinkElement; - HTMLIFrameElement = HTMLIFrameElement; - HTMLFormElement = HTMLFormElement; - HTMLUListElement = HTMLUListElement; - HTMLTrackElement = HTMLTrackElement; - HTMLTableRowElement = HTMLTableRowElement; - HTMLTitleElement = HTMLTitleElement; - HTMLTimeElement = HTMLTimeElement; - HTMLTableSectionElement = HTMLTableSectionElement; - HTMLTableCellElement = HTMLTableCellElement; - HTMLTableElement = HTMLTableElement; - HTMLSpanElement = HTMLSpanElement; - HTMLSourceElement = HTMLSourceElement; - HTMLQuoteElement = HTMLQuoteElement; - HTMLProgressElement = HTMLProgressElement; - HTMLPreElement = HTMLPreElement; - HTMLPictureElement = HTMLPictureElement; - HTMLParamElement = HTMLParamElement; - HTMLParagraphElement = HTMLParagraphElement; - HTMLOutputElement = HTMLOutputElement; - HTMLOListElement = HTMLOListElement; - HTMLObjectElement = HTMLObjectElement; - HTMLMeterElement = HTMLMeterElement; - HTMLMenuElement = HTMLMenuElement; - HTMLMapElement = HTMLMapElement; - HTMLLIElement = HTMLLIElement; - HTMLLegendElement = HTMLLegendElement; - HTMLModElement = HTMLModElement; - HTMLHtmlElement = HTMLHtmlElement; - HTMLHRElement = HTMLHRElement; - HTMLHeadElement = HTMLHeadElement; - HTMLHeadingElement = HTMLHeadingElement; - HTMLFieldSetElement = HTMLFieldSetElement; - HTMLEmbedElement = HTMLEmbedElement; - HTMLDListElement = HTMLDListElement; - HTMLDivElement = HTMLDivElement; - HTMLDetailsElement = HTMLDetailsElement; - HTMLDataListElement = HTMLDataListElement; - HTMLDataElement = HTMLDataElement; - HTMLTableColElement = HTMLTableColElement; - HTMLTableCaptionElement = HTMLTableCaptionElement; - HTMLCanvasElement = HTMLCanvasElement; - HTMLBRElement = HTMLBRElement; - HTMLBodyElement = HTMLBodyElement; - HTMLAreaElement = HTMLAreaElement; - SVGSVGElement = SVGSVGElement; - SVGAnimateElement = SVGAnimateElement; - SVGAnimateMotionElement = SVGAnimateMotionElement; - SVGAnimateTransformElement = SVGAnimateTransformElement; - SVGCircleElement = SVGCircleElement; - SVGClipPathElement = SVGClipPathElement; - SVGDefsElement = SVGDefsElement; - SVGDescElement = SVGDescElement; - SVGEllipseElement = SVGEllipseElement; - SVGFEBlendElement = SVGFEBlendElement; - SVGFEColorMatrixElement = SVGFEColorMatrixElement; - SVGFEComponentTransferElement = SVGFEComponentTransferElement; - SVGFECompositeElement = SVGFECompositeElement; - SVGFEConvolveMatrixElement = SVGFEConvolveMatrixElement; - SVGFEDiffuseLightingElement = SVGFEDiffuseLightingElement; - SVGFEDisplacementMapElement = SVGFEDisplacementMapElement; - SVGFEDistantLightElement = SVGFEDistantLightElement; - SVGFEDropShadowElement = SVGFEDropShadowElement; - SVGFEFloodElement = SVGFEFloodElement; - SVGFEFuncAElement = SVGFEFuncAElement; - SVGFEFuncBElement = SVGFEFuncBElement; - SVGFEFuncGElement = SVGFEFuncGElement; - SVGFEFuncRElement = SVGFEFuncRElement; - SVGFEGaussianBlurElement = SVGFEGaussianBlurElement; - SVGFEImageElement = SVGFEImageElement; - SVGFEMergeElement = SVGFEMergeElement; - SVGFEMergeNodeElement = SVGFEMergeNodeElement; - SVGFEMorphologyElement = SVGFEMorphologyElement; - SVGFEOffsetElement = SVGFEOffsetElement; - SVGFEPointLightElement = SVGFEPointLightElement; - SVGFESpecularLightingElement = SVGFESpecularLightingElement; - SVGFESpotLightElement = SVGFESpotLightElement; - SVGFETileElement = SVGFETileElement; - SVGFETurbulenceElement = SVGFETurbulenceElement; - SVGFilterElement = SVGFilterElement; - SVGForeignObjectElement = SVGForeignObjectElement; - SVGGElement = SVGGElement; - SVGImageElement = SVGImageElement; - SVGLineElement = SVGLineElement; - SVGLinearGradientElement = SVGLinearGradientElement; - SVGMarkerElement = SVGMarkerElement; - SVGMaskElement = SVGMaskElement; - SVGMetadataElement = SVGMetadataElement; - SVGMPathElement = SVGMPathElement; - SVGPathElement = SVGPathElement; - SVGPatternElement = SVGPatternElement; - SVGPolygonElement = SVGPolygonElement; - SVGPolylineElement = SVGPolylineElement; - SVGRadialGradientElement = SVGRadialGradientElement; - SVGRectElement = SVGRectElement; - SVGScriptElement = SVGScriptElement; - SVGSetElement = SVGSetElement; - SVGStopElement = SVGStopElement; - SVGStyleElement = SVGStyleElement; - SVGSwitchElement = SVGSwitchElement; - SVGSymbolElement = SVGSymbolElement; - SVGTextElement = SVGTextElement; - SVGTextPathElement = SVGTextPathElement; - SVGTitleElement = SVGTitleElement; - SVGTSpanElement = SVGTSpanElement; - SVGUseElement = SVGUseElement; - SVGViewElement = SVGViewElement; - SVGElement = SVGElement; - SVGAnimationElement = SVGAnimationElement; - SVGComponentTransferFunctionElement = SVGComponentTransferFunctionElement; - SVGGeometryElement = SVGGeometryElement; - SVGGradientElement = SVGGradientElement; - SVGTextPositioningElement = SVGTextPositioningElement; - SVGGraphicsElement = SVGGraphicsElement; - Event = Event; - UIEvent = UIEvent; - CustomEvent = CustomEvent; - CloseEvent = CloseEvent; - AnimationEvent = AnimationEvent; - KeyboardEvent = KeyboardEvent; - MessageEvent = MessageEvent; - MouseEvent = MouseEvent; - PointerEvent = PointerEvent; - FocusEvent = FocusEvent; - WheelEvent = WheelEvent; - InputEvent = InputEvent; - ErrorEvent = ErrorEvent; - StorageEvent = StorageEvent; - SubmitEvent = SubmitEvent; - ProgressEvent = ProgressEvent; - MediaQueryListEvent = MediaQueryListEvent; - HashChangeEvent = HashChangeEvent; - ClipboardEvent = ClipboardEvent; - CookieChangeEvent = CookieChangeEvent; - TouchEvent = TouchEvent; - PopStateEvent = PopStateEvent; - Touch = Touch; - AudioProcessingEvent = Event; - BeforeInputEvent = Event; - BeforeUnloadEvent = Event; - BlobEvent = Event; - CompositionEvent = Event; - CSSFontFaceLoadEvent = Event; - DeviceLightEvent = Event; - DeviceMotionEvent = Event; - DeviceOrientationEvent = Event; - DeviceProximityEvent = Event; - DOMTransactionEvent = Event; - DragEvent = Event; - EditingBeforeInputEvent = Event; - FetchEvent = Event; - GamepadEvent = Event; - IDBVersionChangeEvent = Event; - MediaStreamEvent = Event; - MutationEvent = Event; - OfflineAudioCompletionEvent = Event; - OverconstrainedError = Event; - PageTransitionEvent = Event; - PaymentRequestUpdateEvent = Event; - RelatedEvent = Event; - RTCDataChannelEvent = Event; - RTCIdentityErrorEvent = Event; - RTCIdentityEvent = Event; - RTCPeerConnectionIceEvent = Event; - SensorEvent = Event; - SVGEvent = Event; - SVGZoomEvent = Event; - TimeEvent = Event; - TrackEvent = Event; - TransitionEvent = Event; - UserProximityEvent = Event; - WebGLContextEvent = Event; - TextEvent = Event; - Permissions = Permissions; - History = History; - Navigator = Navigator; - Clipboard = Clipboard; - TimeRanges = TimeRanges; - TextTrackCueList = TextTrackCueList; - ValidityState = ValidityState; - MutationRecord = MutationRecord; - IntersectionObserver = IntersectionObserver; - IntersectionObserverEntry = IntersectionObserverEntry; - CSSStyleDeclaration = CSSStyleDeclaration; - CSSRule = CSSRule; - CSSContainerRule = CSSContainerRule; - CSSFontFaceRule = CSSFontFaceRule; - CSSKeyframeRule = CSSKeyframeRule; - CSSKeyframesRule = CSSKeyframesRule; - CSSMediaRule = CSSMediaRule; - CSSStyleRule = CSSStyleRule; - CSSSupportsRule = CSSSupportsRule; - CSSConditionRule = CSSConditionRule; - CSSGroupingRule = CSSGroupingRule; - CSSScopeRule = CSSScopeRule; - DOMRect = DOMRect; - DOMRectReadOnly = DOMRectReadOnly; - Plugin = Plugin; - PluginArray = PluginArray; - Location = Location; - CustomElementRegistry = CustomElementRegistry; - ResizeObserver = ResizeObserver; - Blob = Blob; - File = File; - Storage = Storage; - CookieStore = CookieStore; - MimeType = MimeType; - MimeTypeArray = MimeTypeArray; - NodeFilter = NodeFilter_default; - ImageBitmap = ImageBitmap; - HTMLCollection = HTMLCollection; - HTMLFormControlCollection = HTMLFormControlsCollection; - HTMLOptionsCollection = HTMLOptionsCollection; - NodeList = NodeList_default; - RadioNodeList = RadioNodeList; - FileList = FileList; - Screen = Screen; - ScreenDetails = ScreenDetails; - ScreenDetailed = ScreenDetailed; - NamedNodeMap = NamedNodeMap; - TreeWalker = TreeWalker; - NodeIterator = NodeIterator; - DataTransfer = DataTransfer; - DataTransferItem = DataTransferItem; - DataTransferItemList = DataTransferItemList; - XMLSerializer = XMLSerializer; - ClipboardItem = ClipboardItem; - Selection = Selection; - CSSUnitValue = CSSUnitValue; - SVGAngle = SVGAngle; - SVGAnimatedAngle = SVGAnimatedAngle; - SVGAnimatedBoolean = SVGAnimatedBoolean; - SVGAnimatedEnumeration = SVGAnimatedEnumeration; - SVGAnimatedInteger = SVGAnimatedInteger; - SVGAnimatedLength = SVGAnimatedLength; - SVGAnimatedNumber = SVGAnimatedNumber; - SVGAnimatedNumberList = SVGAnimatedNumberList; - SVGAnimatedPreserveAspectRatio = SVGAnimatedPreserveAspectRatio; - SVGAnimatedRect = SVGAnimatedRect; - SVGAnimatedString = SVGAnimatedString; - SVGAnimatedTransformList = SVGAnimatedTransformList; - SVGLength = SVGLength; - SVGLengthList = SVGLengthList; - SVGMatrix = SVGMatrix; - SVGNumber = SVGNumber; - SVGNumberList = SVGNumberList; - SVGPoint = SVGPoint; - SVGPointList = SVGPointList; - SVGPreserveAspectRatio = SVGPreserveAspectRatio; - SVGRect = SVGRect; - SVGStringList = SVGStringList; - SVGTransform = SVGTransform; - SVGTransformList = SVGTransformList; - SVGAnimatedLengthList = SVGAnimatedLengthList; - SVGUnitTypes = SVGUnitTypes; - StylePropertyMap = StylePropertyMap; - StylePropertyMapReadOnly = StylePropertyMapReadOnly; - MediaList = MediaList; - CSSKeywordValue = CSSKeywordValue; - CSSStyleValue = CSSStyleValue; - Window = this.constructor; - URLSearchParams = URLSearchParams4; - WritableStream = Stream3.Writable; - ReadableStream = ReadableStream4; - TransformStream = Stream3.Transform; - PerformanceObserver = PerformanceObserver; - PerformanceEntry = PerformanceEntry; - PerformanceObserverEntryList = PerformanceObserverEntryList; - document; - customElements = new CustomElementRegistry(this); - window = this; - globalThis = this; - performance = performance; - screenLeft = 0; - screenTop = 0; - screenX = 0; - screenY = 0; - crypto = webcrypto; - TextEncoder = TextEncoder; - TextDecoder = TextDecoder2; - closed = false; - console; - name = ""; - Buffer = Buffer8; - [mutationObservers] = []; - [readyStateManager]; - [location]; - [history]; - [navigator]; - [screen]; - [sessionStorage]; - [localStorage]; - [cookieStore]; - [self] = this; - [top] = this; - [parent] = this; - [window] = this; - [frames] = this; - [internalId] = -1; - [customElementReactionStack] = new CustomElementReactionStack(this); - [modules] = { - json: new Map, - css: new Map, - esm: new Map - }; - [moduleImportMap] = null; - [openWebSockets] = []; - [propertyEventListeners] = new Map; - [querySelectorCache] = new Map; - #browserFrame; - #innerWidth = null; - #innerHeight = null; - #outerWidth = null; - #outerHeight = null; - #devicePixelRatio = null; - #zeroDelayTimeout = { timeouts: null }; - #timerLoopStacks = []; - #timerLoopLimits = []; - constructor(browserFrame, options) { - super(); - this.#browserFrame = browserFrame; - this[validateJavaScriptExecutionEnvironment](); - this.console = browserFrame.page.console; - this[readyStateManager] = new DocumentReadyStateManager(browserFrame); - this[navigator] = new Navigator(this); - this[screen] = new Screen; - this[sessionStorage] = new Storage; - this[localStorage] = new Storage; - this[cookieStore] = new CookieStore(illegalConstructor, this); - this[location] = new Location(this.#browserFrame, options?.url ?? "about:blank"); - this[history] = new History(this.#browserFrame, this); - browserFrame[history].currentItem.href = options?.url ?? "about:blank"; - WindowBrowserContext.setWindowBrowserFrameRelation(this, this.#browserFrame); - this[setupVMContext](); - WindowContextClassExtender.extendClasses(this); - this.document = new this.HTMLDocument; - this.document[defaultView] = this; - const taskID = browserFrame[asyncTaskManager].startTask(() => this[readyStateManager].destroy()); - this[readyStateManager].waitUntilComplete().then(() => { - browserFrame[asyncTaskManager].endTask(taskID); - this.document[readyState] = DocumentReadyStateEnum_default.complete; - this.document.dispatchEvent(new Event("readystatechange")); - const loadEvent = new Event("load"); - loadEvent[currentTarget] = this; - loadEvent[target] = this.document; - loadEvent[eventPhase] = EventPhaseEnum_default.atTarget; - this.dispatchEvent(loadEvent); - loadEvent[currentTarget] = null; - loadEvent[eventPhase] = EventPhaseEnum_default.none; - loadEvent[dispatching] = false; - }); - this[bindMethods](); - } - get onsearch() { - return this[propertyEventListeners].get("onsearch") ?? null; - } - set onsearch(value) { - this[propertyEventListeners].set("onsearch", value); - } - get onappinstalled() { - return this[propertyEventListeners].get("onappinstalled") ?? null; - } - set onappinstalled(value) { - this[propertyEventListeners].set("onappinstalled", value); - } - get onbeforeinstallprompt() { - return this[propertyEventListeners].get("onbeforeinstallprompt") ?? null; - } - set onbeforeinstallprompt(value) { - this[propertyEventListeners].set("onbeforeinstallprompt", value); - } - get onabort() { - return this[propertyEventListeners].get("onabort") ?? null; - } - set onabort(value) { - this[propertyEventListeners].set("onabort", value); - } - get onbeforeinput() { - return this[propertyEventListeners].get("onbeforeinput") ?? null; - } - set onbeforeinput(value) { - this[propertyEventListeners].set("onbeforeinput", value); - } - get onbeforematch() { - return this[propertyEventListeners].get("onbeforematch") ?? null; - } - set onbeforematch(value) { - this[propertyEventListeners].set("onbeforematch", value); - } - get onbeforetoggle() { - return this[propertyEventListeners].get("onbeforetoggle") ?? null; - } - set onbeforetoggle(value) { - this[propertyEventListeners].set("onbeforetoggle", value); - } - get onblur() { - return this[propertyEventListeners].get("onblur") ?? null; - } - set onblur(value) { - this[propertyEventListeners].set("onblur", value); - } - get oncancel() { - return this[propertyEventListeners].get("oncancel") ?? null; - } - set oncancel(value) { - this[propertyEventListeners].set("oncancel", value); - } - get oncanplay() { - return this[propertyEventListeners].get("oncanplay") ?? null; - } - set oncanplay(value) { - this[propertyEventListeners].set("oncanplay", value); - } - get oncanplaythrough() { - return this[propertyEventListeners].get("oncanplaythrough") ?? null; - } - set oncanplaythrough(value) { - this[propertyEventListeners].set("oncanplaythrough", value); - } - get onchange() { - return this[propertyEventListeners].get("onchange") ?? null; - } - set onchange(value) { - this[propertyEventListeners].set("onchange", value); - } - get onclick() { - return this[propertyEventListeners].get("onclick") ?? null; - } - set onclick(value) { - this[propertyEventListeners].set("onclick", value); - } - get onclose() { - return this[propertyEventListeners].get("onclose") ?? null; - } - set onclose(value) { - this[propertyEventListeners].set("onclose", value); - } - get oncommand() { - return this[propertyEventListeners].get("oncommand") ?? null; - } - set oncommand(value) { - this[propertyEventListeners].set("oncommand", value); - } - get oncontentvisibilityautostatechange() { - return this[propertyEventListeners].get("oncontentvisibilityautostatechange") ?? null; - } - set oncontentvisibilityautostatechange(value) { - this[propertyEventListeners].set("oncontentvisibilityautostatechange", value); - } - get oncontextlost() { - return this[propertyEventListeners].get("oncontextlost") ?? null; - } - set oncontextlost(value) { - this[propertyEventListeners].set("oncontextlost", value); - } - get oncontextmenu() { - return this[propertyEventListeners].get("oncontextmenu") ?? null; - } - set oncontextmenu(value) { - this[propertyEventListeners].set("oncontextmenu", value); - } - get oncontextrestored() { - return this[propertyEventListeners].get("oncontextrestored") ?? null; - } - set oncontextrestored(value) { - this[propertyEventListeners].set("oncontextrestored", value); - } - get oncuechange() { - return this[propertyEventListeners].get("oncuechange") ?? null; - } - set oncuechange(value) { - this[propertyEventListeners].set("oncuechange", value); - } - get ondblclick() { - return this[propertyEventListeners].get("ondblclick") ?? null; - } - set ondblclick(value) { - this[propertyEventListeners].set("ondblclick", value); - } - get ondrag() { - return this[propertyEventListeners].get("ondrag") ?? null; - } - set ondrag(value) { - this[propertyEventListeners].set("ondrag", value); - } - get ondragend() { - return this[propertyEventListeners].get("ondragend") ?? null; - } - set ondragend(value) { - this[propertyEventListeners].set("ondragend", value); - } - get ondragenter() { - return this[propertyEventListeners].get("ondragenter") ?? null; - } - set ondragenter(value) { - this[propertyEventListeners].set("ondragenter", value); - } - get ondragleave() { - return this[propertyEventListeners].get("ondragleave") ?? null; - } - set ondragleave(value) { - this[propertyEventListeners].set("ondragleave", value); - } - get ondragover() { - return this[propertyEventListeners].get("ondragover") ?? null; - } - set ondragover(value) { - this[propertyEventListeners].set("ondragover", value); - } - get ondragstart() { - return this[propertyEventListeners].get("ondragstart") ?? null; - } - set ondragstart(value) { - this[propertyEventListeners].set("ondragstart", value); - } - get ondrop() { - return this[propertyEventListeners].get("ondrop") ?? null; - } - set ondrop(value) { - this[propertyEventListeners].set("ondrop", value); - } - get ondurationchange() { - return this[propertyEventListeners].get("ondurationchange") ?? null; - } - set ondurationchange(value) { - this[propertyEventListeners].set("ondurationchange", value); - } - get onemptied() { - return this[propertyEventListeners].get("onemptied") ?? null; - } - set onemptied(value) { - this[propertyEventListeners].set("onemptied", value); - } - get onended() { - return this[propertyEventListeners].get("onended") ?? null; - } - set onended(value) { - this[propertyEventListeners].set("onended", value); - } - get onerror() { - return this[propertyEventListeners].get("onerror") ?? null; - } - set onerror(value) { - this[propertyEventListeners].set("onerror", value); - } - get onfocus() { - return this[propertyEventListeners].get("onfocus") ?? null; - } - set onfocus(value) { - this[propertyEventListeners].set("onfocus", value); - } - get onformdata() { - return this[propertyEventListeners].get("onformdata") ?? null; - } - set onformdata(value) { - this[propertyEventListeners].set("onformdata", value); - } - get oninput() { - return this[propertyEventListeners].get("oninput") ?? null; - } - set oninput(value) { - this[propertyEventListeners].set("oninput", value); - } - get oninvalid() { - return this[propertyEventListeners].get("oninvalid") ?? null; - } - set oninvalid(value) { - this[propertyEventListeners].set("oninvalid", value); - } - get onkeydown() { - return this[propertyEventListeners].get("onkeydown") ?? null; - } - set onkeydown(value) { - this[propertyEventListeners].set("onkeydown", value); - } - get onkeypress() { - return this[propertyEventListeners].get("onkeypress") ?? null; - } - set onkeypress(value) { - this[propertyEventListeners].set("onkeypress", value); - } - get onkeyup() { - return this[propertyEventListeners].get("onkeyup") ?? null; - } - set onkeyup(value) { - this[propertyEventListeners].set("onkeyup", value); - } - get onload() { - return this[propertyEventListeners].get("onload") ?? null; - } - set onload(value) { - this[propertyEventListeners].set("onload", value); - } - get onloadeddata() { - return this[propertyEventListeners].get("onloadeddata") ?? null; - } - set onloadeddata(value) { - this[propertyEventListeners].set("onloadeddata", value); - } - get onloadedmetadata() { - return this[propertyEventListeners].get("onloadedmetadata") ?? null; - } - set onloadedmetadata(value) { - this[propertyEventListeners].set("onloadedmetadata", value); - } - get onloadstart() { - return this[propertyEventListeners].get("onloadstart") ?? null; - } - set onloadstart(value) { - this[propertyEventListeners].set("onloadstart", value); - } - get onmousedown() { - return this[propertyEventListeners].get("onmousedown") ?? null; - } - set onmousedown(value) { - this[propertyEventListeners].set("onmousedown", value); - } - get onmouseenter() { - return this[propertyEventListeners].get("onmouseenter") ?? null; - } - set onmouseenter(value) { - this[propertyEventListeners].set("onmouseenter", value); - } - get onmouseleave() { - return this[propertyEventListeners].get("onmouseleave") ?? null; - } - set onmouseleave(value) { - this[propertyEventListeners].set("onmouseleave", value); - } - get onmousemove() { - return this[propertyEventListeners].get("onmousemove") ?? null; - } - set onmousemove(value) { - this[propertyEventListeners].set("onmousemove", value); - } - get onmouseout() { - return this[propertyEventListeners].get("onmouseout") ?? null; - } - set onmouseout(value) { - this[propertyEventListeners].set("onmouseout", value); - } - get onmouseover() { - return this[propertyEventListeners].get("onmouseover") ?? null; - } - set onmouseover(value) { - this[propertyEventListeners].set("onmouseover", value); - } - get onmouseup() { - return this[propertyEventListeners].get("onmouseup") ?? null; - } - set onmouseup(value) { - this[propertyEventListeners].set("onmouseup", value); - } - get onmousewheel() { - return this[propertyEventListeners].get("onmousewheel") ?? null; - } - set onmousewheel(value) { - this[propertyEventListeners].set("onmousewheel", value); - } - get onpause() { - return this[propertyEventListeners].get("onpause") ?? null; - } - set onpause(value) { - this[propertyEventListeners].set("onpause", value); - } - get onplay() { - return this[propertyEventListeners].get("onplay") ?? null; - } - set onplay(value) { - this[propertyEventListeners].set("onplay", value); - } - get onplaying() { - return this[propertyEventListeners].get("onplaying") ?? null; - } - set onplaying(value) { - this[propertyEventListeners].set("onplaying", value); - } - get onprogress() { - return this[propertyEventListeners].get("onprogress") ?? null; - } - set onprogress(value) { - this[propertyEventListeners].set("onprogress", value); - } - get onratechange() { - return this[propertyEventListeners].get("onratechange") ?? null; - } - set onratechange(value) { - this[propertyEventListeners].set("onratechange", value); - } - get onreset() { - return this[propertyEventListeners].get("onreset") ?? null; - } - set onreset(value) { - this[propertyEventListeners].set("onreset", value); - } - get onresize() { - return this[propertyEventListeners].get("onresize") ?? null; - } - set onresize(value) { - this[propertyEventListeners].set("onresize", value); - } - get onscroll() { - return this[propertyEventListeners].get("onscroll") ?? null; - } - set onscroll(value) { - this[propertyEventListeners].set("onscroll", value); - } - get onscrollend() { - return this[propertyEventListeners].get("onscrollend") ?? null; - } - set onscrollend(value) { - this[propertyEventListeners].set("onscrollend", value); - } - get onsecuritypolicyviolation() { - return this[propertyEventListeners].get("onsecuritypolicyviolation") ?? null; - } - set onsecuritypolicyviolation(value) { - this[propertyEventListeners].set("onsecuritypolicyviolation", value); - } - get onseeked() { - return this[propertyEventListeners].get("onseeked") ?? null; - } - set onseeked(value) { - this[propertyEventListeners].set("onseeked", value); - } - get onseeking() { - return this[propertyEventListeners].get("onseeking") ?? null; - } - set onseeking(value) { - this[propertyEventListeners].set("onseeking", value); - } - get onselect() { - return this[propertyEventListeners].get("onselect") ?? null; - } - set onselect(value) { - this[propertyEventListeners].set("onselect", value); - } - get onslotchange() { - return this[propertyEventListeners].get("onslotchange") ?? null; - } - set onslotchange(value) { - this[propertyEventListeners].set("onslotchange", value); - } - get onstalled() { - return this[propertyEventListeners].get("onstalled") ?? null; - } - set onstalled(value) { - this[propertyEventListeners].set("onstalled", value); - } - get onsubmit() { - return this[propertyEventListeners].get("onsubmit") ?? null; - } - set onsubmit(value) { - this[propertyEventListeners].set("onsubmit", value); - } - get onsuspend() { - return this[propertyEventListeners].get("onsuspend") ?? null; - } - set onsuspend(value) { - this[propertyEventListeners].set("onsuspend", value); - } - get ontimeupdate() { - return this[propertyEventListeners].get("ontimeupdate") ?? null; - } - set ontimeupdate(value) { - this[propertyEventListeners].set("ontimeupdate", value); - } - get ontoggle() { - return this[propertyEventListeners].get("ontoggle") ?? null; - } - set ontoggle(value) { - this[propertyEventListeners].set("ontoggle", value); - } - get onvolumechange() { - return this[propertyEventListeners].get("onvolumechange") ?? null; - } - set onvolumechange(value) { - this[propertyEventListeners].set("onvolumechange", value); - } - get onwaiting() { - return this[propertyEventListeners].get("onwaiting") ?? null; - } - set onwaiting(value) { - this[propertyEventListeners].set("onwaiting", value); - } - get onwebkitanimationend() { - return this[propertyEventListeners].get("onwebkitanimationend") ?? null; - } - set onwebkitanimationend(value) { - this[propertyEventListeners].set("onwebkitanimationend", value); - } - get onwebkitanimationiteration() { - return this[propertyEventListeners].get("onwebkitanimationiteration") ?? null; - } - set onwebkitanimationiteration(value) { - this[propertyEventListeners].set("onwebkitanimationiteration", value); - } - get onwebkitanimationstart() { - return this[propertyEventListeners].get("onwebkitanimationstart") ?? null; - } - set onwebkitanimationstart(value) { - this[propertyEventListeners].set("onwebkitanimationstart", value); - } - get onwebkittransitionend() { - return this[propertyEventListeners].get("onwebkittransitionend") ?? null; - } - set onwebkittransitionend(value) { - this[propertyEventListeners].set("onwebkittransitionend", value); - } - get onwheel() { - return this[propertyEventListeners].get("onwheel") ?? null; - } - set onwheel(value) { - this[propertyEventListeners].set("onwheel", value); - } - get onauxclick() { - return this[propertyEventListeners].get("onauxclick") ?? null; - } - set onauxclick(value) { - this[propertyEventListeners].set("onauxclick", value); - } - get ongotpointercapture() { - return this[propertyEventListeners].get("ongotpointercapture") ?? null; - } - set ongotpointercapture(value) { - this[propertyEventListeners].set("ongotpointercapture", value); - } - get onlostpointercapture() { - return this[propertyEventListeners].get("onlostpointercapture") ?? null; - } - set onlostpointercapture(value) { - this[propertyEventListeners].set("onlostpointercapture", value); - } - get onpointerdown() { - return this[propertyEventListeners].get("onpointerdown") ?? null; - } - set onpointerdown(value) { - this[propertyEventListeners].set("onpointerdown", value); - } - get onpointermove() { - return this[propertyEventListeners].get("onpointermove") ?? null; - } - set onpointermove(value) { - this[propertyEventListeners].set("onpointermove", value); - } - get onpointerup() { - return this[propertyEventListeners].get("onpointerup") ?? null; - } - set onpointerup(value) { - this[propertyEventListeners].set("onpointerup", value); - } - get onpointercancel() { - return this[propertyEventListeners].get("onpointercancel") ?? null; - } - set onpointercancel(value) { - this[propertyEventListeners].set("onpointercancel", value); - } - get onpointerover() { - return this[propertyEventListeners].get("onpointerover") ?? null; - } - set onpointerover(value) { - this[propertyEventListeners].set("onpointerover", value); - } - get onpointerout() { - return this[propertyEventListeners].get("onpointerout") ?? null; - } - set onpointerout(value) { - this[propertyEventListeners].set("onpointerout", value); - } - get onpointerenter() { - return this[propertyEventListeners].get("onpointerenter") ?? null; - } - set onpointerenter(value) { - this[propertyEventListeners].set("onpointerenter", value); - } - get onpointerleave() { - return this[propertyEventListeners].get("onpointerleave") ?? null; - } - set onpointerleave(value) { - this[propertyEventListeners].set("onpointerleave", value); - } - get onselectstart() { - return this[propertyEventListeners].get("onselectstart") ?? null; - } - set onselectstart(value) { - this[propertyEventListeners].set("onselectstart", value); - } - get onselectionchange() { - return this[propertyEventListeners].get("onselectionchange") ?? null; - } - set onselectionchange(value) { - this[propertyEventListeners].set("onselectionchange", value); - } - get onanimationcancel() { - return this[propertyEventListeners].get("onanimationcancel") ?? null; - } - set onanimationcancel(value) { - this[propertyEventListeners].set("onanimationcancel", value); - } - get onanimationend() { - return this[propertyEventListeners].get("onanimationend") ?? null; - } - set onanimationend(value) { - this[propertyEventListeners].set("onanimationend", value); - } - get onanimationiteration() { - return this[propertyEventListeners].get("onanimationiteration") ?? null; - } - set onanimationiteration(value) { - this[propertyEventListeners].set("onanimationiteration", value); - } - get onanimationstart() { - return this[propertyEventListeners].get("onanimationstart") ?? null; - } - set onanimationstart(value) { - this[propertyEventListeners].set("onanimationstart", value); - } - get ontransitionrun() { - return this[propertyEventListeners].get("ontransitionrun") ?? null; - } - set ontransitionrun(value) { - this[propertyEventListeners].set("ontransitionrun", value); - } - get ontransitionstart() { - return this[propertyEventListeners].get("ontransitionstart") ?? null; - } - set ontransitionstart(value) { - this[propertyEventListeners].set("ontransitionstart", value); - } - get ontransitionend() { - return this[propertyEventListeners].get("ontransitionend") ?? null; - } - set ontransitionend(value) { - this[propertyEventListeners].set("ontransitionend", value); - } - get ontransitioncancel() { - return this[propertyEventListeners].get("ontransitioncancel") ?? null; - } - set ontransitioncancel(value) { - this[propertyEventListeners].set("ontransitioncancel", value); - } - get onbeforexrselect() { - return this[propertyEventListeners].get("onbeforexrselect") ?? null; - } - set onbeforexrselect(value) { - this[propertyEventListeners].set("onbeforexrselect", value); - } - get onafterprint() { - return this[propertyEventListeners].get("onafterprint") ?? null; - } - set onafterprint(value) { - this[propertyEventListeners].set("onafterprint", value); - } - get onbeforeprint() { - return this[propertyEventListeners].get("onbeforeprint") ?? null; - } - set onbeforeprint(value) { - this[propertyEventListeners].set("onbeforeprint", value); - } - get onbeforeunload() { - return this[propertyEventListeners].get("onbeforeunload") ?? null; - } - set onbeforeunload(value) { - this[propertyEventListeners].set("onbeforeunload", value); - } - get onhashchange() { - return this[propertyEventListeners].get("onhashchange") ?? null; - } - set onhashchange(value) { - this[propertyEventListeners].set("onhashchange", value); - } - get onlanguagechange() { - return this[propertyEventListeners].get("onlanguagechange") ?? null; - } - set onlanguagechange(value) { - this[propertyEventListeners].set("onlanguagechange", value); - } - get onmessage() { - return this[propertyEventListeners].get("onmessage") ?? null; - } - set onmessage(value) { - this[propertyEventListeners].set("onmessage", value); - } - get onmessageerror() { - return this[propertyEventListeners].get("onmessageerror") ?? null; - } - set onmessageerror(value) { - this[propertyEventListeners].set("onmessageerror", value); - } - get onoffline() { - return this[propertyEventListeners].get("onoffline") ?? null; - } - set onoffline(value) { - this[propertyEventListeners].set("onoffline", value); - } - get ononline() { - return this[propertyEventListeners].get("ononline") ?? null; - } - set ononline(value) { - this[propertyEventListeners].set("ononline", value); - } - get onpagehide() { - return this[propertyEventListeners].get("onpagehide") ?? null; - } - set onpagehide(value) { - this[propertyEventListeners].set("onpagehide", value); - } - get onpageshow() { - return this[propertyEventListeners].get("onpageshow") ?? null; - } - set onpageshow(value) { - this[propertyEventListeners].set("onpageshow", value); - } - get onpopstate() { - return this[propertyEventListeners].get("onpopstate") ?? null; - } - set onpopstate(value) { - this[propertyEventListeners].set("onpopstate", value); - } - get onrejectionhandled() { - return this[propertyEventListeners].get("onrejectionhandled") ?? null; - } - set onrejectionhandled(value) { - this[propertyEventListeners].set("onrejectionhandled", value); - } - get onstorage() { - return this[propertyEventListeners].get("onstorage") ?? null; - } - set onstorage(value) { - this[propertyEventListeners].set("onstorage", value); - } - get onunhandledrejection() { - return this[propertyEventListeners].get("onunhandledrejection") ?? null; - } - set onunhandledrejection(value) { - this[propertyEventListeners].set("onunhandledrejection", value); - } - get onunload() { - return this[propertyEventListeners].get("onunload") ?? null; - } - set onunload(value) { - this[propertyEventListeners].set("onunload", value); - } - get ondevicemotion() { - return this[propertyEventListeners].get("ondevicemotion") ?? null; - } - set ondevicemotion(value) { - this[propertyEventListeners].set("ondevicemotion", value); - } - get ondeviceorientation() { - return this[propertyEventListeners].get("ondeviceorientation") ?? null; - } - set ondeviceorientation(value) { - this[propertyEventListeners].set("ondeviceorientation", value); - } - get ondeviceorientationabsolute() { - return this[propertyEventListeners].get("ondeviceorientationabsolute") ?? null; - } - set ondeviceorientationabsolute(value) { - this[propertyEventListeners].set("ondeviceorientationabsolute", value); - } - get onpointerrawupdate() { - return this[propertyEventListeners].get("onpointerrawupdate") ?? null; - } - set onpointerrawupdate(value) { - this[propertyEventListeners].set("onpointerrawupdate", value); - } - get onpageswap() { - return this[propertyEventListeners].get("onpageswap") ?? null; - } - set onpageswap(value) { - this[propertyEventListeners].set("onpageswap", value); - } - get onpagereveal() { - return this[propertyEventListeners].get("onpagereveal") ?? null; - } - set onpagereveal(value) { - this[propertyEventListeners].set("onpagereveal", value); - } - get onscrollsnapchange() { - return this[propertyEventListeners].get("onscrollsnapchange") ?? null; - } - set onscrollsnapchange(value) { - this[propertyEventListeners].set("onscrollsnapchange", value); - } - get onscrollsnapchanging() { - return this[propertyEventListeners].get("onscrollsnapchanging") ?? null; - } - set onscrollsnapchanging(value) { - this[propertyEventListeners].set("onscrollsnapchanging", value); - } - get ongamepadconnected() { - return this[propertyEventListeners].get("ongamepadconnected") ?? null; - } - set ongamepadconnected(value) { - this[propertyEventListeners].set("ongamepadconnected", value); - } - get ongamepaddisconnected() { - return this[propertyEventListeners].get("ongamepaddisconnected") ?? null; - } - set ongamepaddisconnected(value) { - this[propertyEventListeners].set("ongamepaddisconnected", value); - } - get self() { - return this[self]; - } - set self(self2) { - this[self] = self2; - } - get top() { - return this[top]; - } - get parent() { - return this[parent]; - } - set parent(parent2) { - this[parent] = parent2; - } - get frames() { - return this[frames]; - } - set frames(frames2) { - this[parent] = frames2; - } - get location() { - return this[location]; - } - set location(href) { - this[location].href = href; - } - get history() { - return this[history]; - } - get navigator() { - return this[navigator]; - } - get screen() { - return this[screen]; - } - get sessionStorage() { - return this[sessionStorage]; - } - get localStorage() { - return this[localStorage]; - } - get cookieStore() { - return this[cookieStore]; - } - get opener() { - return this.#browserFrame[openerWindow]; - } - get scrollX() { - return this.document?.documentElement?.scrollLeft ?? 0; - } - get pageXOffset() { - return this.scrollX; - } - get scrollY() { - return this.document?.documentElement?.scrollTop ?? 0; - } - get pageYOffset() { - return this.scrollY; - } - get CSS() { - return new CSS; - } - get innerWidth() { - if (this.#innerWidth === null) { - return this.#browserFrame.page.viewport.width; - } - return this.#innerWidth; - } - set innerWidth(value) { - this.#innerWidth = value; - } - get innerHeight() { - if (this.#innerHeight === null) { - return this.#browserFrame.page.viewport.height; - } - return this.#innerHeight; - } - set innerHeight(value) { - this.#innerHeight = value; - } - get outerWidth() { - if (this.#outerWidth === null) { - return this.#browserFrame.page.viewport.width; - } - return this.#outerWidth; - } - set outerWidth(value) { - this.#outerWidth = value; - } - get outerHeight() { - if (this.#outerHeight === null) { - return this.#browserFrame.page.viewport.height; - } - return this.#outerHeight; - } - set outerHeight(value) { - this.#outerHeight = value; - } - get devicePixelRatio() { - if (this.#devicePixelRatio === null) { - return this.#browserFrame.page.viewport.devicePixelRatio; - } - return this.#devicePixelRatio; - } - set devicePixelRatio(value) { - this.#devicePixelRatio = value; - } - getComputedStyle(element) { - if (!(element instanceof Element)) { - throw new this.TypeError("Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'."); - } - element[computedStyle] = element[computedStyle] || new CSSStyleDeclaration(illegalConstructor, this, { element, computed: true }); - return element[computedStyle]; - } - getSelection() { - return this.document.getSelection(); - } - scroll(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this.TypeError("Failed to execute 'scroll' on 'Window': The provided value is not of type 'ScrollToOptions'."); - } - const options = typeof x === "object" ? x : { left: x, top: y }; - if (options.behavior === "smooth") { - this.setTimeout(() => { - if (options.top !== undefined) { - const top2 = Number(options.top); - this.document.documentElement.scrollTop = isNaN(top2) ? 0 : top2; - } - if (options.left !== undefined) { - const left = Number(options.left); - this.document.documentElement.scrollLeft = isNaN(left) ? 0 : left; - } - }); - } else { - if (options.top !== undefined) { - const top2 = Number(options.top); - this.document.documentElement.scrollTop = isNaN(top2) ? 0 : top2; - } - if (options.left !== undefined) { - const left = Number(options.left); - this.document.documentElement.scrollLeft = isNaN(left) ? 0 : left; - } - } - } - scrollTo(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this.TypeError("Failed to execute 'scrollTo' on 'Window': The provided value is not of type 'ScrollToOptions'."); - } - this.scroll(x, y); - } - scrollBy(x, y) { - if (typeof x !== "object" && arguments.length === 1) { - throw new this.TypeError("Failed to execute 'scrollBy' on 'Window': The provided value is not of type 'ScrollToOptions'."); - } - const options = typeof x === "object" ? x : { left: x, top: y }; - this.scroll({ - left: this.document.documentElement.scrollLeft + (options.left ?? 0), - top: this.document.documentElement.scrollTop + (options.top ?? 0), - behavior: options.behavior - }); - } - blur() {} - focus() {} - open(url, target, features) { - return WindowPageOpenUtility.openPage(this.#browserFrame, { - url, - target, - features - }); - } - close() { - if (this.#browserFrame.page.mainFrame === this.#browserFrame && this.#browserFrame[openerWindow]) { - this[destroy](); - this.#browserFrame.page.close(); - } - } - matchMedia(mediaQueryString) { - return new MediaQueryList({ window: this, media: mediaQueryString }); - } - getScreenDetails() { - return Promise.resolve(new ScreenDetails); - } - setTimeout(callback, delay = 0, ...args) { - if (this.closed) { - return {}; - } - const settings = this.#browserFrame.page.context.browser.settings; - if (settings.timer.preventTimerLoops) { - const stack = new Error().stack; - const timerLoopStacks = this.#timerLoopStacks; - const timerLoopLimits = this.#timerLoopLimits; - const index = timerLoopStacks.indexOf(stack); - if (index !== -1) { - timerLoopLimits[index].timeout++; - if (timerLoopLimits[index].timeout >= (settings.timer.preventTimerLoops === true ? 1 : settings.timer.preventTimerLoops.timeout ?? 1)) { - return {}; - } - } else { - timerLoopStacks.push(stack); - timerLoopLimits.push({ - timeout: 0, - requestAnimationFrame: 0 - }); - } - } - if (!delay) { - const zeroDelayTimeout = this.#zeroDelayTimeout; - if (!zeroDelayTimeout.timeouts) { - const useTryCatch = !settings || !settings.disableErrorCapturing && settings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch; - const id = TIMER2.setTimeout(() => { - this.#browserFrame[asyncTaskManager].endTimer(id); - const timeouts = zeroDelayTimeout.timeouts; - zeroDelayTimeout.timeouts = null; - for (const timeout of timeouts) { - if (useTryCatch) { - let result; - try { - result = timeout.callback(); - } catch (error) { - this[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => this[dispatchError](error)); - } - } else { - timeout.callback(); - } - } - }, 0); - zeroDelayTimeout.timeouts = []; - this.#browserFrame[asyncTaskManager].startTimer(id); - } - const timeout = new Timeout(() => callback(...args)); - zeroDelayTimeout.timeouts.push(timeout); - return timeout; - } - const useTryCatch = !settings || !settings.disableErrorCapturing && settings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch; - const id = TIMER2.setTimeout(() => { - this.#browserFrame[asyncTaskManager].endTimer(id); - if (useTryCatch) { - let result; - try { - result = callback(...args); - } catch (error) { - this[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => this[dispatchError](error)); - } - } else { - callback(...args); - } - }, settings?.timer.maxTimeout !== -1 && delay && delay > settings?.timer.maxTimeout ? settings?.timer.maxTimeout : delay); - this.#browserFrame[asyncTaskManager].startTimer(id); - return id; - } - clearTimeout(id) { - if (id && id instanceof Timeout) { - const zeroDelayTimeout = this.#zeroDelayTimeout; - if (!zeroDelayTimeout.timeouts) { - return; - } - const index = zeroDelayTimeout.timeouts.indexOf(id); - if (index !== -1) { - zeroDelayTimeout.timeouts.splice(index, 1); - } - return; - } - if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== "Timeout")) { - return; - } - TIMER2.clearTimeout(id); - this.#browserFrame[asyncTaskManager].endTimer(id); - } - setInterval(callback, delay = 0, ...args) { - if (this.closed) { - return {}; - } - const settings = this.#browserFrame.page.context.browser.settings; - const useTryCatch = !settings || !settings.disableErrorCapturing && settings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch; - let iterations = 0; - const id = TIMER2.setInterval(() => { - if (useTryCatch) { - let result; - try { - result = callback(...args); - } catch (error) { - this.clearInterval(id); - this[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => { - this.clearInterval(id); - this[dispatchError](error); - }); - } - } else { - callback(...args); - } - if (settings?.timer.maxIntervalIterations !== -1) { - if (iterations >= settings?.timer.maxIntervalIterations) { - this.clearInterval(id); - } - iterations++; - } - }, settings?.timer.maxIntervalTime !== -1 && delay && delay > settings?.timer.maxIntervalTime ? settings?.timer.maxIntervalTime : delay); - this.#browserFrame[asyncTaskManager].startTimer(id); - return id; - } - clearInterval(id) { - if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== "Timeout")) { - return; - } - TIMER2.clearInterval(id); - this.#browserFrame[asyncTaskManager].endTimer(id); - } - requestAnimationFrame(callback) { - if (this.closed) { - return {}; - } - const settings = this.#browserFrame.page.context.browser.settings; - if (settings.timer.preventTimerLoops) { - const stack = new Error().stack; - const timerLoopStacks = this.#timerLoopStacks; - const timerLoopLimits = this.#timerLoopLimits; - const index = timerLoopStacks.indexOf(stack); - if (index !== -1) { - timerLoopLimits[index].requestAnimationFrame++; - if (timerLoopLimits[index].requestAnimationFrame >= (settings.timer.preventTimerLoops === true ? 1 : settings.timer.preventTimerLoops.requestAnimationFrame ?? 1)) { - return {}; - } - } else { - timerLoopStacks.push(stack); - timerLoopLimits.push({ - timeout: 0, - requestAnimationFrame: 0 - }); - } - } - const useTryCatch = !settings || !settings.disableErrorCapturing && settings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch; - const id = TIMER2.setImmediate(() => { - this.#browserFrame[asyncTaskManager].endImmediate(id); - if (useTryCatch) { - let result; - try { - result = callback(this.performance.now()); - } catch (error) { - this[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => this[dispatchError](error)); - } - } else { - callback(this.performance.now()); - } - }); - this.#browserFrame[asyncTaskManager].startImmediate(id); - return id; - } - cancelAnimationFrame(id) { - if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== "Immediate")) { - return; - } - TIMER2.clearImmediate(id); - this.#browserFrame[asyncTaskManager].endImmediate(id); - } - queueMicrotask(callback) { - if (this.closed) { - return; - } - let isAborted = false; - const taskId = this.#browserFrame[asyncTaskManager].startTask(() => isAborted = true); - const settings = this.#browserFrame.page.context.browser.settings; - const useTryCatch = !settings || !settings.disableErrorCapturing && settings.errorCapture === BrowserErrorCaptureEnum_default.tryAndCatch; - TIMER2.queueMicrotask(() => { - if (!isAborted) { - this.#browserFrame[asyncTaskManager].endTask(taskId); - if (useTryCatch) { - let result; - try { - result = callback(); - } catch (error) { - this[dispatchError](error); - } - if (result instanceof Promise) { - result.catch((error) => this[dispatchError](error)); - } - } else { - callback(); - } - } - }); - } - async fetch(url, init) { - if (this.closed) { - return Promise.reject(new this.DOMException("Failed to execute 'fetch' on 'Window': The window is closed.", DOMExceptionNameEnum_default.invalidStateError)); - } - return await new Fetch({ - browserFrame: this.#browserFrame, - window: this, - url, - init - }).send(); - } - btoa(data) { - return Base64.btoa(data); - } - atob(data) { - return Base64.atob(data); - } - postMessage(message, targetOrigin = "*", _transfer) { - if (this.closed) { - return; - } - if (targetOrigin && targetOrigin !== "*" && this.location.origin !== targetOrigin) { - throw new this.DOMException(`Failed to execute 'postMessage' on 'Window': The target origin provided ('${targetOrigin}') does not match the recipient window's origin ('${this.location.origin}').`, DOMExceptionNameEnum_default.securityError); - } - try { - JSON.stringify(message); - } catch (error) { - throw new this.DOMException(`Failed to execute 'postMessage' on 'Window': The provided message cannot be serialized.`, DOMExceptionNameEnum_default.invalidStateError); - } - this.setTimeout(() => this.dispatchEvent(new MessageEvent("message", { - data: message, - origin: this.#browserFrame.parentFrame ? this.#browserFrame.parentFrame.window.location.origin : this.#browserFrame.window.location.origin, - source: this.#browserFrame.parentFrame ? this.#browserFrame.parentFrame.window : this.#browserFrame.window, - lastEventId: "" - }))); - } - resizeTo(width, height) { - if (this.closed) { - return; - } - if (!width || !height) { - throw new this.DOMException(`Failed to execute 'resizeTo' on 'Window': 2 arguments required, but only ${arguments.length} present.`); - } - if (this.#browserFrame[popup]) { - this.#browserFrame.page.setViewport({ width, height }); - } - } - resizeBy(width, height) { - if (this.closed) { - return; - } - if (!width || !height) { - throw new this.DOMException(`Failed to execute 'resizeBy' on 'Window': 2 arguments required, but only ${arguments.length} present.`); - } - if (this.#browserFrame[popup]) { - const viewport = this.#browserFrame.page.viewport; - this.#browserFrame.page.setViewport({ - width: viewport.width + width, - height: viewport.height + height - }); - } - } - async createImageBitmap(source, sx, sy, sw, sh, options) { - return new ImageBitmap(illegalConstructor, this, source, sx, sy, sw, sh, options); - } - [dispatchError](error) { - this.#browserFrame.page.console.error(error); - this.dispatchEvent(new ErrorEvent("error", { message: error.message, error })); - } - [evaluateScript](code, options) { - return new VM.Script(code, options).runInContext(this); - } - [setupVMContext]() { - if (!VM.isContext(this)) { - VM.createContext(this); - VMGlobalPropertyScript_default.runInContext(this); - } - } - [validateJavaScriptExecutionEnvironment]() { - const browserFrame = this.#browserFrame; - if ((IS_CODE_GENERATION_FROM_STRINGS_ENVIRONMENT || IS_UNFROZEN_INTRINSICS_ENVIRONMENT) && browserFrame.page.context.browser.settings.enableJavaScriptEvaluation && !browserFrame.page.context.browser.settings.suppressInsecureJavaScriptEnvironmentWarning && !browserFrame.page.context.browser.settings.suppressCodeGenerationFromStringsWarning) { - console.warn(` -Warning! Happy DOM has JavaScript evaluation enabled and is running in an insecure environment.` + ` - -A VM Context is not an isolated environment, and if you run untrusted code you are at risk of RCE (Remote Code Execution) attacks. The attacker can escape the VM and run code at process level.` + ` - -It is recommended to disable code generation and freeze all builtins at process level by running node with the flags "--disallow-code-generation-from-strings" and "--frozen-intrinsics".` + ' You can suppress this warning by setting "suppressInsecureJavaScriptEnvironmentWarning" to "true" at your own risk.' + ` - -For more information, see https://github.com/capricorn86/happy-dom/wiki/JavaScript-Evaluation-Warning - -`); - } - } - [destroy]() { - if (this.closed) { - return; - } - super[destroy](); - this.closed = true; - const mutationObservers2 = this[mutationObservers]; - for (const mutationObserver of mutationObservers2) { - if (mutationObserver[destroy]) { - mutationObserver[destroy](); - } - } - this[mutationObservers] = []; - for (const webSocket of this[openWebSockets]) { - webSocket[destroy](); - } - this[openWebSockets] = []; - this.document[destroy](); - const htmlElement = this.document.createElement("html"); - const headElement = this.document.createElement("head"); - const bodyElement = this.document.createElement("body"); - htmlElement.appendChild(headElement); - htmlElement.appendChild(bodyElement); - this.document[appendChild](htmlElement); - if (this.location[destroy]) { - this.location[destroy](); - } - if (this.customElements[destroy]) { - this.customElements[destroy](); - } - if (this.history[destroy]) { - this.history[destroy](); - } - this[querySelectorCache].clear(); - this[modules].json.clear(); - this[modules].css.clear(); - this[modules].esm.clear(); - this.document[preloads].clear(); - this.document[activeElement] = null; - this.document[nextActiveElement] = null; - this.document[currentScript] = null; - this.document[selection] = null; - this[parent] = null; - this[top] = null; - WindowBrowserContext.removeWindowBrowserFrameRelation(this); - } - [bindMethods]() { - for (const _class of [BrowserWindow, EventTarget]) { - const propertyDescriptors = Object.getOwnPropertyDescriptors(_class.prototype); - const keys = Object.keys(propertyDescriptors); - for (const key of keys) { - const descriptor = propertyDescriptors[key]; - if (descriptor.get || descriptor.set) { - Object.defineProperty(this, key, { - ...descriptor, - get: descriptor.get?.bind(this), - set: descriptor.set?.bind(this) - }); - } else if (key !== "constructor" && typeof descriptor.value === "function" && !descriptor.value.toString().startsWith("class ")) { - Object.defineProperty(this, key, { - ...descriptor, - value: descriptor.value.bind(this) - }); - } - } - } - } -} - -// node_modules/happy-dom/lib/browser/utilities/BrowserFrameScriptEvaluator.js -import { Script as Script2 } from "vm"; - -class BrowserFrameScriptEvaluator { - static evaluate(frame, script) { - if (!frame.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - script = typeof script === "string" ? new Script2(script) : script; - return script.runInContext(frame.window); - } - static async evaluateModule(frame, options) { - if (!frame.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - const window = frame.window; - if (options?.code) { - const url = options.url ? new URL(options.url, window.location.href) : window.location; - const source = options.code; - switch (options?.type || "esm") { - case "esm": - const factory = new ModuleFactory(window, url); - return await new ECMAScriptModule({ window, url, source, factory }).evaluate(); - case "json": - return await new JSONModule({ window, url, source }).evaluate(); - case "css": - return await new CSSModule({ window, url, source }).evaluate(); - } - } - if (options?.url) { - const module = await new ModuleFactory(window, window.location).getModule(options.url, { - with: { type: options.type || "esm" } - }); - return await module.evaluate(); - } - return {}; - } -} - -// node_modules/happy-dom/lib/history/HistoryItemList.js -class HistoryItemList { - currentItem = { - title: "", - href: "about:blank", - state: null, - popState: false, - scrollRestoration: HistoryScrollRestorationEnum_default.auto, - method: "GET", - formData: null - }; - items = [this.currentItem]; - push(historyItem) { - const index = this.items.indexOf(this.currentItem); - if (index !== this.items.length - 1) { - this.items.length = index + 1; - } - this.items.push(historyItem); - this.currentItem = historyItem; - } - replace(historyItem) { - const index = this.items.indexOf(this.currentItem); - if (index !== this.items.length - 1) { - this.items.length = index + 1; - } - if (index === -1) { - throw new Error("Current history item not found"); - } - this.currentItem = historyItem; - this.items[index] = historyItem; - } - clear() { - this.items.length = 0; - this.currentItem = { - title: "", - href: "about:blank", - state: null, - popState: false, - scrollRestoration: HistoryScrollRestorationEnum_default.auto, - method: "GET", - formData: null - }; - this.items.push(this.currentItem); - } -} - -// node_modules/happy-dom/lib/console/VirtualConsole.js -class VirtualConsole { - #printer; - #count = {}; - #time = {}; - #groupID = 0; - #groups = []; - constructor(printer) { - this.#printer = printer; - } - assert(assertion, message, ...args) { - if (!assertion) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.assert, - level: VirtualConsoleLogLevelEnum_default.error, - message: ["Assertion failed:", ...message ? [message, ...args] : args], - group: this.#groups[this.#groups.length - 1] || null - }); - } - } - clear() { - this.#printer.clear(); - } - count(label = "default") { - if (!this.#count[label]) { - this.#count[label] = 0; - } - this.#count[label]++; - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.count, - level: VirtualConsoleLogLevelEnum_default.info, - message: [`${label}: ${this.#count[label]}`], - group: this.#groups[this.#groups.length - 1] || null - }); - } - countReset(label = "default") { - delete this.#count[label]; - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.countReset, - level: VirtualConsoleLogLevelEnum_default.warn, - message: [`${label}: 0`], - group: this.#groups[this.#groups.length - 1] || null - }); - } - debug(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.debug, - level: VirtualConsoleLogLevelEnum_default.log, - message: message ? [message, ...args] : args, - group: this.#groups[this.#groups.length - 1] || null - }); - } - dir(data) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.dir, - level: VirtualConsoleLogLevelEnum_default.log, - message: [data], - group: this.#groups[this.#groups.length - 1] || null - }); - } - dirxml(data) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.dirxml, - level: VirtualConsoleLogLevelEnum_default.log, - message: [data], - group: this.#groups[this.#groups.length - 1] || null - }); - } - error(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.error, - level: VirtualConsoleLogLevelEnum_default.error, - message: message ? [message, ...args] : args, - group: this.#groups[this.#groups.length - 1] || null - }); - } - exception(...args) { - this.error(...args); - } - group(label) { - this.#groupID++; - const group = { - id: this.#groupID, - label: label || "default", - collapsed: false, - parent: this.#groups[this.#groups.length - 1] || null - }; - this.#groups.push(group); - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.group, - level: VirtualConsoleLogLevelEnum_default.log, - message: [label || "default"], - group - }); - } - groupCollapsed(label) { - this.#groupID++; - const group = { - id: this.#groupID, - label: label || "default", - collapsed: true, - parent: this.#groups[this.#groups.length - 1] || null - }; - this.#groups.push(group); - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.groupCollapsed, - level: VirtualConsoleLogLevelEnum_default.log, - message: [label || "default"], - group - }); - } - groupEnd() { - if (this.#groups.length === 0) { - return; - } - this.#groups.pop(); - } - info(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.info, - level: VirtualConsoleLogLevelEnum_default.info, - message: message ? [message, ...args] : args, - group: this.#groups[this.#groups.length - 1] || null - }); - } - log(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.log, - level: VirtualConsoleLogLevelEnum_default.log, - message: message ? [message, ...args] : args, - group: this.#groups[this.#groups.length - 1] || null - }); - } - profile() { - throw new Error("Method not implemented."); - } - profileEnd() { - throw new Error("Method not implemented."); - } - table(data) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.table, - level: VirtualConsoleLogLevelEnum_default.log, - message: [data], - group: this.#groups[this.#groups.length - 1] || null - }); - } - time(label = "default") { - this.#time[label] = performance.now(); - } - timeEnd(label = "default") { - const time = this.#time[label]; - if (time) { - const duration = performance.now() - time; - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.timeEnd, - level: VirtualConsoleLogLevelEnum_default.info, - message: [`${label}: ${duration}ms - timer ended`], - group: this.#groups[this.#groups.length - 1] || null - }); - } - } - timeLog(label = "default", ...args) { - const time = this.#time[label]; - if (time) { - const duration = performance.now() - time; - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.timeLog, - level: VirtualConsoleLogLevelEnum_default.info, - message: [`${label}: ${duration}ms`, ...args], - group: this.#groups[this.#groups.length - 1] || null - }); - } - } - timeStamp() { - throw new Error("Method not implemented."); - } - trace(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.trace, - level: VirtualConsoleLogLevelEnum_default.log, - message: [ - ...message ? [message, ...args] : args, - new Error("stack").stack.replace("Error: stack", "") - ], - group: this.#groups[this.#groups.length - 1] || null - }); - } - warn(message, ...args) { - this.#printer.print({ - type: VirtualConsoleLogTypeEnum_default.warn, - level: VirtualConsoleLogLevelEnum_default.warn, - message: message ? [message, ...args] : args, - group: this.#groups[this.#groups.length - 1] || null - }); - } -} - -// node_modules/happy-dom/lib/browser/utilities/BrowserPageUtility.js -class BrowserPageUtility { - static getFrames(page) { - return this.findFrames(page.mainFrame); - } - static closePage(page) { - if (page.closed) { - return Promise.resolve(); - } - page.closed = true; - const index = page.context.pages.indexOf(page); - if (index !== -1) { - page.context.pages.splice(index, 1); - } - page.virtualConsolePrinter.close(); - return BrowserFrameFactory.destroyFrame(page.mainFrame); - } - static findFrames(parentFrame) { - let frames = [parentFrame]; - for (const frame of parentFrame.childFrames) { - frames = frames.concat(this.findFrames(frame)); - } - return frames; - } -} - -// node_modules/happy-dom/lib/fetch/cache/preflight/PreflightResponseCache.js -class PreflightResponseCache { - #entries = new Map; - get(request) { - const cachedResponse = this.#entries.get(request.url); - if (cachedResponse) { - if (cachedResponse.expires < Date.now()) { - this.#entries.delete(request.url); - return null; - } - return cachedResponse; - } - return null; - } - add(request, response) { - this.#entries.delete(request.url); - if (request.headers.get("Cache-Control")?.includes("no-cache")) { - return null; - } - if (response.status < 200 || response.status >= 300) { - return null; - } - const maxAge = response.headers.get("Access-Control-Max-Age"); - const allowOrigin = response.headers.get("Access-Control-Allow-Origin"); - if (!maxAge || !allowOrigin) { - return null; - } - const allowMethods = []; - if (response.headers.has("Access-Control-Allow-Methods")) { - const allowMethodsHeader = response.headers.get("Access-Control-Allow-Methods"); - if (allowMethodsHeader !== "*") { - for (const method of response.headers.get("Access-Control-Allow-Methods").split(",")) { - allowMethods.push(method.trim().toUpperCase()); - } - } - } - const cachedResponse = { - allowOrigin, - allowMethods, - expires: Date.now() + parseInt(maxAge) * 1000 - }; - if (isNaN(cachedResponse.expires) || cachedResponse.expires < Date.now()) { - return null; - } - this.#entries.set(request.url, cachedResponse); - return cachedResponse; - } - clear() { - this.#entries.clear(); - } -} - -// node_modules/happy-dom/lib/version.js -var version_default = { version: "20.11.6" }; - -// node_modules/happy-dom/lib/browser/DefaultBrowserSettings.js -var DefaultBrowserSettings_default = { - disableJavaScriptEvaluation: false, - enableJavaScriptEvaluation: false, - disableJavaScriptFileLoading: false, - disableCSSFileLoading: false, - enableImageFileLoading: false, - disableIframePageLoading: false, - disableComputedStyleRendering: false, - handleDisabledFileLoadingAsSuccess: false, - disableErrorCapturing: false, - errorCapture: BrowserErrorCaptureEnum_default.tryAndCatch, - enableFileSystemHttpRequests: false, - suppressCodeGenerationFromStringsWarning: false, - suppressInsecureJavaScriptEnvironmentWarning: false, - timer: { - maxTimeout: -1, - maxIntervalTime: -1, - maxIntervalIterations: -1, - preventTimerLoops: false - }, - fetch: { - disableSameOriginPolicy: false, - disableStrictSSL: false, - interceptor: null, - requestHeaders: null, - virtualServers: null - }, - module: { - resolveNodeModules: null, - urlResolver: null, - disableCache: false - }, - navigation: { - disableMainFrameNavigation: false, - disableChildFrameNavigation: false, - disableChildPageNavigation: false, - disableFallbackToSetURL: false, - crossOriginPolicy: BrowserNavigationCrossOriginPolicyEnum_default.anyOrigin, - beforeContentCallback: null - }, - navigator: { - userAgent: `Mozilla/5.0 (X11; ${process.platform.charAt(0).toUpperCase() + process.platform.slice(1) + " " + process.arch}) AppleWebKit/537.36 (KHTML, like Gecko) HappyDOM/${version_default.version}`, - maxTouchPoints: 0 - }, - device: { - prefersColorScheme: "light", - prefersReducedMotion: "no-preference", - mediaType: "screen", - forcedColors: "none" - }, - debug: { - traceWaitUntilComplete: -1 - }, - viewport: { - width: 1024, - height: 768, - devicePixelRatio: 1 - }, - canvasAdapter: null -}; - -// node_modules/happy-dom/lib/browser/BrowserSettingsFactory.js -class BrowserSettingsFactory { - static createSettings(settings) { - if (settings) { - this.validate(DefaultBrowserSettings_default, settings); - } - return { - ...DefaultBrowserSettings_default, - ...settings, - navigation: { - ...DefaultBrowserSettings_default.navigation, - ...settings?.navigation - }, - navigator: { - ...DefaultBrowserSettings_default.navigator, - ...settings?.navigator - }, - timer: { - ...DefaultBrowserSettings_default.timer, - ...settings?.timer - }, - fetch: { - ...DefaultBrowserSettings_default.fetch, - ...settings?.fetch - }, - module: { - ...DefaultBrowserSettings_default.module, - ...settings?.module - }, - device: { - ...DefaultBrowserSettings_default.device, - ...settings?.device - }, - debug: { - ...DefaultBrowserSettings_default.debug, - ...settings?.debug - }, - viewport: { - ...DefaultBrowserSettings_default.viewport, - ...settings?.viewport - }, - canvasAdapter: settings?.canvasAdapter ?? DefaultBrowserSettings_default.canvasAdapter - }; - } - static validate(target, source, parentNamespace) { - for (const key of Object.keys(source)) { - if (target[key] === undefined) { - const namespace = parentNamespace ? parentNamespace + "." + key : key; - throw new Error(`Unknown browser setting "${namespace}"`); - } - if (typeof target[key] === "object" && !Array.isArray(target[key]) && target[key] !== null) { - const namespace = parentNamespace ? parentNamespace + "." + key : key; - if (typeof source[key] !== "object" || Array.isArray(source[key]) || source[key] === null) { - throw new Error(`Browser setting "${namespace}" cannot be null`); - } - this.validate(target[key], source[key], namespace); - } else { - if ((typeof target[key] === "boolean" || typeof target[key] === "number" || typeof target[key] === "string") && typeof source[key] !== typeof target[key]) { - const isValidPreventTimerLoops = key === "preventTimerLoops" && typeof source[key] === "object" && source[key] !== null; - if (!isValidPreventTimerLoops) { - const namespace = parentNamespace ? parentNamespace + "." + key : key; - throw new Error(`Browser setting "${namespace}" must be of type "${typeof target[key]}"`); - } - } - } - } - } -} - -// node_modules/happy-dom/lib/browser/utilities/BrowserExceptionObserver.js -class BrowserExceptionObserver { - static listenerCount = 0; - observedWindows = []; - uncaughtExceptionListener = null; - uncaughtRejectionListener = null; - observe(window) { - if (this.observedWindows.includes(window)) { - throw new Error("Browser window is already being observed."); - } - this.observedWindows.push(window); - if (this.uncaughtExceptionListener) { - return; - } - this.uncaughtExceptionListener = (error, origin) => { - if (origin === "unhandledRejection") { - return; - } - let targetWindow = null; - for (const window of this.observedWindows) { - if (error instanceof window.Error || error instanceof window.DOMException) { - targetWindow = window; - break; - } - } - if (targetWindow) { - targetWindow.console.error(error); - targetWindow.dispatchEvent(new targetWindow.ErrorEvent("error", { - error, - message: error.message - })); - } else if (process.listenerCount("uncaughtException") === this.constructor.listenerCount) { - console.error(error); - process.exit(1); - } - }; - this.uncaughtRejectionListener = (error) => { - let targetWindow = null; - for (const window of this.observedWindows) { - if (error instanceof window.Error || error instanceof window.DOMException) { - targetWindow = window; - break; - } - } - if (targetWindow) { - targetWindow.console.error(error); - targetWindow.dispatchEvent(new targetWindow.ErrorEvent("error", { - error, - message: error.message - })); - } else if (process.listenerCount("unhandledRejection") === this.constructor.listenerCount) { - console.error(error); - process.exit(1); - } - }; - this.constructor.listenerCount++; - process.on("uncaughtException", this.uncaughtExceptionListener); - process.on("unhandledRejection", this.uncaughtRejectionListener); - } - disconnect(window) { - const index = this.observedWindows.indexOf(window); - if (index === -1) { - return; - } - this.observedWindows.splice(index, 1); - if (this.observedWindows.length === 0 && this.uncaughtExceptionListener) { - this.constructor.listenerCount--; - process.off("uncaughtException", this.uncaughtExceptionListener); - if (this.uncaughtRejectionListener) { - process.off("unhandledRejection", this.uncaughtRejectionListener); - } - this.uncaughtExceptionListener = null; - this.uncaughtRejectionListener = null; - } - } -} - -// node_modules/happy-dom/lib/browser/detached-browser/DetachedBrowserFrame.js -class DetachedBrowserFrame { - childFrames = []; - parentFrame = null; - page; - closed = false; - [asyncTaskManager] = new AsyncTaskManager(this); - [listeners] = { navigation: [] }; - [openerFrame] = null; - [openerWindow] = null; - [popup] = false; - [history] = new HistoryItemList; - constructor(page) { - this.page = page; - if (page.context.browser.contexts[0]?.pages[0]?.mainFrame) { - this.window = new this.page.context.browser.windowClass(this); - if (page.context.browser[exceptionObserver]) { - page.context.browser[exceptionObserver].observe(this.window); - } - } - } - get content() { - if (!this.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - return this.window.document.documentElement.outerHTML; - } - set content(content) { - if (!this.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - this.window.document[isFirstWrite] = true; - this.window.document[isFirstWriteAfterOpen] = false; - this.window.document.open(); - this.window.document.write(content); - } - get url() { - if (!this.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - return this.window.location.href; - } - set url(url) { - if (!this.window) { - throw new Error('The frame has been destroyed, the "window" property is not set.'); - } - this.window[location][setURL](this, BrowserFrameURL.getRelativeURL(this, url).href); - } - get document() { - return this.window?.document ?? null; - } - async waitUntilComplete() { - await Promise.all([ - this[asyncTaskManager].waitUntilComplete(), - ...this.childFrames.map((frame) => frame.waitUntilComplete()) - ]); - } - waitForNavigation() { - return new Promise((resolve) => this[listeners].navigation.push(resolve)); - } - abort() { - if (!this.childFrames.length) { - return this[asyncTaskManager].abort(); - } - return new Promise((resolve, reject) => { - Promise.all(this.childFrames.map((frame) => frame.abort()).concat([this[asyncTaskManager].abort()])).then(() => resolve()).catch(reject); - }); - } - evaluate(script) { - return BrowserFrameScriptEvaluator.evaluate(this, script); - } - evaluateModule(options) { - return BrowserFrameScriptEvaluator.evaluateModule(this, options); - } - goto(url, options) { - return BrowserFrameNavigator.navigate({ - windowClass: this.page.context.browser.windowClass, - frame: this, - url, - goToOptions: options - }); - } - goBack(options) { - return BrowserFrameNavigator.navigateBack({ - windowClass: this.page.context.browser.windowClass, - frame: this, - goToOptions: options - }); - } - goForward(options) { - return BrowserFrameNavigator.navigateForward({ - windowClass: this.page.context.browser.windowClass, - frame: this, - goToOptions: options - }); - } - goSteps(steps, options) { - return BrowserFrameNavigator.navigateSteps({ - windowClass: this.page.context.browser.windowClass, - frame: this, - steps, - goToOptions: options - }); - } - reload(options) { - return BrowserFrameNavigator.reload({ - windowClass: this.page.context.browser.windowClass, - frame: this, - goToOptions: options - }); - } -} - -// node_modules/happy-dom/lib/browser/detached-browser/DetachedBrowserPage.js -class DetachedBrowserPage { - virtualConsolePrinter = new VirtualConsolePrinter; - mainFrame; - context; - console; - viewport; - closed = false; - constructor(context) { - this.context = context; - this.console = context.browser.console ?? new VirtualConsole(this.virtualConsolePrinter); - this.mainFrame = new DetachedBrowserFrame(this); - this.viewport = { - width: context.browser.settings.viewport.width, - height: context.browser.settings.viewport.height, - devicePixelRatio: context.browser.settings.viewport.devicePixelRatio - }; - } - get frames() { - return BrowserPageUtility.getFrames(this); - } - get content() { - return this.mainFrame.content; - } - set content(content) { - this.mainFrame.content = content; - } - get url() { - return this.mainFrame.url; - } - set url(url) { - this.mainFrame.url = url; - } - close() { - return new Promise((resolve, reject) => { - const context = this.context; - BrowserPageUtility.closePage(this).then(() => { - if (context.pages[0] === this) { - context.browser.close().then(resolve).catch(reject); - } else { - resolve(); - } - }).catch(reject); - }); - } - waitUntilComplete() { - return this.mainFrame.waitUntilComplete(); - } - waitForNavigation() { - return this.mainFrame.waitForNavigation(); - } - abort() { - return this.mainFrame.abort(); - } - evaluate(script) { - return this.mainFrame.evaluate(script); - } - evaluateModule(options) { - return this.mainFrame.evaluateModule(options); - } - setViewport(viewport) { - const previousViewport = Object.assign({}, this.viewport); - Object.assign(this.viewport, viewport); - if (previousViewport.width !== this.viewport.width || previousViewport.height !== this.viewport.height || previousViewport.devicePixelRatio !== this.viewport.devicePixelRatio) { - this.mainFrame.window.dispatchEvent(new Event("resize")); - } - } - goto(url, options) { - return this.mainFrame.goto(url, options); - } - goBack(options) { - return this.mainFrame.goBack(options); - } - goForward(options) { - return this.mainFrame.goForward(options); - } - goSteps(steps, options) { - return this.mainFrame.goSteps(steps, options); - } - reload(options) { - return this.mainFrame.reload(options); - } -} - -// node_modules/happy-dom/lib/browser/detached-browser/DetachedBrowserContext.js -class DetachedBrowserContext { - pages; - browser; - cookieContainer = new CookieContainer; - responseCache = new ResponseCache; - preflightResponseCache = new PreflightResponseCache; - closed = false; - [moduleCache] = new Map; - constructor(browser) { - this.browser = browser; - this.pages = []; - this.pages.push(new DetachedBrowserPage(this)); - } - async close() { - if (this.closed) { - return; - } - if (this.browser.contexts[0] === this) { - throw new Error("Cannot close the default context. Use `browser.close()` to close the browser instead."); - } - this.closed = true; - await Promise.all(this.pages.slice().map((page) => page.close())); - const browser = this.browser; - const index = browser.contexts.indexOf(this); - if (index !== -1) { - browser.contexts.splice(index, 1); - } - this.pages = []; - this.cookieContainer.clearCookies(); - this.responseCache.clear(); - this.preflightResponseCache.clear(); - } - async waitUntilComplete() { - await Promise.all(this.pages.map((page) => page.waitUntilComplete())); - } - abort() { - return new Promise((resolve, reject) => { - if (!this.pages.length) { - resolve(); - return; - } - Promise.all(this.pages.slice().map((page) => page.abort())).then(() => resolve()).catch((error) => reject(error)); - }); - } - newPage() { - const page = new DetachedBrowserPage(this); - this.pages.push(page); - return page; - } -} - -// node_modules/happy-dom/lib/browser/detached-browser/DetachedBrowser.js -class DetachedBrowser { - contexts; - settings; - console; - windowClass; - [exceptionObserver] = null; - constructor(windowClass, options) { - this.windowClass = windowClass; - this.console = options?.console || null; - this.settings = BrowserSettingsFactory.createSettings(options?.settings); - if (this.settings.errorCapture === BrowserErrorCaptureEnum_default.processLevel) { - this[exceptionObserver] = new BrowserExceptionObserver; - } - this.contexts = []; - this.contexts.push(new DetachedBrowserContext(this)); - } - get closed() { - return this.contexts.length === 0; - } - get defaultContext() { - if (this.contexts.length === 0) { - throw new Error("No default context. The browser has been closed."); - } - return this.contexts[0]; - } - async close() { - if (this.contexts.length === 0) { - return; - } - const contexts = this.contexts; - this.contexts = []; - await Promise.all(contexts.map((context) => context.close())); - } - async waitUntilComplete() { - await Promise.all(this.contexts.map((page) => page.waitUntilComplete())); - } - abort() { - return new Promise((resolve, reject) => { - if (!this.contexts.length) { - resolve(); - return; - } - Promise.all(this.contexts.slice().map((context) => context.abort())).then(() => resolve()).catch((error) => reject(error)); - }); - } - newIncognitoContext() { - throw new Error("Not possible to create a new context on a detached browser."); - } - newPage() { - if (this.contexts.length === 0) { - throw new Error("No default context. The browser has been closed."); - } - return this.contexts[0].newPage(); - } -} - -// node_modules/happy-dom/lib/window/DetachedWindowAPI.js -class DetachedWindowAPI { - #browserFrame; - constructor(browserFrame) { - this.#browserFrame = browserFrame; - } - get settings() { - return this.#browserFrame.page.context.browser.settings; - } - get virtualConsolePrinter() { - return this.#browserFrame.page.virtualConsolePrinter; - } - waitUntilComplete() { - return this.#browserFrame.waitUntilComplete(); - } - whenAsyncComplete() { - return this.waitUntilComplete(); - } - abort() { - return this.#browserFrame.abort(); - } - cancelAsync() { - return this.abort(); - } - close() { - return this.#browserFrame.page.close(); - } - setURL(url) { - this.#browserFrame.url = url; - } - setViewport(viewport) { - this.#browserFrame.page.setViewport(viewport); - } - setWindowSize(options) { - this.setViewport({ - width: options?.width, - height: options?.height - }); - } - setInnerWidth(width) { - this.setViewport({ width }); - } - setInnerHeight(height) { - this.setViewport({ height }); - } -} - -// node_modules/happy-dom/lib/window/Window.js -class Window extends BrowserWindow { - happyDOM; - constructor(options) { - const browser = new DetachedBrowser(BrowserWindow, { - console: options?.console, - settings: options?.settings - }); - const browserPage = browser.defaultContext.pages[0]; - const browserFrame = browserPage.mainFrame; - if (options && (options.width || options.height || options.innerWidth || options.innerHeight)) { - Object.assign(browserPage.viewport, { - width: options.width || options.innerWidth || browserPage.viewport.width, - height: options.height || options.innerHeight || browserPage.viewport.height - }); - } - super(browserFrame, { - url: options?.url - }); - browserFrame.window = this; - if (browserFrame.page.context.browser[exceptionObserver]) { - browserFrame.page.context.browser[exceptionObserver].observe(this); - } - this.happyDOM = new DetachedWindowAPI(browserFrame); - } -} - -// node_modules/happy-dom/lib/window/GlobalWindow.js -import { Buffer as Buffer9 } from "buffer"; - -class GlobalWindow extends Window { - Array = globalThis.Array; - ArrayBuffer = globalThis.ArrayBuffer; - Boolean = globalThis.Boolean; - Buffer = Buffer9; - DataView = globalThis.DataView; - Date = globalThis.Date; - Error = globalThis.Error; - EvalError = globalThis.EvalError; - Float32Array = globalThis.Float32Array; - Float64Array = globalThis.Float64Array; - Function = globalThis.Function; - Infinity = globalThis.Infinity; - Int16Array = globalThis.Int16Array; - Int32Array = globalThis.Int32Array; - Int8Array = globalThis.Int8Array; - Intl = globalThis.Intl; - JSON = globalThis.JSON; - Map = globalThis.Map; - Math = globalThis.Math; - NaN = globalThis.NaN; - Number = globalThis.Number; - Object = globalThis.Object; - Promise = globalThis.Promise; - RangeError = globalThis.RangeError; - ReferenceError = globalThis.ReferenceError; - RegExp = globalThis.RegExp; - Set = globalThis.Set; - String = globalThis.String; - Symbol = globalThis.Symbol; - SyntaxError = globalThis.SyntaxError; - TypeError = globalThis.TypeError; - URIError = globalThis.URIError; - Uint16Array = globalThis.Uint16Array; - Uint32Array = globalThis.Uint32Array; - Uint8Array = globalThis.Uint8Array; - Uint8ClampedArray = globalThis.Uint8ClampedArray; - WeakMap = globalThis.WeakMap; - WeakSet = globalThis.WeakSet; - decodeURI = globalThis.decodeURI; - decodeURIComponent = globalThis.decodeURIComponent; - encodeURI = globalThis.encodeURI; - encodeURIComponent = globalThis.encodeURIComponent; - eval = globalThis.eval; - escape = globalThis.escape; - global = globalThis; - isFinite = globalThis.isFinite; - isNaN = globalThis.isNaN; - parseFloat = globalThis.parseFloat; - parseInt = globalThis.parseInt; - undefined = globalThis.undefined; - unescape = globalThis.unescape; - [evaluateScript](code, options) { - if (options?.filename) { - return this.eval(`${code} -//# sourceURL=${options.filename}`); - } - return this.eval(code); - } - [setupVMContext]() {} -} - -// src/proxy/captcha-happy.ts -import { ProxyAgent, setGlobalDispatcher } from "undici"; -import crypto from "crypto"; -import fs from "fs"; -import os from "os"; -import path from "path"; -import { Worker } from "worker_threads"; -var SYNC_FETCH_BUF_BYTES = 8 * 1024 * 1024; -var SYNC_FETCH_HEADER_BYTES = 64; -var SYNC_FETCH_TIMEOUT_MS = Number(process.env.CAPTCHA_SYNC_FETCH_TIMEOUT_MS || 12000); -var _syncFetchWorker = null; -var SYNC_WORKER_SRC = ` - const { parentPort } = require("node:worker_threads"); - const enc = new TextEncoder(); - parentPort.on("message", (m) => { - (async () => { - const i32 = new Int32Array(m.sab); - const u8 = new Uint8Array(m.sab); - // Fixed-size header (bytes), NOT i32.length * 4 \u2014 that is the whole SAB. - const payloadAt = 64; - const fail = (msg) => { - const b = enc.encode(msg); - u8.set(b, payloadAt); - i32[5] = b.length; i32[1] = 0; i32[2] = 0; i32[3] = 0; i32[4] = 0; - i32[0] = 2; Atomics.notify(i32, 0); - }; - try { - const res = await fetch(m.url, m.init); - const body = Buffer.from(await res.arrayBuffer()); - const headers = {}; - for (const [k, v] of res.headers) headers[k] = v; - const setCookie = typeof res.headers.getSetCookie === "function" ? res.headers.getSetCookie() : []; - const statusText = enc.encode(res.statusText || ""); - const headersJson = enc.encode(JSON.stringify(headers)); - const setCookieJson = enc.encode(JSON.stringify(setCookie)); - let off = payloadAt; - u8.set(statusText, off); i32[2] = statusText.length; off += statusText.length; - u8.set(headersJson, off); i32[3] = headersJson.length; off += headersJson.length; - u8.set(setCookieJson, off); i32[4] = setCookieJson.length; off += setCookieJson.length; - u8.set(body, off); i32[5] = body.length; - i32[1] = res.status; - i32[0] = 1; Atomics.notify(i32, 0); - } catch (err) { - fail(String((err && err.message) || err)); - } - })(); - }); -`; -function ensureSyncFetchWorker() { - if (_syncFetchWorker) - return _syncFetchWorker; - _syncFetchWorker = new Worker(SYNC_WORKER_SRC, { eval: true }); - return _syncFetchWorker; -} -function syncFetchBlocking(url, init, timeoutMs = SYNC_FETCH_TIMEOUT_MS) { - try { - const worker = ensureSyncFetchWorker(); - const sab = new SharedArrayBuffer(SYNC_FETCH_HEADER_BYTES + SYNC_FETCH_BUF_BYTES); - const i32 = new Int32Array(sab); - const u8 = new Uint8Array(sab); - worker.postMessage({ sab, url, init }); - const waitResult = Atomics.wait(i32, 0, 0, timeoutMs); - if (waitResult === "timed-out") - return { error: "sync fetch timeout" }; - const dec = new TextDecoder; - const payloadAt = SYNC_FETCH_HEADER_BYTES; - let off = payloadAt; - const readSlice = (len) => { - const slice = u8.subarray(off, off + len); - off += len; - return slice; - }; - const statusText = dec.decode(readSlice(i32[2])); - const headers = i32[3] ? JSON.parse(dec.decode(readSlice(i32[3]))) : {}; - const setCookie = i32[4] ? JSON.parse(dec.decode(readSlice(i32[4]))) : []; - const body = Buffer.from(readSlice(i32[5])); - if (i32[0] === 2) - return { error: dec.decode(u8.subarray(payloadAt, payloadAt + i32[5])) || "sync fetch failed" }; - return { status: i32[1], statusText, headers, setCookie, body }; - } catch (err) { - try { - _syncFetchWorker?.terminate(); - } catch {} - _syncFetchWorker = null; - return { error: `sync fetch error: ${err?.message ?? err}` }; - } -} -function shutdownSyncFetchWorker() { - try { - _syncFetchWorker?.terminate(); - } catch {} - _syncFetchWorker = null; -} -var CDN_CACHE_DIR = path.join(os.homedir(), ".zcode-captcha-cdn-cache"); -var _memCdnCache = new Map; -var MEM_CDN_CACHE_CAP = 16; -function rememberCdnBody(url, body) { - _memCdnCache.set(url, body); - if (_memCdnCache.size > MEM_CDN_CACHE_CAP) { - for (const key of _memCdnCache.keys()) { - _memCdnCache.delete(key); - if (_memCdnCache.size <= MEM_CDN_CACHE_CAP) - break; - } - } -} -var _cookieCache = { cookies: [], ts: 0 }; -var COOKIE_CACHE_TTL_MS = 5 * 60 * 1000; -var _DEBUG = /^(1|true|yes)$/i.test(process.env.CAPTCHA_DEBUG || process.env.CAPTCHA_DEBUG_BODIES || ""); -var proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; -if (proxyUrl) { - try { - setGlobalDispatcher(new ProxyAgent(proxyUrl)); - } catch (_) {} -} -var REQUEST_LOG_CAP = 256; -var _requestLog = []; -function noteRequest(entry) { - _requestLog.push(entry); - if (_requestLog.length > REQUEST_LOG_CAP) { - _requestLog.splice(0, _requestLog.length - REQUEST_LOG_CAP); - } -} -var _stallCounts = new Map; -var _bypassPeCacheOnce = false; -function noteStallAndMaybeEvict(peUrl) { - try { - if (!peUrl || !/dynamicJS\//.test(peUrl)) - return; - _bypassPeCacheOnce = true; - const n = (_stallCounts.get(peUrl) || 0) + 1; - _stallCounts.set(peUrl, n); - if (n >= 2 && !_DEBUG) { - process.stderr.write(`[pe-cache-evict] ${peUrl.split("/").pop()} stalled ${n}x \u2014 evicting cache -`); - } - if (n >= 2) { - _memCdnCache.delete(peUrl); - try { - fs.unlinkSync(diskPathFor(peUrl)); - } catch (_) {} - _stallCounts.delete(peUrl); - } - } catch (_) {} -} -function generateFingerprint() { - const userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36"; - const uaMajor = "127"; - const uaFull = "127.0.0.0"; - const platform = "Linux x86_64"; - const screen = { w: 1280, h: 720, aw: 1280, ah: 720 }; - const webglUnmaskedVendor = "Google Inc. (Google)"; - const webglUnmaskedRenderer = "ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)"; - const canvasImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="; - return { userAgent, uaMajor, uaFull, platform, screen, webglUnmaskedVendor, webglUnmaskedRenderer, canvasImage }; -} -var fp = generateFingerprint(); -var HTML = ` -
- -`; -function diskPathFor(url) { - return path.join(CDN_CACHE_DIR, crypto.createHash("sha1").update(String(url)).digest("hex")); -} -function sniffMime(url) { - if (/\.js(\?|$)/i.test(url)) - return "application/javascript"; - if (/\.css(\?|$)/i.test(url)) - return "text/css"; - if (/\.png(\?|$)/i.test(url)) - return "image/png"; - if (/\.(jpg|jpeg)(\?|$)/i.test(url)) - return "image/jpeg"; - if (/\.json(\?|$)/i.test(url)) - return "application/json"; - return "application/octet-stream"; -} -var peVmCallRegex = /55==A\?\(f=r\[n\+\+\],l=e\.pop\(\),h=e\.pop\(\),o=\[\],\w+\(f\)\.forEach\(function\(\)\{o\.unshift\(e\.pop\(\)\)\}\),p=null===h\?l\.apply\((\w+),o\):h\[l\]\.apply\(h,o\),r\[n\+\+\]&&e\.push\(p\)\):/; -function patchPeBundle(buf, url) { - if (process.env.PE_PATCH === "off") - return buf; - if (!/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) - return buf; - let src = buf.toString("utf8"); - if (src.includes("__DBT")) - return buf; - const m = src.match(peVmCallRegex); - if (!m) - return buf; - const locals = m[1]; - const hook = `55==A?(f=r[n++],l=e.pop(),h=e.pop(),o=[],v(f).forEach(function(){o.unshift(e.pop())}),p=null===h?l.apply(${locals},o):h[l].apply(h,o),r[n++]&&e.push(p),function(){try{if(l===window.btoa||l===window.atob){window.__DBT=window.__DBT||[];var __sav=[];for(var __i=0;__i 0) { - return cookies.map((c) => `${c.name}=${c.value}`).join("; "); - } - } catch (_) {} - return null; -} -function storeSetCookies(res, url) { - try { - const list = typeof res.headers.getSetCookie === "function" ? res.headers.getSetCookie() : []; - if (list.length) { - const cookieContainer = global.__cookieContainer; - if (cookieContainer) { - for (const raw of list) { - const u = new URL(url); - const parts = raw.split(";"); - const pair = parts[0].split("="); - const cookie = { - name: pair[0].trim(), - value: pair.slice(1).join("=").trim(), - url: u.origin, - domain: u.hostname, - path: "/" - }; - for (const p of parts.slice(1)) { - const kv = p.trim().split(/=(.*)/s); - const k = (kv[0] || "").toLowerCase(); - if (k === "domain" && kv[1]) - cookie.domain = kv[1]; - if (k === "path" && kv[1]) - cookie.path = kv[1]; - if (k === "expires") - cookie.expires = new Date(kv[1]).getTime(); - if (k === "max-age") - cookie.maxAge = parseInt(kv[1], 10); - if (k === "httponly") - cookie.httpOnly = true; - if (k === "secure") - cookie.secure = true; - if (k === "samesite") - cookie.sameSite = kv[1]; - } - try { - cookieContainer.addCookies([cookie]); - } catch (_) {} - } - } - } - } catch (_) {} -} -function makeInterceptor(bypassPeCache = false) { - const skipPeCache = (url) => bypassPeCache && /dynamicJS\/.*\/pe\.\d+\./.test(url); - return { - async beforeAsyncRequest({ request, window: w }) { - const url = request.url; - noteRequest({ at: Date.now(), method: request.method, url }); - injectRequestHeaders(request); - if (/\balicdn\.com/i.test(url)) { - let body = skipPeCache(url) ? null : getCachedBody(url); - if (body && /\.js(\?|$)/i.test(url)) { - try { - new Function(body.toString("utf8")); - } catch (parseErr) { - process.stderr.write(`[cache-bad-js] ${url} len=${body.length} ${parseErr.message} \u2014 refetch fresh -`); - _memCdnCache.delete(url); - try { - fs.unlinkSync(diskPathFor(url)); - } catch (_) {} - body = null; - } - } - if (body) { - if (/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) { - try { - w.__lastPeUrl = url; - } catch (_) {} - } - return new w.Response(patchPeBundle(Buffer.from(body), url), { - status: 200, - statusText: "OK", - headers: { "content-type": sniffMime(url) } - }); - } - } - try { - const init = { method: request.method, headers: {} }; - request.headers.forEach((value, key) => { - init.headers[key] = value; - }); - const bs = new URL(url); - const cookie = cookieHeader(request, w, global.__browserFrame); - if (cookie) - init.headers.cookie = cookie; - let hasBody = false; - try { - if (request.body) { - const ab = await request.arrayBuffer(); - if (ab && ab.byteLength > 0) { - init.body = ab; - hasBody = true; - } - } - } catch (_) {} - const res = await fetch(url, init); - const buf = Buffer.from(await res.arrayBuffer()); - storeSetCookies(res, url); - if (_DEBUG && /captcha-open|verify\.|device\.saf|cloudauth-device|upload\./i.test(url) && buf.length && buf.length < 4096) { - try { - process.stderr.write(`[xhr-body] ${request.method} ${bs.hostname}${bs.pathname}-> ${res.status} ${buf.toString("utf8").slice(0, 1200)} -`); - } catch (_) {} - } - const headers = {}; - const ct = res.headers.get("content-type"); - if (ct) - headers["content-type"] = ct; - const logHost = bs.hostname; - if (_DEBUG) - process.stderr.write(`[xhr] ${request.method} ${logHost}${bs.pathname} -> ${res.status} (${buf.length}b) -`); - return new w.Response(buf, { - status: res.status, - statusText: res.statusText || "", - headers - }); - } catch (err) { - if (_DEBUG) - process.stderr.write(`[xhr-err] ${url}: ${err.message} -`); - return new w.Response("", { status: 503, statusText: "passthrough failed" }); - } - }, - beforeSyncRequest({ request, window: w }) { - const url = request.url; - noteRequest({ at: Date.now(), method: request.method, url, sync: true }); - injectRequestHeaders(request); - let body = null; - if (/\balicdn\.com/i.test(url)) { - body = skipPeCache(url) ? null : getCachedBody(url); - if (body && /\.js(\?|$)/i.test(url)) { - try { - new Function(body.toString("utf8")); - } catch (parseErr) { - process.stderr.write(`[cache-bad-js:sync] ${url} len=${body.length} ${parseErr.message} \u2014 refetch fresh -`); - _memCdnCache.delete(url); - try { - fs.unlinkSync(diskPathFor(url)); - } catch (_) {} - body = null; - } - } - } - if (body) { - if (/dynamicJS\/[^/]*\/pe\.\d+\./.test(url)) { - try { - w.__lastPeUrl = url; - } catch (_) {} - } - return { - status: 200, - statusText: "OK", - ok: true, - url, - redirected: false, - headers: new w.Headers({ "content-type": sniffMime(url) }), - body: patchPeBundle(Buffer.from(body), url), - [virtualServerFile]: null - }; - } - const init = { method: request.method, headers: {} }; - request.headers.forEach((value, key) => { - init.headers[key] = value; - }); - const cookie = cookieHeader(request, w, global.__browserFrame); - if (cookie) - init.headers.cookie = cookie; - try { - if (request.body) { - const ab = request.body; - if (ab && ab.byteLength > 0) - init.body = ab; - } - } catch (_) {} - const res = syncFetchBlocking(url, init); - if (res.error) { - process.stderr.write(`[sync-xhr-err] ${url}: ${res.error} -`); - return new w.Response("", { status: 503, statusText: "sync fetch failed" }); - } - try { - for (const raw of res.setCookie || []) { - const cookieContainer = global.__cookieContainer; - if (!cookieContainer) - break; - const u = new URL(url); - const parts = raw.split(";"); - const pair = parts[0].split("="); - const cookie = { - name: pair[0].trim(), - value: pair.slice(1).join("=").trim(), - url: u.origin, - domain: u.hostname, - path: "/" - }; - for (const p of parts.slice(1)) { - const kv = p.trim().split(/=(.*)/s); - const k = (kv[0] || "").toLowerCase(); - if (k === "domain" && kv[1]) - cookie.domain = kv[1]; - if (k === "path" && kv[1]) - cookie.path = kv[1]; - if (k === "expires") - cookie.expires = new Date(kv[1]).getTime(); - if (k === "max-age") - cookie.maxAge = parseInt(kv[1], 10); - if (k === "httponly") - cookie.httpOnly = true; - if (k === "secure") - cookie.secure = true; - if (k === "samesite") - cookie.sameSite = kv[1]; - } - try { - cookieContainer.addCookies([cookie]); - } catch (_) {} - } - } catch (_) {} - const hdrs = {}; - for (const [k, v] of Object.entries(res.headers || {})) - hdrs[k] = String(v); - return { - status: res.status, - statusText: res.statusText || "", - ok: res.status >= 200 && res.status < 300, - url, - redirected: false, - headers: new w.Headers(hdrs), - body: Buffer.from(res.body), - [virtualServerFile]: null - }; - } - }; -} -var GUEST_TIMER_PROPS = ["setTimeout", "setInterval", "clearTimeout", "clearInterval"]; -var GUEST_SCOPE_ROOT = "__capGuestScopes"; -var _guestScopeSeq = 0; -function installGuestScope(w) { - const root = globalThis[GUEST_SCOPE_ROOT] ??= Object.create(null); - const id = `w${++_guestScopeSeq}`; - const scope = Object.create(null); - for (const name of GUEST_TIMER_PROPS) { - const fn = w[name]; - scope[name] = typeof fn === "function" ? fn.bind(w) : fn; - } - scope.Function = makeScopedFunction(w); - if (!_DEBUG && w.console) - scope.console = w.console; - root[id] = scope; - w.__capScopeId = id; - return id; -} -function removeGuestScope(w) { - try { - const id = w && w.__capScopeId; - const root = globalThis[GUEST_SCOPE_ROOT]; - if (id && root) - delete root[id]; - } catch {} -} -function makeScopedFunction(w) { - const Scoped = function(...args) { - const body = args.length ? String(args[args.length - 1]) : ""; - const params = args.slice(0, -1).map(String).join(","); - const id = w.__capScopeId; - const source = `return function(${params}){with(globalThis.${GUEST_SCOPE_ROOT}[${JSON.stringify(id)}]){ -${body} -}}`; - return Function(source)(); - }; - Scoped.prototype = Function.prototype; - try { - Object.defineProperty(Scoped, "name", { value: "Function", configurable: true }); - Object.defineProperty(Scoped, "toString", { - value: () => "function Function() { [native code] }", - configurable: true, - writable: true - }); - } catch {} - return Scoped; -} -function wrapGuestSource(code, filename, scopeId) { - const sourceUrl = filename && /^https?:/.test(String(filename)) ? ` -//# sourceURL=${filename}` : ""; - const scopeRef = `globalThis.${GUEST_SCOPE_ROOT}[${JSON.stringify(scopeId)}]`; - return `with(${scopeRef}){ -${code} -}${sourceUrl}`; -} -function installEvalInstrumentation(w) { - const sym = exports_PropertySymbol && evaluateScript; - if (!sym || typeof w[sym] !== "function") { - process.stderr.write(`[instr] no evaluateScript symbol, host hook skipped -`); - return; - } - const orig = w[sym]; - w[sym] = function(code, options) { - const scopeId = w.__capScopeId; - try { - if (scopeId) { - try { - return orig.call(this, wrapGuestSource(String(code ?? ""), options && options.filename, scopeId), options); - } catch (scopeErr) { - if (!(scopeErr instanceof SyntaxError)) - throw scopeErr; - process.stderr.write(`[instr] guest scope rejected (${scopeErr.message.slice(0, 80)}), evaluating unwrapped -`); - } - } - return orig.call(this, code, options); - } catch (err) { - try { - const src = String(code || ""); - const filename = options && options.filename || "?"; - const sha1 = crypto.createHash("sha1").update(src).digest("hex"); - process.stderr.write(` -[EVAL-PARSE-FAIL] file=${filename} len=${src.length} sha1=${sha1} -` + ` head300: ${JSON.stringify(src.slice(0, 300))} -` + ` tail100: ${JSON.stringify(src.slice(-100))} -` + ` err: ${err && err.message} -`); - if (/^https?:/.test(filename)) { - (async () => { - try { - const res = await fetch(filename, { headers: { "user-agent": fp.userAgent } }); - const fresh = Buffer.from(await res.arrayBuffer()); - process.stderr.write(`[EVAL-CACHE-COMPARE] cachedLen=${src.length} freshLen=${fresh.length} freshSha1=${crypto.createHash("sha1").update(fresh).digest("hex")} http=${res.status} -`); - if (fresh.length > 0 && fresh.length !== src.length) { - process.stderr.write(`[EVAL-CACHE-MISMATCH] deleting ${diskPathFor(filename)} (stale/truncated cache) -`); - try { - fs.unlinkSync(diskPathFor(filename)); - } catch (_) {} - _memCdnCache.delete(filename); - } - } catch (fetchErr) { - process.stderr.write(`[EVAL-CACHE-COMPARE-ERR] ${fetchErr.message} -`); - } - })(); - } - } catch (e2) {} - throw err; - } - }; -} -function installNativeToString(w) { - const realToString = Function.prototype.toString; - const nativeRe = /\[native code\]/; - const mask = (fn) => { - if (typeof fn !== "function") - return; - try { - if (nativeRe.test(realToString.call(fn))) - return; - const name = fn.name || ""; - const nativeStr = `function ${name}() { [native code] }`; - Object.defineProperty(fn, "toString", { - value: () => nativeStr, - configurable: true, - writable: true - }); - } catch (_) {} - }; - const seen = new w.Set; - const maskObj = (obj, depth) => { - if (!obj || typeof obj !== "object" && typeof obj !== "function" || depth > 5) - return; - try { - if (obj.constructor && obj.constructor.prototype !== Object.prototype) { - const ctorName = obj.constructor.name; - if (/^(WriteStream|ReadStream|Socket|Process|Timeout|Immediate)$/.test(ctorName)) - return; - } - } catch (_) {} - if (seen.has(obj)) - return; - try { - seen.add(obj); - } catch (_) { - return; - } - let names = []; - try { - names = Object.getOwnPropertyNames(obj); - } catch (_) { - return; - } - for (const name of names) { - if (name === "toString" || name === "constructor") - continue; - let desc; - try { - desc = Object.getOwnPropertyDescriptor(obj, name); - } catch (_) { - continue; - } - if (!desc) - continue; - if (typeof desc.value === "function") { - mask(desc.value); - } else if (typeof desc.get === "function") { - mask(desc.get); - try { - const v = desc.get.call(obj); - if (typeof v === "function") - mask(v); - else if (v && typeof v.then === "function") - v.catch(() => {}); - } catch {} - } - if (depth < 3) { - try { - const v = desc.value; - if (v && (typeof v === "function" || typeof v === "object")) - maskObj(v, depth + 1); - } catch (_) {} - } - } - }; - const targets = [ - w, - w.navigator, - w.document, - w.Document && w.Document.prototype, - w.Element && w.Element.prototype, - w.HTMLElement && w.HTMLElement.prototype, - w.Node && w.Node.prototype, - w.EventTarget && w.EventTarget.prototype, - w.HTMLCanvasElement && w.HTMLCanvasElement.prototype, - w.XMLHttpRequest && w.XMLHttpRequest.prototype, - w.Event && w.Event.prototype, - w.Window && w.Window.prototype - ].filter(Boolean); - for (const t of targets) { - try { - maskObj(t, 0); - } catch (_) {} - } -} -var GUEST_EVAL_PATCH = ` -(function() { - try { - Object.defineProperty(Event.prototype, "isTrusted", { - get() { return true; }, - configurable: true - }); - } catch (e) {} - try { - if (window.HTMLDocument) { - Object.defineProperty(window.HTMLDocument, "name", { value: "HTMLDocument", configurable: true }); - Object.defineProperty(window.HTMLDocument.prototype, Symbol.toStringTag, { value: "HTMLDocument", configurable: true }); - } - } catch (e) {} - try { - Object.defineProperty(window.Document.prototype, Symbol.toStringTag, { value: "HTMLDocument", configurable: true }); - } catch (e) {} - // Guest errors are RECORDED, not printed: the Aliyun/FeiLin SDKs throw - // benign uncaught TypeErrors inside happy-dom on every solve (imperfect DOM - // emulation) while the solve still succeeds \u2014 printing them flooded the - // console with [WINDOW-ERROR] spam. They land in window.__capErrs (capped, - // deduped) which solveTraceless surfaces only when a solve FAILS. - // CAPTCHA_DEBUG=1 streams them live again. - var __capDebug = ${_DEBUG ? "true" : "false"}; - function __capRecord(kind, msg, stack) { - try { - var m = String(msg || "?"); - var s = String(stack || "").split("\\n").slice(0, 2).join(" | "); - if (!window.__capErrs) window.__capErrs = []; - var last = window.__capErrs[window.__capErrs.length - 1]; - if (last && last.k === kind && last.m === m) { - last.n = (last.n || 1) + 1; - } else { - window.__capErrs.push({ k: kind, m: m, s: s, n: 1 }); - if (window.__capErrs.length > 8) window.__capErrs.shift(); - } - if (__capDebug) console.error("[" + kind + "]", m, s); - } catch (e2) {} - } - try { - window.addEventListener("unhandledrejection", function(e) { - var r = e && e.reason; - __capRecord("UH-REASON", (r && r.message) || typeof r, r && r.stack); - }); - } catch (e) {} - try { - window.addEventListener("error", function(e) { - __capRecord("WINDOW-ERROR", e && e.message, e && e.error && e.error.stack); - }); - } catch (e) {} - // ---- eval/Function parse-fail instrumentation (installed before pe chain) ---- - // Catches SyntaxError from guest-side eval()/new Function() (the dynamic pe.* - // chunk is evaluated this way in some SDK paths). Host-side twin: the - // PropertySymbol.evaluateScript wrapper in installEvalInstrumentation(). - function __capFailDump(kind, code) { - try { - var src = String(code || ""); - if (typeof window.__capDebugDump === "function") { - window.__capDebugDump(window.__lastPeUrl || "?", src, kind); - } else { - console.error("[" + kind + "] url=" + (window.__lastPeUrl || "?") + " len=" + src.length + " head=" + JSON.stringify(src.slice(0, 300)) + " tail=" + JSON.stringify(src.slice(-100))); - } - } catch (e2) {} - } - try { - var _origEval2 = window.eval; - if (_origEval2) { - window.eval = function(code) { - try { return _origEval2.call(window, code); } - catch (e) { - if (e && (/unexpected|invalid|parse|syntax/i.test(String((e && e.message) || e)))) { - __capFailDump("REALM-EVAL-FAIL", code); - } - throw e; - } - }; - } - } catch (e) {} - try { - var _of = window.Function; - if (_of) { - var _WF = function() { - var args = Array.prototype.slice.call(arguments); - var body = args.length ? String(args[args.length - 1]) : ""; - try { return _of.apply(this, args); } - catch (e) { - if (e && (/unexpected|invalid|parse|syntax/i.test(String((e && e.message) || e)))) { - __capFailDump("REALM-FN-FAIL", body); - } - throw e; - } - }; - _WF.prototype = _of.prototype; - try { Object.defineProperty(_WF, "name", { value: "Function", configurable: true }); } catch (e) {} - window.Function = _WF; - } - } catch (e) {} -})(); -`; -function applyPolyfills(w) { - if (process.env.CAPTCHA_DEBUG_BODIES === "1") { - installTrafficLogger(w); - } - if (typeof w.Option !== "function") { - w.Option = class Option extends w.HTMLOptionElement { - constructor(text, value, defaultSelected, selected) { - super(); - if (text !== undefined) { - const el = w.document.createElement("option"); - el.text = text; - if (value !== undefined) - el.value = value; - if (defaultSelected) - el.defaultSelected = true; - if (selected) - el.selected = true; - return el; - } - } - }; - } - if (typeof w.Video !== "function" && w.HTMLVideoElement) { - w.Video = class Video extends w.HTMLVideoElement { - constructor() { - return w.document.createElement("video"); - } - }; - } - if (typeof w.alert !== "function") - w.alert = () => {}; - if (typeof w.prompt !== "function") - w.prompt = () => null; - if (typeof w.confirm !== "function") - w.confirm = () => false; - if (typeof w.open !== "function") - w.open = () => null; - if (typeof w.close !== "function") - w.close = () => {}; - try { - Object.defineProperty(w, "alert", { value: w.alert, configurable: true, writable: true }); - } catch (_) {} - try { - Object.defineProperty(w, "prompt", { value: w.prompt, configurable: true, writable: true }); - } catch (_) {} - try { - Object.defineProperty(w, "confirm", { value: w.confirm, configurable: true, writable: true }); - } catch (_) {} - try { - Object.defineProperty(w, "open", { value: w.open, configurable: true, writable: true }); - } catch (_) {} - try { - Object.defineProperty(w, "close", { value: w.close, configurable: true, writable: true }); - } catch (_) {} - const extraGlobals = { - print: () => {}, - stop: () => {}, - moveTo: () => {}, - moveBy: () => {}, - showModalDialog: () => null, - find: () => false - }; - for (const [k, v] of Object.entries(extraGlobals)) { - try { - Object.defineProperty(w, k, { value: v, configurable: true, writable: true }); - } catch (_) {} - } - try { - Object.defineProperty(w, "open", { value: () => null, configurable: true, writable: true }); - } catch (_) {} - try { - Object.defineProperty(w, "close", { value: () => {}, configurable: true, writable: true }); - } catch (_) {} - if (!w.Option) { - w.Option = class { - constructor(text, value, defaultSelected, selected) { - this.text = text ?? ""; - this.value = value ?? ""; - this.selected = selected ?? defaultSelected ?? false; - this.defaultSelected = !!defaultSelected; - this.disabled = false; - this.label = this.text; - this.index = 0; - } - }; - } - if (!w.EventSource) { - w.EventSource = class { - constructor() { - this.readyState = 2; - this.onopen = null; - this.onmessage = null; - this.onerror = null; - } - close() { - this.readyState = 2; - } - addEventListener() {} - removeEventListener() {} - }; - } - if (!w.Beacon) - w.Beacon = class { - }; - if (!w.RTCPeerConnection) { - w.RTCPeerConnection = class { - constructor() {} - createDataChannel() { - return {}; - } - close() {} - createOffer() { - return Promise.resolve({}); - } - setLocalDescription() { - return Promise.resolve(); - } - addEventListener() {} - removeEventListener() {} - }; - } - if (!w.MessageChannel) { - w.MessageChannel = class { - constructor() { - this.port1 = { onmessage: null, postMessage() {}, start() {}, close() {}, addEventListener() {}, removeEventListener() {} }; - this.port2 = { onmessage: null, postMessage() {}, start() {}, close() {}, addEventListener() {}, removeEventListener() {} }; - } - }; - } - w.IntersectionObserver = w.IntersectionObserver || class { - constructor(cb) { - this.cb = cb; - } - observe() {} - unobserve() {} - disconnect() {} - takeRecords() { - return []; - } - }; - w.ResizeObserver = w.ResizeObserver || class { - observe() {} - unobserve() {} - disconnect() {} - }; - w.DeviceOrientationEvent = w.DeviceOrientationEvent || class extends w.Event { - constructor(type, opts) { - super(type, opts); - } - alpha = null; - beta = null; - gamma = null; - absolute = false; - }; - w.DeviceMotionEvent = w.DeviceMotionEvent || class extends w.Event { - constructor(type, opts) { - super(type, opts); - } - acceleration = null; - accelerationIncludingGravity = null; - rotationRate = null; - interval = 16; - }; - w.requestIdleCallback = w.requestIdleCallback || ((cb) => w.setTimeout(() => cb({ didTimeout: false, timeRemaining: () => 10 }), 1)); - w.cancelIdleCallback = w.cancelIdleCallback || ((id) => w.clearTimeout(id)); - w.matchMedia = w.matchMedia || (() => ({ - matches: false, - media: "", - onchange: null, - addListener() {}, - removeListener() {}, - addEventListener() {}, - removeEventListener() {}, - dispatchEvent() { - return false; - } - })); - if (!w.visualViewport) { - const VisualViewport = function() {}; - VisualViewport.prototype = { - width: fp.screen.w - 16, - height: fp.screen.h - 120, - scale: 1, - offsetLeft: 0, - offsetTop: 0, - pageLeft: 0, - pageTop: 0, - onresize: null, - onscroll: null, - onscrollend: null - }; - w.VisualViewport = VisualViewport; - w.visualViewport = Object.create(w.VisualViewport.prototype); - } - if (!w.indexedDB) { - const IDBFactory = function() {}; - IDBFactory.prototype = { - open: () => ({ onupgradeneeded: null, onsuccess: null, onerror: null }), - deleteDatabase: () => ({}), - databases: () => Promise.resolve([]) - }; - w.IDBFactory = IDBFactory; - w.indexedDB = Object.create(w.IDBFactory.prototype); - } - if (!w.speechSynthesis) { - const SpeechSynthesis = function() {}; - SpeechSynthesis.prototype = { - speak() {}, - cancel() {}, - pause() {}, - resume() {}, - getVoices: () => [] - }; - w.SpeechSynthesis = SpeechSynthesis; - w.speechSynthesis = Object.create(w.SpeechSynthesis.prototype); - w.SpeechSynthesisUtterance = function() {}; - } - w.Worker = w.Worker || class { - postMessage() {} - terminate() {} - addEventListener() {} - removeEventListener() {} - }; - w.Notification = w.Notification || class { - static permission = "default"; - static requestPermission() { - return Promise.resolve("default"); - } - close() {} - }; - const proto = w.HTMLCanvasElement.prototype; - const nativeGetContext = typeof proto.getContext === "function" ? proto.getContext : null; - proto.getContext = function(type, ...rest) { - if (/webgl/i.test(type)) { - return makeWebGLMock(this); - } - if (nativeGetContext) { - try { - const ctx = nativeGetContext.call(this, type, ...rest); - if (ctx) - return ctx; - } catch (_) {} - } - return make2DStub(this); - }; - function makeWebGLMock(canvas) { - return { - canvas, - getParameter(p) { - if (p === 7936) - return "WebKit"; - if (p === 7937) - return "WebKit WebGL"; - if (p === 7938) - return "WebGL 1.0 (OpenGL ES 2.0 Chromium)"; - if (p === 35724) - return "WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)"; - if (p === 37445) - return fp.webglUnmaskedVendor; - if (p === 37446) - return fp.webglUnmaskedRenderer; - return "Intel Inc."; - }, - getExtension(name) { - if (name === "WEBGL_debug_renderer_info") { - return { UNMASKED_VENDOR_WEBGL: 37445, UNMASKED_RENDERER_WEBGL: 37446 }; - } - return null; - }, - getSupportedExtensions() { - return [ - "ANGLE_instanced_arrays", - "EXT_blend_minmax", - "EXT_color_buffer_half_float", - "EXT_disjoint_timer_query", - "EXT_float_blend", - "EXT_frag_depth", - "EXT_shader_texture_lod", - "EXT_texture_compression_bptc", - "EXT_texture_compression_rgtc", - "EXT_texture_filter_anisotropic", - "EXT_sRGB", - "KHR_parallel_shader_compile", - "OES_element_index_uint", - "OES_fbo_render_mipmap", - "OES_standard_derivatives", - "OES_texture_float", - "OES_texture_float_linear", - "OES_texture_half_float", - "OES_texture_half_float_linear", - "OES_vertex_array_object", - "WEBGL_color_buffer_float", - "WEBGL_compressed_texture_astc", - "WEBGL_compressed_texture_etc", - "WEBGL_compressed_texture_etc1", - "WEBGL_compressed_texture_s3tc", - "WEBGL_compressed_texture_s3tc_srgb", - "WEBGL_debug_renderer_info", - "WEBGL_debug_shaders", - "WEBGL_depth_texture", - "WEBGL_draw_buffers", - "WEBGL_lose_context", - "WEBGL_multi_draw" - ]; - }, - getContextAttributes() { - return { - alpha: true, - antialias: true, - depth: true, - failIfMajorPerformanceCaveat: false, - powerPreference: "default", - premultipliedAlpha: true, - preserveDrawingBuffer: false, - stencil: false, - desynchronized: false - }; - }, - getShaderPrecisionFormat() { - return { precision: 23, rangeMin: 127, rangeMax: 127 }; - } - }; - } - function make2DStub(canvas) { - return { - canvas, - fillRect() {}, - clearRect() {}, - getImageData: (_x, _y, w2 = 1, h2 = 1) => new w.ImageData(w2, h2), - putImageData() {}, - createImageData: (w2 = 1, h2 = 1) => new w.ImageData(w2, h2), - setTransform() {}, - transform() {}, - drawImage() {}, - save() {}, - restore() {}, - beginPath() {}, - moveTo() {}, - lineTo() {}, - bezierCurveTo() {}, - quadraticCurveTo() {}, - closePath() {}, - clip() {}, - stroke() {}, - fill() {}, - arc() {}, - rect() {}, - ellipse() {}, - translate() {}, - scale() {}, - rotate() {}, - fillText() {}, - strokeText() {}, - measureText: (t) => ({ width: String(t).length * 8 }), - createLinearGradient: () => ({ addColorStop() {} }), - createRadialGradient: () => ({ addColorStop() {} }), - createPattern: () => ({}), - isPointInPath: () => false, - font: "10px sans-serif", - textBaseline: "alphabetic", - textAlign: "start", - fillStyle: "#000", - strokeStyle: "#000", - globalAlpha: 1, - lineWidth: 1, - shadowBlur: 0, - shadowColor: "" - }; - } - const nativeToDataURL = typeof proto.toDataURL === "function" ? proto.toDataURL : null; - proto.toDataURL = function(...a) { - try { - if (nativeToDataURL) - return nativeToDataURL.apply(this, a); - } catch (_) {} - return fp.canvasImage; - }; - if (typeof proto.toBlob !== "function") { - proto.toBlob = (cb) => cb && cb(new w.Blob); - } - w.OffscreenCanvas = w.OffscreenCanvas || class { - constructor(width, height) { - this.width = width; - this.height = height; - } - getContext() { - return proto.getContext.call(this); - } - }; - const audioMock = class { - constructor() { - this.sampleRate = 44100; - this.currentTime = 0; - this.state = "suspended"; - } - createOscillator() { - return { - type: "sine", - frequency: { value: 440, setValueAtTime() {} }, - connect() {}, - start() {}, - stop() {} - }; - } - createDynamicsCompressor() { - return { - threshold: { value: -24, setValueAtTime() {} }, - knee: { value: 30, setValueAtTime() {} }, - ratio: { value: 12, setValueAtTime() {} }, - attack: { value: 0.003, setValueAtTime() {} }, - release: { value: 0.25, setValueAtTime() {} }, - connect() {} - }; - } - createAnalyser() { - return { - fftSize: 2048, - frequencyBinCount: 1024, - getByteFrequencyData() {}, - getByteTimeDomainData() {}, - connect() {} - }; - } - createGain() { - return { gain: { value: 1 }, connect() {} }; - } - destination = {}; - resume() { - this.state = "running"; - return Promise.resolve(); - } - close() { - this.state = "closed"; - return Promise.resolve(); - } - }; - w.AudioContext = w.AudioContext || audioMock; - w.OfflineAudioContext = w.OfflineAudioContext || class extends audioMock { - constructor(_channels, length, sampleRate) { - super(); - this.length = length; - this.sampleRate = sampleRate; - } - startRendering() { - const len = this.length || 44100; - const sr = this.sampleRate || 44100; - const buf = new Float32Array(len); - for (let i = 0;i < len; i += 1) { - const t = i / sr; - buf[i] = Math.sin(2 * Math.PI * 1000 * t) * Math.exp(-t * 1.2) * 0.6 + Math.sin(2 * Math.PI * 3000 * t) * Math.exp(-t * 1.5) * 0.25 + Math.sin(2 * Math.PI * 5000 * t) * Math.exp(-t * 2) * 0.12; - } - return Promise.resolve({ - numberOfChannels: 1, - length: len, - sampleRate: sr, - getChannelData: () => buf - }); - } - }; - w.requestAnimationFrame = w.requestAnimationFrame || ((cb) => w.setTimeout(() => cb(Date.now()), 16)); - w.cancelAnimationFrame = w.cancelAnimationFrame || ((id) => w.clearTimeout(id)); - try { - Object.defineProperty(w.document, "hidden", { value: false, configurable: true }); - Object.defineProperty(w.document, "visibilityState", { - value: "visible", - configurable: true - }); - } catch (_) {} - if (!w.document.fonts) { - w.document.fonts = { - ready: Promise.resolve(), - check: () => true, - addEventListener() {}, - removeEventListener() {} - }; - } - if (!w.chrome) { - w.chrome = { - app: { - isInstalled: false, - InstallState: { DISABLED: "disabled", INSTALLED: "installed", NOT_INSTALLED: "not_installed" }, - RunningState: { CANNOT_RUN: "cannot_run", CAN_RUN: "can_run", RUNNING: "running" }, - getDetails() { - return null; - }, - getIsInstalled() { - return false; - }, - installState(cb) { - if (cb) - cb("not_installed"); - }, - runningState(cb) { - if (cb) - cb("cannot_run"); - } - }, - csi() { - const now = Date.now(); - return { startE: now - 100, onloadT: now, pageT: 100, tran: 15 }; - }, - loadTimes() { - const now = Date.now() / 1000; - return { - requestTime: now - 0.1, - startLoadTime: now - 0.1, - commitLoadTime: now - 0.05, - finishDocumentLoadTime: now, - finishLoadTime: now, - firstPaintTime: now - 0.02, - firstPaintAfterLoadTime: 0, - navigationType: "Other", - wasFetchedViaSpdy: true, - wasNpnNegotiated: true, - npnNegotiatedProtocol: "h2", - wasAlternateProtocolAvailable: false, - connectionInfo: "h2" - }; - } - }; - } - const nav = w.navigator; - const plugins = createNavigatorPlugins(w); - const navPatch = { - userAgent: fp.userAgent, - platform: fp.platform, - language: "en-US", - languages: ["en-US", "en"], - vendor: "Google Inc.", - webdriver: false, - hardwareConcurrency: 12, - deviceMemory: 8, - maxTouchPoints: 0, - cookieEnabled: true, - plugins: plugins.plugins, - mimeTypes: plugins.mimeTypes, - appVersion: fp.userAgent.replace(/^Mozilla\//, ""), - appName: "Netscape", - appCodeName: "Mozilla", - product: "Gecko", - productSub: "20030107", - vendorSub: "", - oscpu: undefined, - doNotTrack: null, - sendBeacon: (url, data) => { - try { - const xhr = new w.XMLHttpRequest; - xhr.open("POST", url, true); - xhr.send(data); - return true; - } catch (_) { - return false; - } - } - }; - for (const [k, v] of Object.entries(navPatch)) { - try { - Object.defineProperty(nav, k, { value: v, configurable: true }); - } catch (_) {} - } - const makeNS = (protoObj) => { - const C = new w.Function; - C.prototype = protoObj; - return new C; - }; - if (!nav.connection) { - const NetInfo = () => {}; - NetInfo.prototype = { onchange: null, effectiveType: "4g", rtt: 50, downlink: 10, saveData: false }; - w.NetworkInformation = NetInfo; - try { - Object.defineProperty(nav, "connection", { value: makeNS(NetInfo.prototype), configurable: true }); - } catch (_) {} - } - if (!nav.userAgentData) { - const UAData = function() {}; - UAData.prototype = { - brands: [ - { brand: "Chromium", version: fp.uaMajor }, - { brand: "Not)A;Brand", version: "24" } - ], - mobile: false, - platform: "Linux", - getHighEntropyValues: () => Promise.resolve({ - brands: [ - { brand: "Chromium", version: fp.uaMajor }, - { brand: "Not)A;Brand", version: "24" } - ], - mobile: false, - platform: "Linux", - platformVersion: "6.5.0", - architecture: "x86", - model: "", - uaFullVersion: fp.uaFull, - fullVersionList: [ - { brand: "Chromium", version: fp.uaFull }, - { brand: "Not)A;Brand", version: "24.0.0.0" } - ] - }) - }; - try { - Object.defineProperty(nav, "userAgentData", { value: makeNS(UAData.prototype), configurable: true }); - } catch (_) {} - } - if (!w.Permissions) { - const Perms = () => {}; - Perms.prototype = { - query: (param) => Promise.resolve({ state: param.name === "notifications" ? "prompt" : "granted", onchange: null }) - }; - w.Permissions = Perms; - } - try { - if (!nav.permissions) - Object.defineProperty(nav, "permissions", { value: makeNS(w.Permissions.prototype), configurable: true }); - } catch (_) {} - try { - if (!nav.clipboard) - Object.defineProperty(nav, "clipboard", { - value: makeNS({ readText: () => Promise.resolve(""), writeText: () => Promise.resolve() }), - configurable: true - }); - } catch (_) {} - try { - if (!nav.geolocation) - Object.defineProperty(nav, "geolocation", { - value: makeNS({ - getCurrentPosition: (s) => s && s({ coords: { latitude: 0, longitude: 0, accuracy: 1 } }), - watchPosition: () => 1, - clearWatch: () => {} - }), - configurable: true - }); - } catch (_) {} - try { - if (!nav.credentials) - Object.defineProperty(nav, "credentials", { - value: makeNS({ get: () => Promise.resolve(null), create: () => Promise.resolve(null), store: () => Promise.resolve(), preventSilentAccess: () => Promise.resolve() }), - configurable: true - }); - } catch (_) {} - try { - if (!nav.storage) - Object.defineProperty(nav, "storage", { - value: makeNS({ estimate: () => Promise.resolve({ quota: 1e8, usage: 0 }), persisted: () => Promise.resolve(false), persist: () => Promise.resolve(false) }), - configurable: true - }); - } catch (_) {} - try { - if (!nav.usb) - Object.defineProperty(nav, "usb", { - value: makeNS({ getDevices: () => Promise.resolve([]), requestDevice: () => Promise.reject(new Error("no devices")) }), - configurable: true - }); - } catch (_) {} - try { - if (!nav.mediaDevices) - Object.defineProperty(nav, "mediaDevices", { - value: makeNS({ enumerateDevices: () => Promise.resolve([]), getUserMedia: () => Promise.reject(new Error("NotAllowedError")) }), - configurable: true - }); - } catch (_) {} - const screenPatch = { - width: fp.screen.w, - height: fp.screen.h, - availWidth: fp.screen.w, - availHeight: fp.screen.ah, - availLeft: 0, - availTop: 0, - colorDepth: 24, - pixelDepth: 24, - orientation: { angle: 0, type: "landscape-primary", onchange: null } - }; - for (const [k, v] of Object.entries(screenPatch)) { - try { - Object.defineProperty(w.screen, k, { get: () => v, configurable: true }); - } catch (_) {} - } - w.outerWidth = fp.screen.w; - w.outerHeight = fp.screen.h - 40; - w.innerWidth = fp.screen.w - 16; - w.innerHeight = fp.screen.h - 120; - w.devicePixelRatio = 1; -} -function createNavigatorPlugins(w) { - const indexed = [ - { name: "PDF Viewer", filename: "internal-pdf-viewer", description: "Portable Document Format" }, - { name: "Chrome PDF Viewer", filename: "mhjfbmdgcfjbbpaeojofohoefgiehjai", description: "" }, - { name: "Chromium PDF Viewer", filename: "mhjfbmdgcfjbbpaeojofohoefgiehjai", description: "" } - ]; - const plugins = w.PluginArray ? Object.create(w.PluginArray.prototype) : {}; - const mockIndexed = []; - for (let i = 0;i < indexed.length; i++) { - const p = Object.create(w.Plugin && w.Plugin.prototype || Object.prototype); - Object.defineProperty(p, "name", { value: indexed[i].name, configurable: true, enumerable: true }); - Object.defineProperty(p, "filename", { value: indexed[i].filename, configurable: true, enumerable: true }); - Object.defineProperty(p, "description", { value: indexed[i].description, configurable: true, enumerable: true }); - Object.defineProperty(p, "length", { value: 1, configurable: true, enumerable: true }); - Object.defineProperty(p, "0", { value: p, configurable: true, enumerable: true }); - p.item = () => p; - p.namedItem = () => p; - plugins[i] = p; - mockIndexed.push(p); - } - Object.defineProperty(plugins, "length", { value: indexed.length, configurable: true, enumerable: true }); - plugins.item = (i) => plugins[i] ?? null; - plugins.namedItem = (name) => mockIndexed.find((p) => p.name === name) ?? null; - plugins.refresh = () => {}; - const mimeTypes = w.MimeTypeArray ? Object.create(w.MimeTypeArray.prototype) : {}; - Object.defineProperty(mimeTypes, "length", { value: 0, configurable: true, enumerable: true }); - mimeTypes.item = () => null; - mimeTypes.namedItem = () => null; - return { plugins, mimeTypes }; -} -function installTrafficLogger(w) { - const origOpen = w.XMLHttpRequest.prototype.open; - const origSend = w.XMLHttpRequest.prototype.send; - w.XMLHttpRequest.prototype.open = function(method, url, ...rest) { - this.__capMethod = method; - this.__capUrl = url; - return origOpen.call(this, method, url, ...rest); - }; - w.XMLHttpRequest.prototype.send = function(body) { - const url = String(this.__capUrl || ""); - const DEBUG_HOSTS = /(cloudauth-device|captcha-open|verify|upload|nocaptcha|aliyuncs)/i; - if (DEBUG_HOSTS.test(url)) { - this.addEventListener("load", () => { - let respPreview = ""; - try { - respPreview = String(this.responseText || "").slice(0, 3000); - } catch (_) {} - try { - process.stderr.write(` -===== XHR ${String(this.__capMethod || "?")} ${url} ---- RESP (${respPreview.length}b) --- -${respPreview} -===== -`); - } catch (_) {} - }); - } - return origSend.call(this, body); - }; -} -function safeJson(x) { - try { - if (x instanceof Error) - return `Error: ${x.message} -${(x.stack || "").slice(0, 1500)}`; - const s = JSON.stringify(x); - return s !== undefined && s.length < 3000 ? s : String(x); - } catch (_) { - return String(x); - } -} -function simulateBehavior(w, durationMs = 600) { - const { document, MouseEvent, KeyboardEvent, UIEvent } = w; - if (!document || !MouseEvent) - return; - const fire = (type, ctor, opts) => { - try { - const Ctor = ctor || UIEvent; - const ev = new Ctor(type, { bubbles: true, cancelable: true, view: w, ...opts }); - document.dispatchEvent(ev); - if (document.body) - document.body.dispatchEvent(ev); - } catch (_) {} - }; - let x = 140 + Math.random() * 30; - let y = 110 + Math.random() * 20; - const targetX = 540 + Math.random() * 40; - const targetY = 380 + Math.random() * 30; - const steps = 22; - let i = 0; - const start = Date.now(); - const moveStep = () => { - if (i > steps) - return; - x += (targetX - x) * 0.16 + (Math.random() - 0.5) * 5; - y += (targetY - y) * 0.16 + (Math.random() - 0.5) * 4; - fire("mousemove", MouseEvent, { - screenX: Math.round(x), - screenY: Math.round(y), - clientX: Math.round(x), - clientY: Math.round(y), - button: 0, - buttons: 1 - }); - i += 1; - const done = Date.now() - start >= durationMs; - if (i <= steps && !done) { - w.setTimeout(moveStep, 26 + Math.floor(Math.random() * 32)); - } else { - fire("mousedown", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0, buttons: 1 }); - fire("mouseup", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0, buttons: 0 }); - fire("click", MouseEvent, { clientX: Math.round(x), clientY: Math.round(y), button: 0 }); - try { - fire("keyup", KeyboardEvent, { key: "a", code: "KeyA", keyCode: 65, which: 65 }); - } catch (_) {} - } - }; - moveStep(); -} -function waitFor(cond, timeoutMs = 15000, intervalMs = 40) { - return new Promise((res, rej) => { - const started = Date.now(); - const timer = setInterval(() => { - let ok = false; - try { - ok = cond(); - } catch (_) {} - if (ok) { - clearInterval(timer); - res(); - } else if (Date.now() - started > timeoutMs) { - clearInterval(timer); - rej(new Error("timeout")); - } - }, intervalMs); - }); -} -async function createDom(region, prefix) { - let cookies = []; - const now = Date.now(); - if (_cookieCache.ts > 0 && now - _cookieCache.ts < COOKIE_CACHE_TTL_MS) { - cookies = _cookieCache.cookies; - } else { - try { - const res = await fetch("https://zcode.z.ai/", { - headers: { - "User-Agent": fp.userAgent, - "sec-ch-ua": '"Chromium";v="' + fp.uaMajor + '", "Not)A;Brand";v="24"', - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": '"Linux"', - "Accept-Language": "en-US,en;q=0.9" - } - }); - cookies = typeof res.headers.getSetCookie === "function" ? res.headers.getSetCookie() : []; - _cookieCache = { cookies, ts: Date.now() }; - } catch (_) {} - } - const interceptor = makeInterceptor(_bypassPeCacheOnce); - _bypassPeCacheOnce = false; - if (!process.__capUnhandledRejectionHooked) { - process.__capUnhandledRejectionHooked = true; - process.on("unhandledRejection", (reason) => { - if (!_DEBUG) - return; - try { - const r = reason && reason.stack ? reason.stack : String(reason); - process.stderr.write(`[host-unhandledRejection] ${typeof reason} ${JSON.stringify(reason).slice(0, 200)} ${r} -`); - } catch (_) {} - }); - process.on("uncaughtException", (err) => { - try { - const msg = err && err.message ? err.message : String(err); - process.stderr.write(`[captcha-guest-uncaught] ${msg} -`); - } catch (_) {} - }); - } - const noop = () => {}; - const guestConsole = _DEBUG ? { - log: (...a) => process.stderr.write(`[guest-log] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`), - warn: (...a) => process.stderr.write(`[guest-warn] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`), - error: (...a) => process.stderr.write(`[guest-err] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`), - info: (...a) => process.stderr.write(`[guest-info] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`), - debug: (...a) => process.stderr.write(`[guest-debug] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`), - trace: (...a) => process.stderr.write(`[guest-trace] ${a.map((x) => typeof x === "object" ? safeJson(x) : String(x)).join(" ")} -`) - } : { log: noop, warn: noop, error: noop, info: noop, debug: noop, trace: noop }; - const w = new GlobalWindow({ - url: "https://zcode.z.ai/", - console: guestConsole, - settings: { - enableJavaScriptEvaluation: true, - enableImageFileLoading: true, - suppressInsecureJavaScriptEnvironmentWarning: true, - navigator: { userAgent: fp.userAgent }, - viewport: { width: fp.screen.w, height: fp.screen.h, devicePixelRatio: 1 }, - fetch: { - disableSameOriginPolicy: true, - interceptor - } - } - }); - const browserFrame = new WindowBrowserContext(w).getBrowserFrame(); - global.__browserFrame = browserFrame; - global.__cookieContainer = browserFrame.page.context.cookieContainer; - for (const raw of cookies) { - try { - const u = new URL("https://zcode.z.ai/"); - const parts = raw.split(";"); - const pair = parts[0].split("="); - const cookie = { - name: pair[0].trim(), - value: pair.slice(1).join("=").trim(), - url: u.origin, - domain: u.hostname, - path: "/" - }; - for (const p of parts.slice(1)) { - const kv = p.trim().split(/=(.*)/s); - const k = (kv[0] || "").toLowerCase(); - if (k === "domain" && kv[1]) - cookie.domain = kv[1]; - if (k === "path" && kv[1]) - cookie.path = kv[1]; - if (k === "expires") - cookie.expires = new Date(kv[1]).getTime(); - if (k === "max-age") - cookie.maxAge = parseInt(kv[1], 10); - if (k === "httponly") - cookie.httpOnly = true; - if (k === "secure") - cookie.secure = true; - if (k === "samesite") - cookie.sameSite = kv[1]; - } - browserFrame.page.context.cookieContainer.addCookies([cookie]); - } catch (_) {} - } - const visitorId = crypto.randomUUID(); - const deviceMid = crypto.randomUUID(); - const pre = [ - { name: "zcode_visitor_id", value: visitorId, domain: "zcode.z.ai" }, - { name: "zcode_device_mid", value: deviceMid, domain: "zcode.z.ai" }, - { name: "visitor_id", value: visitorId, domain: "zcode.z.ai", httpOnly: true } - ]; - for (const c of pre) { - try { - browserFrame.page.context.cookieContainer.addCookies([{ ...c, url: "https://zcode.z.ai", path: "/" }]); - } catch (_) {} - } - applyPolyfills(w); - installNativeToString(w); - installGuestScope(w); - installEvalInstrumentation(w); - const needsGlobalAlias = typeof Bun !== "undefined"; - if (needsGlobalAlias) { - const g = globalThis; - installGlobalWindowAlias(g, w); - } - if (w.Error) { - w.Error.prepareStackTrace = Error.prepareStackTrace; - } - w.__capDebugDump = (url, src, kind) => { - try { - const s = String(src || ""); - const sha1 = crypto.createHash("sha1").update(s).digest("hex"); - process.stderr.write(` -[${kind}] url=${url} len=${s.length} sha1=${sha1} -` + ` head300: ${JSON.stringify(s.slice(0, 300))} -` + ` tail100: ${JSON.stringify(s.slice(-100))} -`); - if (/^https?:/.test(String(url))) { - (async () => { - try { - const res = await fetch(url, { headers: { "user-agent": fp.userAgent } }); - const fresh = Buffer.from(await res.arrayBuffer()); - process.stderr.write(`[${kind}-CACHE-COMPARE] cachedLen=${s.length} freshLen=${fresh.length} freshSha1=${crypto.createHash("sha1").update(fresh).digest("hex")} http=${res.status} -`); - if (fresh.length > 0 && fresh.length !== s.length) { - process.stderr.write(`[${kind}-MISMATCH] deleting ${diskPathFor(url)} (stale/truncated cache) -`); - try { - fs.unlinkSync(diskPathFor(url)); - } catch (_) {} - _memCdnCache.delete(url); - } - } catch (fetchErr) { - process.stderr.write(`[${kind}-CACHE-COMPARE-ERR] ${fetchErr.message} -`); - } - })(); - } - } catch (_) {} - }; - w.eval(GUEST_EVAL_PATCH); - w.document.write(HTML); - w.AliyunCaptchaConfig = { region, prefix }; - return { window: w, browserFrame }; -} -var HOST_CRITICAL_GLOBALS = new Set([ - "process", - "Bun", - "console", - "performance", - "crypto", - "fetch", - "queueMicrotask", - "structuredClone", - "TextEncoder", - "TextDecoder", - "setTimeout", - "setInterval", - "clearTimeout", - "clearInterval", - "URL", - "URLSearchParams", - "AbortController", - "AbortSignal", - "ReadableStream", - "WritableStream", - "TransformStream", - "Blob", - "File", - "FormData", - "Headers", - "Request", - "Response", - "Event", - "EventTarget", - "MessageChannel", - "MessagePort", - "Buffer", - "global", - "globalThis", - "Array", - "ArrayBuffer", - "Boolean", - "DataView", - "Date", - "Error", - "EvalError", - "Float32Array", - "Float64Array", - "Function", - "Infinity", - "Int8Array", - "Int16Array", - "Int32Array", - "Intl", - "JSON", - "Map", - "Math", - "NaN", - "Number", - "Object", - "Promise", - "RangeError", - "ReferenceError", - "RegExp", - "Reflect", - "Set", - "String", - "Symbol", - "SyntaxError", - "TypeError", - "URIError", - "Uint8Array", - "Uint8ClampedArray", - "Uint16Array", - "Uint32Array", - "WeakMap", - "WeakSet", - "decodeURI", - "decodeURIComponent", - "encodeURI", - "encodeURIComponent", - "escape", - "isFinite", - "isNaN", - "parseFloat", - "parseInt", - "unescape", - "eval" -]); -var EXTRA_WINDOW_PROPS = [ - "moveBy", - "moveTo", - "resizeBy", - "resizeTo", - "scrollTo", - "scrollBy", - "scroll", - "open", - "close", - "stop", - "focus", - "blur", - "print", - "alert", - "confirm", - "prompt", - "getSelection", - "find" -]; -var INERT_WINDOW_METHODS = new Set(EXTRA_WINDOW_PROPS); -var _aliasRefCount = 0; -var ALIAS_TOMBSTONE_MS = 30000; -var _aliasGeneration = 0; -var _tombstoneMs = ALIAS_TOMBSTONE_MS; -var _hostSetTimeout = globalThis.setTimeout; -var _aliasGetters = new WeakSet; -var _savedHostGlobalDescriptors; -function installGlobalWindowAlias(g, w, tombstoneMs) { - if (_aliasRefCount < 0) - _aliasRefCount = 0; - _aliasRefCount += 1; - _aliasGeneration += 1; - _tombstoneMs = typeof tombstoneMs === "number" ? tombstoneMs : ALIAS_TOMBSTONE_MS; - const props = new Set(Object.getOwnPropertyNames(w)); - for (const name of EXTRA_WINDOW_PROPS) - props.add(name); - for (const proto = Object.getPrototypeOf(w);proto && proto !== Object.prototype; ) { - for (const name of Object.getOwnPropertyNames(proto)) - props.add(name); - break; - } - if (_aliasRefCount === 1 && !_savedHostGlobalDescriptors) { - const saved = {}; - for (const prop of props) { - if (prop === "constructor" || HOST_CRITICAL_GLOBALS.has(prop)) - continue; - try { - const d = Object.getOwnPropertyDescriptor(g, prop); - if (d && d.get && _aliasGetters.has(d.get)) - continue; - if (d) - saved[prop] = d; - } catch (_) {} - } - for (const prop of ["window", "self", "top", "parent", "__capWindowFor"]) { - try { - const d = Object.getOwnPropertyDescriptor(g, prop); - if (d && d.get && _aliasGetters.has(d.get)) - continue; - if (d && !saved[prop]) - saved[prop] = d; - } catch (_) {} - } - _savedHostGlobalDescriptors = saved; - } - for (const prop of props) { - if (HOST_CRITICAL_GLOBALS.has(prop)) - continue; - try { - const getter = function() { - return w[prop]; - }; - _aliasGetters.add(getter); - Object.defineProperty(g, prop, { - get: getter, - set(v) { - try { - w[prop] = v; - } catch (_) {} - }, - configurable: true - }); - } catch (_) {} - } - for (const prop of ["window", "self", "top", "parent"]) { - try { - const getter = function() { - return w; - }; - _aliasGetters.add(getter); - Object.defineProperty(g, prop, { get: getter, configurable: true }); - } catch (_) {} - } - try { - const capGetter = function() { - return w; - }; - _aliasGetters.add(capGetter); - Object.defineProperty(g, "__capWindowFor", { - get: capGetter, - configurable: true - }); - } catch (_) {} -} -function removeGlobalWindowAlias(g, w) { - _aliasRefCount -= 1; - if (_aliasRefCount > 0) - return; - const restored = new Set; - if (_savedHostGlobalDescriptors) { - for (const [name, desc] of Object.entries(_savedHostGlobalDescriptors)) { - try { - Object.defineProperty(g, name, desc); - } catch (_) {} - restored.add(name); - } - _savedHostGlobalDescriptors = undefined; - } - const generation = _aliasGeneration; - const names = []; - try { - for (const name of Object.getOwnPropertyNames(w)) { - if (restored.has(name)) - continue; - try { - if (Object.getOwnPropertyDescriptor(g, name)?.get) - names.push(name); - } catch (_) {} - } - for (const prop of ["window", "self", "top", "parent", "__capWindowFor"]) { - if (restored.has(prop)) - continue; - try { - if (Object.getOwnPropertyDescriptor(g, prop)?.get) - names.push(prop); - } catch (_) {} - } - } catch (_) {} - try { - const t = _hostSetTimeout(() => { - if (generation !== _aliasGeneration || _aliasRefCount > 0) - return; - for (const name of names) { - try { - if (!Object.getOwnPropertyDescriptor(g, name)?.get) - continue; - const stub = INERT_WINDOW_METHODS.has(name) ? () => {} : undefined; - Object.defineProperty(g, name, { - value: stub, - configurable: true, - writable: true - }); - } catch (_) {} - } - }, _tombstoneMs); - try { - if (t && typeof t.unref === "function") - t.unref(); - } catch (_) {} - } catch (_) {} -} -var _gcStats = { calls: 0, lastAt: 0 }; -function reclaimCaptchaHeap() { - try { - const gc = typeof Bun !== "undefined" && typeof Bun.gc === "function" && Bun.gc || typeof globalThis.gc === "function" && globalThis.gc; - if (!gc) - return; - const raw = Number(process.env.CAPTCHA_GC_MIN_INTERVAL_MS); - const minMs = Number.isFinite(raw) && raw >= 0 ? raw : 5000; - const now = Date.now(); - if (now - _gcStats.lastAt < minMs) - return; - _gcStats.lastAt = now; - _gcStats.calls += 1; - gc(true); - } catch (_) {} -} -function destroyDom(win) { - try { - const cap = win.document.getElementById("cap"); - if (cap) - cap.replaceChildren(); - win.happyDOM.close(); - } catch (_) {} - try { - global.__cookieContainer = null; - global.__browserFrame = null; - } catch (_) {} - try { - if (typeof Bun !== "undefined") - removeGlobalWindowAlias(globalThis, win); - } catch (_) {} - removeGuestScope(win); - try { - shutdownSyncFetchWorker(); - } catch (_) {} - reclaimCaptchaHeap(); -} -function extractVerifyParam(param) { - let verifyParam = param; - if (param && typeof param === "object") { - verifyParam = param.verifyParam || param.data || param.param; - } - if (!verifyParam || String(verifyParam).length < 20) { - throw new Error("solver returned empty param: " + JSON.stringify(param)); - } - const str = String(verifyParam); - if (str.length < 200) { - throw new Error("verify param too short (" + str.length + " chars) \u2014 degraded result, refusing: " + str.slice(0, 80)); - } - try { - const decoded = JSON.parse(Buffer.from(str, "base64").toString("utf8")); - const secTok = decoded && (decoded.securityToken || decoded.SecurityToken); - if (!secTok || String(secTok).length < 50) { - throw new Error("verify param missing securityToken \u2014 refusing degraded result: " + str.slice(0, 80)); - } - } catch (err) { - if (err instanceof SyntaxError || /securityToken/.test(String(err.message))) { - throw err instanceof SyntaxError ? new Error("verify param not base64-JSON: " + str.slice(0, 80)) : err; - } - throw err; - } - return str; -} -function handleCaptchaResult(result) { - if (result && typeof result === "object" && result.verifyResult === false) { - throw new Error("verify rejected: " + JSON.stringify({ verifyCode: result.verifyCode, certifyId: result.certifyId })); - } - return result; -} -var _reusePool = { window: null, browserFrame: null, solves: 0, lastUsedAt: 0 }; -var REUSE_MAX_SOLVES = Number(process.env.CAPTCHA_REUSE_MAX_SOLVES || 8); -var REUSE_MAX_IDLE_MS = Number(process.env.CAPTCHA_REUSE_MAX_IDLE_MS || 120000); -function takeReusableWindow() { - const p = _reusePool; - if (!p.window) - return null; - if (p.solves >= REUSE_MAX_SOLVES) { - discardReusableWindow(); - return null; - } - if (Date.now() - p.lastUsedAt > REUSE_MAX_IDLE_MS) { - discardReusableWindow(); - return null; - } - return { window: p.window, browserFrame: p.browserFrame, reused: true }; -} -function stageReusableWindow(window, browserFrame) { - _reusePool.window = window; - _reusePool.browserFrame = browserFrame; - _reusePool.solves = 0; - _reusePool.lastUsedAt = Date.now(); -} -function discardReusableWindow() { - const p = _reusePool; - if (p.window) { - try { - destroyDom(p.window); - } catch (_) {} - } - p.window = null; - p.browserFrame = null; - p.solves = 0; -} -function noteWindowSolved() { - _reusePool.solves += 1; - _reusePool.lastUsedAt = Date.now(); -} -function guestErrorSummary(w, max = 4) { - try { - const errs = w && w.__capErrs; - if (!errs || !errs.length) - return ""; - const total = errs.reduce((a, e) => a + (e && e.n || 1), 0); - const parts = errs.slice(0, max).map((e) => { - const n = e && e.n && e.n > 1 ? `x${e.n}` : ""; - return `${e && e.k || "?"}${n}: ${String(e && e.m || "?").slice(0, 120)}`; - }); - return ` guestErrors(${total}): ${parts.join(" || ")}`; - } catch (_) { - return ""; - } -} -async function solveTraceless(opts) { - const scene = opts.scene || "11xygtvd"; - const region = opts.region || "sgp"; - const prefix = opts.prefix || "no8xfe"; - const timeoutMs = opts.timeoutMs ?? Number(process.env.CAPTCHA_SOLVE_TIMEOUT_MS || 20000); - const wantReuse = opts.reuseWindow ?? process.env.CAPTCHA_WINDOW_REUSE !== "0"; - let dom; - let reused = false; - if (wantReuse) { - dom = takeReusableWindow(); - if (dom) - reused = true; - } - if (!dom) { - dom = await createDom(region, prefix); - } - const { window: w, browserFrame } = dom; - const solveStart = Date.now(); - let solveSucceeded = false; - let keepWindow = false; - try { - await waitFor(() => typeof w.initAliyunCaptcha === "function", timeoutMs, 50); - simulateBehavior(w, 600); - const param = await new Promise((resolve, reject) => { - const timer = setTimeout(() => { - const peUrl = (() => { - try { - return w.__lastPeUrl || "?"; - } catch (_) { - return "?"; - } - })(); - const reqs = _requestLog.filter((r) => r.at >= solveStart).map((r) => `${r.at - solveStart}ms ${r.method} ${String(r.url).replace(/^https?:\/\//, "").slice(0, 60)}`).slice(-12); - reject(new Error(`captcha solve timeout pe=${peUrl.split("/").pop() || peUrl} reqs=${JSON.stringify(reqs)}`)); - }, timeoutMs); - const stallMs = opts.stallMs ?? Number(process.env.CAPTCHA_STALL_MS || 6000); - const stallTimer = setInterval(() => { - const last = _requestLog[_requestLog.length - 1]; - if (last && Date.now() - last.at > stallMs) { - const peUrl = (() => { - try { - return w.__lastPeUrl || "?"; - } catch (_) { - return "?"; - } - })(); - noteStallAndMaybeEvict(peUrl); - const reqs = _requestLog.filter((r) => r.at >= solveStart).map((r) => `${r.at - solveStart}ms ${r.method} ${String(r.url).replace(/^https?:\/\//, "").slice(0, 60)}`).slice(-12); - clearTimeout(timer); - clearInterval(stallTimer); - reject(new Error(`captcha solve stall pe=${peUrl.split("/").pop() || peUrl} lastXhr=${last.at - solveStart}ms reqs=${JSON.stringify(reqs)}`)); - } - }, 500); - const finish = (fn) => (value) => { - clearTimeout(timer); - clearInterval(stallTimer); - fn(value); - }; - try { - w.initAliyunCaptcha({ - SceneId: scene, - mode: "popup", - region, - prefix, - language: "en", - element: "#cap", - button: "#btn", - captchaLogoImg: "", - showErrorTip: false, - getInstance: (inst) => { - try { - (inst.startTracelessVerification || inst.show).call(inst); - } catch (e) { - finish(reject)(new Error(`start: ${e.message}`)); - } - }, - success: (result) => { - try { - finish(resolve)(handleCaptchaResult(result)); - } catch (err) { - finish(reject)(err); - } - }, - fail: (err) => finish(reject)(new Error(`fail: ${JSON.stringify(err)}`)), - onError: (err) => finish(reject)(new Error(`onError: ${JSON.stringify(err)}`)) - }); - } catch (err) { - clearTimeout(timer); - reject(err); - } - }); - try { - const okPe = w.__lastPeUrl; - if (okPe) - _stallCounts.delete(okPe); - w.__capErrs = []; - } catch (_) {} - if (process.env.CAPTCHA_DUMP_DBT === "1") { - try { - const dbt = w.__DBT || []; - fs.writeFileSync(process.env.CAPTCHA_DBT_FILE || "/tmp/pe-dbt.json", JSON.stringify({ count: dbt.length, last: dbt.slice(-8), all: dbt }, null, 1)); - } catch (_) {} - } - solveSucceeded = true; - const out = extractVerifyParam(param); - if (wantReuse) { - if (reused) - noteWindowSolved(); - else - stageReusableWindow(w, browserFrame); - keepWindow = true; - } - return out; - } catch (err) { - const summary = guestErrorSummary(w); - if (summary) { - try { - err.message = `${err && err.message ? err.message : String(err)} |${summary}`; - } catch (_) {} - } - throw err; - } finally { - if (!keepWindow) { - if (_reusePool.window === w) - _reusePool.window = null; - destroyDom(w); - } - } -} - -// src/proxy/captcha-worker-entry.ts -var port = parentPort; -if (!port) - throw new Error("captcha worker entry requires a worker_threads parent"); -port.on("message", (m) => { - (async () => { - try { - const param = await solveTraceless({ scene: m.scene, region: m.region, prefix: m.prefix }); - port.postMessage({ id: m.id, ok: true, param }); - } catch (err) { - port.postMessage({ id: m.id, ok: false, error: String(err?.message ?? err) }); - } - })(); -});