import { h } from './chunks/d4789960.js';
import './chunks/456564be.js';
import { u as useProp } from './chunks/c26036df.js';
import { u as useEvent } from './chunks/d4058887.js';
import './chunks/4ccc6eeb.js';
import './chunks/34f18ef7.js';
import { g as getComponentOrDefine } from './chunks/071ed725.js';
import './chunks/23e44913.js';
import './chunks/d91e4e4a.js';
import { M as Maybe_3 } from './chunks/d76d6172.js';
import './kun-icon.js';
import './kun-button-puer.js';
import './kun-checkbox.js';
import { r } from './chunks/18a657cf.js';

var style = ":host {\n}\n";

// final val OPEN = Value(1, "OPEN")
// final val LINK = Value(2, "LINK") // title, link
// final val BOOK = Value(3, "BOOK") // book, link`
// final val CALC = Value(4, "CALC") // book, link`
// final val SELECT = Value(5, "SELECT") // book, link`
// final val ORDER = Value(6, "ORDER") // book, link`
// final val CHECK = Value(7, "CHECK") // book, link`

const getTitle = type => {
  if (type === "SELECT") {
    return "选择题";
  }

  if (type === "OPEN") {
    return "问答题";
  }

  if (type === "CALC") {
    return "计算题";
  }

  if (type === "CHECK") {
    return "判断题";
  }

  return "练习题";
};

const defaultSeries = {
  channelId: 50,
  seriesId: "AR",
  postId: "den",
  id: "8ca3c6a0-a13a-11ea-b2de-8583ea9a54e8",
  exerciseType: "OPEN",
  background: null,
  title: "dddd",
  tips: null,
  tags: [],
  correct: [],
  options: [],
  answer: "d",
  editor: "d13e2460-b025-11e9-b2ef-bff457d1b4dd",
  editorName: "liming",
  postTitle: null,
  seriesName: null,
  seriesType: null
};

const KunItemExercise = () => {
  const [kunExercise] = useProp("kunExercise");
  const [kunNumber] = useProp("kunNumber");
  const onEdit = useEvent("MyEdit", {
    composed: true,
    bubbles: true
  });
  const onDelete = useEvent("MyDelete", {
    composed: true,
    bubbles: true
  });
  const exercise = Maybe_3.fromNullable(kunExercise).orDefault(defaultSeries);

  const deleteExercise = exerciseItem => {
    onDelete(exerciseItem);
  };

  const editExercise = exerciseItem => {
    onEdit(exerciseItem);
  };

  return h("host", null, h("style", null, style), h("div", {
    class: "border border-r-2 border-solid p-4 bg-white"
  }, h("div", {
    class: "flex items-center mb-4"
  }, "\u9898\u76EE", kunNumber, h("span", {
    class: "ml-2"
  }, getTitle(exercise.exerciseType))), h("div", {
    class: "flex flex-row"
  }, h("span", {
    class: "mr-2"
  }, "\u95EE\u9898:"), exercise.title), exercise.exerciseType === r.SELECT && h("div", {
    className: "flex flex-row"
  }, h("span", {
    className: "mr-2"
  }, "\u7B54\u6848:"), h("div", {
    class: "ml-8"
  }, exercise.options.map((option, index) => h("div", {
    class: "flex flex-row mt-2 items-center"
  }, h("kun-checkbox", {
    checked: exercise.correct.indexOf(index) > -1,
    class: "mr-2",
    disabled: true
  }), h("div", null, option))))), exercise.exerciseType === r.OPEN && h("div", {
    className: "flex flex-row"
  }, h("span", {
    className: "mr-2"
  }, "\u7B54\u6848:"), exercise.answer), h("div", {
    class: "py-2 flex flex-row justify-end items-center"
  }, h("kun-icon", {
    iconType: "bianji",
    iconWidth: 28,
    iconHeight: 28,
    onclick: () => editExercise(exercise)
  }), h("kun-icon", {
    iconType: "shanchu",
    iconWidth: 20,
    iconHeight: 20,
    onclick: () => deleteExercise(exercise)
  }))));
};

KunItemExercise.props = {
  kunExercise: {
    type: Object
  },
  kunNumber: {
    type: Number,
    value: 1
  }
};
var kunItemExercise = getComponentOrDefine("kun-item-exercise", KunItemExercise);

export default kunItemExercise;
//# sourceMappingURL=kun-item-exercise.js.map
