System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, sys, Singleton, Utils, GameConst, _dec, _class, _crd, ccclass, property, SettingData, settingData;

  function _reportPossibleCrUseOfSingleton(extras) {
    _reporterNs.report("Singleton", "../core/manager/Singleton", _context.meta, extras);
  }

  function _reportPossibleCrUseOfUtils(extras) {
    _reporterNs.report("Utils", "../core/utils/Utils", _context.meta, extras);
  }

  function _reportPossibleCrUseOfGameConst(extras) {
    _reporterNs.report("GameConst", "../core/common/GameConst", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      sys = _cc.sys;
    }, function (_unresolved_2) {
      Singleton = _unresolved_2.Singleton;
    }, function (_unresolved_3) {
      Utils = _unresolved_3.default;
    }, function (_unresolved_4) {
      GameConst = _unresolved_4.GameConst;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "87ebcQ+nuBFsImwA+JoSKmd", "SettingData", undefined);

      __checkObsolete__(['_decorator', 'sys']);

      ({
        ccclass,
        property
      } = _decorator);
      SettingData = (_dec = ccclass("SettingData"), _dec(_class = class SettingData extends (_crd && Singleton === void 0 ? (_reportPossibleCrUseOfSingleton({
        error: Error()
      }), Singleton) : Singleton) {
        constructor(...args) {
          super(...args);
          this._data = null;
        }

        get data() {
          if (!this._data) {
            this.loadFromCache();
          }

          return this._data;
        }
        /**
         * 读取数据缓存
         */


        loadFromCache() {
          let l = sys.localStorage.getItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.settingData);

          if (l) {
            this._data = JSON.parse((_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
              error: Error()
            }), Utils) : Utils).decrypt(l));
          } else {
            //没有数据保存一份默认的初始数据
            this._data = {
              bgMusic: true,
              //背景音乐开关
              soundFx: true,
              //音效开关
              vibration: false //震动开关

            };
            this.saveToCache();
          }

          return this.data;
        }
        /**
        * 得到设置的数据数组
        */


        getSettingDatas() {
          const displayNames = ["背景音乐", "音效", "震动"];
          const dataKeys = Object.keys(this.data); // 确保字段顺序一致

          return dataKeys.map((key, index) => ({
            name: displayNames[index],
            selected: this.data[key]
          }));
        }
        /**
         * 保存到缓存中
         */


        saveToCache() {
          const data = JSON.stringify(this.data); //序列化JSON字符串过后加密存储

          sys.localStorage.setItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.settingData, (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).encrypt(data));
        }
        /**
         * 删除缓存
         */


        remove() {
          sys.localStorage.removeItem((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
            error: Error()
          }), GameConst) : GameConst).localCache.settingData);
          this.loadFromCache();
        }

      }) || _class); //全局单例

      _export("settingData", settingData = SettingData.ins());

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=12b2943f0751291fbe13daad8c04a8a92c054643.js.map