<script setup>
import { computed } from "vue";
import { schema } from "./schema";
import { getStructFieldTitle } from "../../../schema";
import { Field, FieldLabel } from "../../../../ui/field";
import TriggersField from "../../../components/triggers-field.vue";
defineOptions({ name: "ShwfedEventDispatchActionConfig" });
const value = defineModel({ type: null, ...{ required: true } });
const triggersTitle = getStructFieldTitle(schema(() => {
}), "triggers") ?? "\u89E6\u53D1\u7684\u64CD\u4F5C";
const triggers = computed(() => value.value.triggers ?? []);
function updateTriggers(next) {
  const draft = { ...value.value };
  if (next.length === 0) Reflect.deleteProperty(draft, "triggers");
  else draft.triggers = next;
  value.value = draft;
}
</script>

<template>
  <div class="flex flex-col gap-3">
    <Field orientation="vertical">
      <FieldLabel class="text-xs text-zinc-500">
        {{ triggersTitle }}
      </FieldLabel>
      <TriggersField
        :triggers="triggers"
        @update:triggers="updateTriggers"
      />
    </Field>
  </div>
</template>
