'use strict';

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

var env_env = require('../env/env.js');
var msdk_msdk = require('./msdk.js');
require('@babel/runtime/helpers/typeof');
require('../loader/little-loader.js');

function launchMiniProgramInSlugSdk(appId, path) {
  if (typeof window.customBrowserInterface === 'undefined') {
    msdk_msdk.callJsBrowserAdapter().then(function () {
      var _a;
      (_a = window.customBrowserInterface) === null || _a === void 0 ? void 0 : _a.openMiniProgram(appId, path);
    });
  } else {
    window.customBrowserInterface.openMiniProgram(appId, path);
  }
}
function launchMiniProgramInGame(_ref) {
  var _ref$appId = _ref.appId,
    appId = _ref$appId === void 0 ? '' : _ref$appId,
    _ref$path = _ref.path,
    path = _ref$path === void 0 ? '' : _ref$path,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 0 : _ref$type,
    _ref$isWxMp = _ref.isWxMp,
    isWxMp = _ref$isWxMp === void 0 ? true : _ref$isWxMp;
  var env = env_env.initEnv();
  if (env.isSlugSdk) {
    return launchMiniProgramInSlugSdk(appId, path);
  }
  var param = {};
  if (isWxMp) {
    param = {
      MsdkMethod: 'WGLaunchMiniApp',
      userName: appId,
      path: path,
      type: type
    };
  } else {
    param = {
      MsdkMethod: 'WGLaunchQQMiniApp',
      miniProgramAppid: appId,
      miniProgramPath: path,
      type: type
    };
  }
  var paramStr = JSON.stringify(param);
  if (typeof window.msdkShare === 'undefined') {
    msdk_msdk.callJsBrowserAdapter().then(function () {
      window.msdkShare(paramStr);
    });
  } else {
    window.msdkShare(paramStr);
  }
}

exports.launchMiniProgramInGame = launchMiniProgramInGame;
exports.launchMiniProgramInSlugSdk = launchMiniProgramInSlugSdk;
