/* ExpandedFrame.tsx generated by @compiled/babel-plugin v0.39.1 */
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ExpandedFrame = void 0;
require("./ExpandedFrame.compiled.css");
var React = _interopRequireWildcard(require("react"));
var _runtime = require("@compiled/react/runtime");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
var _useLinkClicked = require("../../../state/analytics/useLinkClicked");
var _utils = require("../../common/utils");
var _styled = require("./styled");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
// eslint-disable-next-line no-unused-vars
var styles = {
  linkWrapper: "_zulpu2gc _kqswh2mm _1e0c1txw _2lx21bp4 _4t3ik5xz _ca0qu2gc _u5f3u2gc _n3tdu2gc _19bvu2gc _uiztglyw _qc5o94zs _14mjpb1k _aetrb3bt _18postnw _15l2idpf _32rxidpf _1x88idpf _19doidpf _1hfk1j28 _1bqqidpf _u94kidpf _1ifiidpf",
  linkWrapperInheritDimensions: "_4t3i1osq",
  linkWrapperSelected: "_8x3u1yw3",
  linkWrapperBorderAndBackground: "_1tqzia51 _1hfkhp5a _1ifikb7n",
  linkWrapperInteractiveNotHidden: "_hcgvia51 _4tpuhp5a _x148kb7n",
  header: "_11c81qyo _zulp1b66 _1e0c1txw _4cvr1h6o _1bah1yb4 _4t3igktf _1pbykb7n",
  leftSection: "_zulp1b66 _1e0c1txw _4cvr1h6o _1ul9idpf",
  tooltipWrapper: "_1reo15vq _18m915vq",
  headerAnchor: "_11c81qyo _1reo15vq _18m915vq _1e0c1ule _1bto1l2s _o5721q9c _9oik1r31 _1bnxglyw _jf4cnqa1",
  headerIcon: "_11c81qyo _1bsb7vkz _4t3i7vkz",
  contentStyle: "_19itdlqj _2rkoy00x _1reo15vq _18m915vq _v56414au _bfhkhp5a _16jlkb7n _4t3i1osq _1pbykb7n",
  contentInteractiveActiveBorder: "_1jhm1tt7",
  contentOverflowAuto: "_1reo1wug _18m91wug"
};
var ExpandedFrame = exports.ExpandedFrame = function ExpandedFrame(_ref) {
  var _ref$isPlaceholder = _ref.isPlaceholder,
    isPlaceholder = _ref$isPlaceholder === void 0 ? false : _ref$isPlaceholder,
    children = _ref.children,
    onClick = _ref.onClick,
    onAuxClick = _ref.onAuxClick,
    onContextMenu = _ref.onContextMenu,
    icon = _ref.icon,
    text = _ref.text,
    isSelected = _ref.isSelected,
    _ref$frameStyle = _ref.frameStyle,
    frameStyle = _ref$frameStyle === void 0 ? 'showOnHover' : _ref$frameStyle,
    href = _ref.href,
    minWidth = _ref.minWidth,
    maxWidth = _ref.maxWidth,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'expanded-frame' : _ref$testId,
    inheritDimensions = _ref.inheritDimensions,
    _ref$allowScrollBar = _ref.allowScrollBar,
    allowScrollBar = _ref$allowScrollBar === void 0 ? false : _ref$allowScrollBar,
    _ref$setOverflow = _ref.setOverflow,
    setOverflow = _ref$setOverflow === void 0 ? true : _ref$setOverflow,
    CompetitorPrompt = _ref.CompetitorPrompt,
    onContentMouseEnter = _ref.onContentMouseEnter,
    onContentMouseLeave = _ref.onContentMouseLeave;
  var isInteractive = function isInteractive() {
    return !isPlaceholder && (Boolean(href) || Boolean(onClick));
  };
  var handleClick = function handleClick(event) {
    return (0, _utils.handleClickCommon)(event, onClick);
  };
  var handleMouseDown = (0, _useLinkClicked.useMouseDownEvent)();
  var CompetitorPromptComponent = CompetitorPrompt && href ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
    sourceUrl: href,
    linkType: "embed"
  }) : null;
  var renderHeader = function renderHeader() {
    return frameStyle !== 'hide' && /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.header, "embed-header"])
    }, /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.leftSection])
    }, /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.headerIcon])
    }, icon), /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.tooltipWrapper])
    }, !isPlaceholder && /*#__PURE__*/React.createElement(_tooltip.default, {
      content: text,
      hideTooltipOnMouseDown: true
    }, /*#__PURE__*/React.createElement("a", {
      href: href,
      onClick: handleClick,
      onAuxClick: onAuxClick,
      onContextMenu: onContextMenu,
      onMouseDown: handleMouseDown,
      className: (0, _runtime.ax)([styles.headerAnchor])
    }, text)))), CompetitorPromptComponent);
  };
  var interactive = isInteractive();
  var showBackgroundAlways = frameStyle === 'show' || isSelected && frameStyle !== 'hide';
  var showBackgroundOnHover = interactive && frameStyle !== 'hide';
  var renderContent = function renderContent() {
    return /*#__PURE__*/React.createElement("div", {
      "data-testid": "embed-content-wrapper",
      // This fixes an issue with input fields in cross domain iframes (ie. databases and jira fields from different domains)
      // See: HOT-107830
      contentEditable: false,
      onMouseEnter: onContentMouseEnter,
      onMouseLeave: onContentMouseLeave,
      onFocus: onContentMouseEnter,
      onBlur: onContentMouseLeave,
      className: (0, _runtime.ax)([styles.contentStyle, setOverflow && allowScrollBar && styles.contentOverflowAuto, interactive && !showBackgroundAlways && !showBackgroundOnHover && styles.contentInteractiveActiveBorder])
    }, children);
  };
  return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    className: (0, _runtime.ax)([styles.linkWrapper, inheritDimensions && styles.linkWrapperInheritDimensions, isSelected && frameStyle !== 'hide' && styles.linkWrapperSelected, showBackgroundAlways && styles.linkWrapperBorderAndBackground, showBackgroundOnHover && !showBackgroundAlways && styles.linkWrapperInteractiveNotHidden, _styled.className]),
    style: {
      minWidth: minWidth ? "".concat(minWidth, "px") : '',
      maxWidth: maxWidth ? "".concat(maxWidth, "px") : ''
    },
    "data-testid": testId,
    "data-trello-do-not-use-override": testId
    // Due to limitations of testing library, we can't assert ::after
    ,
    "data-is-selected": isSelected
  }, (isPlaceholder || !href) && {
    'data-wrapper-type': 'default',
    'data-is-interactive': isInteractive()
  }), renderHeader(), renderContent());
};