"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireDefault(require("react"));

require("./index.less");

var _LinkModal = _interopRequireDefault(require("../LinkModal"));

var _Iconfont = _interopRequireDefault(require("../Iconfont"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var __extends = void 0 && (void 0).__extends || function () {
  var _extendStatics = function extendStatics(d, b) {
    _extendStatics = Object.setPrototypeOf || {
      __proto__: []
    } instanceof Array && function (d, b) {
      d.__proto__ = b;
    } || function (d, b) {
      for (var p in b) {
        if (b.hasOwnProperty(p)) d[p] = b[p];
      }
    };

    return _extendStatics(d, b);
  };

  return function (d, b) {
    _extendStatics(d, b);

    function __() {
      this.constructor = d;
    }

    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();

var UrlPicker =
/** @class */
function (_super) {
  __extends(UrlPicker, _super);

  function UrlPicker() {
    var _this = _super !== null && _super.apply(this, arguments) || this;

    _this.state = {
      visible: false
    };
    return _this;
  }

  UrlPicker.prototype.render = function () {
    var _this = this;

    var visible = this.state.visible;
    var _a = this.props,
        value = _a.value,
        _onChange = _a.onChange;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "m-url-picker"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "input-url"
    }, /*#__PURE__*/_react["default"].createElement("input", {
      onChange: function onChange(e) {
        return _onChange(e.target.value);
      },
      placeholder: "Please add a link",
      type: "text",
      value: value
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: "icon-btns"
    }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
      color: "#000",
      onClick: function onClick() {
        return _this.setState({
          visible: true
        });
      },
      size: "20px",
      type: "icon-URLguanli"
    }), /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
      color: "#FF4141",
      onClick: function onClick() {
        return _onChange('');
      },
      size: "20px",
      type: "icon-delete1"
    }))), visible && /*#__PURE__*/_react["default"].createElement(_LinkModal["default"], {
      onClose: function onClose() {
        return _this.setState({
          visible: false
        });
      },
      onConfirm: function onConfirm(value) {
        _onChange(value);

        _this.setState({
          visible: false
        });
      },
      visible: visible
    }));
  };

  UrlPicker.defaultProps = {
    value: '',
    onChange: function onChange() {}
  };
  return UrlPicker;
}(_react["default"].Component);

var _default = UrlPicker;
exports["default"] = _default;