"use strict";
/**
 * Parent Class Detector
 *
 * Determines whether a module should extend Content or AbstractApiData
 * based on the presence of Content-specific fields or explicit configuration.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectExtendsContent = detectExtendsContent;
exports.getParentClassName = getParentClassName;
exports.getParentInterfaceName = getParentInterfaceName;
exports.getParentInputType = getParentInputType;
exports.getParentClassImport = getParentClassImport;
exports.needsAddContentInput = needsAddContentInput;
exports.getInheritedFields = getInheritedFields;
const field_mapping_types_1 = require("../types/field-mapping.types");
/**
 * Check if a module should extend Content
 *
 * @param fields - Array of field definitions from JSON schema
 * @param explicitValue - Optional explicit value from JSON schema
 * @returns true if the module should extend Content
 */
function detectExtendsContent(fields, explicitValue) {
    // If explicitly set in JSON schema, use that value
    if (explicitValue !== undefined) {
        return explicitValue;
    }
    // Otherwise, auto-detect based on fields
    const fieldNames = fields.map((f) => f.name);
    return field_mapping_types_1.CONTENT_INDICATOR_FIELDS.some((indicator) => fieldNames.includes(indicator));
}
/**
 * Get the parent class name based on detection result
 *
 * @param extendsContent - Whether the module extends Content
 * @returns Parent class name
 */
function getParentClassName(extendsContent) {
    return extendsContent ? "Content" : "AbstractApiData";
}
/**
 * Get the parent interface name based on detection result
 *
 * @param extendsContent - Whether the module extends Content
 * @returns Parent interface name
 */
function getParentInterfaceName(extendsContent) {
    return extendsContent ? "ContentInterface" : "BaseInterface";
}
/**
 * Get the parent input type name based on detection result
 *
 * @param extendsContent - Whether the module extends Content
 * @returns Parent input type or null if standalone
 */
function getParentInputType(extendsContent) {
    return extendsContent ? "ContentInput" : null;
}
/**
 * Get the import path for the parent class
 *
 * @param extendsContent - Whether the module extends Content
 * @returns Import path for parent class
 */
function getParentClassImport(extendsContent) {
    if (extendsContent) {
        return '@carlonicora/nextjs-jsonapi/core';
    }
    return '@carlonicora/nextjs-jsonapi/core';
}
/**
 * Check if the module needs to call super.addContentInput() in createJsonApi
 *
 * @param extendsContent - Whether the module extends Content
 * @returns true if super.addContentInput() should be called
 */
function needsAddContentInput(extendsContent) {
    return extendsContent;
}
/**
 * Get fields that are inherited from Content and should not be declared
 *
 * @param extendsContent - Whether the module extends Content
 * @returns Array of field names to exclude from generation
 */
function getInheritedFields(extendsContent) {
    if (extendsContent) {
        // These fields are already in Content, don't redeclare them
        return ["name", "tldr", "abstract", "relevance"];
    }
    return [];
}
//# sourceMappingURL=parent-detector.js.map