import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__ant_design_icons__ from "@ant-design/icons";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE__style_theme_index_mjs__ from "../../../style/theme/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__input_index_mjs__ from "../input/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__Markdown_Void_mjs__ from "./Markdown.Void.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__style_mjs__ from "./style.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__util_mjs__ from "./util.mjs";
const Markdown = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.connect)(__WEBPACK_EXTERNAL_MODULE_antd__.Input.TextArea, (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapProps)((props, field)=>({
        autoSize: {
            maxRows: 10,
            minRows: 3
        },
        ...props,
        suffix: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
            children: (null == field ? void 0 : field['loading']) || (null == field ? void 0 : field['validating']) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.LoadingOutlined, {}) : props.suffix
        })
    })), (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.mapReadPretty)((props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(MarkdownReadPretty, {
        ...props
    })));
const MarkdownReadPretty = (props)=>{
    const { isDarkTheme } = (0, __WEBPACK_EXTERNAL_MODULE__style_theme_index_mjs__.useGlobalTheme)();
    const { wrapSSR, hashId, componentCls: className } = (0, __WEBPACK_EXTERNAL_MODULE__style_mjs__.useStyles)({
        isDarkTheme
    });
    const { html = '', loading } = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.useParseMarkdown)(props.value);
    const text = (0, __WEBPACK_EXTERNAL_MODULE__util_mjs__.convertToText)(html);
    const value = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        className: "".concat(hashId, " ").concat(className, " tb-markdown tb-markdown-default tb-markdown-table"),
        dangerouslySetInnerHTML: {
            __html: html
        }
    });
    if (loading) return wrapSSR(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Spin, {}));
    return wrapSSR(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__input_index_mjs__.ReadPretty.TextArea, {
        ...props,
        autop: false,
        text: text,
        value: value
    }));
};
Markdown.Void = __WEBPACK_EXTERNAL_MODULE__Markdown_Void_mjs__.MarkdownVoid;
const Markdown_rslib_entry_ = Markdown;
export { Markdown, MarkdownReadPretty, Markdown_rslib_entry_ as default };
