"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 resolve_focus_position_exports = {};
__export(resolve_focus_position_exports, {
  resolveFocusPosition: () => resolveFocusPosition
});
module.exports = __toCommonJS(resolve_focus_position_exports);
var import_state = require("./../../pm/state.js");
var import_min_max = require("../utilities/min-max.js");
function resolveFocusPosition(doc, position = null) {
  if (!position) {
    return null;
  }
  const selectionAtStart = import_state.Selection.atStart(doc);
  const selectionAtEnd = import_state.Selection.atEnd(doc);
  if (position === "start" || position === true) {
    return selectionAtStart;
  }
  if (position === "end") {
    return selectionAtEnd;
  }
  const minPos = selectionAtStart.from;
  const maxPos = selectionAtEnd.to;
  if (position === "all") {
    return import_state.TextSelection.create(
      doc,
      (0, import_min_max.minMax)(0, minPos, maxPos),
      (0, import_min_max.minMax)(doc.content.size, minPos, maxPos)
    );
  }
  return import_state.TextSelection.create(
    doc,
    (0, import_min_max.minMax)(position, minPos, maxPos),
    (0, import_min_max.minMax)(position, minPos, maxPos)
  );
}
//# sourceMappingURL=resolve-focus-position.js.map
