/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

import { __extends } from 'tslib';
import React__default from 'react';
import { themeable } from 'amis-core';
import { HTMLFilterContext } from '../HTMLFilterContext.js';

/**
 * @file Html
 * @description
 * @author fex
 */
var Html = /** @class */ (function (_super) {
    __extends(Html, _super);
    function Html(props) {
        var _this = _super.call(this, props) || this;
        _this.htmlRef = _this.htmlRef.bind(_this);
        return _this;
    }
    Html.prototype.componentDidUpdate = function (prevProps) {
        if (this.props.html !== prevProps.html) {
            this._render();
        }
    };
    Html.prototype.htmlRef = function (dom) {
        this.dom = dom;
        if (!dom) {
            return;
        }
        this._render();
    };
    Html.prototype._render = function () {
        var _a = this.props, html = _a.html, filterHtml = _a.filterHtml;
        if (html) {
            var filter = filterHtml || this.context || (function (text) { return text; });
            this.dom.innerHTML = filter(html);
        }
    };
    Html.prototype.render = function () {
        var _a = this.props, className = _a.className, wrapperComponent = _a.wrapperComponent, inline = _a.inline; _a.classPrefix; var cx = _a.classnames;
        var Component = wrapperComponent || (inline ? 'span' : 'div');
        return (React__default.createElement(Component, { ref: this.htmlRef, className: cx("Html", className) }));
    };
    Html.defaultProps = {
        inline: true
    };
    Html.contextType = HTMLFilterContext;
    return Html;
}(React__default.Component));
var Html$1 = themeable(Html);

export { Html, Html$1 as default };
