import { __require as requireGetIntrinsic } from "../../get-intrinsic/index.js";
import { __require as requireType } from "../../es-errors/type.js";
import { __require as requireIsInteger } from "../../math-intrinsics/isInteger.js";
import { __require as requireIsObject } from "../../es-object-atoms/isObject.js";
import { __require as requireArrayCreate } from "./ArrayCreate.js";
import { __require as requireGet } from "./Get.js";
import { __require as requireIsArray } from "./IsArray.js";
import { __require as requireIsConstructor } from "./IsConstructor.js";
var ArraySpeciesCreate;
var hasRequiredArraySpeciesCreate;
function requireArraySpeciesCreate() {
  if (hasRequiredArraySpeciesCreate) return ArraySpeciesCreate;
  hasRequiredArraySpeciesCreate = 1;
  var GetIntrinsic = requireGetIntrinsic();
  var $species = GetIntrinsic("%Symbol.species%", true);
  var $TypeError = requireType();
  var isInteger = requireIsInteger();
  var isObject = requireIsObject();
  var ArrayCreate = requireArrayCreate();
  var Get = requireGet();
  var IsArray = requireIsArray();
  var IsConstructor = requireIsConstructor();
  ArraySpeciesCreate = function ArraySpeciesCreate2(originalArray, length) {
    if (!isInteger(length) || length < 0) {
      throw new $TypeError("Assertion failed: length must be an integer >= 0");
    }
    var isArray = IsArray(originalArray);
    if (!isArray) {
      return ArrayCreate(length);
    }
    var C = Get(originalArray, "constructor");
    if ($species && isObject(C)) {
      C = Get(C, $species);
      if (C === null) {
        C = void 0;
      }
    }
    if (typeof C === "undefined") {
      return ArrayCreate(length);
    }
    if (!IsConstructor(C)) {
      throw new $TypeError("C must be a constructor");
    }
    return new C(length);
  };
  return ArraySpeciesCreate;
}
export {
  requireArraySpeciesCreate as __require
};
