import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["childRef", "className", "extensionKey"];
import React from 'react';
import { Page } from '@atlaskit/embedded-confluence';
import { useConfluencePageData } from '../../../hooks/useConfluencePageData';
/**
 * Iframe element isolated for DI purposes
 */
export var IFrame = function IFrame(_ref) {
  var childRef = _ref.childRef,
    className = _ref.className,
    extensionKey = _ref.extensionKey,
    props = _objectWithoutProperties(_ref, _excluded);
  var confluencePageData = useConfluencePageData(props.src || '', extensionKey || '');

  // Conditional rendering: Page component for lp-cc-embed URLs, iframe for everything else
  return confluencePageData ? /*#__PURE__*/React.createElement(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.createElement("iframe", _extends({
    className: className
  }, props, {
    ref: childRef,
    title: props.title
  }));
};