// needed to preserve 3.x behavior for saving item data
export function serializeItemParams(requestOptions) {
    requestOptions.params = Object.assign(Object.assign({}, requestOptions.params), serializeItem(requestOptions.item));
    return requestOptions;
}
// copied from https://github.com/Esri/arcgis-rest-js/blob/8eccee45394850467194e53390df7df3e661f104/packages/arcgis-rest-portal/src/items/helpers.ts#L255
/* istanbul ignore next -- @preserve */
function serializeItem(item) {
    // create a clone so we're not messing with the original
    const clone = JSON.parse(JSON.stringify(item));
    // binary data needs POSTed as a `file`
    // JSON object literals should be passed as `text`.
    if (clone.data) {
        // if you are updating this file, remove this comment and address the lint error
        // eslint-disable-next-line @typescript-eslint/no-unused-expressions
        (typeof Blob !== "undefined" && item.data instanceof Blob) ||
            // Node.js doesn't implement Blob
            item.data.constructor.name === "ReadStream"
            ? (clone.file = item.data)
            : (clone.text = item.data);
        delete clone.data;
    }
    return clone;
}
//# sourceMappingURL=helpers.js.map