"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index$2 = require("../define-data-property/index.cjs");
const index = require("../has-property-descriptors/index.cjs");
const index$1 = require("../functions-have-names/index.cjs");
const type = require("../es-errors/type.cjs");
var define = index$2.defineDataProperty;
var hasDescriptors = index.hasPropertyDescriptors_1();
var functionsHaveConfigurableNames = index$1.functionsHaveNames_1.functionsHaveConfigurableNames();
var $TypeError = type.type;
var setFunctionName = function setFunctionName2(fn, name) {
  if (typeof fn !== "function") {
    throw new $TypeError("`fn` is not a function");
  }
  var loose = arguments.length > 2 && !!arguments[2];
  if (!loose || functionsHaveConfigurableNames) {
    if (hasDescriptors) {
      define(
        /** @type {Parameters<define>[0]} */
        fn,
        "name",
        name,
        true,
        true
      );
    } else {
      define(
        /** @type {Parameters<define>[0]} */
        fn,
        "name",
        name
      );
    }
  }
  return fn;
};
exports.setFunctionName = setFunctionName;
//# sourceMappingURL=index.cjs.map
