/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { inject, Inject, Injectable } from '@angular/core'; import { BreakpointObserver } from '@angular/cdk/layout'; import { Platform } from '@angular/cdk/platform'; import { DOCUMENT } from '@angular/common'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/platform"; /** CSS class applied to the document body when in black-on-white high-contrast mode. */ export const BLACK_ON_WHITE_CSS_CLASS = 'cdk-high-contrast-black-on-white'; /** CSS class applied to the document body when in white-on-black high-contrast mode. */ export const WHITE_ON_BLACK_CSS_CLASS = 'cdk-high-contrast-white-on-black'; /** CSS class applied to the document body when in high-contrast mode. */ export const HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS = 'cdk-high-contrast-active'; /** * Service to determine whether the browser is currently in a high-contrast-mode environment. * * Microsoft Windows supports an accessibility feature called "High Contrast Mode". This mode * changes the appearance of all applications, including web applications, to dramatically increase * contrast. * * IE, Edge, and Firefox currently support this mode. Chrome does not support Windows High Contrast * Mode. This service does not detect high-contrast mode as added by the Chrome "High Contrast" * browser extension. */ export class HighContrastModeDetector { constructor(_platform, document) { this._platform = _platform; this._document = document; this._breakpointSubscription = inject(BreakpointObserver) .observe('(forced-colors: active)') .subscribe(() => { if (this._hasCheckedHighContrastMode) { this._hasCheckedHighContrastMode = false; this._applyBodyHighContrastModeCssClasses(); } }); } /** Gets the current high-contrast-mode for the page. */ getHighContrastMode() { if (!this._platform.isBrowser) { return 0 /* HighContrastMode.NONE */; } // Create a test element with an arbitrary background-color that is neither black nor // white; high-contrast mode will coerce the color to either black or white. Also ensure that // appending the test element to the DOM does not affect layout by absolutely positioning it const testElement = this._document.createElement('div'); testElement.style.backgroundColor = 'rgb(1,2,3)'; testElement.style.position = 'absolute'; this._document.body.appendChild(testElement); // Get the computed style for the background color, collapsing spaces to normalize between // browsers. Once we get this color, we no longer need the test element. Access the `window` // via the document so we can fake it in tests. Note that we have extra null checks, because // this logic will likely run during app bootstrap and throwing can break the entire app. const documentWindow = this._document.defaultView || window; const computedStyle = documentWindow && documentWindow.getComputedStyle ? documentWindow.getComputedStyle(testElement) : null; const computedColor = ((computedStyle && computedStyle.backgroundColor) || '').replace(/ /g, ''); testElement.remove(); switch (computedColor) { // Pre Windows 11 dark theme. case 'rgb(0,0,0)': // Windows 11 dark themes. case 'rgb(45,50,54)': case 'rgb(32,32,32)': return 2 /* HighContrastMode.WHITE_ON_BLACK */; // Pre Windows 11 light theme. case 'rgb(255,255,255)': // Windows 11 light theme. case 'rgb(255,250,239)': return 1 /* HighContrastMode.BLACK_ON_WHITE */; } return 0 /* HighContrastMode.NONE */; } ngOnDestroy() { this._breakpointSubscription.unsubscribe(); } /** Applies CSS classes indicating high-contrast mode to document body (browser-only). */ _applyBodyHighContrastModeCssClasses() { if (!this._hasCheckedHighContrastMode && this._platform.isBrowser && this._document.body) { const bodyClasses = this._document.body.classList; bodyClasses.remove(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, BLACK_ON_WHITE_CSS_CLASS, WHITE_ON_BLACK_CSS_CLASS); this._hasCheckedHighContrastMode = true; const mode = this.getHighContrastMode(); if (mode === 1 /* HighContrastMode.BLACK_ON_WHITE */) { bodyClasses.add(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, BLACK_ON_WHITE_CSS_CLASS); } else if (mode === 2 /* HighContrastMode.WHITE_ON_BLACK */) { bodyClasses.add(HIGH_CONTRAST_MODE_ACTIVE_CSS_CLASS, WHITE_ON_BLACK_CSS_CLASS); } } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: HighContrastModeDetector, deps: [{ token: i1.Platform }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: HighContrastModeDetector, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: HighContrastModeDetector, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: i1.Platform }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGlnaC1jb250cmFzdC1tb2RlLWRldGVjdG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9hMTF5L2hpZ2gtY29udHJhc3QtbW9kZS9oaWdoLWNvbnRyYXN0LW1vZGUtZGV0ZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFZLE1BQU0sZUFBZSxDQUFDO0FBQ3BFLE9BQU8sRUFBQyxrQkFBa0IsRUFBQyxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUMvQyxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0saUJBQWlCLENBQUM7OztBQVV6Qyx3RkFBd0Y7QUFDeEYsTUFBTSxDQUFDLE1BQU0sd0JBQXdCLEdBQUcsa0NBQWtDLENBQUM7QUFFM0Usd0ZBQXdGO0FBQ3hGLE1BQU0sQ0FBQyxNQUFNLHdCQUF3QixHQUFHLGtDQUFrQyxDQUFDO0FBRTNFLHlFQUF5RTtBQUN6RSxNQUFNLENBQUMsTUFBTSxtQ0FBbUMsR0FBRywwQkFBMEIsQ0FBQztBQUU5RTs7Ozs7Ozs7OztHQVVHO0FBRUgsTUFBTSxPQUFPLHdCQUF3QjtJQVNuQyxZQUFvQixTQUFtQixFQUFvQixRQUFhO1FBQXBELGNBQVMsR0FBVCxTQUF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