"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.updateQuizSubmitFlag = exports.submitQuizSessionEvent = exports.sessionStartOrResumeEvent = exports.loadResumeData = exports.editResponse = exports.previewResponse = exports.updateTimerInfo = exports.updateQuizSessionStatusOnPageLoad = exports.updateIsTaking = exports.updateTimerMinimized = exports.backtrackingNextQuestion = exports.previousQuestion = exports.setCurrentSessionItemPosition = void 0;

var _uuid = require("uuid");

var _constants = require("@instructure/quiz-common/lib/constants");

var setCurrentSessionItemPosition = function setCurrentSessionItemPosition(position) {
  return {
    type: _constants.SET_CURRENT_SESSION_ITEM_POSITION,
    payload: {
      position: position
    }
  };
};

exports.setCurrentSessionItemPosition = setCurrentSessionItemPosition;

var previousQuestion = function previousQuestion() {
  return {
    type: _constants.PREVIOUS_QUESTION,
    payload: {}
  };
};

exports.previousQuestion = previousQuestion;

var backtrackingNextQuestion = function backtrackingNextQuestion() {
  return {
    type: _constants.BACKTRACKING_NEXT_QUESTION,
    payload: {}
  };
};

exports.backtrackingNextQuestion = backtrackingNextQuestion;

var updateTimerMinimized = function updateTimerMinimized(bool) {
  return {
    type: _constants.UPDATE_TIMER_MINIMIZED,
    payload: {
      timerMinimized: bool
    }
  };
};

exports.updateTimerMinimized = updateTimerMinimized;

var updateIsTaking = function updateIsTaking(bool) {
  return {
    type: _constants.UPDATE_IS_TAKING,
    payload: {
      isTaking: bool
    }
  };
};

exports.updateIsTaking = updateIsTaking;

var updateQuizSessionStatusOnPageLoad = function updateQuizSessionStatusOnPageLoad(status) {
  return {
    type: _constants.UPDATE_QUIZ_SESSION_STATUS_ON_PAGE_LOAD,
    payload: {
      quizSessionStatusOnPageLoad: status
    }
  };
};

exports.updateQuizSessionStatusOnPageLoad = updateQuizSessionStatusOnPageLoad;

var updateTimerInfo = function updateTimerInfo(timerData) {
  return {
    type: _constants.UPDATE_TIMER_INFO,
    payload: {
      timeLeftInSeconds: timerData.timeLeftInSeconds,
      timerRunning: timerData.timerRunning || false,
      timeRecording: timerData.timeRecording || false
    }
  };
};

exports.updateTimerInfo = updateTimerInfo;

var previewResponse = function previewResponse(quizEntry, value) {
  return {
    type: _constants.PREVIEW_RESPONSE,
    payload: {
      position: quizEntry.position,
      itemId: quizEntry.getEntry().id,
      userResponse: {
        value: value
      }
    }
  };
};

exports.previewResponse = previewResponse;

var editResponse = function editResponse(sessionItem, value) {
  return {
    type: _constants.RESPONSE,
    payload: {
      position: sessionItem.position,
      itemId: sessionItem.getItem().id,
      userResponse: {
        value: value
      }
    }
  };
};

exports.editResponse = editResponse;

var loadResumeData = function loadResumeData(resumeData) {
  return {
    type: _constants.LOAD_RESUME_DATA,
    payload: resumeData
  };
};

exports.loadResumeData = loadResumeData;

var sessionStartOrResumeEvent = function sessionStartOrResumeEvent(userAgent) {
  return {
    type: _constants.SESSION_STARTED_OR_RESUMED_EVENT,
    payload: {
      userAgent: userAgent,
      browserSessionId: (0, _uuid.v4)()
    }
  };
};

exports.sessionStartOrResumeEvent = sessionStartOrResumeEvent;

var submitQuizSessionEvent = function submitQuizSessionEvent() {
  return {
    type: _constants.QUIZ_SUBMISSION_EVENT,
    payload: {}
  };
};

exports.submitQuizSessionEvent = submitQuizSessionEvent;

var updateQuizSubmitFlag = function updateQuizSubmitFlag(value) {
  return {
    type: _constants.UPDATE_QUIZ_SUBMIT_FLAG,
    payload: {
      value: value
    }
  };
};

exports.updateQuizSubmitFlag = updateQuizSubmitFlag;