import { Observable } from 'rxjs';
import * as i0 from '@angular/core';
import { EventEmitter } from '@angular/core';

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
/** */
interface ThemeDescription {
    name: string;
    groups: ThemePropertyGroup[];
}
interface ThemePropertyGroup {
    name: string;
    description?: string;
    properties: ThemeProperty[];
}
interface ThemeProperty {
    name: string;
    usage: string;
    type: ThemePropertyType;
}
type ThemePropertyType = 'color' | 'gradient' | 'font' | 'url' | 'text' | 'number';
interface Theme {
    name: string;
    schemes: ThemeColorSchemes;
    /**
     * A map of icons that overrides the default Element icons.
     * The key must be the key of the original icon that should be overridden.
     * The value has to be a data SVG string.
     *
     * @example
     * ```ts
     * {
     *   elementUser: "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>...</svg>"
     * }
     * ```
     *
     * @experimental
     */
    icons?: Record<string, string>;
}
interface ThemeColorSchemes {
    light?: ThemeColorScheme;
    dark?: ThemeColorScheme;
}
type ThemeColorScheme = {
    [key: string]: string;
};
type ThemeType = 'dark' | 'light' | 'auto';
declare const ELEMENT_THEME_NAME = "element";
declare const elementTheme: ThemeDescription;

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

/**
 * SiThemeStore object is used by the theme service to load and
 * store the themes. You can inject your own implementation to provide
 * a backend implementation. Otherwise a localStorage based implementation
 * is used.
 */
declare abstract class SiThemeStore {
    /**
     * Load and return an alternative custom theme, other then
     * the default element theme. This method is invoked initially
     * to check for an alternative custom theme.
     * @returns The active theme to be used, or undefined if the
     * default element theme shall be used. All wrapped in an observable
     * that can also emit errors.
     */
    abstract loadActiveTheme(): Observable<Theme | undefined>;
    /**
     * Sets the theme with the given name to active.
     * @param name - The name of the theme to become active.
     * @returns True on success, otherwise false.
     */
    abstract activateTheme(name: string): Observable<boolean>;
    /**
     * Deactivate any active theme and makes the element theme the default one.
     * @returns True on success, otherwise false.
     */
    abstract deactivateTheme(): Observable<boolean>;
    /**
     * Load and return the available theme names.
     * @returns An `Observable` of available theme names, other than the
     * default element theme.
     */
    abstract loadThemeNames(): Observable<string[]>;
    /**
     * Load theme with the given `name`.
     * @param name - The name of the theme to be returned.
     * @returns Observable with the named theme or `undefined` if no such theme exist.
     */
    abstract loadTheme(name: string): Observable<Theme | undefined>;
    /**
     * Saves a theme to the store. The name shall not be empty. A theme with
     * identical name gets overwritten.
     * @param theme - The theme to be saved.
     * @returns True on success, otherwise false. All nicely wrapped in
     * an observable that may also emit errors.
     */
    abstract saveTheme(theme: Theme): Observable<boolean>;
    /**
     * Deletes the theme with the given name from the store.
     * @param name - The name of the theme to be deleted.
     * @returns True on success, otherwise false. All nicely wrapped in
     * an observable that may also emit errors. Returns false,
     * if the theme does not exist.
     */
    abstract deleteTheme(name: string): Observable<boolean>;
}
declare const SI_THEME_LOCAL_STORAGE_KEY = "si-themes";
interface ThemeStorage {
    activeTheme: string | undefined;
    themes: {
        [key: string]: Theme;
    };
}
declare class SiDefaultThemeStore extends SiThemeStore {
    private isBrowser;
    constructor(isBrowser: boolean);
    loadActiveTheme(): Observable<Theme | undefined>;
    activateTheme(name: string): Observable<boolean>;
    deactivateTheme(): Observable<boolean>;
    loadThemeNames(): Observable<string[]>;
    saveTheme(theme: Theme): Observable<boolean>;
    loadTheme(name: string): Observable<Theme | undefined>;
    deleteTheme(name: string): Observable<boolean>;
    private loadStore;
    private saveStore;
}

declare class SiThemeService {
    /**
     * The current color scheme. (e.g. light or dark).
     */
    private _resolvedColorScheme;
    private resolvedColorSchemeSub;
    /**
     * Emits events when the color scheme changes.
     *
     * @defaultValue this.resolvedColorSchemeSub.asObservable()
     */
    readonly resolvedColorScheme$: Observable<keyof ThemeColorSchemes>;
    /**
     * The current color scheme. (e.g. light or dark).
     */
    get resolvedColorScheme(): ThemeType | undefined;
    /**
     * All available theme names, including element theme name.
     */
    private _themeNames;
    private themeNamesSub;
    /**
     * Emits events when the list of available theme names changes.
     *
     * @defaultValue this.themeNamesSub.asObservable()
     */
    readonly themeNames$: Observable<string[]>;
    /**
     * All available theme names, including element theme name.
     */
    get themeNames(): string[];
    /**
     * Emits events when the currently applied theme changes. Either by
     * changing to another theme or by re-applying a theme with updated
     * properties. When switching to default theme element, `undefined`
     * is emitted.
     */
    readonly themeChange: EventEmitter<Theme | undefined>;
    /**
     * The name of the theme that is active. Theme name `element` is the default.
     */
    activeThemeName?: string;
    /**
     * Icon overrides by the currently activeTheme.
     * @defaultValue
     * ```
     * {}
     * ```
     */
    readonly themeIcons: i0.WritableSignal<Record<string, string>>;
    private themes;
    private darkMediaQuery?;
    private mediaQueryListener?;
    private isBrowser;
    private previewTheme?;
    private themeStore;
    private meta;
    private document;
    constructor();
    /**
     * Returns `true` if a theme with the given name is available.
     */
    hasTheme(name: string): boolean;
    /**
     * Returns a clone of the theme with the given name or `undefined` if not
     * available or name is `element`.
     * @param name - The name of the theme to be returned.
     * @returns The theme with the given name and `undefined` if name is `element`.
     */
    getTheme(name: string): Observable<Theme | undefined>;
    /**
     * Loads and returns the currently active theme. Returns undefined if no custom theme is used.
     * @returns A custom theme or `undefined` if the default element theme is used.
     */
    getActiveTheme(): Observable<Theme | undefined>;
    /**
     * Adds or updates the given theme in the theme store.
     * @param theme - The theme to be saved.
     * @returns `true` if the theme was saved successfully.
     */
    addOrUpdateTheme(theme: Theme): Observable<boolean>;
    /**
     * Deletes the theme with the given name from the theme store.
     */
    deleteTheme(name: string): Observable<boolean>;
    /**
     * Resets the preview theme to the default element theme.
     */
    resetPreview(): void;
    /**
     * Sets the active theme to the given name. If no name is given, the default element theme is used.
     */
    setActiveTheme(name?: string, type?: ThemeType): Observable<boolean>;
    /**
     * Apply `light` or `dark` theme to the document.
     */
    applyThemeType(type: ThemeType): void;
    /**
     * Applies the given theme to the document. If no theme is given, the active theme is applied.
     */
    applyTheme(theme?: Theme, type?: ThemeType, overwrite?: boolean): void;
    /**
     * Updates the given property of the preview theme.
     */
    updateProperty(name: string, value: string, type: keyof ThemeColorSchemes): void;
    /**
     * Checks if the given theme JSON object is a valid theme.
     */
    isThemeValid(data: unknown): boolean;
    private isThemeTypeValid;
    private applyThemeStyle;
    private activateTheme;
    private hasThemeCSS;
    private createThemeCSS;
    private createThemeVariantCSS;
    private removeThemeCSS;
    private toggleDark;
    private cloneTheme;
    private dispatchThemeSwitchEvent;
    static ɵfac: i0.ɵɵFactoryDeclaration<SiThemeService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<SiThemeService>;
}

export { ELEMENT_THEME_NAME, SI_THEME_LOCAL_STORAGE_KEY, SiDefaultThemeStore, SiThemeService, SiThemeStore, elementTheme };
export type { Theme, ThemeColorScheme, ThemeColorSchemes, ThemeDescription, ThemeProperty, ThemePropertyGroup, ThemePropertyType, ThemeStorage, ThemeType };
