'use strict';

const log = require('./global-slimmer-registry-7bbdb1f2.js');
const staticSubjectTitle = require('./static-subject-title-5829a298.js');
const observer = require('./observer-f49483e8.js');
const changeManager = require('./change-manager-72f643de.js');

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/** The `DarkModeStateControllerSlimmer` class monitors dark mode changes and updates the state accordingly. */
class DarkModeStateControllerSlimmer extends log.VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]
   * Register an observer to watch for dark mode updates, which will cause the component to update.
   */
  connectedCallback() {
    this.observer = new observer.Observer(this.isAcceptObserver.bind(this), (isDark) => {
      this.isInDarkMode = isDark;
    });
    changeManager.ChangeManager.register(staticSubjectTitle.DARK_MODE_CHANGE, this.observer);
  }
  /**
   * cancel dark mode observer when disconnectedCallback
   */
  disconnectResizeObserver() {
    changeManager.ChangeManager.unregister(staticSubjectTitle.DARK_MODE_CHANGE, this.observer);
  }
  /**
   * Determines whether the observer should accept changes.
   *
   * @returns {boolean} Always returns true in the current implementation.
   */
  isAcceptObserver() {
    return true;
  }
}
__decorate([
  log.MapToComponentField({ writable: true })
], DarkModeStateControllerSlimmer.prototype, "isInDarkMode", void 0);
__decorate([
  log.MapToComponentMethod('connectedCallback')
], DarkModeStateControllerSlimmer.prototype, "connectedCallback", null);
__decorate([
  log.MapToComponentMethod('disconnectedCallback')
], DarkModeStateControllerSlimmer.prototype, "disconnectResizeObserver", null);

exports.DarkModeStateControllerSlimmer = DarkModeStateControllerSlimmer;
