import useEngineContext from "../../../hooks/useEngineContext";
import { getUrlParams } from "../dataSourceForm/urlUtils";
var scopeMap = {
  saas: 'saas',
  org: 'organization',
  biz: 'business',
  channel: 'channel',
  board: 'board'
};
var useFormSettingParams = function useFormSettingParams() {
  var _context$appHelper, _app$history;
  var context = useEngineContext();
  var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
    getApp = _context$appHelper$ut.getApp;
  var app = getApp === null || getApp === void 0 ? void 0 : getApp();
  var params = app === null || app === void 0 || (_app$history = app.history) === null || _app$history === void 0 ? void 0 : _app$history.useParams();
  var queryParams = getUrlParams();
  var businessCode = (queryParams === null || queryParams === void 0 ? void 0 : queryParams.biz) || (queryParams === null || queryParams === void 0 ? void 0 : queryParams.business_code);
  var channelCode = queryParams === null || queryParams === void 0 ? void 0 : queryParams.channel;
  var scope = scopeMap[params === null || params === void 0 ? void 0 : params.scope];
  var originTarget = businessCode && channelCode ? "".concat(businessCode, "+").concat(channelCode) : businessCode || channelCode;

  // saas / organization：无需传值
  var target = ['organization', 'saas'].includes(scope) ? undefined : originTarget;
  return {
    businessCode: businessCode,
    channelCode: channelCode,
    scope: scope,
    target: target
  };
};
export default useFormSettingParams;