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

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _cc, TextureManager, MergeManager, _crd, cc, ccclass, property;

  function _reportPossibleCrUseOfTextureManager(extras) {
    _reporterNs.report("TextureManager", "./TextureManager", _context.meta, extras);
  }

  _export("MergeManager", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc2) {
      _cclegacy = _cc2.cclegacy;
      __checkObsolete__ = _cc2.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc2.__checkObsoleteInNamespace__;
      _cc = _cc2;
    }, function (_unresolved_2) {
      TextureManager = _unresolved_2.TextureManager;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "855e2En4fND45+yl9S78Mga", "MergeManager", undefined);

      cc = __checkObsoleteInNamespace__(_cc);
      ({
        ccclass,
        property
      } = cc._decorator);

      _export("MergeManager", MergeManager = class MergeManager {
        /*
        
            paths:路径数组
        
            col:列数
        
            row:行数
        
            imageWidth:单个图片宽度
        
            imageHeight:单个图片高度
        
        */
        constructor(paths, col, row, imageWidth, imageHeight) {
          //图片行数
          this._rowMax = 0;
          //图片列数
          this._colMax = 0;
          //图片行计数
          this._rowCount = 0;
          //图片列计数
          this._colCount = 0;
          //图片计数
          this._imageCount = 0;
          //单个图片宽
          this._imageWidth = 0;
          //单个图片高
          this._imageHeight = 0;
          //下载路径
          this._paths = void 0;
          this._mergeTexture = void 0;
          this._imageMap = new Map();
          this._loaded = false;
          this.onLoaded = void 0;
          this._paths = paths;
          this._colMax = col;
          this._rowMax = row;
          this._imageWidth = imageWidth;
          this._imageHeight = imageHeight;
        }

        init() {
          var array_length = this._imageWidth * this._colMax * this._imageHeight * this._rowMax * 4;
          var imageData = new Uint8Array(array_length);

          for (var i = 0; i < imageData.length; i++) {
            if (i % 4 == 3) {
              imageData[i] = 0; //255 255是白色，0是透明
            } else {
              imageData[i] = 255;
            }
          }

          this._mergeTexture = (_crd && TextureManager === void 0 ? (_reportPossibleCrUseOfTextureManager({
            error: Error()
          }), TextureManager) : TextureManager).createTexture(imageData, this._imageWidth * this._colMax, this._imageHeight * this._rowMax);

          for (var path of this._paths) {
            this.loadImage(path);
          }
        }

        loadImage(path, loaded) {
          // cc.resources.load(path, cc.ImageAsset, (err, image) => {
          cc.assetManager.loadRemote(path, cc.ImageAsset, (err, image) => {
            var tKey = "addImage" + this._imageCount;

            if (err) {
              console.error(err);
            } else {
              var frame = cc.SpriteFrame.createWithImage(image);
              var add = frame.texture;
              var pos = cc.v2(this._colCount * this._imageWidth, this._rowCount * this._imageHeight);

              this._imageMap.set(path, pos);

              this._colCount++;

              if (this._colCount == this._colMax) {
                this._colCount = 0;
                this._rowCount++;
              }

              console.time(tKey);
              this._mergeTexture = (_crd && TextureManager === void 0 ? (_reportPossibleCrUseOfTextureManager({
                error: Error()
              }), TextureManager) : TextureManager).addImage(this._mergeTexture, add, pos);
              console.timeEnd(tKey); //let frame1 = new SpriteFrame();
            }

            this._imageCount++;

            if (this._imageCount == this._paths.length) {
              this._loaded = true;
              this.onLoaded && this.onLoaded(this._mergeTexture);
            }
          });
        }

      });

      _cclegacy._RF.pop();

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