import StyleObserver from 'style-observer';
export class ThemeObserver {
    constructor(host, callback) {
        this.host = host;
        this.callback = callback;
    }
    connect() {
        this.observer = new StyleObserver(records => {
            const theme = records?.[0]?.value?.replaceAll(`'`, '');
            if (!theme)
                return;
            this.callback(theme);
        });
        this.observer.observe(this.host, '--sd-theme');
    }
    disconnect() {
        this.observer?.unobserve(this.host);
    }
}
