"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _state = require("../../../state");
var _helpers = require("../../../state/helpers");
var _useSocialProofExperiment = require("../../../state/hooks/use-social-proof-experiment");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var useExperimentMetaEventAttributes = function useExperimentMetaEventAttributes(_ref) {
  var appearance = _ref.appearance,
    state = _ref.state;
  var _useSmartLinkContext = (0, _state.useSmartLinkContext)(),
    baseUriWithNoTrailingSlash = _useSmartLinkContext.connections.client.baseUrlOverride;
  var details = state.details,
    status = state.status;
  var extensionKey = (0, _helpers.getExtensionKey)(details);
  if (!(0, _platformFeatureFlags.fg)('social-proof-3p-unauth-block-fg') && !(0, _platformFeatureFlags.fg)('platform_sl_3p_preauth_soc_proof_inline_killswitch')) {
    return undefined;
  }
  var blockSocialProofExperimentMeta = appearance === 'block' && status === 'unauthorized' && (0, _platformFeatureFlags.fg)('social-proof-3p-unauth-block-fg') ? (0, _useSocialProofExperiment.getSocialProofExperimentMeta)({
    extensionKey: extensionKey,
    baseUriWithNoTrailingSlash: baseUriWithNoTrailingSlash
  }) : undefined;
  var inlineSocialProofExperimentMeta = appearance === 'inline' && status === 'unauthorized' && (0, _platformFeatureFlags.fg)('platform_sl_3p_preauth_soc_proof_inline_killswitch') ? (0, _useSocialProofExperiment.getInlineSocialProofExperimentMeta)({
    extensionKey: extensionKey,
    baseUriWithNoTrailingSlash: baseUriWithNoTrailingSlash
  }) : undefined;
  var experimentMeta = _objectSpread(_objectSpread({}, blockSocialProofExperimentMeta), inlineSocialProofExperimentMeta);
  if (Object.keys(experimentMeta).length > 0) {
    return experimentMeta;
  }
};
var _default = exports.default = useExperimentMetaEventAttributes;