// biome-ignore lint/suspicious/noExplicitAny: same as stringify
export function serialize(obj) {
  return JSON.stringify(obj, (_key, value) => {
    if (value instanceof Uint8Array) {
      return {
        __type: 'Uint8Array',
        data: Array.from(value)
      };
    }
    if (value instanceof Date) {
      return {
        __type: 'Date',
        data: value.toISOString()
      };
    }
    return value;
  });
}
// biome-ignore lint/suspicious/noExplicitAny: same as stringify and parse
export function serializeV2(obj) {
  return JSON.parse(JSON.stringify(obj, (_key, value) => {
    if (value instanceof Uint8Array) {
      return {
        __type: 'Uint8Array',
        data: Array.from(value)
      };
    }
    if (value instanceof Date) {
      return {
        __type: 'Date',
        data: value.toISOString()
      };
    }
    return value;
  }));
}
export function deserialize(json) {
  return JSON.parse(json, (_key, value) => {
    if (value && value.__type === 'Uint8Array') {
      return value.data;
    }
    if (value && value.__type === 'Date') {
      return new Date(value.data);
    }
    return value;
  });
}
//# sourceMappingURL=serialize.js.map