"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Orientation is given to size() to determine the device orientation.
 * Landscape is the default orientation.
 */
var CodeState;
(function (CodeState) {
    CodeState[CodeState["Scenes"] = 0] = "Scenes";
    CodeState[CodeState["Participant"] = 1] = "Participant";
    CodeState[CodeState["Groups"] = 2] = "Groups";
    CodeState[CodeState["Closed"] = 3] = "Closed";
    CodeState[CodeState["Console"] = 4] = "Console";
    CodeState[CodeState["History"] = 5] = "History";
})(CodeState = exports.CodeState || (exports.CodeState = {}));
/**
 * Max enum value when the code editor should still be shown.
 */
exports.MaxEditableState = CodeState.Groups; // tslint:disable-line
exports.stateToProp = {
    [CodeState.Scenes]: 'scenes',
    [CodeState.Participant]: 'participant',
    [CodeState.Groups]: 'groups',
};
exports.stateToUpdateAction = {
    [CodeState.Scenes]: "CODE_SET_SCENES" /* SetScenes */,
    [CodeState.Participant]: "CODE_SET_PARTICIPANT" /* SetParticipant */,
    [CodeState.Groups]: "CODE_SET_GROUPS" /* SetGroups */,
};
const initialParticipant = `{
  sessionID: 'e1fefc78-d4cc-4c69-b2d9-b36ed5c52893',
  userID: 1,
  username: 'Mr_Tester',
  level: 42,
  lastInputAt: ${Date.now()},
  connectedAt: ${Date.now()},
  disabled: false,
  groupID: 'default',
  sparks: 500,
}`;
const initialGroups = `[
  {
    groupID: 'default',
    sceneID: 'default',
  },
]`;
const initialControls = `[
  {
    sceneID: 'default',
    controls: [
      {
        controlID: 'my_first_button',
        kind: 'button',
        text: 'My First Button',
        cost: 100,
        progress: 0.5,
        disabled: true,
        position: [
          {
            width: 10,
            height: 8,
            size: 'large',
            x: 0,
            y: 0,
          }
        ]
      },
      {
        controlID: 'my_awesome_joystick',
        kind: 'joystick',
        disabled: true,
        angle: 0.7,
        intensity: 0.5,
        position: [
          {
            width: 7,
            height: 7,
            size: 'large',
            x: 11,
            y: 0,
          }
        ]
      }
    ]
  }
]`;
exports.initialState = {
    state: CodeState.Scenes,
    width: 500,
    participant: initialParticipant.split('\n'),
    scenes: initialControls.split('\n'),
    groups: initialGroups.split('\n'),
};
function reducer(state, action) {
    switch (action.type) {
        case "CODE_SET_STATE" /* SetState */:
            return Object.assign({}, state, { state: action.state });
        case "CODE_RESIZE" /* Resize */:
            return Object.assign({}, state, { width: action.width });
        case "CODE_SET_PARTICIPANT" /* SetParticipant */:
            return Object.assign({}, state, { participant: action.data });
        case "CODE_SET_SCENES" /* SetScenes */:
            return Object.assign({}, state, { scenes: action.data });
        case "CODE_SET_GROUPS" /* SetGroups */:
            return Object.assign({}, state, { groups: action.data });
        default:
            return state;
    }
}
exports.reducer = reducer;
