import { buildGenericMarkdownTable } from "../utils/flowVisualiser/nodeFormatUtils.js";
import { DocBuilderRoot } from "./docBuilderRoot.js";
export class DocBuilderPermissionSetGroup extends DocBuilderRoot {
    docType = "PermissionSetGroup";
    promptKey = "PROMPT_DESCRIBE_PERMISSION_SET_GROUP";
    placeholder = "<!-- PermissionSetGroup description -->";
    xmlRootKey = "PermissionSetGroup";
    docsSection = "permissionsetgroups";
    static buildIndexTable(prefix, permissionSetGroupDescriptions, filterObject = null) {
        const filteredPsetGroups = filterObject ? permissionSetGroupDescriptions.filter(pSetGroup => pSetGroup.relatedPermissionSets.includes(filterObject)) : permissionSetGroupDescriptions;
        if (filteredPsetGroups.length === 0) {
            return [];
        }
        const lines = [];
        lines.push(...[
            filterObject ? "## Related Permission Set Groups" : "## Permission Set Groups",
            "",
            "| Permission Set Group | Description |",
            "| :----                | :---------- |"
        ]);
        for (const pSetGroup of filteredPsetGroups) {
            const pSetGroupNameCell = `[${pSetGroup.name}](${prefix}${encodeURIComponent(pSetGroup.name)}.md)`;
            lines.push(...[
                `| ${pSetGroupNameCell} | ${pSetGroup.description || "None"} |`
            ]);
        }
        lines.push("");
        return lines;
    }
    async buildInitialMarkdownLines() {
        const permissionSetTableLines = [
            "| Permission Set |",
            "| :------------- |"
        ];
        if (this.parsedXmlObject.permissionSets) {
            if (!Array.isArray(this.parsedXmlObject.permissionSets)) {
                this.parsedXmlObject.permissionSets = [this.parsedXmlObject.permissionSets];
            }
            for (const permissionSet of this.parsedXmlObject.permissionSets) {
                const permissionSetNameCell = `[${permissionSet}](../permissionsets/${encodeURIComponent(permissionSet)}.md)`;
                permissionSetTableLines.push(`| ${permissionSetNameCell} |`);
            }
        }
        else {
            permissionSetTableLines.push("| None |");
        }
        return [
            `## ${this.metadataName}`,
            '',
            buildGenericMarkdownTable(this.parsedXmlObject, ["label", "description", "status"], "## Permission Set Group attributes", []),
            '',
            '## Permission Sets',
            ...permissionSetTableLines,
            '',
            '<!-- PermissionSetGroup description -->',
            '',
        ];
    }
}
//# sourceMappingURL=docBuilderPermissionSetGroup.js.map