"use strict";
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.activate = void 0;
const vscode = require("vscode");
const notebookSerializer_1 = require("./notebookSerializer");
function activate(context) {
    const serializer = new notebookSerializer_1.NotebookSerializer(context);
    context.subscriptions.push(vscode.workspace.registerNotebookSerializer('jupyter-notebook', serializer, {
        transientOutputs: false,
        transientCellMetadata: {
            breakpointMargin: true,
            inputCollapsed: true,
            outputCollapsed: true,
            custom: false
        }
    }));
    return {
        exportNotebook: (notebook) => {
            return exportNotebook(notebook, serializer);
        },
        setKernelSpec: async (resource, kernelspec) => {
            const document = vscode.workspace.notebookDocuments.find(doc => doc.uri.toString() === resource.toString());
            if (!document) {
                return false;
            }
            const edit = new vscode.WorkspaceEdit();
            edit.replaceNotebookMetadata(resource, {
                ...document.metadata,
                custom: {
                    ...(document.metadata.custom ?? {}),
                    metadata: {
                        ...(document.metadata.custom?.metadata ?? {}),
                        kernelspec: kernelspec
                    },
                }
            });
            return vscode.workspace.applyEdit(edit);
        },
    };
}
exports.activate = activate;
function exportNotebook(notebook, serializer) {
    return serializer.serializeNotebookToString(notebook);
}
function deactivate() { }
exports.deactivate = deactivate;
//# sourceMappingURL=ipynbMain.js.map