"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LazyLazilyRenderCard = LazyLazilyRenderCard;
var _react = _interopRequireWildcard(require("react"));
var _reactLazilyRender = _interopRequireDefault(require("react-lazily-render"));
var _ufoExperiences = require("../../../state/analytics/ufoExperiences");
var _component = require("../component");
var _LoadingCardLink = require("./LoadingCardLink");
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); }
function LazyLazilyRenderCard(props) {
  var appearance = props.appearance,
    container = props.container,
    id = props.id;
  var offset = Math.ceil(window.innerHeight / 4);
  (0, _react.useState)(function () {
    // Start of experience when intersectionObserver is not supported.
    (0, _ufoExperiences.startUfoExperience)('smart-link-rendered', id);
  });
  return /*#__PURE__*/_react.default.createElement(_reactLazilyRender.default, {
    offset: offset,
    component: appearance === 'inline' ? 'span' : 'div'
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    ,
    className: "loader-wrapper",
    placeholder: /*#__PURE__*/_react.default.createElement(_LoadingCardLink.LoadingCardLink, props),
    scrollContainer: container,
    content: /*#__PURE__*/_react.default.createElement(_component.CardWithUrlContent, props)
  });
}