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

  var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Component, find, _dec, _class, _crd, ccclass, property, ComponentEx;

  return {
    setters: [function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      _decorator = _cc._decorator;
      Component = _cc.Component;
      find = _cc.find;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "819feri7DxHQ62MHmCI5Kc2", "ComponentEx", undefined);

      __checkObsolete__(['_decorator', 'Component', 'Node', 'find']);

      ({
        ccclass,
        property
      } = _decorator);

      _export("ComponentEx", ComponentEx = (_dec = ccclass('ComponentEx'), _dec(_class = class ComponentEx extends Component {
        constructor(...args) {
          super(...args);
          this.m_objects = new Map();
        }

        _findInChildren(node, name) {
          var x = node.getChildByName(name);
          if (x) return x;
          if (node.children.length == 0) return null;

          for (var i = 0; i < node.children.length; ++i) {
            var tmp = this._findInChildren(node.children[i], name);

            if (tmp) return tmp;
          }

          return null;
        }

        GetNode(name, refind = false) {
          if (!refind) {
            if (this.m_objects && this.m_objects.has(name)) return this.m_objects.get(name);
            if (name == this.node.name) return this.node;
          }

          if (name.indexOf("/") != -1) {
            var tmp = find(name, this.node);
            if (tmp) this.m_objects.set(name, tmp);
            return tmp;
          } else {
            tmp = this._findInChildren(this.node, name);
            if (tmp) this.m_objects.set(name, tmp);
            return tmp;
          }
        } //从Canvas开始寻找节点


        GetNodeFromCanvas(name) {
          let bui = find("Canvas").getComponent(ComponentEx);
          if (!bui) bui = find("Canvas").getComponentInChildren(ComponentEx);
          return bui.GetNode(name);
        } // @ts-ignore


        findComponentInParent(node, ctor) {
          let parent = node;

          while (parent) {
            let comp = parent.getComponent(ctor);
            if (comp) return comp;
            parent = parent.parent;
          }

          return null;
        }

      }) || _class));

      _cclegacy._RF.pop();

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