"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeaderGen = void 0;
const types_1 = require("../../types");
class HeaderGen {
    gen(schema) {
        let header = `// SPDX-License-Identifier: UNLICENSED\n` +
            `pragma solidity ^0.8.23;\n` +
            `\n`;
        if (schema.imageURI && schema.imageURI.includes('{tokenID}')) {
            header += `import "@openzeppelin/contracts/utils/Strings.sol";\n`;
        }
        header += this.getBaseImports(schema.features).join("");
        if (schema.hasLiteRef()) {
            header += `import "@patchwork/PatchworkLiteRef.sol";\n`;
        }
        if (schema.features.some((feature) => feature === types_1.Feature.MINTABLE)) {
            header += `import "@patchwork/interfaces/IPatchworkMintable.sol";\n`;
        }
        if (schema.storage.fields.some((field) => field.isString)) {
            header += `import "@patchwork/PatchworkUtils.sol";\n`;
        }
        if (schema.hasLiteRef() && schema.features.includes(types_1.Feature.DYNAMICREFLIBRARY)) {
            header += `import "@patchwork/libraries/PatchworkDynamicRefs.sol";\n`;
        }
        return header;
    }
    getBaseImports(features) {
        let imports = [];
        if (features.some((feature) => feature === types_1.Feature.FRAGMENTMULTI)) {
            imports.push(`import "@patchwork/PatchworkFragmentMulti.sol";\n`);
        }
        if (features.some((feature) => feature === types_1.Feature.FRAGMENTSINGLE)) {
            imports.push(`import "@patchwork/PatchworkFragmentSingle.sol";\n`);
        }
        if (features.some((feature) => feature === types_1.Feature.PATCH)) {
            imports.push(`import "@patchwork/PatchworkPatch.sol";\n`);
        }
        if (features.some((feature) => feature === types_1.Feature.PATCH1155)) {
            imports.push(`import "@patchwork/Patchwork1155Patch.sol";\n`);
        }
        if (features.some((feature) => feature === types_1.Feature.PATCHACCOUNT)) {
            imports.push(`import "@patchwork/PatchworkAccountPatch.sol";\n`);
        }
        // If no specific feature is found, default to Patchwork721
        if (imports.length === 0) {
            imports.push(`import "@patchwork/Patchwork721.sol";\n`);
        }
        // Join all imports with a newline
        return imports;
    }
}
exports.HeaderGen = HeaderGen;
