"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
var register_1 = __importDefault(require("../register"));
var antd_1 = require("antd");
var loading_1 = __importDefault(require("components/share/loading"));
var edit_table_1 = __importDefault(require("lib/hooks/edit-table"));
var accounts_1 = require("@cocalc/util/db-schema/accounts");
var keyboard_shortcuts_1 = __importStar(require("@cocalc/frontend/account/keyboard-shortcuts"));
var feature_1 = require("@cocalc/frontend/feature");
var desc = {
    bindings: "Keyboard bindings: standard, sublime, vim and emacs.",
    shortcuts: keyboard_shortcuts_1.desc,
    evaluate_key: "You can use either Shift-Enter or plain Enter to evaluate code in Sage worksheets. If you use Enter for evaluation, use Shift-Enter to enter a new line.  This setting does not impact Jupyter notebooks.",
};
(0, register_1.default)({
    path: "editor/keyboard",
    title: "Keyboard",
    icon: "keyboard",
    desc: "Configure keyboard bindings.",
    search: desc,
    Component: function () {
        var _a = (0, edit_table_1.default)({
            accounts: { editor_settings: null },
        }), edited = _a.edited, original = _a.original, Save = _a.Save, EditSelect = _a.EditSelect, Heading = _a.Heading;
        if (original == null || edited == null) {
            return (0, jsx_runtime_1.jsx)(loading_1.default, {});
        }
        return ((0, jsx_runtime_1.jsxs)(antd_1.Space, __assign({ direction: "vertical", style: { width: "100%" } }, { children: [(0, jsx_runtime_1.jsx)(Save, {}), (0, jsx_runtime_1.jsx)(EditSelect, { path: "editor_settings.bindings", icon: "keyboard", desc: desc.bindings, options: accounts_1.EDITOR_BINDINGS }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(Heading, { title: "Editor Keyboard Shortcuts", desc: desc.shortcuts }), (0, jsx_runtime_1.jsx)(KeyboardShortcuts, {}), (0, jsx_runtime_1.jsx)(EditSelect, { title: "Sage Worksheet Evaluate Key", path: "evaluate_key", desc: desc.evaluate_key, options: ["Shift-Enter", "Enter"] })] })));
    },
});
var columns = [
    {
        title: "Command",
        dataIndex: "command",
        key: "command",
        width: "50%",
        filterSearch: true,
        onFilter: function (value, record) { return record.name.includes(value); },
    },
    {
        title: "Shortcut",
        dataIndex: "shortcut",
        key: "shortcut",
    },
];
function KeyboardShortcuts() {
    var shortcuts = (0, keyboard_shortcuts_1.default)(feature_1.IS_MACOS);
    var data = [];
    for (var command in shortcuts) {
        var shortcut = shortcuts[command];
        data.push({ command: command, shortcut: shortcut });
    }
    return (0, jsx_runtime_1.jsx)(antd_1.Table, { columns: columns, dataSource: data, pagination: false });
}
//# sourceMappingURL=keyboard.js.map