"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_json = require('../primordials/json.js');

//#region src/memo/_internal.ts
/**
* @file Private internals for `memo/*` modules — the shared `cacheRegistry`
*   (each memoize variant registers its per-instance clear function here so
*   `clearAllMemoizationCaches` can fan out). `defaultKeyGen` is co-located
*   because both `memoize` and `memoizeAsync` use it as the default cache-key
*   encoder.
*/
/**
* Global registry of memoization cache clear functions.
*/
const cacheRegistry = [];
/**
* Default cache key generator that disambiguates `undefined`, `BigInt`, and
* `Map`/`Set` arguments (which `JSON.stringify` drops or collapses).
*/
function defaultKeyGen(args) {
	return require_primordials_json.JSONStringify(args, (_key, value) => {
		if (value === void 0) return "\0undefined";
		if (typeof value === "bigint") return `\0bigint:${value.toString()}`;
		if (typeof value === "function")
 /* c8 ignore next */
		return `\0fn:${value.name || "anonymous"}`;
		if (value instanceof Map) return {
			__tag: "Map",
			entries: Array.from(value.entries())
		};
		if (value instanceof Set) return {
			__tag: "Set",
			values: Array.from(value.values())
		};
		return value;
	});
}

//#endregion
exports.cacheRegistry = cacheRegistry;
exports.defaultKeyGen = defaultKeyGen;