/** * @license Angular v19.2.13 * (c) 2010-2025 Google LLC. https://angular.io/ * License: MIT */ import { isPlatformServer, DOCUMENT, ɵgetDOM as _getDOM } from '@angular/common'; import * as i0 from '@angular/core'; import { InjectionToken, ɵRuntimeError as _RuntimeError, Inject, Injectable, APP_ID, CSP_NONCE, PLATFORM_ID, Optional, ViewEncapsulation, ɵTracingService as _TracingService, RendererStyleFlags2 } from '@angular/core'; /** * The injection token for plugins of the `EventManager` service. * * @publicApi */ const EVENT_MANAGER_PLUGINS = new InjectionToken(ngDevMode ? 'EventManagerPlugins' : ''); /** * An injectable service that provides event management for Angular * through a browser plug-in. * * @publicApi */ class EventManager { _zone; _plugins; _eventNameToPlugin = new Map(); /** * Initializes an instance of the event-manager service. */ constructor(plugins, _zone) { this._zone = _zone; plugins.forEach((plugin) => { plugin.manager = this; }); this._plugins = plugins.slice().reverse(); } /** * Registers a handler for a specific element and event. * * @param element The HTML element to receive event notifications. * @param eventName The name of the event to listen for. * @param handler A function to call when the notification occurs. Receives the * event object as an argument. * @param options Options that configure how the event listener is bound. * @returns A callback function that can be used to remove the handler. */ addEventListener(element, eventName, handler, options) { const plugin = this._findPluginFor(eventName); return plugin.addEventListener(element, eventName, handler, options); } /** * Retrieves the compilation zone in which event listeners are registered. */ getZone() { return this._zone; } /** @internal */ _findPluginFor(eventName) { let plugin = this._eventNameToPlugin.get(eventName); if (plugin) { return plugin; } const plugins = this._plugins; plugin = plugins.find((plugin) => plugin.supports(eventName)); if (!plugin) { throw new _RuntimeError(5101 /* RuntimeErrorCode.NO_PLUGIN_FOR_EVENT */, (typeof ngDevMode === 'undefined' || ngDevMode) && `No event manager plugin found for event ${eventName}`); } this._eventNameToPlugin.set(eventName, plugin); return plugin; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: EventManager, deps: [{ token: EVENT_MANAGER_PLUGINS }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: EventManager }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: EventManager, decorators: [{ type: Injectable }], ctorParameters: () => [{ type: undefined, decorators: [{ type: Inject, args: [EVENT_MANAGER_PLUGINS] }] }, { type: i0.NgZone }] }); /** * The plugin definition for the `EventManager` class * * It can be used as a base class to create custom manager plugins, i.e. you can create your own * class that extends the `EventManagerPlugin` one. * * @publicApi */ class EventManagerPlugin { _doc; // TODO: remove (has some usage in G3) constructor(_doc) { this._doc = _doc; } // Using non-null assertion because it's set by EventManager's constructor manager; } /** The style elements attribute name used to set value of `APP_ID` token. */ const APP_ID_ATTRIBUTE_NAME = 'ng-app-id'; /** * Removes all provided elements from the document. * @param elements An array of HTML Elements. */ function removeElements(elements) { for (const element of elements) { element.remove(); } } /** * Creates a `style` element with the provided inline style content. * @param style A string of the inline style content. * @param doc A DOM Document to use to create the element. * @returns An HTMLStyleElement instance. */ function createStyleElement(style, doc) { const styleElement = doc.createElement('style'); styleElement.textContent = style; return styleElement; } /** * Searches a DOM document's head element for style elements with a matching application * identifier attribute (`ng-app-id`) to the provide identifier and adds usage records for each. * @param doc An HTML DOM document instance. * @param appId A string containing an Angular application identifer. * @param inline A Map object for tracking inline (defined via `styles` in component decorator) style usage. * @param external A Map object for tracking external (defined via `styleUrls` in component decorator) style usage. */ function addServerStyles(doc, appId, inline, external) { const elements = doc.head?.querySelectorAll(`style[${APP_ID_ATTRIBUTE_NAME}="${appId}"],link[${APP_ID_ATTRIBUTE_NAME}="${appId}"]`); if (elements) { for (const styleElement of elements) { styleElement.removeAttribute(APP_ID_ATTRIBUTE_NAME); if (styleElement instanceof HTMLLinkElement) { // Only use filename from href // The href is build time generated with a unique value to prevent duplicates. external.set(styleElement.href.slice(styleElement.href.lastIndexOf('/') + 1), { usage: 0, elements: [styleElement], }); } else if (styleElement.textContent) { inline.set(styleElement.textContent, { usage: 0, elements: [styleElement] }); } } } } /** * Creates a `link` element for the provided external style URL. * @param url A string of the URL for the stylesheet. * @param doc A DOM Document to use to create the element. * @returns An HTMLLinkElement instance. */ function createLinkElement(url, doc) { const linkElement = doc.createElement('link'); linkElement.setAttribute('rel', 'stylesheet'); linkElement.setAttribute('href', url); return linkElement; } class SharedStylesHost { doc; appId; nonce; /** * Provides usage information for active inline style content and associated HTML