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

  var _reporterNs, _cclegacy, gateClientProto, Result, AHttpClient, GateClient, _crd;

  function _reportPossibleCrUseOfBaseHttpClient(extras) {
    _reporterNs.report("BaseHttpClient", "tsrpc-base-client", _context.meta, extras);
  }

  function _reportPossibleCrUseOfBaseHttpClientOptions(extras) {
    _reporterNs.report("BaseHttpClientOptions", "tsrpc-base-client", _context.meta, extras);
  }

  function _reportPossibleCrUseOfApiReturn(extras) {
    _reporterNs.report("ApiReturn", "tsrpc-proto", _context.meta, extras);
  }

  function _reportPossibleCrUseOfServiceProto(extras) {
    _reporterNs.report("ServiceProto", "tsrpc-proto", _context.meta, extras);
  }

  function _reportPossibleCrUseOfgateClientProto(extras) {
    _reporterNs.report("gateClientProto", "./protocols/serviceProto", _context.meta, extras);
  }

  function _reportPossibleCrUseOfgateServiceType(extras) {
    _reporterNs.report("gateServiceType", "./protocols/serviceProto", _context.meta, extras);
  }

  function _reportPossibleCrUseOfIGameServerInfo(extras) {
    _reporterNs.report("IGameServerInfo", "../gateClient/GameServer", _context.meta, extras);
  }

  function _reportPossibleCrUseOfResult(extras) {
    _reporterNs.report("Result", "../tsgf/Result", _context.meta, extras);
  }

  function _reportPossibleCrUseOfAHttpClient(extras) {
    _reporterNs.report("AHttpClient", "../tsgf/AClient", _context.meta, extras);
  }

  function _reportPossibleCrUseOfResGetServerList(extras) {
    _reporterNs.report("ResGetServerList", "./protocols/PtlGetServerList", _context.meta, extras);
  }

  _export("GateClient", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
    }, function (_unresolved_2) {
      gateClientProto = _unresolved_2.serviceProto;
    }, function (_unresolved_3) {
      Result = _unresolved_3.Result;
    }, function (_unresolved_4) {
      AHttpClient = _unresolved_4.AHttpClient;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "8cf0eNQLmhMCIBP0iPRWbyA", "gateClient", undefined);

      _export("GateClient", GateClient = class GateClient extends (_crd && AHttpClient === void 0 ? (_reportPossibleCrUseOfAHttpClient({
        error: Error()
      }), AHttpClient) : AHttpClient) {
        constructor(buildClient, serverUrl) {
          super(buildClient, _crd && gateClientProto === void 0 ? (_reportPossibleCrUseOfgateClientProto({
            error: Error()
          }), gateClientProto) : gateClientProto, {
            server: serverUrl,
            json: false,
            logger: console
          });
        }
        /**
         * 获取游戏服务器列表
         * @returns game servers 
         */


        async getGameServers() {
          return await this.client.callApi("GetServerList", {});
        }
        /**
         * 使用自定义用户名登录
         * @param gameServerInfo 
         * @param userName 
         * @returns 返回是否有错误消息,null表示成功
         */


        async loginByCustomUserName(gameServerInfo, userName) {
          const ret = await this.client.callApi("LoginToGame", {
            gameServerId: gameServerInfo.serverId,
            userName: userName
          });

          if (!ret.isSucc) {
            return (_crd && Result === void 0 ? (_reportPossibleCrUseOfResult({
              error: Error()
            }), Result) : Result).buildErr(ret.err.message);
          }

          return (_crd && Result === void 0 ? (_reportPossibleCrUseOfResult({
            error: Error()
          }), Result) : Result).buildSucc(ret.res.gameLoginToken);
        }

      });

      _cclegacy._RF.pop();

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