import { DestroyRef, Injectable, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { BehaviorSubject, fromEvent } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, tap } from 'rxjs/operators';
import * as i0 from "@angular/core";
export class ScreenSizeService {
    constructor() {
        this.destroyRef = inject(DestroyRef);
        this.screenSizeSubject = new BehaviorSubject(this.getScreenSize());
        this.screenSize$ = this.screenSizeSubject.asObservable();
        fromEvent(window, 'resize')
            .pipe(distinctUntilChanged(), debounceTime(200), map(() => this.getScreenSize()), startWith(this.getScreenSize()), tap(() => console.log('test updated')), takeUntilDestroyed(this.destroyRef))
            .subscribe(this.screenSizeSubject);
    }
    getScreenSize() {
        const width = window.innerWidth;
        if (width < 640)
            return 'xs';
        if (width >= 640 && width < 768)
            return 'sm';
        if (width >= 768 && width < 1024)
            return 'md';
        if (width >= 1024 && width < 1280)
            return 'lg';
        if (width >= 1280 && width < 1536)
            return 'xl';
        return '2xl';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ScreenSizeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ScreenSizeService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ScreenSizeService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }], ctorParameters: () => [] });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyZWVuLXNpemUuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2NpcmNsZXRvbmUvc3JjL2xpYi9zZXJ2aWNlcy9zY3JlZW4tc2l6ZS5zZXJ2aWNlLnRzI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