import { Schema } from "effect";
import { ActionSchemaFields } from "../../../../actions/schema.js";
import { commonFieldFields } from "../../../utils/common.js";
export const type = "com.shwfed.form.field.actions";
export const compatibilityDate = "2026-04-24";
export const metadata = {
  name: "\u64CD\u4F5C",
  icon: "fluent:cursor-click-20-regular",
  w: { initial: 8, min: 4, max: Infinity },
  h: { initial: 2, min: 2, max: Infinity },
  // Drills into its own nested button layout editor — too complex for the
  // fullscreen inline-config pane; keep the (fullscreen-exiting) drill-down.
  inlineConfig: false
};
export function schema(configure) {
  const { fields: actionFields } = ActionSchemaFields(configure);
  const { groups, items, ...rest } = actionFields;
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    ...commonFieldFields(configure),
    ...rest,
    // Form's add-field factory creates new fields with only { type, compatibilityDate, id },
    // so `groups` / `items` need defaults to decode an empty actions field.
    groups: Schema.optionalWith(groups, { default: () => [] }),
    items: Schema.optionalWith(items, { default: () => [] })
  }).annotations({
    title: "ActionsField",
    description: "\u6E32\u67D3\u4E00\u7EC4\u64CD\u4F5C\u6309\u94AE\uFF08\u4EC5\u5C55\u793A\uFF0C\u4E0D\u53C2\u4E0E\u8868\u5355\u63D0\u4EA4\uFF09"
  });
}
