"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    ReadPretty: ()=>ReadPretty
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
require("react");
const components_namespaceObject = require("@tachybase/components");
const css_namespaceObject = require("@emotion/css");
const external_antd_namespaceObject = require("antd");
const external_classnames_namespaceObject = require("classnames");
var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_classnames_namespaceObject);
const external_index_js_namespaceObject = require("../../index.js");
const external_EllipsisWithTooltip_js_namespaceObject = require("./EllipsisWithTooltip.js");
const external_shared_js_namespaceObject = require("./shared.js");
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n          margin-bottom: 0;\n          line-height: 1.5;\n          font-size: 90%;\n        "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const ReadPretty = ()=>null;
const _Input = (props)=>{
    const prefixCls = (0, components_namespaceObject.usePrefixCls)('description-input', props);
    const compile = (0, external_index_js_namespaceObject.useCompile)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: external_classnames_default()(prefixCls, props.className),
        style: {
            display: 'flex',
            alignItems: 'center',
            overflowWrap: 'break-word',
            whiteSpace: 'normal',
            ...props.style
        },
        children: [
            compile(props.addonBefore),
            compile(props.prefix),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_EllipsisWithTooltip_js_namespaceObject.EllipsisWithTooltip, {
                ellipsis: props.ellipsis,
                children: compile(props.value)
            }),
            compile(props.suffix),
            compile(props.addonAfter)
        ]
    });
};
const _TextArea = (props)=>{
    const prefixCls = (0, components_namespaceObject.usePrefixCls)('description-textarea', props);
    const compile = (0, external_index_js_namespaceObject.useCompile)();
    var _props_value;
    const value = compile(null !== (_props_value = props.value) && void 0 !== _props_value ? _props_value : '');
    const { autop = true, ellipsis, text } = props;
    const html = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        style: {
            lineHeight: 1.612
        },
        dangerouslySetInnerHTML: {
            __html: (0, external_shared_js_namespaceObject.HTMLEncode)(value).split('\n').join('<br/>')
        }
    });
    const content = ellipsis ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_EllipsisWithTooltip_js_namespaceObject.EllipsisWithTooltip, {
        ellipsis: ellipsis,
        popoverContent: autop ? html : value,
        children: text || value
    }) : autop ? html : value;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: external_classnames_default()(prefixCls, props.className),
        style: {
            overflowWrap: 'break-word',
            ...props.style
        },
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
function convertToText(html) {
    const temp = document.createElement('div');
    temp.innerHTML = html;
    const text = temp.innerText;
    return (null == text ? void 0 : text.replace(/[\n\r]/g, '')) || '';
}
const _Html = (props)=>{
    const prefixCls = (0, components_namespaceObject.usePrefixCls)('description-textarea', props);
    const compile = (0, external_index_js_namespaceObject.useCompile)();
    var _props_value;
    const value = compile(null !== (_props_value = props.value) && void 0 !== _props_value ? _props_value : '');
    const { autop = true, ellipsis } = props;
    const html = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        dangerouslySetInnerHTML: {
            __html: value
        }
    });
    const text = convertToText(value);
    const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_EllipsisWithTooltip_js_namespaceObject.EllipsisWithTooltip, {
        ellipsis: ellipsis,
        popoverContent: autop ? html : value,
        children: ellipsis ? text : html
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: external_classnames_default()(prefixCls, props.className),
        style: {
            overflowWrap: 'break-word',
            ...props.style
        },
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
const _URL = (props)=>{
    var _props_value;
    const prefixCls = (0, components_namespaceObject.usePrefixCls)('description-url', props);
    const content = props.value && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Link, {
        ellipsis: true,
        target: '_blank',
        href: props.value,
        children: null === (_props_value = props.value) || void 0 === _props_value ? void 0 : _props_value.toString()
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        className: external_classnames_default()(prefixCls, props.className),
        style: props.style,
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
const _JSON = (props)=>{
    const prefixCls = (0, components_namespaceObject.usePrefixCls)('json', props);
    var _props_space;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
        className: external_classnames_default()(prefixCls, props.className, (0, css_namespaceObject.css)(_templateObject())),
        style: props.style,
        children: null != props.value ? JSON.stringify(props.value, null, null !== (_props_space = props.space) && void 0 !== _props_space ? _props_space : 2) : ''
    });
};
ReadPretty.Input = _Input;
ReadPretty.TextArea = _TextArea;
ReadPretty.URL = _URL;
ReadPretty.Html = _Html;
ReadPretty.JSON = _JSON;
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
