"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IFrame = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _embeddedConfluence = require("@atlaskit/embedded-confluence");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _useConfluencePageData = require("../../../hooks/useConfluencePageData");
var _excluded = ["childRef", "className", "extensionKey"];
/**
 * Iframe element isolated for DI purposes
 */
var IFrame = exports.IFrame = function IFrame(_ref) {
  var childRef = _ref.childRef,
    className = _ref.className,
    extensionKey = _ref.extensionKey,
    props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var confluencePageData = (0, _platformFeatureFlags.fg)('platform_deprecate_lp_cc_embed') ?
  // eslint-disable-next-line react-hooks/rules-of-hooks
  (0, _useConfluencePageData.useConfluencePageData)(props.src || '', extensionKey || '') : undefined;

  // Conditional rendering: Page component for lp-cc-embed URLs, iframe for everything else
  return confluencePageData && (0, _platformFeatureFlags.fg)('platform_deprecate_lp_cc_embed') ? /*#__PURE__*/_react.default.createElement(_embeddedConfluence.Page, {
    hostname: confluencePageData.hostname,
    spaceKey: confluencePageData.spaceKey,
    contentId: confluencePageData.contentId,
    parentProduct: confluencePageData.parentProduct,
    hash: confluencePageData.hash,
    mode: confluencePageData.mode,
    locale: confluencePageData.locale,
    iframeRef: childRef,
    onLoad: props.onLoad,
    onMouseEnter: props.onMouseEnter,
    onMouseLeave: props.onMouseLeave,
    sandbox: props.sandbox,
    allowedFeatures: confluencePageData.allowedFeatures,
    themeState: confluencePageData.themeStateObject,
    userInfo: confluencePageData.userInfo
  }) :
  /*#__PURE__*/
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
  _react.default.createElement("iframe", (0, _extends2.default)({
    className: className
  }, props, {
    ref: childRef,
    title: props.title
  }));
};