import _defineProperty from "@babel/runtime/helpers/defineProperty";
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) { _defineProperty(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; }
import { fg } from '@atlaskit/platform-feature-flags';
import { useSmartLinkContext } from '../../../state';
import { getExtensionKey } from '../../../state/helpers';
import { getEmbedRovoActionsFooterExperimentMeta } from '../../../state/hooks/use-embed-rovo-actions-footer-experiment';
import useRovoConfig from '../../../state/hooks/use-rovo-config';
import { getSocialProofExperimentMeta, getInlineSocialProofExperimentMeta } from '../../../state/hooks/use-social-proof-experiment';
import { getIsRovoChatEnabled } from '../../../utils/rovo';
var useExperimentMetaEventAttributes = function useExperimentMetaEventAttributes(_ref) {
  var _actionOptions$rovoCh, _actionOptions$rovoCh2;
  var actionOptions = _ref.actionOptions,
    appearance = _ref.appearance,
    state = _ref.state;
  var _useSmartLinkContext = useSmartLinkContext(),
    baseUriWithNoTrailingSlash = _useSmartLinkContext.connections.client.baseUrlOverride;
  var _useRovoConfig = useRovoConfig(),
    rovoOptions = _useRovoConfig.rovoOptions,
    product = _useRovoConfig.product;
  var details = state.details,
    status = state.status;
  var extensionKey = getExtensionKey(details);
  var embedRovoActionsFooterExperimentMeta = appearance === 'embed' && status === 'resolved' ? getEmbedRovoActionsFooterExperimentMeta({
    extensionKey: extensionKey,
    isRovoChatActionOptedIn: (_actionOptions$rovoCh = actionOptions === null || actionOptions === void 0 || (_actionOptions$rovoCh2 = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh2 === void 0 ? void 0 : _actionOptions$rovoCh2.optIn) !== null && _actionOptions$rovoCh !== void 0 ? _actionOptions$rovoCh : false,
    isRovoChatEnabled: getIsRovoChatEnabled(rovoOptions),
    product: product
  }) : undefined;
  if (!embedRovoActionsFooterExperimentMeta && !fg('social-proof-3p-unauth-block-fg') && !fg('platform_sl_3p_preauth_soc_proof_inline_killswitch')) {
    return undefined;
  }
  var blockSocialProofExperimentMeta = appearance === 'block' && status === 'unauthorized' && fg('social-proof-3p-unauth-block-fg') ? getSocialProofExperimentMeta({
    extensionKey: extensionKey,
    baseUriWithNoTrailingSlash: baseUriWithNoTrailingSlash
  }) : undefined;
  var inlineSocialProofExperimentMeta = appearance === 'inline' && status === 'unauthorized' && fg('platform_sl_3p_preauth_soc_proof_inline_killswitch') ? getInlineSocialProofExperimentMeta({
    extensionKey: extensionKey,
    baseUriWithNoTrailingSlash: baseUriWithNoTrailingSlash
  }) : undefined;
  var experimentMeta = _objectSpread(_objectSpread(_objectSpread({}, blockSocialProofExperimentMeta), inlineSocialProofExperimentMeta), embedRovoActionsFooterExperimentMeta);
  if (Object.keys(experimentMeta).length > 0) {
    return experimentMeta;
  }
};
export default useExperimentMetaEventAttributes;