var __assign = (this && this.__assign) || function () {
    __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;
    };
    return __assign.apply(this, arguments);
};
import { handleActions } from 'redux-actions';
import { selectObject, deselectObject, deselectAllObjects, setActiveOperation, unsetActiveOperation, deleteObject, setAdvancedMode, } from '../../actions/threed';
var initialState = {
    selectedIds: [],
    activeOperation: null,
    advancedMode: JSON.parse(sessionStorage.getItem('advancedMode')) || false,
};
var ui = handleActions(new Map([
    [
        selectObject,
        function (state, _a) {
            var payload = _a.payload;
            return (__assign({}, state, { activeOperation: null, selectedIds: payload.addToSelection
                    ? new Set(state.selectedIds).add(payload.object.id).slice() : [payload.object.id] }));
        },
    ],
    [
        deselectObject,
        function (state, _a) {
            var payload = _a.payload;
            return (__assign({}, state, { activeOperation: null, selectedIds: state.selectedIds.filter(function (id) { return id !== payload.id; }) }));
        },
    ],
    [
        deselectAllObjects,
        function (state) { return (__assign({}, state, { selectedIds: [], activeOperation: null })); },
    ],
    [
        setActiveOperation,
        function (state, _a) {
            var payload = _a.payload;
            return (__assign({}, state, { activeOperation: payload }));
        },
    ],
    [unsetActiveOperation, function (state) { return (__assign({}, state, { activeOperation: null })); }],
    [
        deleteObject,
        function (state, _a) {
            var payload = _a.payload;
            return (__assign({}, state, { activeOperation: null, selectedIds: state.selectedIds.filter(function (id) { return id !== payload.id; }) }));
        },
    ],
    [
        setAdvancedMode,
        function (state, _a) {
            var payload = _a.payload;
            return (__assign({}, state, { advancedMode: payload }));
        },
    ],
]), initialState);
export default ui;
//# sourceMappingURL=ui.js.map