import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React, { PureComponent } from "react";
import MonacoEditor from "@alilc/lowcode-plugin-base-monaco-editor";
export var JSFunctionComp = /*#__PURE__*/function (_PureComponent) {
  function JSFunctionComp() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
    _this.handleEditorChange = function (newValue) {
      var _this$props$onChange, _this$props;
      (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, {
        type: "JSFunction",
        value: newValue
      });
    };
    return _this;
  }
  _inheritsLoose(JSFunctionComp, _PureComponent);
  var _proto = JSFunctionComp.prototype;
  _proto.render = function render() {
    var _value$value;
    var value = this.props.value;
    return /*#__PURE__*/React.createElement("div", {
      className: "jsFunction_box"
    }, /*#__PURE__*/React.createElement(MonacoEditor, {
      theme: "vs-vision",
      value: (_value$value = value === null || value === void 0 ? void 0 : value.value) !== null && _value$value !== void 0 ? _value$value : "",
      language: "javascript",
      onChange: this.handleEditorChange
    }));
  };
  return JSFunctionComp;
}(PureComponent);