import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import React, { useState } from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import { HotKeys } from "react-hotkeys";
import DatasetEditor from "./";

var Controller = function Controller(props) {
  var _useState = useState(props.initialDataset),
      _useState2 = _slicedToArray(_useState, 2),
      dataset = _useState2[0],
      changeDataset = _useState2[1];

  return /*#__PURE__*/React.createElement(DatasetEditor, Object.assign({
    dataset: dataset,
    onChangeDataset: function onChangeDataset() {
      changeDataset.apply(void 0, arguments);
      action("onChangeDataset").apply(void 0, arguments);
    }
  }, props));
};

storiesOf("DatasetEditor", module).add("Basic", function () {
  return /*#__PURE__*/React.createElement(Controller, {
    initialDataset: {
      interface: {
        type: "image_segmentation",
        labels: ["valid", "invalid"],
        regionTypesAllowed: ["bounding-box", "polygon", "point"]
      },
      samples: [{
        imageUrl: "https://s3.amazonaws.com/asset.workaround.online/example-jobs/sticky-notes/image1.jpg"
      }, {
        imageUrl: "https://s3.amazonaws.com/asset.workaround.online/example-jobs/sticky-notes/image2.jpg"
      }],
      taskOutput: [{
        regionType: "bounding-box",
        centerX: 0.5,
        centerY: 0.5,
        width: 0.25,
        height: 0.25
      }]
    },
    onChangeFileName: action("onChangeFileName")
  });
}).add("Basic with Hotkeys", function () {
  return /*#__PURE__*/React.createElement(HotKeys, {
    keyMap: {
      zoom_tool: "z",
      pan_tool: "p"
    }
  }, /*#__PURE__*/React.createElement(Controller, {
    initialDataset: {
      interface: {
        type: "image_segmentation",
        labels: ["valid", "invalid"],
        regionTypesAllowed: ["bounding-box", "polygon", "point"]
      },
      samples: [{
        imageUrl: "https://s3.amazonaws.com/asset.workaround.online/example-jobs/sticky-notes/image1.jpg"
      }, {
        imageUrl: "https://s3.amazonaws.com/asset.workaround.online/example-jobs/sticky-notes/image2.jpg"
      }],
      taskOutput: [{
        regionType: "bounding-box",
        centerX: 0.5,
        centerY: 0.5,
        width: 0.25,
        height: 0.25
      }]
    },
    onChangeFileName: action("onChangeFileName")
  }));
});