"use strict";
/* Socket Lib - Built with esbuild */
"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 instant_exports = {};
__export(instant_exports, {
  Instant: () => Instant,
  describe: () => describe,
  epochNanosecondsImpl: () => epochNanosecondsImpl,
  isValidEpochNanoseconds: () => isValidEpochNanoseconds
});
module.exports = __toCommonJS(instant_exports);
var import_globals = require("../primordials/globals");
var import_error = require("../primordials/error");
var import_slots = require("./slots");
const NS_MAX_INSTANT = 8640000000000000000000n;
const NS_MIN_INSTANT = -NS_MAX_INSTANT;
function isValidEpochNanoseconds(epochNanoseconds) {
  if (epochNanoseconds < NS_MIN_INSTANT || epochNanoseconds > NS_MAX_INSTANT) {
    return false;
  }
  return true;
}
class Instant {
  constructor(epochNanoseconds) {
    let ns;
    try {
      ns = (0, import_globals.BigIntCtor)(epochNanoseconds);
    } catch {
      throw new import_error.TypeErrorCtor(
        `Temporal.Instant: epochNanoseconds must be coercible to BigInt; saw ${describe(epochNanoseconds)}. Pass a bigint literal (e.g. 1700000000000000000n) or a numeric string.`
      );
    }
    if (!isValidEpochNanoseconds(ns)) {
      throw new import_error.RangeErrorCtor(
        `Temporal.Instant: epochNanoseconds out of range; saw ${ns}n. Must be in [-8.64e21, 8.64e21] (\xB1100,000,000 days from 1970-01-01T00:00:00Z).`
      );
    }
    (0, import_slots.setInstantSlots)(this, ns);
  }
}
function epochNanosecondsImpl() {
  const instant = this;
  if (!(0, import_slots.hasInstantSlot)(instant)) {
    throw new import_error.TypeErrorCtor(
      `Temporal.Instant.prototype.epochNanoseconds: receiver lacks [[InitializedTemporalInstant]] internal slot; saw ${describe(instant)}. Call on a Temporal.Instant instance constructed via 'new Temporal.Instant(\u2026)'.`
    );
  }
  const ns = (0, import_slots.getInstantNanoseconds)(instant);
  return ns;
}
Object.defineProperty(Instant.prototype, "epochNanoseconds", {
  get: epochNanosecondsImpl,
  configurable: true
});
function describe(value) {
  if (value === null) {
    return "null";
  }
  if (typeof value === "bigint") {
    return `${value}n`;
  }
  if (typeof value === "object") {
    const ctor = value.constructor;
    return ctor && ctor.name ? `<${ctor.name}>` : "<object>";
  }
  return typeof value === "string" ? JSON.stringify(value) : String(value);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Instant,
  describe,
  epochNanosecondsImpl,
  isValidEpochNanoseconds
});
