import { __require as requireHasown } from "../../hasown/index.js";
import { __require as requireType } from "../../es-errors/type.js";
import { __require as requireIsObject } from "../../es-object-atoms/isObject.js";
import { __require as requireIsCallable } from "./IsCallable.js";
import { __require as requireToBoolean } from "./ToBoolean.js";
var ToPropertyDescriptor;
var hasRequiredToPropertyDescriptor;
function requireToPropertyDescriptor() {
  if (hasRequiredToPropertyDescriptor) return ToPropertyDescriptor;
  hasRequiredToPropertyDescriptor = 1;
  var hasOwn = requireHasown();
  var $TypeError = requireType();
  var isObject = requireIsObject();
  var IsCallable = requireIsCallable();
  var ToBoolean = requireToBoolean();
  ToPropertyDescriptor = function ToPropertyDescriptor2(Obj) {
    if (!isObject(Obj)) {
      throw new $TypeError("ToPropertyDescriptor requires an object");
    }
    var desc = {};
    if (hasOwn(Obj, "enumerable")) {
      desc["[[Enumerable]]"] = ToBoolean(Obj.enumerable);
    }
    if (hasOwn(Obj, "configurable")) {
      desc["[[Configurable]]"] = ToBoolean(Obj.configurable);
    }
    if (hasOwn(Obj, "value")) {
      desc["[[Value]]"] = Obj.value;
    }
    if (hasOwn(Obj, "writable")) {
      desc["[[Writable]]"] = ToBoolean(Obj.writable);
    }
    if (hasOwn(Obj, "get")) {
      var getter = Obj.get;
      if (typeof getter !== "undefined" && !IsCallable(getter)) {
        throw new $TypeError("getter must be a function");
      }
      desc["[[Get]]"] = getter;
    }
    if (hasOwn(Obj, "set")) {
      var setter = Obj.set;
      if (typeof setter !== "undefined" && !IsCallable(setter)) {
        throw new $TypeError("setter must be a function");
      }
      desc["[[Set]]"] = setter;
    }
    if ((hasOwn(desc, "[[Get]]") || hasOwn(desc, "[[Set]]")) && (hasOwn(desc, "[[Value]]") || hasOwn(desc, "[[Writable]]"))) {
      throw new $TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");
    }
    return desc;
  };
  return ToPropertyDescriptor;
}
export {
  requireToPropertyDescriptor as __require
};
