'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');

function getMJSchemeParam(_ref) {
  var seriesId = _ref.seriesId,
    gameId = _ref.gameId,
    uin = _ref.uin;
  var schemeParam = "firmMatch=1&seriesid=".concat(seriesId, "&gameid=").concat(gameId, "&uin=").concat(uin);
  return schemeParam;
}
/**
 * 拉起 MJ
 * @param {object} params 拉起参数
 * @param {string} params.seriesId series id
 * @param {string} params.gameId game id
 * @param {string} params.uin uin
 * @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
 * launchMJGameRoom({
 *   seriesId: '12',
 *   gameId: '123',
 *   uin: '222',
 * })
 * ```
 */
function launchMJGameRoom(_ref2) {
  var _ref2$seriesId = _ref2.seriesId,
    seriesId = _ref2$seriesId === void 0 ? '' : _ref2$seriesId,
    _ref2$gameId = _ref2.gameId,
    gameId = _ref2$gameId === void 0 ? '' : _ref2$gameId,
    _ref2$uin = _ref2.uin,
    uin = _ref2$uin === void 0 ? '' : _ref2$uin,
    context = _ref2.context,
    qrCodeLib = _ref2.qrCodeLib,
    dialogHandler = _ref2.dialogHandler,
    otherDialogParams = _ref2.otherDialogParams,
    _ref2$wxJSLink = _ref2.wxJSLink,
    wxJSLink = _ref2$wxJSLink === void 0 ? launchGame_helper.DEFAULT_WX_JS_SDK : _ref2$wxJSLink,
    _ref2$env = _ref2.env,
    env = _ref2$env === void 0 ? env_env.initEnv() : _ref2$env;
  var schemeParam = getMJSchemeParam({
    seriesId: seriesId,
    gameId: gameId,
    uin: uin
  });
  return launchGame_helper.launchCore({
    launchParams: {
      seriesId: seriesId,
      gameId: gameId,
      uin: uin
    },
    schemeParam: schemeParam,
    context: context,
    qrCodeLib: qrCodeLib,
    dialogHandler: dialogHandler,
    otherDialogParams: otherDialogParams,
    schemePrefix: launchGame_helper.GAME_SCHEME_PREFIX_MAP.MJ,
    wxJSLink: wxJSLink,
    env: env
  });
}

exports.launchMJGameRoom = launchMJGameRoom;
