{"version":3,"file":"ng-doc-app-services-theme.mjs","sources":["../../../../libs/app/services/theme/theme.service.ts","../../../../libs/app/services/theme/ng-doc-app-services-theme.ts"],"sourcesContent":["import { DOCUMENT, inject, Injectable } from '@angular/core';\nimport { NG_DOC_STORE_THEME_KEY } from '@ng-doc/app/constants';\nimport { NgDocStoreService } from '@ng-doc/app/services/store';\nimport { Observable, Subject } from 'rxjs';\n\n/**\n * Service for managing themes.\n */\n@Injectable({ providedIn: 'root' })\nexport class NgDocThemeService {\n  protected readonly document = inject(DOCUMENT);\n  protected readonly store = inject(NgDocStoreService);\n  protected readonly change$ = new Subject<string | null>();\n  protected readonly documentElement = this.document.documentElement;\n\n  /**\n   * Returns the current theme.\n   */\n  get currentTheme(): string | null {\n    return document.documentElement.getAttribute('data-theme');\n  }\n\n  themeChanges(): Observable<string | null> {\n    return this.change$.asObservable();\n  }\n\n  /**\n   * Sets the theme by id.\n   * @param id - Theme id. If not provided, the theme will be removed.\n   */\n  set(id?: string): void {\n    id\n      ? this.documentElement.setAttribute('data-theme', id)\n      : this.documentElement.removeAttribute('data-theme');\n\n    this.store.set(NG_DOC_STORE_THEME_KEY, id ?? '');\n    this.change$.next(id ?? null);\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAKA;;AAEG;MAEU,iBAAiB,CAAA;AAD9B,IAAA,WAAA,GAAA;AAEqB,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC3B,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACjC,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,OAAO,EAAiB;AACtC,QAAA,IAAA,CAAA,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe;AAyBnE,IAAA;AAvBC;;AAEG;AACH,IAAA,IAAI,YAAY,GAAA;QACd,OAAO,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,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