"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var TimeFormatLocalizationServer_exports = {};
__export(TimeFormatLocalizationServer_exports, {
  TimeFormatLocalizationServer: () => TimeFormatLocalizationServer
});
module.exports = __toCommonJS(TimeFormatLocalizationServer_exports);
var import_general = require("@matter/general");
var import_time_format_localization = require("@matter/types/clusters/time-format-localization");
var import_TimeFormatLocalizationBehavior = require("./TimeFormatLocalizationBehavior.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const logger = import_general.Logger.get("TimeFormatLocalizationServer");
class TimeFormatLocalizationServer extends import_TimeFormatLocalizationBehavior.TimeFormatLocalizationBehavior.with("CalendarFormat") {
  initialize() {
    if (this.state.hourFormat === void 0) {
      this.state.hourFormat = this.detectedHourFormat;
    }
    if (this.state.activeCalendarType === void 0) {
      this.state.activeCalendarType = this.detectedCalendarType;
    }
    if (this.state.supportedCalendarTypes === void 0) {
      this.state.supportedCalendarTypes = [this.state.activeCalendarType];
    }
  }
  /** Override this getter with own implementation to detect the hour format of the system. */
  get detectedHourFormat() {
    if (Intl.DateTimeFormat(void 0, { hour: "numeric" }).resolvedOptions().hour12) {
      return import_time_format_localization.TimeFormatLocalization.HourFormat["12Hr"];
    }
    return import_time_format_localization.TimeFormatLocalization.HourFormat["24Hr"];
  }
  /** Override this getter with own implementation to detect the calendar type of the system. */
  get detectedCalendarType() {
    const type = Intl.DateTimeFormat().resolvedOptions().calendar;
    switch (type) {
      case "buddhist":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Buddhist;
      case "chinese":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Chinese;
      case "coptic":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Coptic;
      case "ethiopian":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Ethiopian;
      case "gregory":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Gregorian;
      case "ethiopic":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Ethiopian;
      case "hebrew":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Hebrew;
      case "indian":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Indian;
      case "islamic":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Islamic;
      case "japanese":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Japanese;
      case "dangi":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Korean;
      case "persian":
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Persian;
      default:
        logger.warn(`Unmapped calendar type "${type}"; falling back to Gregorian`);
        return import_time_format_localization.TimeFormatLocalization.CalendarType.Gregorian;
    }
  }
}
((TimeFormatLocalizationServer2) => {
})(TimeFormatLocalizationServer || (TimeFormatLocalizationServer = {}));
//# sourceMappingURL=TimeFormatLocalizationServer.js.map
