import { initEnv } from '../env/env.mjs';
import { getGPSchemeParam, launchCore, GAME_SCHEME_PREFIX_MAP, DEFAULT_WX_JS_SDK } from './helper.mjs';
import '@babel/runtime/helpers/defineProperty';
import '../game/game.mjs';
import '../constant/gid.mjs';
import '../loader/little-loader.mjs';
import '../msdk/msdk.mjs';
import '@babel/runtime/helpers/typeof';
import '../url/url.mjs';

/**
 * 拉起 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 ? DEFAULT_WX_JS_SDK : _ref$wxJSLink,
    _ref$env = _ref.env,
    env = _ref$env === void 0 ? initEnv() : _ref$env;
  var schemeParam = getGPSchemeParam(roomId, roomPwd);
  return launchCore({
    launchParams: {
      roomId: roomId,
      roomPwd: roomPwd
    },
    schemeParam: schemeParam,
    context: context,
    qrCodeLib: qrCodeLib,
    dialogHandler: dialogHandler,
    otherDialogParams: otherDialogParams,
    schemePrefix: GAME_SCHEME_PREFIX_MAP.GN,
    wxJSLink: wxJSLink,
    env: env
  });
}

export { launchGNGameRoom };
