import PropTypes from "prop-types";
import React, { Component } from "react";
import { BlockSpoilerComponent } from "../block-spoiler-component.js";
const SpoilerEditorWrapper = (config) => (WrappedComponent) => {
  var _a;
  return _a = class extends Component {
    constructor(props) {
      super(props);
      this.handleDescriptionChange = (description) => {
        this.updateComponentData({ description });
      };
      this.handleButtonContentChange = (buttonContent) => {
        this.updateComponentData({ buttonContent });
      };
      this.updateComponentData = (data) => {
        const { componentData } = this.props;
        const { spoiler } = componentData?.config ?? {};
        const config2 = { ...componentData?.config, spoiler: { ...spoiler, ...data } };
        this.props.store.update(
          "componentData",
          { ...componentData, config: config2 },
          this.props.block.getKey()
        );
      };
      const type = props.blockProps.type?.replace("wix-draft-plugin-", "");
      this.pluginType = type[0].toUpperCase() + type.slice(1);
    }
    render() {
      const { componentData, onClick, className, setInPluginEditingMode, blockProps, isMobile, t } = this.props;
      const hasSpoiler = this.props.componentData?.config?.spoiler?.enabled || false;
      return hasSpoiler ? /* @__PURE__ */ React.createElement(
        BlockSpoilerComponent,
        {
          disabledRevealSpoilerBtn: true,
          isEditableText: true,
          handleButtonContentChange: this.handleButtonContentChange,
          handleDescriptionChange: this.handleDescriptionChange,
          pluginType: this.pluginType,
          componentData,
          onClick,
          className,
          setFocusToBlock: blockProps?.setFocusToBlock,
          setInPluginEditingMode,
          isMobile,
          t,
          ...config
        },
        /* @__PURE__ */ React.createElement(WrappedComponent, { ...this.props })
      ) : /* @__PURE__ */ React.createElement(WrappedComponent, { ...this.props });
    }
  }, _a.alignmentClassName = WrappedComponent?.alignmentClassName, _a.sizeClassName = WrappedComponent?.sizeClassName, _a.textWrapClassName = WrappedComponent?.textWrapClassName, _a.customClassName = WrappedComponent?.customClassName, _a.propTypes = {
    blockProps: PropTypes.object,
    componentData: PropTypes.object,
    pluginType: PropTypes.string,
    onClick: PropTypes.func,
    className: PropTypes.string,
    setFocusToBlock: PropTypes.func,
    setInPluginEditingMode: PropTypes.func,
    store: PropTypes.object,
    block: PropTypes.object,
    t: PropTypes.func,
    isMobile: PropTypes.bool
  }, _a;
};
export {
  SpoilerEditorWrapper
};
//# sourceMappingURL=spoiler-editor-wrapper.js.map
