import { isAllOfSchema, isObjectSchema, isOneOfSchema } from "./type-utils.js";
export function visitSchemaProperties(schema, path, callback) {
    if (isObjectSchema(schema)) {
        for (const [name, propSchema] of Object.entries(schema.properties)) {
            const newPath = [...path, 'properties', name];
            callback(propSchema, newPath);
            if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
                visitSchemaProperties(propSchema, newPath, callback);
            }
        }
    }
    else if (isAllOfSchema(schema)) {
        for (const [index, propSchema] of Object.entries(schema.allOf)) {
            const newPath = [...path, 'allOf', index];
            callback(propSchema, newPath);
            if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
                visitSchemaProperties(propSchema, newPath, callback);
            }
        }
    }
    else if (isOneOfSchema(schema)) {
        for (const [index, propSchema] of Object.entries(schema.oneOf)) {
            const newPath = [...path, 'oneOf', index];
            callback(propSchema, newPath);
            if (isObjectSchema(propSchema) || isAllOfSchema(propSchema) || isOneOfSchema(propSchema)) {
                visitSchemaProperties(propSchema, newPath, callback);
            }
        }
    }
    else {
        callback(schema, path);
    }
}
export function visitShapeProperties(shapes, callback) {
    for (const [shapeName, shape] of Object.entries(shapes)) {
        visitSchemaProperties(shape.schema, ['shapes', shapeName, 'schema'], callback);
    }
}
