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

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, Sprite, SpriteFrame, i18n, Logger, _dec, _dec2, _class, _class2, _descriptor, _descriptor2, _dec3, _dec4, _class4, _class5, _descriptor3, _class6, _crd, ccclass, property, SpriteFrameSet, LocalizedSprite;

  function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }

  function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }

  function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }

  function _reportPossibleCrUseOfi18n(extras) {
    _reporterNs.report("i18n", "./LanguageData", _context.meta, extras);
  }

  function _reportPossibleCrUseOfLogger(extras) {
    _reporterNs.report("Logger", "../../extend/Logger", _context.meta, extras);
  }

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Component = _cc.Component;
      Sprite = _cc.Sprite;
      SpriteFrame = _cc.SpriteFrame;
    }, function (_unresolved_2) {
      i18n = _unresolved_2.default;
    }, function (_unresolved_3) {
      Logger = _unresolved_3.Logger;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "28bd9xEMv1GKLbTuAi4B4dI", "LocalizedSprite", undefined);

      __checkObsolete__(['_decorator', 'Component', 'Sprite', 'SpriteFrame']);

      ({
        ccclass,
        property
      } = _decorator); //图片信息类

      _export("SpriteFrameSet", SpriteFrameSet = (_dec = ccclass("SpriteFrameSet"), _dec2 = property({
        type: SpriteFrame
      }), _dec(_class = (_class2 = class SpriteFrameSet {
        constructor() {
          _initializerDefineProperty(this, "language", _descriptor, this);

          _initializerDefineProperty(this, "spriteFrame", _descriptor2, this);
        }

      }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "language", [property], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return '';
        }
      }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "spriteFrame", [_dec2], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return null;
        }
      })), _class2)) || _class));
      /**多语言图片
       * 图片多语言 直接挂载LocalizedSprite类 到对应的sprite节点上去
         然后根据languages.length的列表填入如 “en” 然后拖入英文的图片，然后“zh” 拖入中文的图片
       */


      _export("default", LocalizedSprite = (_dec3 = ccclass("LocalizedSprite"), _dec4 = property({
        type: [SpriteFrameSet],
        displayOrder: 1
      }), _dec3(_class4 = (_class5 = (_class6 = class LocalizedSprite extends Component {
        constructor(...args) {
          super(...args);
          this.sprite = null;

          _initializerDefineProperty(this, "spriteFrameSet", _descriptor3, this);
        }

        onLoad() {
          this.fetchRender();
        }

        fetchRender() {
          let sprite = this.getComponent(Sprite);

          if (sprite) {
            this.sprite = sprite;
            this.updateSprite((_crd && i18n === void 0 ? (_reportPossibleCrUseOfi18n({
              error: Error()
            }), i18n) : i18n).curLang);
            return;
          }
        }

        getSpriteFrameByLang(lang) {
          for (let i = 0; i < this.spriteFrameSet.length; ++i) {
            if (this.spriteFrameSet[i].language === lang) {
              return this.spriteFrameSet[i].spriteFrame;
            }
          }
        }

        updateSprite(language) {
          if (!this.sprite) {
            (_crd && Logger === void 0 ? (_reportPossibleCrUseOfLogger({
              error: Error()
            }), Logger) : Logger).error('Failed to update localized sprite, sprite component is invalid!');
            return;
          }

          let spriteFrame = this.getSpriteFrameByLang(language);

          if (!spriteFrame && this.spriteFrameSet[0]) {
            spriteFrame = this.spriteFrameSet[0].spriteFrame;
          }

          if (spriteFrame) {
            this.sprite.spriteFrame = spriteFrame;
          }
        }

      }, _class6.editor = {
        executeInEditMode: true,
        inspector: 'packages://i18n/inspector/localized-sprite.js',
        menu: 'i18n/LocalizedSprite'
      }, _class6), (_descriptor3 = _applyDecoratedDescriptor(_class5.prototype, "spriteFrameSet", [_dec4], {
        configurable: true,
        enumerable: true,
        writable: true,
        initializer: function () {
          return [];
        }
      })), _class5)) || _class4));

      _cclegacy._RF.pop();

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