class ZeroDepError extends Error{category;source;value;constructor(message="An unexpected error has occurred",category="unknown",source="unknown",value=void 0){super(message),this.category=category,this.source=source,this.value=value,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}let isArray=value=>{try{return Array.isArray(value)}catch{return!1}},isBigInt=value=>{try{return"bigint"==typeof value}catch{return!1}},isBoolean=value=>{try{return"[object Boolean]"===Object.prototype.toString.call(value)}catch{return!1}},isDate=value=>{if("[object Date]"!==Object.prototype.toString.call(value))return!1;if("Invalid Date"===value)return!1;try{var ms=value.getTime();return!Number.isNaN(ms)}catch{return!1}},isNil=value=>{try{return null==value}catch{return!1}},isNumber=value=>{try{return"[object Number]"===Object.prototype.toString.call(value)&&Math.abs(value)!==1/0&&!Number.isNaN(value)}catch{return!1}},isPromise=value=>{try{return"[object Promise]"===Object.prototype.toString.call(value)}catch{return!1}},isSet=value=>{try{return"[object Set]"===Object.prototype.toString.call(value)}catch{return!1}},isString=value=>{try{return"[object String]"===Object.prototype.toString.call(value)}catch{return!1}},isTypedArray=value=>{try{return-1!==["[object BigInt64Array]","[object BigUint64Array]","[object Float32Array]","[object Float64Array]","[object Int16Array]","[object Int32Array]","[object Int8Array]","[object SharedArrayBuffer]","[object Uint16Array]","[object Uint32Array]","[object Uint8Array]","[object Uint8ClampedArray]"].indexOf(Object.prototype.toString.call(value))}catch{return!1}},isWeakMap=value=>{try{return"[object WeakMap]"===Object.prototype.toString.call(value)}catch{return!1}},isWeakSet=value=>{try{return"[object WeakSet]"===Object.prototype.toString.call(value)}catch{return!1}},isFunction=value=>{try{var type=Object.prototype.toString.call(value);return"[object Function]"===type||"[object AsyncFunction]"===type}catch{return!1}},replacer=(_key,value)=>{var type=Object.prototype.toString.call(value);if("[object BigInt]"===type||"[object Date]"===type)return value.toString();if("[object Set]"===type)return[...value];if("[object Map]"===type)return Object.fromEntries(value);if("[object Array]"!==type&&"[object BigInt]"!==type&&"[object Boolean]"!==type&&"[object Null]"!==type&&"[object Number]"!==type&&"[object Object]"!==type&&"[object String]"!==type&&"[object Undefined]"!==type)throw(type=new ZeroDepError(errMessage)).value=value,type;return value},errMessage="Cannot convert to JSON",toPojo=value=>{var error,type=Object.prototype.toString.call(value);if("[object Null]"===type||"[object Undefined]"===type)return null;if("[object Array]"!==type&&"[object Map]"!==type&&"[object Object]"!==type&&"[object Set]"!==type&&"[object Function]"!==type&&"[object AsyncFunction]"!==type)throw(error=new ZeroDepError(errMessage)).value=value,error;let maybeJson;"toJSON"in value&&isFunction(value.toJSON)&&(maybeJson=value.toJSON());try{return JSON.parse(JSON.stringify(maybeJson??value,replacer))}catch(error){type=new ZeroDepError(errMessage);throw error.value&&(type.value=error.value),type}},toString=value=>{if(isString(value))return value;if(isNil(value))return"";if(isBoolean(value))return value?"true":"false";if(isDate(value))return value.toISOString();if(isNumber(value))return""+value;if("[object Number]"===Object.prototype.toString.call(value))return String(value);if(isBigInt(value))return value.toString();if(isArray(value)||isSet(value)){var item,items=[];for(item of[...value])items.push(toString(item));return items.join(", ")}var error;if(isWeakSet(value)||isWeakMap(value)||isTypedArray(value)||isPromise(value))throw(error=new ZeroDepError("Cannot convert to string")).value=value,error;try{return JSON.stringify(toPojo(value))}catch{let error=new ZeroDepError("Cannot convert to string");throw error.value=value,error}};exports.toString=toString;