import z from 'zod';

export const KeyValueSchema = <
  TK extends z.ZodTypeAny,
  TV extends z.ZodTypeAny,
>(
  keySchema: TK,
  valueSchema: TV,
) =>
  z.object({
    command: z.string().describe('Command').optional(),
    description: z.string().describe('Description text').optional(),
    enabled: z.boolean().describe('Whether this is enabled').optional(),
    group: z.string().describe('Group').optional(),
    key: keySchema.describe('Key').optional(),
    label: z.string().describe('Label').optional(),
    selected: z
      .boolean()
      .describe('Whether this option is currently selected')
      .optional(),
    sort: z.number().describe('Sort criteria').optional(),
    value: valueSchema.describe('Value').optional(),
  });

export const KeyValueOfStringAndStringSchema = KeyValueSchema(
  z.string(),
  z.string(),
);

export type KeyValueOfStringAndString = z.infer<
  typeof KeyValueOfStringAndStringSchema
>;
