import { Builder } from "./builder.js";
import { execPipeline } from "../../pipeline/index.js";
import { intl } from "../../i18n/index.js";
const buildSpec = (builder, advancedVSeed)=>{
    const start = "u" > typeof performance ? performance.now() : Date.now();
    const { chartType } = builder.vseed;
    const pipeline = Builder.getSpecPipeline(chartType);
    if (!pipeline) throw new Error(`please invoke registerAll or register ${chartType} before build, no spec pipeline for chartType ${chartType}`);
    const context = {
        vseed: builder.vseed,
        advancedVSeed
    };
    if (builder.locale) intl.setLocale(builder.locale);
    try {
        const spec = execPipeline(pipeline, context);
        builder.spec = spec;
        return spec;
    } catch (e) {
        console.error(e);
        throw new Error(`buildSpec error: ${e.message}`);
    } finally{
        const end = "u" > typeof performance ? performance.now() : Date.now();
        builder.performance['buildSpec'] = `${(end - start).toFixed(4)}ms`;
    }
};
export { buildSpec };

//# sourceMappingURL=buildSpec.js.map