"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var focus_reducer_exports = {};
__export(focus_reducer_exports, {
  focusReducer: () => focusReducer
});
module.exports = __toCommonJS(focus_reducer_exports);
const focusReducer = (prev, event) => {
  switch (prev) {
    case "not-focused":
      switch (event.type) {
        case "pointer-focus":
          return "editor-focused";
        case "keyboard-focus":
          return "editor-focused-outlined";
        case "keyboard-focus-awaiting":
          return "awaiting-keyboard-input";
        default:
          return prev;
      }
    case "editor-focused":
      switch (event.type) {
        case "keydown":
          if (event.event.key === "Escape") {
            return "container-focused";
          }
          return prev;
        case "blur":
          return "not-focused";
        default:
          return prev;
      }
    case "editor-focused-outlined":
      switch (event.type) {
        case "keydown":
          if (event.event.key === "Escape") {
            return "container-focused";
          }
          return prev;
        case "blur":
          return "not-focused";
        case "pointer-focus":
          return "editor-focused";
        default:
          return prev;
      }
    case "container-focused":
      switch (event.type) {
        case "keydown":
          if (event.event.key === "Shift") {
            event.event.stopPropagation();
            return prev;
          }
          if (event.event.key === "Tab") {
            event.event.stopPropagation();
            return "not-focused";
          }
          return "editor-focused";
        case "blur":
          return "not-focused";
        case "pointer-focus":
          return "editor-focused";
        default:
          return prev;
      }
    case "awaiting-keyboard-input":
      switch (event.type) {
        case "keydown":
          if (event.event.key === "Shift") {
            event.event.stopPropagation();
            return prev;
          }
          if (event.event.key === "Tab") {
            event.event.stopPropagation();
            return "not-focused";
          }
          if (event.event.key === "Escape") {
            return prev;
          }
          return "editor-focused-outlined";
        case "blur":
          return "not-focused";
        case "pointer-focus":
          return "editor-focused";
        default:
          return prev;
      }
    default:
      return prev;
  }
};
//# sourceMappingURL=focus-reducer.js.map
