"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CodeEditor = void 0;
const react_1 = __importDefault(require("@monaco-editor/react"));
const react_2 = require("react");
const react_3 = __importDefault(require("react"));
function CodeEditor(_a) {
    var { readOnly, lineNumbers = 'off', style } = _a, props = __rest(_a, ["readOnly", "lineNumbers", "style"]);
    const monacoRef = (0, react_2.useRef)(null);
    function handleEditorWillMount(monaco) {
        // here is the monaco instance
        // do something before editor is mounted
        monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
        monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
        // noSemanticValidation: true,
        // noSyntaxValidation: true,
        });
        monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
            jsx: monaco.languages.typescript.JsxEmit.React,
            noEmit: true,
            jsxFactory: 'React.createElement',
            reactNamespace: 'React',
            allowNonTsExtensions: true,
            allowJs: true,
            target: monaco.languages.typescript.ScriptTarget.Latest
        });
    }
    const handleEditorDidMount = function (editor, monaco) {
        // here is another way to get monaco instance
        // you can also store it in `useRef` for further usage
        monacoRef.current = editor;
        editor.updateOptions({
            readOnly,
            lineNumbers,
            minimap: {
                enabled: false
            },
            lineDecorationsWidth: 0,
            glyphMargin: false,
            folding: false,
            automaticLayout: true
        });
    };
    react_3.default.useEffect(() => {
        if (monacoRef.current) {
            monacoRef.current.updateOptions({
                readOnly,
                lineNumbers
            });
        }
    }, [readOnly, lineNumbers]);
    return (react_3.default.createElement("div", { style: style },
        react_3.default.createElement(react_1.default, Object.assign({ language: "typescript", height: '200px', beforeMount: handleEditorWillMount, onMount: handleEditorDidMount }, props))));
}
exports.CodeEditor = CodeEditor;
//# sourceMappingURL=index.js.map