import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React, { useState } from "react";
import SimpleDialog from "../SimpleDialog";
import TextAreaWithUpload from "../TextAreaWithUpload";

var ImportTextSnippetsDialog = function ImportTextSnippetsDialog(_ref) {
  var open = _ref.open,
      onClose = _ref.onClose,
      onAddSamples = _ref.onAddSamples;

  var _useState = useState(""),
      _useState2 = _slicedToArray(_useState, 2),
      content = _useState2[0],
      changeContent = _useState2[1];

  return /*#__PURE__*/React.createElement(SimpleDialog, {
    open: open,
    onClose: onClose,
    title: "Import Text Snippets",
    actions: [{
      text: "Add Samples",
      onClick: function onClick() {
        onAddSamples(content.split("\n").map(function (l) {
          return l.trim();
        }).filter(Boolean).map(function (s) {
          return {
            document: s
          };
        }));
      }
    }]
  }, /*#__PURE__*/React.createElement(TextAreaWithUpload, {
    content: content,
    onChangeContent: changeContent,
    placeholder: "Paste Snippets here\nOne snippet per line.\n\nYou can also drag a text or csv file here (double click to open file dialog)"
  }));
};

export default ImportTextSnippetsDialog;