import { reservedValidationFields } from "@inkline/inkline/constants";
export function setSchemaStateRecursively(schema, values) {
  const resolvedSchema = {
    ...schema
  };
  Object.keys(values).forEach((key) => {
    const value = values[key];
    if (!Array.isArray(schema)) {
      resolvedSchema[key] = value;
    }
  });
  Object.keys(schema).filter((key) => !reservedValidationFields.includes(key)).forEach((key) => {
    const field = schema[key];
    if (typeof schema[key] === "object" || Array.isArray(schema[key])) {
      resolvedSchema[key] = setSchemaStateRecursively(
        field,
        values
      );
    }
  });
  return resolvedSchema;
}
