import { serializeRef } from "../refs.js";
import { isObjectSchema } from "../types/utils.js";
class ShapeImpl {
    #schema;
    #ref;
    #shape;
    #dereferencedSchema;
    constructor(parent, ref, shape) {
        this.#schema = parent;
        this.#ref = ref;
        this.#shape = shape;
    }
    get name() {
        return this.#shape.name;
    }
    get ref() {
        return serializeRef(this.#ref);
    }
    get refItem() {
        return this.#ref;
    }
    get json() {
        return this.#shape;
    }
    getObjectSchema() {
        if (!this.#dereferencedSchema) {
            this.#dereferencedSchema = this.#schema.dereferenceSchema(this.#shape.schema);
        }
        if (isObjectSchema(this.#dereferencedSchema)) {
            return this.#dereferencedSchema;
        }
    }
}
export function createShape(parent, ref, shape) {
    return new ShapeImpl(parent, ref, shape);
}
