const fromJSONLight = (object) => {
  const { version, createdTimestamp, updatedTimestamp } = object.metadata || {};
  const content = {
    nodes: object.nodes,
    metadata: {
      version,
      createdTimestamp: fromJsonTimestamp(createdTimestamp),
      updatedTimestamp: fromJsonTimestamp(updatedTimestamp)
    }
  };
  return content;
};
const toJSONLight = (content) => {
  const { version, createdTimestamp, updatedTimestamp } = content.metadata || {};
  const object = {
    nodes: content.nodes,
    metadata: {
      version,
      createdTimestamp: createdTimestamp?.toISOString(),
      updatedTimestamp: updatedTimestamp?.toISOString()
    }
  };
  return object;
};
const baseTimestamp = { seconds: 0, nanos: 0 };
const TimestampObj = {
  fromJSON(object) {
    const message = { ...baseTimestamp };
    if (object.seconds !== void 0 && object.seconds !== null) {
      message.seconds = Number(object.seconds);
    } else {
      message.seconds = 0;
    }
    if (object.nanos !== void 0 && object.nanos !== null) {
      message.nanos = Number(object.nanos);
    } else {
      message.nanos = 0;
    }
    return message;
  },
  toJSON(message) {
    const obj = {};
    message.seconds !== void 0 && (obj.seconds = message.seconds);
    message.nanos !== void 0 && (obj.nanos = message.nanos);
    return obj;
  }
};
function fromTimestamp(t) {
  let millis = t.seconds * 1e3;
  millis += t.nanos / 1e6;
  return new Date(millis);
}
function fromJsonTimestamp(o) {
  if (o instanceof Date) {
    return o;
  } else if (typeof o === "string") {
    return new Date(o);
  } else {
    return fromTimestamp(TimestampObj.fromJSON(o));
  }
}
export {
  fromJSONLight,
  toJSONLight
};
//# sourceMappingURL=json-utils.js.map
