import Colors from "../constants/colors";
import Networks from "../constants/networks";
import { Icons, Logos, Social, Flags } from "../constants/icons";
export const IconsControl = {
    options: Icons,
    control: {
        type: 'select',
    },
};
export const LogosControl = {
    options: Logos,
    control: {
        type: 'select',
    },
};
export const SocialControl = {
    options: Social,
    control: {
        type: 'select',
    },
};
export const ColorsControl = {
    options: Colors,
    control: {
        type: 'select',
    },
};
export const NetworksControl = {
    options: Networks,
    control: {
        type: 'radio',
    },
};
export const NetworksMaskControl = {
    options: Networks,
    control: {
        type: 'radio',
    },
};
export const CountriesControl = {
    options: Flags,
    control: {
        type: 'select',
    },
};
export const toProps = (args, except = []) => {
    return Object.keys(args)
        .filter(key => !except.includes(key))
        .map(key => `${key.replace(/[A-Z]/, match => '-' + match.toLowerCase())}="${args[key]}"`)
        .join(' ');
};
export default class Template {
    constructor(template) {
        this.template = template;
        this.argsValues = {};
        this.argsTypes = {};
        this.doc = null;
    }
    readme(readme) {
        this.doc = readme;
        return this;
    }
    args(value) {
        this.argsValues = value;
        return this;
    }
    types(value) {
        this.argsTypes = value;
        return this;
    }
    build(overrideTemplate = null) {
        const base = overrideTemplate || this.template;
        const build = {
            render: base,
        };
        build.args = this.argsValues;
        build.argTypes = this.argsTypes;
        if (this.doc) {
            build.parameters = {
                notes: this.doc,
                docs: {
                    source: {
                        originalSource: base(build.args),
                        code: base(build.args)
                    }
                },
                storySource: {
                    source: base(build.args)
                }
            };
        }
        return build;
    }
}
