'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var env_env = require('../env/env.js');
var launchGame_helper = require('./helper.js');
require('@babel/runtime/helpers/defineProperty');
require('../game/game.js');
require('../constant/gid.js');
require('../loader/little-loader.js');
require('../msdk/msdk.js');
require('@babel/runtime/helpers/typeof');
require('../url/url.js');

/**
 * 拉起 GN
 * @param {object} params 拉起参数
 * @param {string} params.roomId 房间 Id
 * @param {string} params.roomPwd 房间 Pwd
 * @param {object} [params.context] 上下文，可传入组件实例 this
 * @param {object} [params.qrCodeLib] qrcode
 * @param {object} [params.dialogHandler] 弹窗 handler
 * @param {object} [params.otherDialogParams] 弹窗的其他参数
 * @param {string} [params.wxJSLink] wx js link
 * @param {object} [params.env] 环境对象
 * @returns Promise<boolean | number>
 *
 * @example
 * ```ts
 * launchGNGameRoom({
 *   roomId: '12',
 *   roomPwd: '123'
 * })
 * ```
 */
function launchGNGameRoom(_ref) {
  var _ref$roomId = _ref.roomId,
    roomId = _ref$roomId === void 0 ? '' : _ref$roomId,
    _ref$roomPwd = _ref.roomPwd,
    roomPwd = _ref$roomPwd === void 0 ? '' : _ref$roomPwd,
    context = _ref.context,
    qrCodeLib = _ref.qrCodeLib,
    dialogHandler = _ref.dialogHandler,
    otherDialogParams = _ref.otherDialogParams,
    _ref$wxJSLink = _ref.wxJSLink,
    wxJSLink = _ref$wxJSLink === void 0 ? launchGame_helper.DEFAULT_WX_JS_SDK : _ref$wxJSLink,
    _ref$env = _ref.env,
    env = _ref$env === void 0 ? env_env.initEnv() : _ref$env;
  var schemeParam = launchGame_helper.getGPSchemeParam(roomId, roomPwd);
  return launchGame_helper.launchCore({
    launchParams: {
      roomId: roomId,
      roomPwd: roomPwd
    },
    schemeParam: schemeParam,
    context: context,
    qrCodeLib: qrCodeLib,
    dialogHandler: dialogHandler,
    otherDialogParams: otherDialogParams,
    schemePrefix: launchGame_helper.GAME_SCHEME_PREFIX_MAP.GN,
    wxJSLink: wxJSLink,
    env: env
  });
}

exports.launchGNGameRoom = launchGNGameRoom;
