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

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Prefab, sys, constants, utils, localConfig, Data, Utils, _dec, _class, _class2, _crd, ccclass, property, levelsData;

  function _reportPossibleCrUseOfconstants(extras) {
    _reporterNs.report("constants", "./constants", _context.meta, extras);
  }

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

  function _reportPossibleCrUseOflocalConfig(extras) {
    _reporterNs.report("localConfig", "../manager/localConfig", _context.meta, extras);
  }

  function _reportPossibleCrUseOfData(extras) {
    _reporterNs.report("Data", "../scripts/core/manager/Data", _context.meta, extras);
  }

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

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Prefab = _cc.Prefab;
      sys = _cc.sys;
    }, function (_unresolved_2) {
      constants = _unresolved_2.constants;
    }, function (_unresolved_3) {
      utils = _unresolved_3.utils;
    }, function (_unresolved_4) {
      localConfig = _unresolved_4.localConfig;
    }, function (_unresolved_5) {
      Data = _unresolved_5.default;
    }, function (_unresolved_6) {
      Utils = _unresolved_6.default;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "3b744Kuy8NH4q/cKl7BVA35", "levelsData", undefined);

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

      ({
        ccclass,
        property
      } = _decorator);

      _export("levelsData", levelsData = (_dec = ccclass("levelsData"), _dec(_class = (_class2 = class levelsData {
        constructor() {
          this.data = null;
          this._levelTable = null;
          this._modelsTable = null;
        }

        get levelTable() {
          if (!this._levelTable) {
            this._levelTable = (_crd && localConfig === void 0 ? (_reportPossibleCrUseOflocalConfig({
              error: Error()
            }), localConfig) : localConfig).instance.getTableArr('levels');
          }

          return this._levelTable;
        }

        get modelsTable() {
          if (!this._modelsTable) {
            this._modelsTable = (_crd && localConfig === void 0 ? (_reportPossibleCrUseOflocalConfig({
              error: Error()
            }), localConfig) : localConfig).instance.getTableArr('model_names');
          }

          return this._modelsTable;
        }
        /**单例*/


        static ins() {
          if (!this.instance) {
            this.instance = new levelsData();
          }

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


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

          if (l) {
            this.data = JSON.parse((_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
              error: Error()
            }), utils) : utils).decrypt(l));
          } else {
            //没有数据保存一份默认的初始数据
            this.data = {};
            this.saveToCache();
          }
        }
        /**
         * 得到解锁的模型名字数组
         */


        getDeblockDatas() {
          return this.modelsTable.map(item => item.name);
        }
        /**
         * 得到标准模型名字数组
         */


        getNormModelDatas() {
          return this.modelsTable.map(item => item.name);
        }
        /**
         * 得到当前关卡下的数据
         */


        getCurLevelInfo() {
          let datas = this.levelTable;
          let lv = (_crd && Data === void 0 ? (_reportPossibleCrUseOfData({
            error: Error()
          }), Data) : Data).user.lv - 1;

          if (lv > datas.length) {
            return datas[datas.length - 1];
          } else {
            return datas[lv];
          }
        }

        async LoadItemPrefabByName(name) {
          console.log("FFFFFFF = " + name);
          return (_crd && Utils === void 0 ? (_reportPossibleCrUseOfUtils({
            error: Error()
          }), Utils) : Utils).loadRes("Cube", "item_bundle", Prefab);
        }
        /**
         * 保存到缓存中
         */


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

          sys.localStorage.setItem((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
            error: Error()
          }), constants) : constants).localCache.levelsData, (_crd && utils === void 0 ? (_reportPossibleCrUseOfutils({
            error: Error()
          }), utils) : utils).encrypt(data));
        }
        /**
         * 删除缓存
         */


        remove() {
          sys.localStorage.removeItem((_crd && constants === void 0 ? (_reportPossibleCrUseOfconstants({
            error: Error()
          }), constants) : constants).localCache.levelsData);
          this.loadFromCache();
        }

      }, _class2.instance = null, _class2)) || _class));

      _export("default", levelsData.ins());

      _cclegacy._RF.pop();

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