"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer");
const crypto_1 = require("crypto");
const util_1 = require("util");
const stream_1 = __importDefault(require("stream"));
const web_1 = require("stream/web");
const url_1 = require("url");
const vm_1 = __importDefault(require("vm"));
const PropertySymbol = __importStar(require("../PropertySymbol.cjs"));
const Base64_js_1 = __importDefault(require("../base64/Base64.cjs"));
const BrowserErrorCaptureEnum_js_1 = __importDefault(require("../browser/enums/BrowserErrorCaptureEnum.cjs"));
const Clipboard_js_1 = __importDefault(require("../clipboard/Clipboard.cjs"));
const CSS_js_1 = __importDefault(require("../css/CSS.cjs"));
const CSSRule_js_1 = __importDefault(require("../css/CSSRule.cjs"));
const CSSStyleDeclaration_js_1 = __importDefault(require("../css/declaration/CSSStyleDeclaration.cjs"));
const CSSContainerRule_js_1 = __importDefault(require("../css/rules/CSSContainerRule.cjs"));
const CSSFontFaceRule_js_1 = __importDefault(require("../css/rules/CSSFontFaceRule.cjs"));
const CSSKeyframeRule_js_1 = __importDefault(require("../css/rules/CSSKeyframeRule.cjs"));
const CSSKeyframesRule_js_1 = __importDefault(require("../css/rules/CSSKeyframesRule.cjs"));
const CSSMediaRule_js_1 = __importDefault(require("../css/rules/CSSMediaRule.cjs"));
const CSSStyleRule_js_1 = __importDefault(require("../css/rules/CSSStyleRule.cjs"));
const CSSSupportsRule_js_1 = __importDefault(require("../css/rules/CSSSupportsRule.cjs"));
const CustomElementRegistry_js_1 = __importDefault(require("../custom-element/CustomElementRegistry.cjs"));
const Event_js_1 = __importDefault(require("../event/Event.cjs"));
const EventTarget_js_1 = __importDefault(require("../event/EventTarget.cjs"));
const Touch_js_1 = __importDefault(require("../event/Touch.cjs"));
const UIEvent_js_1 = __importDefault(require("../event/UIEvent.cjs"));
const AnimationEvent_js_1 = __importDefault(require("../event/events/AnimationEvent.cjs"));
const ClipboardEvent_js_1 = __importDefault(require("../event/events/ClipboardEvent.cjs"));
const CustomEvent_js_1 = __importDefault(require("../event/events/CustomEvent.cjs"));
const ErrorEvent_js_1 = __importDefault(require("../event/events/ErrorEvent.cjs"));
const FocusEvent_js_1 = __importDefault(require("../event/events/FocusEvent.cjs"));
const HashChangeEvent_js_1 = __importDefault(require("../event/events/HashChangeEvent.cjs"));
const InputEvent_js_1 = __importDefault(require("../event/events/InputEvent.cjs"));
const KeyboardEvent_js_1 = __importDefault(require("../event/events/KeyboardEvent.cjs"));
const MediaQueryListEvent_js_1 = __importDefault(require("../event/events/MediaQueryListEvent.cjs"));
const MessageEvent_js_1 = __importDefault(require("../event/events/MessageEvent.cjs"));
const MouseEvent_js_1 = __importDefault(require("../event/events/MouseEvent.cjs"));
const PointerEvent_js_1 = __importDefault(require("../event/events/PointerEvent.cjs"));
const ProgressEvent_js_1 = __importDefault(require("../event/events/ProgressEvent.cjs"));
const StorageEvent_js_1 = __importDefault(require("../event/events/StorageEvent.cjs"));
const SubmitEvent_js_1 = __importDefault(require("../event/events/SubmitEvent.cjs"));
const TouchEvent_js_1 = __importDefault(require("../event/events/TouchEvent.cjs"));
const WheelEvent_js_1 = __importDefault(require("../event/events/WheelEvent.cjs"));
const DOMExceptionNameEnum_js_1 = __importDefault(require("../exception/DOMExceptionNameEnum.cjs"));
const Fetch_js_1 = __importDefault(require("../fetch/Fetch.cjs"));
const Blob_js_1 = __importDefault(require("../file/Blob.cjs"));
const File_js_1 = __importDefault(require("../file/File.cjs"));
const History_js_1 = __importDefault(require("../history/History.cjs"));
const IntersectionObserver_js_1 = __importDefault(require("../intersection-observer/IntersectionObserver.cjs"));
const IntersectionObserverEntry_js_1 = __importDefault(require("../intersection-observer/IntersectionObserverEntry.cjs"));
const Location_js_1 = __importDefault(require("../location/Location.cjs"));
const MediaQueryList_js_1 = __importDefault(require("../match-media/MediaQueryList.cjs"));
const MutationRecord_js_1 = __importDefault(require("../mutation-observer/MutationRecord.cjs"));
const MimeType_js_1 = __importDefault(require("../navigator/MimeType.cjs"));
const MimeTypeArray_js_1 = __importDefault(require("../navigator/MimeTypeArray.cjs"));
const Navigator_js_1 = __importDefault(require("../navigator/Navigator.cjs"));
const Plugin_js_1 = __importDefault(require("../navigator/Plugin.cjs"));
const PluginArray_js_1 = __importDefault(require("../navigator/PluginArray.cjs"));
const Attr_js_1 = __importDefault(require("../nodes/attr/Attr.cjs"));
const CharacterData_js_1 = __importDefault(require("../nodes/character-data/CharacterData.cjs"));
const DocumentType_js_1 = __importDefault(require("../nodes/document-type/DocumentType.cjs"));
const DocumentReadyStateEnum_js_1 = __importDefault(require("../nodes/document/DocumentReadyStateEnum.cjs"));
const DocumentReadyStateManager_js_1 = __importDefault(require("../nodes/document/DocumentReadyStateManager.cjs"));
const DOMRect_js_1 = __importDefault(require("../dom/DOMRect.cjs"));
const DOMRectReadOnly_js_1 = __importDefault(require("../dom/DOMRectReadOnly.cjs"));
const Element_js_1 = __importDefault(require("../nodes/element/Element.cjs"));
const HTMLCollection_js_1 = __importDefault(require("../nodes/element/HTMLCollection.cjs"));
const HTMLAnchorElement_js_1 = __importDefault(require("../nodes/html-anchor-element/HTMLAnchorElement.cjs"));
const HTMLAreaElement_js_1 = __importDefault(require("../nodes/html-area-element/HTMLAreaElement.cjs"));
const HTMLAudioElement_js_1 = __importDefault(require("../nodes/html-audio-element/HTMLAudioElement.cjs"));
const HTMLBaseElement_js_1 = __importDefault(require("../nodes/html-base-element/HTMLBaseElement.cjs"));
const HTMLBodyElement_js_1 = __importDefault(require("../nodes/html-body-element/HTMLBodyElement.cjs"));
const HTMLBRElement_js_1 = __importDefault(require("../nodes/html-br-element/HTMLBRElement.cjs"));
const HTMLButtonElement_js_1 = __importDefault(require("../nodes/html-button-element/HTMLButtonElement.cjs"));
const HTMLCanvasElement_js_1 = __importDefault(require("../nodes/html-canvas-element/HTMLCanvasElement.cjs"));
const HTMLDListElement_js_1 = __importDefault(require("../nodes/html-d-list-element/HTMLDListElement.cjs"));
const HTMLDataElement_js_1 = __importDefault(require("../nodes/html-data-element/HTMLDataElement.cjs"));
const HTMLDataListElement_js_1 = __importDefault(require("../nodes/html-data-list-element/HTMLDataListElement.cjs"));
const HTMLDetailsElement_js_1 = __importDefault(require("../nodes/html-details-element/HTMLDetailsElement.cjs"));
const HTMLDialogElement_js_1 = __importDefault(require("../nodes/html-dialog-element/HTMLDialogElement.cjs"));
const HTMLDivElement_js_1 = __importDefault(require("../nodes/html-div-element/HTMLDivElement.cjs"));
const HTMLElement_js_1 = __importDefault(require("../nodes/html-element/HTMLElement.cjs"));
const HTMLEmbedElement_js_1 = __importDefault(require("../nodes/html-embed-element/HTMLEmbedElement.cjs"));
const HTMLFieldSetElement_js_1 = __importDefault(require("../nodes/html-field-set-element/HTMLFieldSetElement.cjs"));
const HTMLFormControlsCollection_js_1 = __importDefault(require("../nodes/html-form-element/HTMLFormControlsCollection.cjs"));
const HTMLFormElement_js_1 = __importDefault(require("../nodes/html-form-element/HTMLFormElement.cjs"));
const RadioNodeList_js_1 = __importDefault(require("../nodes/html-form-element/RadioNodeList.cjs"));
const HTMLHeadElement_js_1 = __importDefault(require("../nodes/html-head-element/HTMLHeadElement.cjs"));
const HTMLHeadingElement_js_1 = __importDefault(require("../nodes/html-heading-element/HTMLHeadingElement.cjs"));
const HTMLHRElement_js_1 = __importDefault(require("../nodes/html-hr-element/HTMLHRElement.cjs"));
const HTMLHtmlElement_js_1 = __importDefault(require("../nodes/html-html-element/HTMLHtmlElement.cjs"));
const HTMLIFrameElement_js_1 = __importDefault(require("../nodes/html-iframe-element/HTMLIFrameElement.cjs"));
const HTMLImageElement_js_1 = __importDefault(require("../nodes/html-image-element/HTMLImageElement.cjs"));
const FileList_js_1 = __importDefault(require("../nodes/html-input-element/FileList.cjs"));
const HTMLInputElement_js_1 = __importDefault(require("../nodes/html-input-element/HTMLInputElement.cjs"));
const HTMLLabelElement_js_1 = __importDefault(require("../nodes/html-label-element/HTMLLabelElement.cjs"));
const HTMLLegendElement_js_1 = __importDefault(require("../nodes/html-legend-element/HTMLLegendElement.cjs"));
const HTMLLIElement_js_1 = __importDefault(require("../nodes/html-li-element/HTMLLIElement.cjs"));
const HTMLLinkElement_js_1 = __importDefault(require("../nodes/html-link-element/HTMLLinkElement.cjs"));
const HTMLMapElement_js_1 = __importDefault(require("../nodes/html-map-element/HTMLMapElement.cjs"));
const HTMLMediaElement_js_1 = __importDefault(require("../nodes/html-media-element/HTMLMediaElement.cjs"));
const TextTrackCueList_js_1 = __importDefault(require("../nodes/html-media-element/TextTrackCueList.cjs"));
const TimeRanges_js_1 = __importDefault(require("../nodes/html-media-element/TimeRanges.cjs"));
const HTMLMenuElement_js_1 = __importDefault(require("../nodes/html-menu-element/HTMLMenuElement.cjs"));
const HTMLMetaElement_js_1 = __importDefault(require("../nodes/html-meta-element/HTMLMetaElement.cjs"));
const HTMLMeterElement_js_1 = __importDefault(require("../nodes/html-meter-element/HTMLMeterElement.cjs"));
const HTMLModElement_js_1 = __importDefault(require("../nodes/html-mod-element/HTMLModElement.cjs"));
const HTMLOListElement_js_1 = __importDefault(require("../nodes/html-o-list-element/HTMLOListElement.cjs"));
const HTMLObjectElement_js_1 = __importDefault(require("../nodes/html-object-element/HTMLObjectElement.cjs"));
const HTMLOptGroupElement_js_1 = __importDefault(require("../nodes/html-opt-group-element/HTMLOptGroupElement.cjs"));
const HTMLOptionElement_js_1 = __importDefault(require("../nodes/html-option-element/HTMLOptionElement.cjs"));
const HTMLOutputElement_js_1 = __importDefault(require("../nodes/html-output-element/HTMLOutputElement.cjs"));
const HTMLParagraphElement_js_1 = __importDefault(require("../nodes/html-paragraph-element/HTMLParagraphElement.cjs"));
const HTMLParamElement_js_1 = __importDefault(require("../nodes/html-param-element/HTMLParamElement.cjs"));
const HTMLPictureElement_js_1 = __importDefault(require("../nodes/html-picture-element/HTMLPictureElement.cjs"));
const HTMLPreElement_js_1 = __importDefault(require("../nodes/html-pre-element/HTMLPreElement.cjs"));
const HTMLProgressElement_js_1 = __importDefault(require("../nodes/html-progress-element/HTMLProgressElement.cjs"));
const HTMLQuoteElement_js_1 = __importDefault(require("../nodes/html-quote-element/HTMLQuoteElement.cjs"));
const HTMLScriptElement_js_1 = __importDefault(require("../nodes/html-script-element/HTMLScriptElement.cjs"));
const HTMLSelectElement_js_1 = __importDefault(require("../nodes/html-select-element/HTMLSelectElement.cjs"));
const HTMLSlotElement_js_1 = __importDefault(require("../nodes/html-slot-element/HTMLSlotElement.cjs"));
const HTMLSourceElement_js_1 = __importDefault(require("../nodes/html-source-element/HTMLSourceElement.cjs"));
const HTMLSpanElement_js_1 = __importDefault(require("../nodes/html-span-element/HTMLSpanElement.cjs"));
const HTMLStyleElement_js_1 = __importDefault(require("../nodes/html-style-element/HTMLStyleElement.cjs"));
const HTMLTableCaptionElement_js_1 = __importDefault(require("../nodes/html-table-caption-element/HTMLTableCaptionElement.cjs"));
const HTMLTableCellElement_js_1 = __importDefault(require("../nodes/html-table-cell-element/HTMLTableCellElement.cjs"));
const HTMLTableColElement_js_1 = __importDefault(require("../nodes/html-table-col-element/HTMLTableColElement.cjs"));
const HTMLTableElement_js_1 = __importDefault(require("../nodes/html-table-element/HTMLTableElement.cjs"));
const HTMLTableRowElement_js_1 = __importDefault(require("../nodes/html-table-row-element/HTMLTableRowElement.cjs"));
const HTMLTableSectionElement_js_1 = __importDefault(require("../nodes/html-table-section-element/HTMLTableSectionElement.cjs"));
const HTMLTemplateElement_js_1 = __importDefault(require("../nodes/html-template-element/HTMLTemplateElement.cjs"));
const HTMLTextAreaElement_js_1 = __importDefault(require("../nodes/html-text-area-element/HTMLTextAreaElement.cjs"));
const HTMLTimeElement_js_1 = __importDefault(require("../nodes/html-time-element/HTMLTimeElement.cjs"));
const HTMLTitleElement_js_1 = __importDefault(require("../nodes/html-title-element/HTMLTitleElement.cjs"));
const HTMLTrackElement_js_1 = __importDefault(require("../nodes/html-track-element/HTMLTrackElement.cjs"));
const HTMLUListElement_js_1 = __importDefault(require("../nodes/html-u-list-element/HTMLUListElement.cjs"));
const HTMLUnknownElement_js_1 = __importDefault(require("../nodes/html-unknown-element/HTMLUnknownElement.cjs"));
const HTMLVideoElement_js_1 = __importDefault(require("../nodes/html-video-element/HTMLVideoElement.cjs"));
const Node_js_1 = __importDefault(require("../nodes/node/Node.cjs"));
const NodeList_js_1 = __importDefault(require("../nodes/node/NodeList.cjs"));
const ProcessingInstruction_js_1 = __importDefault(require("../nodes/processing-instruction/ProcessingInstruction.cjs"));
const ShadowRoot_js_1 = __importDefault(require("../nodes/shadow-root/ShadowRoot.cjs"));
const SVGElement_js_1 = __importDefault(require("../nodes/svg-element/SVGElement.cjs"));
const Permissions_js_1 = __importDefault(require("../permissions/Permissions.cjs"));
const ResizeObserver_js_1 = __importDefault(require("../resize-observer/ResizeObserver.cjs"));
const Screen_js_1 = __importDefault(require("../screen/Screen.cjs"));
const Storage_js_1 = __importDefault(require("../storage/Storage.cjs"));
const NodeFilter_js_1 = __importDefault(require("../tree-walker/NodeFilter.cjs"));
const URL_js_1 = __importDefault(require("../url/URL.cjs"));
const ValidityState_js_1 = __importDefault(require("../validity-state/ValidityState.cjs"));
const VMGlobalPropertyScript_js_1 = __importDefault(require("./VMGlobalPropertyScript.cjs"));
const WindowErrorUtility_js_1 = __importDefault(require("./WindowErrorUtility.cjs"));
const WindowPageOpenUtility_js_1 = __importDefault(require("./WindowPageOpenUtility.cjs"));
const node_perf_hooks_1 = require("node:perf_hooks");
const EventPhaseEnum_js_1 = __importDefault(require("../event/EventPhaseEnum.cjs"));
const HTMLOptionsCollection_js_1 = __importDefault(require("../nodes/html-select-element/HTMLOptionsCollection.cjs"));
const WindowContextClassExtender_js_1 = __importDefault(require("./WindowContextClassExtender.cjs"));
const WindowBrowserContext_js_1 = __importDefault(require("./WindowBrowserContext.cjs"));
const SVGSVGElement_js_1 = __importDefault(require("../nodes/svg-svg-element/SVGSVGElement.cjs"));
const SVGGraphicsElement_js_1 = __importDefault(require("../nodes/svg-graphics-element/SVGGraphicsElement.cjs"));
const SVGAnimateElement_js_1 = __importDefault(require("../nodes/svg-animate-element/SVGAnimateElement.cjs"));
const SVGAnimateMotionElement_js_1 = __importDefault(require("../nodes/svg-animate-motion-element/SVGAnimateMotionElement.cjs"));
const SVGAnimateTransformElement_js_1 = __importDefault(require("../nodes/svg-animate-transform-element/SVGAnimateTransformElement.cjs"));
const SVGCircleElement_js_1 = __importDefault(require("../nodes/svg-circle-element/SVGCircleElement.cjs"));
const SVGClipPathElement_js_1 = __importDefault(require("../nodes/svg-clip-path-element/SVGClipPathElement.cjs"));
const SVGDefsElement_js_1 = __importDefault(require("../nodes/svg-defs-element/SVGDefsElement.cjs"));
const SVGDescElement_js_1 = __importDefault(require("../nodes/svg-desc-element/SVGDescElement.cjs"));
const SVGEllipseElement_js_1 = __importDefault(require("../nodes/svg-ellipse-element/SVGEllipseElement.cjs"));
const SVGFEBlendElement_js_1 = __importDefault(require("../nodes/svg-fe-blend-element/SVGFEBlendElement.cjs"));
const SVGFEColorMatrixElement_js_1 = __importDefault(require("../nodes/svg-fe-color-matrix-element/SVGFEColorMatrixElement.cjs"));
const SVGFEComponentTransferElement_js_1 = __importDefault(require("../nodes/svg-fe-component-transfer-element/SVGFEComponentTransferElement.cjs"));
const SVGFECompositeElement_js_1 = __importDefault(require("../nodes/svg-fe-composite-element/SVGFECompositeElement.cjs"));
const SVGFEConvolveMatrixElement_js_1 = __importDefault(require("../nodes/svg-fe-convolve-matrix-element/SVGFEConvolveMatrixElement.cjs"));
const SVGFEDiffuseLightingElement_js_1 = __importDefault(require("../nodes/svg-fe-diffuse-lighting-element/SVGFEDiffuseLightingElement.cjs"));
const SVGFEDisplacementMapElement_js_1 = __importDefault(require("../nodes/svg-fe-displacement-map-element/SVGFEDisplacementMapElement.cjs"));
const SVGFEDistantLightElement_js_1 = __importDefault(require("../nodes/svg-fe-distant-light-element/SVGFEDistantLightElement.cjs"));
const SVGFEDropShadowElement_js_1 = __importDefault(require("../nodes/svg-fe-drop-shadow-element/SVGFEDropShadowElement.cjs"));
const SVGFEFloodElement_js_1 = __importDefault(require("../nodes/svg-fe-flood-element/SVGFEFloodElement.cjs"));
const SVGFEFuncAElement_js_1 = __importDefault(require("../nodes/svg-fe-func-a-element/SVGFEFuncAElement.cjs"));
const SVGFEFuncBElement_js_1 = __importDefault(require("../nodes/svg-fe-func-b-element/SVGFEFuncBElement.cjs"));
const SVGFEFuncGElement_js_1 = __importDefault(require("../nodes/svg-fe-func-g-element/SVGFEFuncGElement.cjs"));
const SVGFEFuncRElement_js_1 = __importDefault(require("../nodes/svg-fe-func-r-element/SVGFEFuncRElement.cjs"));
const SVGFEGaussianBlurElement_js_1 = __importDefault(require("../nodes/svg-fe-gaussian-blur-element/SVGFEGaussianBlurElement.cjs"));
const SVGFEImageElement_js_1 = __importDefault(require("../nodes/svg-fe-image-element/SVGFEImageElement.cjs"));
const SVGFEMergeElement_js_1 = __importDefault(require("../nodes/svg-fe-merge-element/SVGFEMergeElement.cjs"));
const SVGFEMergeNodeElement_js_1 = __importDefault(require("../nodes/svg-fe-merge-node-element/SVGFEMergeNodeElement.cjs"));
const SVGFEMorphologyElement_js_1 = __importDefault(require("../nodes/svg-fe-morphology-element/SVGFEMorphologyElement.cjs"));
const SVGFEOffsetElement_js_1 = __importDefault(require("../nodes/svg-fe-offset-element/SVGFEOffsetElement.cjs"));
const SVGFEPointLightElement_js_1 = __importDefault(require("../nodes/svg-fe-point-light-element/SVGFEPointLightElement.cjs"));
const SVGFESpecularLightingElement_js_1 = __importDefault(require("../nodes/svg-fe-specular-lighting-element/SVGFESpecularLightingElement.cjs"));
const SVGFESpotLightElement_js_1 = __importDefault(require("../nodes/svg-fe-spot-light-element/SVGFESpotLightElement.cjs"));
const SVGFETileElement_js_1 = __importDefault(require("../nodes/svg-fe-tile-element/SVGFETileElement.cjs"));
const SVGFETurbulenceElement_js_1 = __importDefault(require("../nodes/svg-fe-turbulence-element/SVGFETurbulenceElement.cjs"));
const SVGFilterElement_js_1 = __importDefault(require("../nodes/svg-filter-element/SVGFilterElement.cjs"));
const SVGForeignObjectElement_js_1 = __importDefault(require("../nodes/svg-foreign-object-element/SVGForeignObjectElement.cjs"));
const SVGGElement_js_1 = __importDefault(require("../nodes/svg-g-element/SVGGElement.cjs"));
const SVGImageElement_js_1 = __importDefault(require("../nodes/svg-image-element/SVGImageElement.cjs"));
const SVGLineElement_js_1 = __importDefault(require("../nodes/svg-line-element/SVGLineElement.cjs"));
const SVGLinearGradientElement_js_1 = __importDefault(require("../nodes/svg-linear-gradient-element/SVGLinearGradientElement.cjs"));
const SVGMarkerElement_js_1 = __importDefault(require("../nodes/svg-marker-element/SVGMarkerElement.cjs"));
const SVGMaskElement_js_1 = __importDefault(require("../nodes/svg-mask-element/SVGMaskElement.cjs"));
const SVGMetadataElement_js_1 = __importDefault(require("../nodes/svg-metadata-element/SVGMetadataElement.cjs"));
const SVGMPathElement_js_1 = __importDefault(require("../nodes/svg-m-path-element/SVGMPathElement.cjs"));
const SVGPathElement_js_1 = __importDefault(require("../nodes/svg-path-element/SVGPathElement.cjs"));
const SVGPatternElement_js_1 = __importDefault(require("../nodes/svg-pattern-element/SVGPatternElement.cjs"));
const SVGPolygonElement_js_1 = __importDefault(require("../nodes/svg-polygon-element/SVGPolygonElement.cjs"));
const SVGPolylineElement_js_1 = __importDefault(require("../nodes/svg-polyline-element/SVGPolylineElement.cjs"));
const SVGRadialGradientElement_js_1 = __importDefault(require("../nodes/svg-radial-gradient-element/SVGRadialGradientElement.cjs"));
const SVGRectElement_js_1 = __importDefault(require("../nodes/svg-rect-element/SVGRectElement.cjs"));
const SVGScriptElement_js_1 = __importDefault(require("../nodes/svg-script-element/SVGScriptElement.cjs"));
const SVGSetElement_js_1 = __importDefault(require("../nodes/svg-set-element/SVGSetElement.cjs"));
const SVGStopElement_js_1 = __importDefault(require("../nodes/svg-stop-element/SVGStopElement.cjs"));
const SVGStyleElement_js_1 = __importDefault(require("../nodes/svg-style-element/SVGStyleElement.cjs"));
const SVGSwitchElement_js_1 = __importDefault(require("../nodes/svg-switch-element/SVGSwitchElement.cjs"));
const SVGSymbolElement_js_1 = __importDefault(require("../nodes/svg-symbol-element/SVGSymbolElement.cjs"));
const SVGTextElement_js_1 = __importDefault(require("../nodes/svg-text-element/SVGTextElement.cjs"));
const SVGTextPathElement_js_1 = __importDefault(require("../nodes/svg-text-path-element/SVGTextPathElement.cjs"));
const SVGTitleElement_js_1 = __importDefault(require("../nodes/svg-title-element/SVGTitleElement.cjs"));
const SVGTSpanElement_js_1 = __importDefault(require("../nodes/svg-t-span-element/SVGTSpanElement.cjs"));
const SVGUseElement_js_1 = __importDefault(require("../nodes/svg-use-element/SVGUseElement.cjs"));
const SVGViewElement_js_1 = __importDefault(require("../nodes/svg-view-element/SVGViewElement.cjs"));
const SVGAnimationElement_js_1 = __importDefault(require("../nodes/svg-animation-element/SVGAnimationElement.cjs"));
const SVGComponentTransferFunctionElement_js_1 = __importDefault(require("../nodes/svg-component-transfer-function-element/SVGComponentTransferFunctionElement.cjs"));
const SVGGeometryElement_js_1 = __importDefault(require("../nodes/svg-geometry-element/SVGGeometryElement.cjs"));
const SVGGradientElement_js_1 = __importDefault(require("../nodes/svg-gradient-element/SVGGradientElement.cjs"));
const SVGTextPositioningElement_js_1 = __importDefault(require("../nodes/svg-text-positioning-element/SVGTextPositioningElement.cjs"));
const DOMMatrixReadOnly_js_1 = __importDefault(require("../dom/dom-matrix/DOMMatrixReadOnly.cjs"));
const DOMMatrix_js_1 = __importDefault(require("../dom/dom-matrix/DOMMatrix.cjs"));
const SVGAngle_js_1 = __importDefault(require("../svg/SVGAngle.cjs"));
const SVGAnimatedAngle_js_1 = __importDefault(require("../svg/SVGAnimatedAngle.cjs"));
const SVGAnimatedBoolean_js_1 = __importDefault(require("../svg/SVGAnimatedBoolean.cjs"));
const SVGAnimatedEnumeration_js_1 = __importDefault(require("../svg/SVGAnimatedEnumeration.cjs"));
const SVGAnimatedInteger_js_1 = __importDefault(require("../svg/SVGAnimatedInteger.cjs"));
const SVGAnimatedLength_js_1 = __importDefault(require("../svg/SVGAnimatedLength.cjs"));
const SVGLength_js_1 = __importDefault(require("../svg/SVGLength.cjs"));
const SVGAnimatedNumber_js_1 = __importDefault(require("../svg/SVGAnimatedNumber.cjs"));
const SVGAnimatedNumberList_js_1 = __importDefault(require("../svg/SVGAnimatedNumberList.cjs"));
const SVGAnimatedPreserveAspectRatio_js_1 = __importDefault(require("../svg/SVGAnimatedPreserveAspectRatio.cjs"));
const SVGAnimatedRect_js_1 = __importDefault(require("../svg/SVGAnimatedRect.cjs"));
const SVGAnimatedString_js_1 = __importDefault(require("../svg/SVGAnimatedString.cjs"));
const SVGAnimatedTransformList_js_1 = __importDefault(require("../svg/SVGAnimatedTransformList.cjs"));
const SVGLengthList_js_1 = __importDefault(require("../svg/SVGLengthList.cjs"));
const SVGMatrix_js_1 = __importDefault(require("../svg/SVGMatrix.cjs"));
const SVGNumber_js_1 = __importDefault(require("../svg/SVGNumber.cjs"));
const SVGNumberList_js_1 = __importDefault(require("../svg/SVGNumberList.cjs"));
const SVGPoint_js_1 = __importDefault(require("../svg/SVGPoint.cjs"));
const SVGPointList_js_1 = __importDefault(require("../svg/SVGPointList.cjs"));
const SVGPreserveAspectRatio_js_1 = __importDefault(require("../svg/SVGPreserveAspectRatio.cjs"));
const SVGRect_js_1 = __importDefault(require("../svg/SVGRect.cjs"));
const SVGStringList_js_1 = __importDefault(require("../svg/SVGStringList.cjs"));
const SVGTransform_js_1 = __importDefault(require("../svg/SVGTransform.cjs"));
const SVGTransformList_js_1 = __importDefault(require("../svg/SVGTransformList.cjs"));
const SVGUnitTypes_js_1 = __importDefault(require("../svg/SVGUnitTypes.cjs"));
const DOMPoint_js_1 = __importDefault(require("../dom/DOMPoint.cjs"));
const SVGAnimatedLengthList_js_1 = __importDefault(require("../svg/SVGAnimatedLengthList.cjs"));
const TIMER = {
    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)
};
const IS_NODE_JS_TIMEOUT_ENVIRONMENT = setTimeout.toString().includes('new Timeout');
/**
 * Class for PerformanceObserverEntryList as it is only available as an interface from Node.js.
 */
class PerformanceObserverEntryList {
    /**
     * Constructor.
     */
    constructor() {
        throw new TypeError('Illegal constructor');
    }
}
/**
 * Zero Timeout.
 */
class Timeout {
    callback;
    /**
     * Constructor.
     * @param callback Callback.
     */
    constructor(callback) {
        this.callback = callback;
    }
}
/**
 * Browser window.
 *
 * Reference:
 * https://developer.mozilla.org/en-US/docs/Web/API/Window.
 */
class BrowserWindow extends EventTarget_js_1.default {
    // Nodes
    Node = Node_js_1.default;
    Attr = Attr_js_1.default;
    ShadowRoot = ShadowRoot_js_1.default;
    ProcessingInstruction = ProcessingInstruction_js_1.default;
    Element = Element_js_1.default;
    CharacterData = CharacterData_js_1.default;
    DocumentType = DocumentType_js_1.default;
    // HTML Element classes
    HTMLAnchorElement = HTMLAnchorElement_js_1.default;
    HTMLButtonElement = HTMLButtonElement_js_1.default;
    HTMLOptGroupElement = HTMLOptGroupElement_js_1.default;
    HTMLOptionElement = HTMLOptionElement_js_1.default;
    HTMLElement = HTMLElement_js_1.default;
    HTMLUnknownElement = HTMLUnknownElement_js_1.default;
    HTMLTemplateElement = HTMLTemplateElement_js_1.default;
    HTMLInputElement = HTMLInputElement_js_1.default;
    HTMLSelectElement = HTMLSelectElement_js_1.default;
    HTMLTextAreaElement = HTMLTextAreaElement_js_1.default;
    HTMLImageElement = HTMLImageElement_js_1.default;
    HTMLStyleElement = HTMLStyleElement_js_1.default;
    HTMLLabelElement = HTMLLabelElement_js_1.default;
    HTMLSlotElement = HTMLSlotElement_js_1.default;
    HTMLMetaElement = HTMLMetaElement_js_1.default;
    HTMLMediaElement = HTMLMediaElement_js_1.default;
    HTMLAudioElement = HTMLAudioElement_js_1.default;
    HTMLVideoElement = HTMLVideoElement_js_1.default;
    HTMLBaseElement = HTMLBaseElement_js_1.default;
    HTMLDialogElement = HTMLDialogElement_js_1.default;
    HTMLScriptElement = HTMLScriptElement_js_1.default;
    HTMLLinkElement = HTMLLinkElement_js_1.default;
    HTMLIFrameElement = HTMLIFrameElement_js_1.default;
    HTMLFormElement = HTMLFormElement_js_1.default;
    HTMLUListElement = HTMLUListElement_js_1.default;
    HTMLTrackElement = HTMLTrackElement_js_1.default;
    HTMLTableRowElement = HTMLTableRowElement_js_1.default;
    HTMLTitleElement = HTMLTitleElement_js_1.default;
    HTMLTimeElement = HTMLTimeElement_js_1.default;
    HTMLTableSectionElement = HTMLTableSectionElement_js_1.default;
    HTMLTableCellElement = HTMLTableCellElement_js_1.default;
    HTMLTableElement = HTMLTableElement_js_1.default;
    HTMLSpanElement = HTMLSpanElement_js_1.default;
    HTMLSourceElement = HTMLSourceElement_js_1.default;
    HTMLQuoteElement = HTMLQuoteElement_js_1.default;
    HTMLProgressElement = HTMLProgressElement_js_1.default;
    HTMLPreElement = HTMLPreElement_js_1.default;
    HTMLPictureElement = HTMLPictureElement_js_1.default;
    HTMLParamElement = HTMLParamElement_js_1.default;
    HTMLParagraphElement = HTMLParagraphElement_js_1.default;
    HTMLOutputElement = HTMLOutputElement_js_1.default;
    HTMLOListElement = HTMLOListElement_js_1.default;
    HTMLObjectElement = HTMLObjectElement_js_1.default;
    HTMLMeterElement = HTMLMeterElement_js_1.default;
    HTMLMenuElement = HTMLMenuElement_js_1.default;
    HTMLMapElement = HTMLMapElement_js_1.default;
    HTMLLIElement = HTMLLIElement_js_1.default;
    HTMLLegendElement = HTMLLegendElement_js_1.default;
    HTMLModElement = HTMLModElement_js_1.default;
    HTMLHtmlElement = HTMLHtmlElement_js_1.default;
    HTMLHRElement = HTMLHRElement_js_1.default;
    HTMLHeadElement = HTMLHeadElement_js_1.default;
    HTMLHeadingElement = HTMLHeadingElement_js_1.default;
    HTMLFieldSetElement = HTMLFieldSetElement_js_1.default;
    HTMLEmbedElement = HTMLEmbedElement_js_1.default;
    HTMLDListElement = HTMLDListElement_js_1.default;
    HTMLDivElement = HTMLDivElement_js_1.default;
    HTMLDetailsElement = HTMLDetailsElement_js_1.default;
    HTMLDataListElement = HTMLDataListElement_js_1.default;
    HTMLDataElement = HTMLDataElement_js_1.default;
    HTMLTableColElement = HTMLTableColElement_js_1.default;
    HTMLTableCaptionElement = HTMLTableCaptionElement_js_1.default;
    HTMLCanvasElement = HTMLCanvasElement_js_1.default;
    HTMLBRElement = HTMLBRElement_js_1.default;
    HTMLBodyElement = HTMLBodyElement_js_1.default;
    HTMLAreaElement = HTMLAreaElement_js_1.default;
    // SVG Element classes
    SVGSVGElement = SVGSVGElement_js_1.default;
    SVGAnimateElement = SVGAnimateElement_js_1.default;
    SVGAnimateMotionElement = SVGAnimateMotionElement_js_1.default;
    SVGAnimateTransformElement = SVGAnimateTransformElement_js_1.default;
    SVGCircleElement = SVGCircleElement_js_1.default;
    SVGClipPathElement = SVGClipPathElement_js_1.default;
    SVGDefsElement = SVGDefsElement_js_1.default;
    SVGDescElement = SVGDescElement_js_1.default;
    SVGEllipseElement = SVGEllipseElement_js_1.default;
    SVGFEBlendElement = SVGFEBlendElement_js_1.default;
    SVGFEColorMatrixElement = SVGFEColorMatrixElement_js_1.default;
    SVGFEComponentTransferElement = SVGFEComponentTransferElement_js_1.default;
    SVGFECompositeElement = SVGFECompositeElement_js_1.default;
    SVGFEConvolveMatrixElement = SVGFEConvolveMatrixElement_js_1.default;
    SVGFEDiffuseLightingElement = SVGFEDiffuseLightingElement_js_1.default;
    SVGFEDisplacementMapElement = SVGFEDisplacementMapElement_js_1.default;
    SVGFEDistantLightElement = SVGFEDistantLightElement_js_1.default;
    SVGFEDropShadowElement = SVGFEDropShadowElement_js_1.default;
    SVGFEFloodElement = SVGFEFloodElement_js_1.default;
    SVGFEFuncAElement = SVGFEFuncAElement_js_1.default;
    SVGFEFuncBElement = SVGFEFuncBElement_js_1.default;
    SVGFEFuncGElement = SVGFEFuncGElement_js_1.default;
    SVGFEFuncRElement = SVGFEFuncRElement_js_1.default;
    SVGFEGaussianBlurElement = SVGFEGaussianBlurElement_js_1.default;
    SVGFEImageElement = SVGFEImageElement_js_1.default;
    SVGFEMergeElement = SVGFEMergeElement_js_1.default;
    SVGFEMergeNodeElement = SVGFEMergeNodeElement_js_1.default;
    SVGFEMorphologyElement = SVGFEMorphologyElement_js_1.default;
    SVGFEOffsetElement = SVGFEOffsetElement_js_1.default;
    SVGFEPointLightElement = SVGFEPointLightElement_js_1.default;
    SVGFESpecularLightingElement = SVGFESpecularLightingElement_js_1.default;
    SVGFESpotLightElement = SVGFESpotLightElement_js_1.default;
    SVGFETileElement = SVGFETileElement_js_1.default;
    SVGFETurbulenceElement = SVGFETurbulenceElement_js_1.default;
    SVGFilterElement = SVGFilterElement_js_1.default;
    SVGForeignObjectElement = SVGForeignObjectElement_js_1.default;
    SVGGElement = SVGGElement_js_1.default;
    SVGImageElement = SVGImageElement_js_1.default;
    SVGLineElement = SVGLineElement_js_1.default;
    SVGLinearGradientElement = SVGLinearGradientElement_js_1.default;
    SVGMarkerElement = SVGMarkerElement_js_1.default;
    SVGMaskElement = SVGMaskElement_js_1.default;
    SVGMetadataElement = SVGMetadataElement_js_1.default;
    SVGMPathElement = SVGMPathElement_js_1.default;
    SVGPathElement = SVGPathElement_js_1.default;
    SVGPatternElement = SVGPatternElement_js_1.default;
    SVGPolygonElement = SVGPolygonElement_js_1.default;
    SVGPolylineElement = SVGPolylineElement_js_1.default;
    SVGRadialGradientElement = SVGRadialGradientElement_js_1.default;
    SVGRectElement = SVGRectElement_js_1.default;
    SVGScriptElement = SVGScriptElement_js_1.default;
    SVGSetElement = SVGSetElement_js_1.default;
    SVGStopElement = SVGStopElement_js_1.default;
    SVGStyleElement = SVGStyleElement_js_1.default;
    SVGSwitchElement = SVGSwitchElement_js_1.default;
    SVGSymbolElement = SVGSymbolElement_js_1.default;
    SVGTextElement = SVGTextElement_js_1.default;
    SVGTextPathElement = SVGTextPathElement_js_1.default;
    SVGTitleElement = SVGTitleElement_js_1.default;
    SVGTSpanElement = SVGTSpanElement_js_1.default;
    SVGUseElement = SVGUseElement_js_1.default;
    SVGViewElement = SVGViewElement_js_1.default;
    // Abstract SVG Element classes
    SVGElement = SVGElement_js_1.default;
    SVGAnimationElement = SVGAnimationElement_js_1.default;
    SVGComponentTransferFunctionElement = SVGComponentTransferFunctionElement_js_1.default;
    SVGGeometryElement = SVGGeometryElement_js_1.default;
    SVGGradientElement = SVGGradientElement_js_1.default;
    SVGTextPositioningElement = SVGTextPositioningElement_js_1.default;
    SVGGraphicsElement = SVGGraphicsElement_js_1.default;
    // Event classes
    Event = Event_js_1.default;
    UIEvent = UIEvent_js_1.default;
    CustomEvent = CustomEvent_js_1.default;
    AnimationEvent = AnimationEvent_js_1.default;
    KeyboardEvent = KeyboardEvent_js_1.default;
    MessageEvent = MessageEvent_js_1.default;
    MouseEvent = MouseEvent_js_1.default;
    PointerEvent = PointerEvent_js_1.default;
    FocusEvent = FocusEvent_js_1.default;
    WheelEvent = WheelEvent_js_1.default;
    InputEvent = InputEvent_js_1.default;
    ErrorEvent = ErrorEvent_js_1.default;
    StorageEvent = StorageEvent_js_1.default;
    SubmitEvent = SubmitEvent_js_1.default;
    ProgressEvent = ProgressEvent_js_1.default;
    MediaQueryListEvent = MediaQueryListEvent_js_1.default;
    HashChangeEvent = HashChangeEvent_js_1.default;
    ClipboardEvent = ClipboardEvent_js_1.default;
    TouchEvent = TouchEvent_js_1.default;
    Touch = Touch_js_1.default;
    // Non-implemented event classes
    AudioProcessingEvent = Event_js_1.default;
    BeforeInputEvent = Event_js_1.default;
    BeforeUnloadEvent = Event_js_1.default;
    BlobEvent = Event_js_1.default;
    CloseEvent = Event_js_1.default;
    CompositionEvent = Event_js_1.default;
    CSSFontFaceLoadEvent = Event_js_1.default;
    DeviceLightEvent = Event_js_1.default;
    DeviceMotionEvent = Event_js_1.default;
    DeviceOrientationEvent = Event_js_1.default;
    DeviceProximityEvent = Event_js_1.default;
    DOMTransactionEvent = Event_js_1.default;
    DragEvent = Event_js_1.default;
    EditingBeforeInputEvent = Event_js_1.default;
    FetchEvent = Event_js_1.default;
    GamepadEvent = Event_js_1.default;
    IDBVersionChangeEvent = Event_js_1.default;
    MediaStreamEvent = Event_js_1.default;
    MutationEvent = Event_js_1.default;
    OfflineAudioCompletionEvent = Event_js_1.default;
    OverconstrainedError = Event_js_1.default;
    PageTransitionEvent = Event_js_1.default;
    PaymentRequestUpdateEvent = Event_js_1.default;
    PopStateEvent = Event_js_1.default;
    RelatedEvent = Event_js_1.default;
    RTCDataChannelEvent = Event_js_1.default;
    RTCIdentityErrorEvent = Event_js_1.default;
    RTCIdentityEvent = Event_js_1.default;
    RTCPeerConnectionIceEvent = Event_js_1.default;
    SensorEvent = Event_js_1.default;
    SVGEvent = Event_js_1.default;
    SVGZoomEvent = Event_js_1.default;
    TimeEvent = Event_js_1.default;
    TrackEvent = Event_js_1.default;
    TransitionEvent = Event_js_1.default;
    UserProximityEvent = Event_js_1.default;
    WebGLContextEvent = Event_js_1.default;
    TextEvent = Event_js_1.default;
    // Other classes that don't have to be bound to the Window context
    Permissions = Permissions_js_1.default;
    History = History_js_1.default;
    Navigator = Navigator_js_1.default;
    Clipboard = Clipboard_js_1.default;
    TimeRanges = TimeRanges_js_1.default;
    TextTrackCueList = TextTrackCueList_js_1.default;
    ValidityState = ValidityState_js_1.default;
    MutationRecord = MutationRecord_js_1.default;
    IntersectionObserver = IntersectionObserver_js_1.default;
    IntersectionObserverEntry = IntersectionObserverEntry_js_1.default;
    CSSStyleDeclaration = CSSStyleDeclaration_js_1.default;
    CSSRule = CSSRule_js_1.default;
    CSSContainerRule = CSSContainerRule_js_1.default;
    CSSFontFaceRule = CSSFontFaceRule_js_1.default;
    CSSKeyframeRule = CSSKeyframeRule_js_1.default;
    CSSKeyframesRule = CSSKeyframesRule_js_1.default;
    CSSMediaRule = CSSMediaRule_js_1.default;
    CSSStyleRule = CSSStyleRule_js_1.default;
    CSSSupportsRule = CSSSupportsRule_js_1.default;
    DOMRect = DOMRect_js_1.default;
    DOMRectReadOnly = DOMRectReadOnly_js_1.default;
    Plugin = Plugin_js_1.default;
    PluginArray = PluginArray_js_1.default;
    Location = Location_js_1.default;
    CustomElementRegistry = CustomElementRegistry_js_1.default;
    ResizeObserver = ResizeObserver_js_1.default;
    URL = URL_js_1.default;
    Blob = Blob_js_1.default;
    File = File_js_1.default;
    Storage = Storage_js_1.default;
    MimeType = MimeType_js_1.default;
    MimeTypeArray = MimeTypeArray_js_1.default;
    NodeFilter = NodeFilter_js_1.default;
    HTMLCollection = HTMLCollection_js_1.default;
    HTMLFormControlCollection = HTMLFormControlsCollection_js_1.default;
    HTMLOptionsCollection = HTMLOptionsCollection_js_1.default;
    NodeList = NodeList_js_1.default;
    RadioNodeList = RadioNodeList_js_1.default;
    FileList = FileList_js_1.default;
    Screen = Screen_js_1.default;
    DOMMatrixReadOnly = DOMMatrixReadOnly_js_1.default;
    DOMMatrix = DOMMatrix_js_1.default;
    SVGAngle = SVGAngle_js_1.default;
    SVGAnimatedAngle = SVGAnimatedAngle_js_1.default;
    SVGAnimatedBoolean = SVGAnimatedBoolean_js_1.default;
    SVGAnimatedEnumeration = SVGAnimatedEnumeration_js_1.default;
    SVGAnimatedInteger = SVGAnimatedInteger_js_1.default;
    SVGAnimatedLength = SVGAnimatedLength_js_1.default;
    SVGAnimatedNumber = SVGAnimatedNumber_js_1.default;
    SVGAnimatedNumberList = SVGAnimatedNumberList_js_1.default;
    SVGAnimatedPreserveAspectRatio = SVGAnimatedPreserveAspectRatio_js_1.default;
    SVGAnimatedRect = SVGAnimatedRect_js_1.default;
    SVGAnimatedString = SVGAnimatedString_js_1.default;
    SVGAnimatedTransformList = SVGAnimatedTransformList_js_1.default;
    SVGLength = SVGLength_js_1.default;
    SVGLengthList = SVGLengthList_js_1.default;
    SVGMatrix = SVGMatrix_js_1.default;
    SVGNumber = SVGNumber_js_1.default;
    SVGNumberList = SVGNumberList_js_1.default;
    SVGPoint = SVGPoint_js_1.default;
    SVGPointList = SVGPointList_js_1.default;
    SVGPreserveAspectRatio = SVGPreserveAspectRatio_js_1.default;
    SVGRect = SVGRect_js_1.default;
    SVGStringList = SVGStringList_js_1.default;
    SVGTransform = SVGTransform_js_1.default;
    SVGTransformList = SVGTransformList_js_1.default;
    SVGAnimatedLengthList = SVGAnimatedLengthList_js_1.default;
    SVGUnitTypes = SVGUnitTypes_js_1.default;
    DOMPoint = DOMPoint_js_1.default;
    Window = this.constructor;
    // Node.js Classes
    URLSearchParams = url_1.URLSearchParams;
    WritableStream = stream_1.default.Writable;
    ReadableStream = web_1.ReadableStream;
    TransformStream = stream_1.default.Transform;
    PerformanceObserver = node_perf_hooks_1.PerformanceObserver;
    PerformanceEntry = node_perf_hooks_1.PerformanceEntry;
    PerformanceObserverEntryList = PerformanceObserverEntryList;
    // Events
    onload = null;
    onerror = null;
    // Public properties.
    document;
    customElements = new CustomElementRegistry_js_1.default(this);
    window = this;
    globalThis = this;
    performance = performance;
    screenLeft = 0;
    screenTop = 0;
    screenX = 0;
    screenY = 0;
    crypto = crypto_1.webcrypto;
    TextEncoder = util_1.TextEncoder;
    TextDecoder = util_1.TextDecoder;
    closed = false;
    console;
    name = '';
    Buffer = buffer_1.Buffer;
    // Public internal properties
    // Used for tracking capture event listeners to improve performance when they are not used.
    // See EventTarget class.
    [PropertySymbol.mutationObservers] = [];
    [PropertySymbol.readyStateManager] = new DocumentReadyStateManager_js_1.default(this);
    [PropertySymbol.location];
    [PropertySymbol.history];
    [PropertySymbol.navigator];
    [PropertySymbol.screen];
    [PropertySymbol.sessionStorage];
    [PropertySymbol.localStorage];
    [PropertySymbol.self] = this;
    [PropertySymbol.top] = this;
    [PropertySymbol.parent] = this;
    [PropertySymbol.window] = this;
    [PropertySymbol.internalId] = -1;
    // Private properties
    #browserFrame;
    #innerWidth = null;
    #innerHeight = null;
    #outerWidth = null;
    #outerHeight = null;
    #devicePixelRatio = null;
    #zeroDelayTimeout = { timeouts: null };
    #timerLoopStacks = [];
    /**
     * Constructor.
     *
     * @param browserFrame Browser frame.
     * @param [options] Options.
     * @param [options.url] URL.
     */
    constructor(browserFrame, options) {
        super();
        this.#browserFrame = browserFrame;
        this.console = browserFrame.page.console;
        this[PropertySymbol.navigator] = new Navigator_js_1.default(this);
        this[PropertySymbol.screen] = new Screen_js_1.default();
        this[PropertySymbol.sessionStorage] = new Storage_js_1.default();
        this[PropertySymbol.localStorage] = new Storage_js_1.default();
        this[PropertySymbol.location] = new Location_js_1.default(this.#browserFrame, options?.url ?? 'about:blank');
        this[PropertySymbol.history] = new History_js_1.default(this.#browserFrame, this);
        WindowBrowserContext_js_1.default.setWindowBrowserFrameRelation(this, this.#browserFrame);
        this[PropertySymbol.setupVMContext]();
        WindowContextClassExtender_js_1.default.extendClasses(this);
        // Document
        this.document = new this.HTMLDocument();
        this.document[PropertySymbol.defaultView] = this;
        // Ready state manager
        this[PropertySymbol.readyStateManager].waitUntilComplete().then(() => {
            this.document[PropertySymbol.readyState] = DocumentReadyStateEnum_js_1.default.complete;
            this.document.dispatchEvent(new Event_js_1.default('readystatechange'));
            // Not sure why target is set to document here, but this is how it works in the browser
            const loadEvent = new Event_js_1.default('load');
            loadEvent[PropertySymbol.currentTarget] = this.document;
            loadEvent[PropertySymbol.target] = this.document;
            loadEvent[PropertySymbol.eventPhase] = EventPhaseEnum_js_1.default.atTarget;
            this.dispatchEvent(loadEvent);
            loadEvent[PropertySymbol.target] = null;
            loadEvent[PropertySymbol.currentTarget] = null;
            loadEvent[PropertySymbol.eventPhase] = EventPhaseEnum_js_1.default.none;
        });
        this[PropertySymbol.bindMethods]();
    }
    /**
     * Returns self.
     *
     * @returns Self.
     */
    get self() {
        return this[PropertySymbol.self];
    }
    /**
     * Returns self.
     *
     * @param self Self.
     */
    set self(self) {
        this[PropertySymbol.self] = self;
    }
    /**
     * Returns top.
     *
     * @returns Top.
     */
    get top() {
        return this[PropertySymbol.top];
    }
    /**
     * Returns parent.
     *
     * @returns Parent.
     */
    get parent() {
        return this[PropertySymbol.parent];
    }
    /**
     * Returns parent.
     *
     * @param parent Parent.
     */
    set parent(parent) {
        this[PropertySymbol.parent] = parent;
    }
    /**
     * Returns location.
     */
    get location() {
        return this[PropertySymbol.location];
    }
    /**
     * Returns location.
     *
     * @param href Href.
     */
    set location(href) {
        this[PropertySymbol.location].href = href;
    }
    /**
     * Returns history.
     */
    get history() {
        return this[PropertySymbol.history];
    }
    /**
     * Returns navigator.
     */
    get navigator() {
        return this[PropertySymbol.navigator];
    }
    /**
     * Returns screen.
     */
    get screen() {
        return this[PropertySymbol.screen];
    }
    /**
     * Returns session storage.
     */
    get sessionStorage() {
        return this[PropertySymbol.sessionStorage];
    }
    /**
     * Returns local storage.
     */
    get localStorage() {
        return this[PropertySymbol.localStorage];
    }
    /**
     * Returns opener.
     *
     * @returns Opener.
     */
    get opener() {
        return this.#browserFrame[PropertySymbol.openerWindow];
    }
    /**
     * The number of pixels that the document is currently scrolled horizontally.
     *
     * @returns Scroll X.
     */
    get scrollX() {
        return this.document?.documentElement?.scrollLeft ?? 0;
    }
    /**
     * The read-only Window property pageXOffset is an alias for scrollX.
     *
     * @returns Scroll X.
     */
    get pageXOffset() {
        return this.scrollX;
    }
    /**
     * The number of pixels that the document is currently scrolled vertically.
     *
     * @returns Scroll Y.
     */
    get scrollY() {
        return this.document?.documentElement?.scrollTop ?? 0;
    }
    /**
     * The read-only Window property pageYOffset is an alias for scrollY.
     *
     * @returns Scroll Y.
     */
    get pageYOffset() {
        return this.scrollY;
    }
    /**
     * The CSS interface holds useful CSS-related methods.
     *
     * @returns CSS interface.
     */
    get CSS() {
        return new CSS_js_1.default();
    }
    /**
     * Returns inner width.
     *
     * @returns Inner width.
     */
    get innerWidth() {
        if (this.#innerWidth === null) {
            return this.#browserFrame.page.viewport.width;
        }
        return this.#innerWidth;
    }
    /**
     * Sets inner width.
     *
     * @param value Inner width.
     */
    set innerWidth(value) {
        this.#innerWidth = value;
    }
    /**
     * Returns inner height.
     *
     * @returns Inner height.
     */
    get innerHeight() {
        // It seems like this value can be defined according to spec, but changing it has no effect on the actual viewport.
        if (this.#innerHeight === null) {
            return this.#browserFrame.page.viewport.height;
        }
        return this.#innerHeight;
    }
    /**
     * Sets inner height.
     *
     * @param value Inner height.
     */
    set innerHeight(value) {
        this.#innerHeight = value;
    }
    /**
     * Returns outer width.
     *
     * @returns Outer width.
     */
    get outerWidth() {
        // It seems like this value can be defined according to spec, but changing it has no effect on the actual viewport.
        if (this.#outerWidth === null) {
            return this.#browserFrame.page.viewport.width;
        }
        return this.#outerWidth;
    }
    /**
     * Sets outer width.
     *
     * @param value Outer width.
     */
    set outerWidth(value) {
        this.#outerWidth = value;
    }
    /**
     * Returns outer height.
     *
     * @returns Outer height.
     */
    get outerHeight() {
        if (this.#outerHeight === null) {
            return this.#browserFrame.page.viewport.height;
        }
        return this.#outerHeight;
    }
    /**
     * Sets outer height.
     *
     * @param value Outer height.
     */
    set outerHeight(value) {
        this.#outerHeight = value;
    }
    /**
     * Returns device pixel ratio.
     *
     * @returns Device pixel ratio.
     */
    get devicePixelRatio() {
        // It seems like this value can be defined according to spec, but changing it has no effect on the actual viewport.
        if (this.#devicePixelRatio === null) {
            return this.#browserFrame.page.viewport.devicePixelRatio;
        }
        return this.#devicePixelRatio;
    }
    /**
     * Sets device pixel ratio.
     *
     * @param value Device pixel ratio.
     */
    set devicePixelRatio(value) {
        this.#devicePixelRatio = value;
    }
    /**
     * Returns an object containing the values of all CSS properties of an element.
     *
     * @param element Element.
     * @returns CSS style declaration.
     */
    getComputedStyle(element) {
        element[PropertySymbol.computedStyle] =
            element[PropertySymbol.computedStyle] ||
                new CSSStyleDeclaration_js_1.default(PropertySymbol.illegalConstructor, this, { element, computed: true });
        return element[PropertySymbol.computedStyle];
    }
    /**
     * Returns selection.
     *
     * @returns Selection.
     */
    getSelection() {
        return this.document.getSelection();
    }
    /**
     * Scrolls to a particular set of coordinates.
     *
     * @param x X position or options object.
     * @param y Y position.
     */
    scroll(x, y) {
        if (typeof x === 'object') {
            if (x.behavior === 'smooth') {
                this.setTimeout(() => {
                    if (x.top !== undefined) {
                        this.document.documentElement.scrollTop = x.top;
                    }
                    if (x.left !== undefined) {
                        this.document.documentElement.scrollLeft = x.left;
                    }
                });
            }
            else {
                if (x.top !== undefined) {
                    this.document.documentElement.scrollTop = x.top;
                }
                if (x.left !== undefined) {
                    this.document.documentElement.scrollLeft = x.left;
                }
            }
        }
        else if (x !== undefined && y !== undefined) {
            this.document.documentElement.scrollLeft = x;
            this.document.documentElement.scrollTop = y;
        }
    }
    /**
     * Scrolls to a particular set of coordinates.
     *
     * @param x X position or options object.
     * @param y Y position.
     */
    scrollTo(x, y) {
        this.scroll(x, y);
    }
    /**
     * Shifts focus away from the window.
     */
    blur() {
        // TODO: Implement.
    }
    /**
     * Gives focus to the window.
     */
    focus() {
        // TODO: Implement.
    }
    /**
     * Loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name.
     *
     * @param [url] URL.
     * @param [target] Target.
     * @param [features] Window features.
     * @returns Window.
     */
    open(url, target, features) {
        return WindowPageOpenUtility_js_1.default.openPage(this.#browserFrame, {
            url,
            target,
            features
        });
    }
    /**
     * Closes the window.
     */
    close() {
        // When using a Window instance directly, the Window instance is the main frame and we will close the page and destroy the browser.
        // When using the Browser API we should only close the page when the Window instance is connected to the main frame (we should not close child frames such as iframes).
        if (this.#browserFrame.page?.mainFrame === this.#browserFrame) {
            this[PropertySymbol.destroy]();
            this.#browserFrame.page.close();
        }
    }
    /**
     * Returns a new MediaQueryList object that can then be used to determine if the document matches the media query string.
     *
     * @param mediaQueryString A string specifying the media query to parse into a MediaQueryList.
     * @returns A new MediaQueryList.
     */
    matchMedia(mediaQueryString) {
        return new MediaQueryList_js_1.default({ window: this, media: mediaQueryString });
    }
    /**
     * Sets a timer which executes a function once the timer expires.
     *
     * @param callback Function to be executed.
     * @param [delay=0] Delay in ms.
     * @param args Arguments passed to the callback function.
     * @returns Timeout ID.
     */
    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;
            if (timerLoopStacks.includes(stack)) {
                return;
            }
            timerLoopStacks.push(stack);
        }
        // We can group timeouts with a delay of 0 into one timeout to improve performance.
        // Grouping timeouts will also improve the performance of the async task manager.
        // It also makes the async task manager more stable as many timeouts may cause waitUntilComplete() to be resolved too early.
        if (!delay) {
            const zeroDelayTimeout = this.#zeroDelayTimeout;
            if (!zeroDelayTimeout.timeouts) {
                const useTryCatch = !settings ||
                    (!settings.disableErrorCapturing &&
                        settings.errorCapture === BrowserErrorCaptureEnum_js_1.default.tryAndCatch);
                const id = TIMER.setTimeout(() => {
                    // We need to call endTimer() before the callback as the callback might throw an error.
                    this.#browserFrame[PropertySymbol.asyncTaskManager].endTimer(id);
                    const timeouts = zeroDelayTimeout.timeouts;
                    zeroDelayTimeout.timeouts = null;
                    for (const timeout of timeouts) {
                        if (useTryCatch) {
                            WindowErrorUtility_js_1.default.captureError(this, () => timeout.callback());
                        }
                        else {
                            timeout.callback();
                        }
                    }
                });
                zeroDelayTimeout.timeouts = [];
                this.#browserFrame[PropertySymbol.asyncTaskManager].startTimer(id);
            }
            const timeout = new Timeout(() => callback(...args));
            zeroDelayTimeout.timeouts.push(timeout);
            return timeout;
        }
        const useTryCatch = !settings ||
            (!settings.disableErrorCapturing &&
                settings.errorCapture === BrowserErrorCaptureEnum_js_1.default.tryAndCatch);
        const id = TIMER.setTimeout(() => {
            // We need to call endTimer() before the callback as the callback might throw an error.
            this.#browserFrame[PropertySymbol.asyncTaskManager].endTimer(id);
            if (useTryCatch) {
                WindowErrorUtility_js_1.default.captureError(this, () => callback(...args));
            }
            else {
                callback(...args);
            }
        }, settings?.timer.maxTimeout !== -1 && delay && delay > settings?.timer.maxTimeout
            ? settings?.timer.maxTimeout
            : delay);
        this.#browserFrame[PropertySymbol.asyncTaskManager].startTimer(id);
        return id;
    }
    /**
     * Cancels a timeout previously established by calling setTimeout().
     *
     * @param id ID of the timeout.
     */
    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;
        }
        // We need to make sure that the ID is a Timeout object, otherwise Node.js might throw an error.
        // This is only necessary if we are in a Node.js environment.
        if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== 'Timeout')) {
            return;
        }
        TIMER.clearTimeout(id);
        this.#browserFrame[PropertySymbol.asyncTaskManager].endTimer(id);
    }
    /**
     * Calls a function with a fixed time delay between each call.
     *
     * @param callback Function to be executed.
     * @param [delay=0] Delay in ms.
     * @param args Arguments passed to the callback function.
     * @returns Interval 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_js_1.default.tryAndCatch);
        let iterations = 0;
        const id = TIMER.setInterval(() => {
            if (useTryCatch) {
                WindowErrorUtility_js_1.default.captureError(this, () => callback(...args), () => this.clearInterval(id));
            }
            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[PropertySymbol.asyncTaskManager].startTimer(id);
        return id;
    }
    /**
     * Cancels a timed repeating action which was previously established by a call to setInterval().
     *
     * @param id ID of the interval.
     */
    clearInterval(id) {
        // We need to make sure that the ID is a Timeout object, otherwise Node.js might throw an error.
        // This is only necessary if we are in a Node.js environment.
        if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== 'Timeout')) {
            return;
        }
        TIMER.clearInterval(id);
        this.#browserFrame[PropertySymbol.asyncTaskManager].endTimer(id);
    }
    /**
     * Mock animation frames with timeouts.
     *
     * @param callback Callback.
     * @returns 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;
            if (timerLoopStacks.includes(stack)) {
                return;
            }
            timerLoopStacks.push(stack);
        }
        const useTryCatch = !settings ||
            (!settings.disableErrorCapturing &&
                settings.errorCapture === BrowserErrorCaptureEnum_js_1.default.tryAndCatch);
        const id = TIMER.setImmediate(() => {
            // We need to call endImmediate() before the callback as the callback might throw an error.
            this.#browserFrame[PropertySymbol.asyncTaskManager].endImmediate(id);
            if (useTryCatch) {
                WindowErrorUtility_js_1.default.captureError(this, () => callback(this.performance.now()));
            }
            else {
                callback(this.performance.now());
            }
        });
        this.#browserFrame[PropertySymbol.asyncTaskManager].startImmediate(id);
        return id;
    }
    /**
     * Mock animation frames with timeouts.
     *
     * @param id ID.
     */
    cancelAnimationFrame(id) {
        // We need to make sure that the ID is an Immediate object, otherwise Node.js might throw an error.
        // This is only necessary if we are in a Node.js environment.
        if (IS_NODE_JS_TIMEOUT_ENVIRONMENT && (!id || id.constructor.name !== 'Immediate')) {
            return;
        }
        TIMER.clearImmediate(id);
        this.#browserFrame[PropertySymbol.asyncTaskManager].endImmediate(id);
    }
    /**
     * Queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.
     *
     * @param callback Function to be executed.
     */
    queueMicrotask(callback) {
        if (this.closed) {
            return;
        }
        let isAborted = false;
        const taskId = this.#browserFrame[PropertySymbol.asyncTaskManager].startTask(() => (isAborted = true));
        const settings = this.#browserFrame.page?.context?.browser?.settings;
        const useTryCatch = !settings ||
            (!settings.disableErrorCapturing &&
                settings.errorCapture === BrowserErrorCaptureEnum_js_1.default.tryAndCatch);
        TIMER.queueMicrotask(() => {
            if (!isAborted) {
                // We need to call endTask() before the callback as the callback might throw an error.
                this.#browserFrame[PropertySymbol.asyncTaskManager].endTask(taskId);
                if (useTryCatch) {
                    WindowErrorUtility_js_1.default.captureError(this, callback);
                }
                else {
                    callback();
                }
            }
        });
    }
    /**
     * This method provides an easy, logical way to fetch resources asynchronously across the network.
     *
     * @param url URL.
     * @param [init] Init.
     * @returns Promise.
     */
    async fetch(url, init) {
        if (this.closed) {
            return Promise.reject(new this.DOMException("Failed to execute 'fetch' on 'Window': The window is closed.", DOMExceptionNameEnum_js_1.default.invalidStateError));
        }
        return await new Fetch_js_1.default({
            browserFrame: this.#browserFrame,
            window: this,
            url,
            init
        }).send();
    }
    /**
     * Creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/btoa
     * @param data Binay data.
     * @returns Base64-encoded string.
     */
    btoa(data) {
        return Base64_js_1.default.btoa(data);
    }
    /**
     * Decodes a string of data which has been encoded using Base64 encoding.
     *
     * @see https://developer.mozilla.org/en-US/docs/Web/API/atob
     * @see https://infra.spec.whatwg.org/#forgiving-base64-encode.
     * @see Https://html.spec.whatwg.org/multipage/webappapis.html#btoa.
     * @param data Binay string.
     * @returns An ASCII string containing decoded data from encodedData.
     */
    atob(data) {
        return Base64_js_1.default.atob(data);
    }
    /**
     * Safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.
     *
     * @param message Message.
     * @param [targetOrigin=*] Target origin.
     * @param _transfer Transfer. Not implemented.
     */
    postMessage(message, targetOrigin = '*', _transfer) {
        // TODO: Implement 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_js_1.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_js_1.default.invalidStateError);
        }
        this.setTimeout(() => this.dispatchEvent(new MessageEvent_js_1.default('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: ''
        })));
    }
    /**
     * Resizes the window.
     *
     * @param width Width.
     * @param height Height.
     */
    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.`);
        }
        // We can only resize the window if it is a popup.
        if (this.#browserFrame[PropertySymbol.popup]) {
            this.#browserFrame.page.setViewport({ width, height });
        }
    }
    /**
     * Resizes the current window by a specified amount.
     *
     * @param width Width.
     * @param height 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.`);
        }
        // We can only resize the window if it is a popup.
        if (this.#browserFrame[PropertySymbol.popup]) {
            const viewport = this.#browserFrame.page.viewport;
            this.#browserFrame.page.setViewport({
                width: viewport.width + width,
                height: viewport.height + height
            });
        }
    }
    /**
     * Setup of VM context.
     */
    [PropertySymbol.setupVMContext]() {
        if (!vm_1.default.isContext(this)) {
            vm_1.default.createContext(this);
            // Sets global properties from the VM to the Window object.
            // Otherwise "this.Array" will be undefined for example.
            VMGlobalPropertyScript_js_1.default.runInContext(this);
        }
    }
    /**
     * Destroys the window.
     */
    [PropertySymbol.destroy]() {
        if (this.closed) {
            return;
        }
        this.closed = true;
        const mutationObservers = this[PropertySymbol.mutationObservers];
        for (const mutationObserver of mutationObservers) {
            if (mutationObserver[PropertySymbol.destroy]) {
                mutationObserver[PropertySymbol.destroy]();
            }
        }
        this[PropertySymbol.mutationObservers] = [];
        this[PropertySymbol.asyncTaskManager] = null;
        this[PropertySymbol.mutationObservers] = [];
        // Disconnects nodes from the document, so that they can be garbage collected.
        const childNodes = this.document[PropertySymbol.nodeArray];
        while (childNodes.length > 0) {
            // Makes sure that something won't be triggered by the disconnect.
            if (childNodes[0].disconnectedCallback) {
                delete childNodes[0].disconnectedCallback;
            }
            this.document.removeChild(childNodes[0]);
        }
        // Create some empty elements for scripts that are still running.
        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[PropertySymbol.destroy]) {
            this.location[PropertySymbol.destroy]();
        }
        if (this.customElements[PropertySymbol.destroy]) {
            this.customElements[PropertySymbol.destroy]();
        }
        if (this.history[PropertySymbol.destroy]) {
            this.history[PropertySymbol.destroy]();
        }
        this.document[PropertySymbol.activeElement] = null;
        this.document[PropertySymbol.nextActiveElement] = null;
        this.document[PropertySymbol.currentScript] = null;
        this.document[PropertySymbol.selection] = null;
        WindowBrowserContext_js_1.default.removeWindowBrowserFrameRelation(this);
    }
    /**
     * Binds methods to a window as scope.
     */
    [PropertySymbol.bindMethods]() {
        for (const _class of [BrowserWindow, EventTarget_js_1.default]) {
            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)
                    });
                }
            }
        }
    }
}
exports.default = BrowserWindow;
//# sourceMappingURL=BrowserWindow.cjs.map