import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import React from "react";
import Survey from "material-survey/components/Survey";
import getTaskDescription from "../../utils/get-task-description.js";
import SampleContainer from "../SampleContainer";
export var DataEntry = function DataEntry(_ref) {
  var containerProps = _ref.containerProps,
      iface = _ref.interface,
      sample = _ref.sample,
      sampleIndex = _ref.sampleIndex,
      onModifySample = _ref.onModifySample;
  var form = sample.surveyjs || iface.surveyjs;
  if (!form) throw new Error("No survey/form created. Try adding some inputs in Setup");
  return /*#__PURE__*/React.createElement(SampleContainer, Object.assign({}, containerProps, {
    currentSampleIndex: sampleIndex,
    taskOutput: sample === null || sample === void 0 ? void 0 : sample.annotation,
    description: getTaskDescription(sample) || (iface === null || iface === void 0 ? void 0 : iface.description)
  }), /*#__PURE__*/React.createElement(Survey, {
    key: sampleIndex,
    variant: "flat",
    form: form,
    defaultAnswers: sample.annotation || undefined,
    completeText: "Save & Next",
    onFinish: function onFinish(answers) {
      onModifySample(_objectSpread(_objectSpread({}, sample), {}, {
        annotation: answers
      }));
      containerProps.onExit("go-to-next");
    }
  }));
};
export default DataEntry;