"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const React = __importStar(require("react"));
const withStyles_1 = __importDefault(require("components/hoc/withStyles"));
const styles_1 = __importDefault(require("./styles"));
const WizardSteps_1 = __importDefault(require("../../bosons/WizardSteps"));
const uploadFile_1 = __importDefault(require("./uploadFile"));
const mapData_1 = __importDefault(require("./mapData"));
const detailData_1 = __importDefault(require("./detailData"));
const findIndex_1 = __importDefault(require("lodash/findIndex"));
class DataImports extends React.Component {
    constructor(props) {
        super(props);
        this._makeStepActive = (index) => {
            let { wizardStep } = this.state;
            let pos = findIndex_1.default(wizardStep, { active: true });
            if (pos > -1) {
                wizardStep[pos] = Object.assign({}, wizardStep[pos], { active: false });
                wizardStep[index] = Object.assign({}, wizardStep[index], { active: true });
                this.setState({ wizardStep });
            }
        };
        this._markedVisited = (index) => {
            let { wizardStep } = this.state;
            wizardStep[index] = Object.assign({}, wizardStep[index], { visited: true });
            this.setState({
                wizardStep,
            });
        };
        this._unmarkedVisited = (index) => {
            let { wizardStep } = this.state;
            wizardStep[index] = Object.assign({}, wizardStep[index], { visited: false });
            this.setState({
                wizardStep,
            });
        };
        this._onStepClick = (step, index) => {
            this._makeStepActive(index);
        };
        this.state = {
            wizardStep: [
                {
                    label: 'Upload',
                    active: true,
                    component: (React.createElement(uploadFile_1.default, { classes: props.classes, makeStepActive: this._makeStepActive, markedVisited: this._markedVisited })),
                },
                {
                    label: 'Map',
                    component: (React.createElement(mapData_1.default, { classes: props.classes, makeStepActive: this._makeStepActive, markedVisited: this._markedVisited, unmarkedVisited: this._unmarkedVisited })),
                },
                {
                    label: 'Details',
                    component: (React.createElement(detailData_1.default, { classes: props.classes, makeStepActive: this._makeStepActive, markedVisited: this._markedVisited, unmarkedVisited: this._unmarkedVisited })),
                },
            ]
        };
    }
    render() {
        return (React.createElement(React.Fragment, null,
            React.createElement("div", null,
                React.createElement(WizardSteps_1.default, { steps: this.state.wizardStep, onStepClick: this._onStepClick }))));
    }
}
exports.default = withStyles_1.default(styles_1.default)(DataImports);
//# sourceMappingURL=index.js.map