<template>
  <TempLine :data="tData" :ref="(v: any) => shape = v?.shape" :id="data.id" />
  <PropertyUpdate
    :describes="describes"
    :data="data"
    :target="shape"
    @change="emit('updateShape', { ...data })"
  />
  <Operate :target="shape" :menus="operateMenus" />
</template>

<script lang="ts" setup>
import { TriangleData, getMouseStyle, defaultStyle } from "./index.ts";
import { PropertyUpdate, Operate } from "../../propertys";
import TempLine from "./temp-triangle.vue";
import { useComponentStatus } from "@/core/hook/use-component.ts";

const props = defineProps<{ data: TriangleData }>();
const emit = defineEmits<{
  (e: "updateShape", value: TriangleData): void;
  (e: "addShape", value: TriangleData): void;
  (e: "delShape"): void;
}>();

const { shape, tData, operateMenus, describes } = useComponentStatus({
  emit,
  props,
  getMouseStyle,
  defaultStyle,
  transformType: "line",
  copyHandler(tf, data) {
    data.points = data.points.map((v) => tf.point(v));
    return data;
  },
});
</script>
