"use strict";
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 });
const jsx_runtime_1 = require("react/jsx-runtime");
const register_1 = __importDefault(require("../register"));
const antd_1 = require("antd");
const loading_1 = __importDefault(require("components/share/loading"));
const edit_table_1 = __importDefault(require("lib/hooks/edit-table"));
const accounts_1 = require("@cocalc/util/db-schema/accounts");
const keyboard_shortcuts_1 = __importStar(require("@cocalc/frontend/account/keyboard-shortcuts"));
const feature_1 = require("@cocalc/frontend/feature");
const 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: () => {
        const { edited, original, Save, EditSelect, Heading } = (0, edit_table_1.default)({
            accounts: { editor_settings: null },
        });
        if (original == null || edited == null) {
            return (0, jsx_runtime_1.jsx)(loading_1.default, {});
        }
        return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { 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"] })] }));
    },
});
const columns = [
    {
        title: "Command",
        dataIndex: "command",
        key: "command",
        width: "50%",
        filterSearch: true,
        onFilter: (value, record) => record.name.includes(value),
    },
    {
        title: "Shortcut",
        dataIndex: "shortcut",
        key: "shortcut",
    },
];
function KeyboardShortcuts() {
    const shortcuts = (0, keyboard_shortcuts_1.default)(feature_1.IS_MACOS);
    const data = [];
    for (const command in shortcuts) {
        const shortcut = shortcuts[command];
        data.push({ command, shortcut });
    }
    return (0, jsx_runtime_1.jsx)(antd_1.Table, { columns: columns, dataSource: data, pagination: false });
}
//# sourceMappingURL=keyboard.js.map