import type { DragRule } from 'form-create-designer';
import other from "/@/utils/other";

// Create a map of rule creators
const ruleCreators: Record<string, () => DragRule> = {
	UserPicker: () => ({
		menu: 'biz',
		icon: 'iconfont icon-icon-',
		label: '人员',
		name: 'UserPicker',
		mask: true,
		rule() {
			return {
				type: 'UserPicker',
				field: 'UserPicker' +  other.getNonDuplicateID(),
				title: '人员',
				$required: true,
				props: {
					multiple: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '多选',
					field: 'multiple',
					value: false,
				},
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				},
			];
		},
	}),
	RolePicker: () => ({
		menu: 'biz',
		icon: 'iconfont icon-gerenzhongxin',
		label: '角色',
		name: 'RolePicker',
		mask: true,
		rule() {
			return {
				type: 'RolePicker',
				field: 'RolePicker' +  other.getNonDuplicateID(),
				title: '角色',
				$required: true,
				props: {
					multiple: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '多选',
					field: 'multiple',
					value: false,
				},
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	PostPicker: () => ({
		menu: 'biz',
		icon: 'iconfont icon-siweidaotu font14',
		label: '岗位',
		name: 'PostPicker',
		mask: true,
		rule() {
			return {
				type: 'PostPicker',
				field: 'PostPicker' +  other.getNonDuplicateID(),
				title: '岗位',
				$required: true,
				props: {
					multiple: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '多选',
					field: 'multiple',
					value: false,
				},
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	DeptPicker: () => ({
		menu: 'biz',
		icon: 'iconfont icon-shouye',
		label: '部门',
		name: 'DeptPicker',
		mask: true,
		rule() {
			return {
				type: 'DeptPicker',
				field: 'DeptPicker' +  other.getNonDuplicateID(),
				title: '部门',
				$required: true,
				props: {
					multiple: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '多选',
					field: 'multiple',
					value: false,
				},
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	PhoneInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-dianhua',
		label: '手机号',
		name: 'PhoneInput',
		mask: true,
		rule() {
			return {
				type: 'PhoneInput',
				field: 'PhoneInput' +  other.getNonDuplicateID(),
				title: '手机号',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	IdCartInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-tupianyulan',
		label: '身份证号',
		name: 'IdCartInput',
		mask: true,
		rule() {
			return {
				type: 'IdCartInput',
				field: 'IdCartInput' +  other.getNonDuplicateID(),
				title: '身份证号',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	FormNameInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-putong',
		label: '表单名称',
		name: 'FormNameInput',
		mask: true,
		rule() {
			return {
				type: 'FormNameInput',
				field: 'formName',
				title: '表单名称',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	FlowNameInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-shuxingtu',
		label: '流程名称',
		name: 'FlowNameInput',
		mask: true,
		rule() {
			return {
				type: 'FlowNameInput',
				field: 'flowName',
				title: '流程名称',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	FormCodeInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-quanjushezhi_o',
		label: '流程CODE',
		name: 'FormCodeInput',
		mask: true,
		rule() {
			return {
				type: 'FormCodeInput',
				field: 'code',
				title: '流程CODE',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	EmailInput: () => ({
		menu: 'biz',
		icon: 'iconfont icon-xingqiu',
		label: '邮箱',
		name: 'EmailInput',
		mask: true,
		rule() {
			return {
				type: 'EmailInput',
				field: 'EmailInput' +  other.getNonDuplicateID(),
				title: '邮箱',
				$required: true,
				props: {
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				}
			];
		},
	}),
	SignInput: () => ({
		menu: 'biz',
		icon: 'icon-edit',
		label: '签名',
		name: 'SignInput',
		mask: true,
		rule() {
			return {
				type: 'SignInput',
				field: 'SignInput'+ other.getNonDuplicateID(),
				title: '签名',
				$required: true,
				props: {
					bgColor: '#F6F8FA',
					isClearBgColor: false,
					disabled: false,
				},
			};
		},
		props() {
			return [
				{
					type: 'switch',
					title: '禁用',
					field: 'disabled',
					value: false,
				},
				{
					type: 'number',
					title: '宽度',
					field: 'width',
					value: 300,
					props: {
						min: 100,
						max: 1000,
					},
				},
				{
					type: 'number',
					title: '高度',
					field: 'height',
					value: 150,
					props: {
						min: 50,
						max: 500,
					},
				},
				{
					type: 'number',
					title: '线宽',
					field: 'lineWidth',
					value: 4,
					props: {
						min: 1,
						max: 20,
					},
				},
				{
					type: 'colorPicker',
					title: '线条颜色',
					field: 'lineColor',
					value: '#000000',
				},
				{
					type: 'colorPicker',
					title: '背景颜色',
					field: 'bgColor',
					value: '#F6F8FA',
				},
				{
					type: 'switch',
					title: '裁剪空白',
					field: 'isCrop',
					value: false,
				},
				{
					type: 'switch',
					title: '清除背景',
					field: 'isClearBgColor',
					value: false,
				},
			];
		},
	}),
};

// Export all rules as an array
export const rules: any[] = Object.values(ruleCreators).map((creator) => creator());
