"use strict";
const React = require("react");
const classNames = require("../_util/classNames.js");
const is = require("../_util/is.js");
const text = require("./text.js");
const image = require("./image.js");
const index = require("../ConfigProvider/index.js");
const useMergeProps = require("../_util/hooks/useMergeProps.js");
const pick = require("../_util/pick.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
function getComponentProps(prop) {
  return is.isObject(prop) ? prop : {};
}
var defaultProps = {
  text: true,
  loading: true
};
function Skeleton(baseProps, ref) {
  var _a;
  var _b = React.useContext(index.ConfigContext), getPrefixCls = _b.getPrefixCls, componentConfig = _b.componentConfig, rtl = _b.rtl;
  var props = useMergeProps(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Skeleton);
  var style = props.style, className = props.className, animation = props.animation, loading = props.loading, image$1 = props.image, text$1 = props.text, children = props.children;
  var imageProps = getComponentProps(image$1);
  var textProps = getComponentProps(text$1);
  var prefixCls = getPrefixCls("skeleton");
  var classNames$1 = classNames(prefixCls, (_a = {}, _a[prefixCls + "-animate"] = animation, _a[prefixCls + "-rtl"] = rtl, _a), className);
  function renderImage() {
    return image$1 && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: prefixCls + "-header",
      children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(image, {
        ...__assign({
          prefixCls
        }, imageProps)
      })
    });
  }
  function renderText() {
    return text$1 && /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: prefixCls + "-content",
      children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(text, {
        ...__assign({
          prefixCls
        }, textProps)
      })
    });
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(emotionReactJsxRuntime_browser_esm.Fragment, {
    children: loading ? /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
      ...__assign({}, pick.pickDataAttributes(props), {
        className: classNames$1,
        style,
        ref
      }),
      children: [imageProps.position !== "right" && renderImage(), renderText(), imageProps.position === "right" && renderImage()]
    }) : children
  });
}
var SkeletonComponent = React.forwardRef(Skeleton);
SkeletonComponent.displayName = "Skeleton";
const Skeleton$1 = SkeletonComponent;
module.exports = Skeleton$1;
//# sourceMappingURL=index.js.map
