"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var interactionModes_1 = require("./helpers/interactionModes");
var DEFAULTS = {
    onHaikuComponentWillInitialize: null,
    onHaikuComponentDidMount: null,
    onHaikuComponentWillMount: null,
    onHaikuComponentDidInitialize: null,
    onHaikuComponentWillUnmount: null,
    options: {
        seed: null,
        automount: true,
        autoplay: true,
        forceFlush: false,
        freeze: false,
        loop: false,
        frame: null,
        clock: {},
        sizing: null,
        alwaysComputeSizing: true,
        preserve3d: 'auto',
        contextMenu: 'enabled',
        position: 'relative',
        overflowX: null,
        overflowY: null,
        overflow: null,
        mixpanel: '6f31d4f99cf71024ce27c3e404a79a61',
        useWebkitPrefix: void (0),
        interactionMode: interactionModes_1.InteractionMode.LIVE,
    },
    states: null,
    eventHandlers: null,
    timelines: null,
    vanities: null,
    children: null,
    placeholder: null,
};
function seed() {
    return Math.random().toString(36).slice(2);
}
function build() {
    var argums = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        argums[_i] = arguments[_i];
    }
    var config = {
        onHaikuComponentWillInitialize: null,
        onHaikuComponentDidMount: null,
        onHaikuComponentDidInitialize: null,
        onHaikuComponentWillUnmount: null,
        options: null,
        states: null,
        eventHandlers: null,
        timelines: null,
        template: null,
        vanities: null,
        children: null,
        placeholder: null,
    };
    var args = argums.slice();
    args.unshift(DEFAULTS);
    args.forEach(function (incoming) {
        if (!incoming || typeof incoming !== 'object') {
            return;
        }
        if (incoming.onHaikuComponentWillInitialize) {
            config.onHaikuComponentWillInitialize = incoming.onHaikuComponentWillInitialize;
        }
        if (incoming.onHaikuComponentDidMount) {
            config.onHaikuComponentDidMount = incoming.onHaikuComponentDidMount;
        }
        if (incoming.onHaikuComponentDidInitialize) {
            config.onHaikuComponentDidInitialize = incoming.onHaikuComponentDidInitialize;
        }
        if (incoming.onHaikuComponentWillUnmount) {
            config.onHaikuComponentWillUnmount = incoming.onHaikuComponentWillUnmount;
        }
        if (incoming.options) {
            config.options = __assign({}, config.options, incoming.options);
        }
        for (var key in incoming) {
            if (incoming[key] !== undefined && DEFAULTS.options.hasOwnProperty(key)) {
                config.options[key] = incoming[key];
            }
        }
        if (incoming.states) {
            config.states = __assign({}, config.states, incoming.states);
        }
        if (incoming.initialStates && typeof incoming.initialStates === 'object') {
            config.states = __assign({}, config.states, incoming.initialStates);
        }
        if (incoming.eventHandlers) {
            config.eventHandlers = __assign({}, config.eventHandlers, incoming.eventHandlers);
        }
        if (incoming.timelines) {
            config.timelines = __assign({}, config.timelines, incoming.timelines);
        }
        if (incoming.vanities) {
            config.vanities = __assign({}, config.vanities, incoming.vanities);
        }
        if (incoming.children) {
            config.children = incoming.children;
        }
        if (incoming.placeholder) {
            config.placeholder = incoming.placeholder;
        }
    });
    if (config.options.overflow && (config.options.overflowX || config.options.overflowY)) {
        console.warn('[haiku core] `overflow` overrides `overflowY`/`overflowX`');
        config.options.overflowX = null;
        config.options.overflowY = null;
    }
    return config;
}
exports.default = {
    build: build,
    seed: seed,
    DEFAULTS: DEFAULTS,
};
//# sourceMappingURL=Config.js.map