import { Schema } from "effect";
import { Expression } from "../../../../../share/expression.js";
import { Locale } from "../../../../../share/locale.js";
import { commonFieldFields, derivedField, FieldOrientationSchema } from "../../../utils/common.js";
export const type = "com.shwfed.form.field.number";
export const compatibilityDate = "2026-04-28";
export const metadata = {
  name: "\u6570\u503C\u8F93\u5165",
  icon: "fluent:number-symbol-20-regular",
  w: { initial: 8, min: 4, max: Infinity },
  h: { initial: 2, min: 2, max: 2 }
};
export function schema(configure) {
  const CelBool = Expression({ configure, resultType: "bool" });
  const CelNumber = Expression({ configure, resultType: "number" });
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    ...commonFieldFields(configure),
    label: Schema.optional(Locale.annotations({
      title: "\u6807\u7B7E",
      description: "\u5B57\u6BB5\u524D\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u5219\u4E0D\u6E32\u67D3\u6807\u7B7E"
    })),
    placeholder: Schema.optional(Locale.annotations({
      title: "\u5360\u4F4D\u7B26",
      description: "\u8F93\u5165\u4E3A\u7A7A\u65F6\u7684\u5360\u4F4D\u6587\u672C"
    })),
    tooltip: Schema.optional(Locale.annotations({
      title: "\u63D0\u793A",
      description: "\u9F20\u6807\u60AC\u505C\u5728\u6807\u7B7E\u4E0A\u65F6\u5C55\u793A\u7684\u8BF4\u660E"
    })),
    orientation: Schema.optional(FieldOrientationSchema),
    binding: Schema.optional(Schema.String.pipe(Schema.minLength(1)).annotations({
      title: "\u7ED1\u5B9A\u8DEF\u5F84",
      description: "\u5199\u5165\u8868\u5355\u72B6\u6001\u7684 `dot-prop` \u8DEF\u5F84\uFF0C\u4F8B\u5982 `user.age`\uFF1B\u7559\u7A7A\u5219\u4E3A\u975E\u53D7\u63A7\u5B57\u6BB5\uFF0C\u4E0D\u5199\u5165\u8868\u5355\u72B6\u6001"
    })),
    disabled: Schema.optional(CelBool.annotations({
      title: "\u7981\u7528\u6761\u4EF6",
      description: "\u8FD4\u56DE `true` \u65F6\u8F93\u5165\u6846\u4ECD\u7136\u6E32\u67D3\u4F46\u4E0D\u53EF\u7F16\u8F91"
    })),
    readonly: Schema.optional(CelBool.annotations({
      title: "\u53EA\u8BFB\u6761\u4EF6",
      description: "\u8FD4\u56DE `true` \u65F6\u4EC5\u4EE5\u7EAF\u6587\u672C\u5C55\u793A\u5F53\u524D\u503C"
    })),
    derived: derivedField(configure, "number"),
    precision: Schema.optional(Schema.Number.pipe(Schema.int(), Schema.nonNegative()).annotations({
      title: "\u5C0F\u6570\u4F4D\u6570",
      description: "\u4FDD\u7559\u7684\u5C0F\u6570\u4F4D\u6570\uFF1B\u7559\u7A7A\u8868\u793A\u4E0D\u9650\u5236\uFF08\u4EFB\u610F\u7CBE\u5EA6\uFF09"
    })),
    roundingMode: Schema.optional(Schema.Literal("round", "floor", "ceil").annotations({
      title: "\u53D6\u6574\u6A21\u5F0F",
      description: "\u8BBE\u7F6E\u4E86\u300C\u5C0F\u6570\u4F4D\u6570\u300D\u65F6\uFF0C\u5931\u7126\u65F6\u6309\u6B64\u6A21\u5F0F\u5C06\u503C\u53D6\u6574\uFF1B\u9ED8\u8BA4 `round`\uFF08\u56DB\u820D\u4E94\u5165\uFF09"
    })),
    step: Schema.optional(Schema.Number.pipe(Schema.positive()).annotations({
      title: "\u6B65\u957F",
      description: "\u53D6\u503C\u7684\u6700\u5C0F\u6B65\u957F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\uFF08\u4EFB\u610F\u7CBE\u5EA6\uFF09"
    })),
    valueAsString: Schema.optional(Schema.Boolean.annotations({
      title: "\u4EE5\u5B57\u7B26\u4E32\u8BFB\u5199",
      description: "\u5F00\u542F\u540E\u8868\u5355\u72B6\u6001\u4EE5\u5B57\u7B26\u4E32\u5F62\u5F0F\u5B58\u50A8\u8BE5\u503C\uFF08\u9002\u7528\u4E8E\u540E\u7AEF\u4F7F\u7528 `DECIMAL` / `BIGINT` \u7B49\u9700\u8981\u539F\u6837\u56DE\u4F20\u7684\u5B57\u6BB5\uFF09\uFF1B\u5173\u95ED\u65F6\u82E5\u8BFB\u5230\u7684\u662F\u6570\u503C\u5B57\u7B26\u4E32\u4E5F\u4F1A\u88AB\u89E3\u6790\uFF0C\u4F46\u5199\u56DE\u4ECD\u4E3A\u6570\u503C\u3002\u6CE8\u610F\uFF1A\u8F93\u5165\u65F6\u4ECD\u7ECF\u8FC7 JavaScript \u6D6E\u70B9\u6570\uFF0C\u4EC5\u80FD\u5728\u300C\u88C5\u8F7D-\u56DE\u4F20\u300D\u672A\u7F16\u8F91\u573A\u666F\u4E0B\u4FDD\u7559\u7CBE\u5EA6"
    })),
    min: Schema.optional(CelNumber.annotations({
      title: "\u6700\u5C0F\u503C",
      description: "\u5141\u8BB8\u8F93\u5165\u7684\u6700\u5C0F\u503C\u8868\u8FBE\u5F0F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\u4E0B\u9650"
    })),
    max: Schema.optional(CelNumber.annotations({
      title: "\u6700\u5927\u503C",
      description: "\u5141\u8BB8\u8F93\u5165\u7684\u6700\u5927\u503C\u8868\u8FBE\u5F0F\uFF1B\u7559\u7A7A\u65F6\u4E0D\u9650\u5236\u4E0A\u9650"
    }))
  }).annotations({
    title: "NumberField",
    description: "\u6570\u503C\u8F93\u5165"
  });
}
