/*!
 * Custom elements for Nanopore-Digital Web applications
 */
import { helpers, nativeHelpers, filters, templates, } from "./containers";
import SqrlErr from "./err";
import { copyProps } from "./utils";
/* END TYPES */
const defaultConfig = {
    varName: 'it',
    autoTrim: [false, 'nl'],
    autoEscape: true,
    defaultFilter: false,
    tags: ['{{', '}}'],
    l: function (container, name) {
        if (container === 'H') {
            const hRet = this.storage.helpers.get(name);
            if (hRet) {
                return hRet;
            }
            else {
                throw SqrlErr("Can't find helper '" + name + "'");
            }
        }
        else if (container === 'F') {
            const fRet = this.storage.filters.get(name);
            if (fRet) {
                return fRet;
            }
            else {
                throw SqrlErr("Can't find filter '" + name + "'");
            }
        }
    },
    async: false,
    storage: {
        helpers: helpers,
        nativeHelpers: nativeHelpers,
        filters: filters,
        templates: templates,
    },
    prefixes: {
        h: '@',
        b: '#',
        i: '',
        r: '*',
        c: '/',
        e: '!',
    },
    cache: false,
    plugins: [],
    useWith: false,
};
defaultConfig.l.bind(defaultConfig);
function getConfig(override, baseConfig) {
    // TODO: run more tests on this
    const res = {}; // Linked
    copyProps(res, defaultConfig); // Creates deep clone of res, 1 layer deep
    if (baseConfig) {
        copyProps(res, baseConfig);
    }
    if (override) {
        copyProps(res, override);
    }
    res.l.bind(res);
    return res;
}
export { defaultConfig, getConfig };
