"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.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 react_1 = __importStar(require("react"));
const Compiler_1 = require("../compiler/Compiler");
const CodeEditor_1 = __importDefault(require("./CodeEditor"));
require("./CodeSample.css");
const CodeViewer_1 = __importDefault(require("./CodeViewer"));
function CodeSample(props) {
    let [content, setContent] = react_1.useState(props.children);
    let onInput = react_1.useMemo(() => {
        return (e) => {
            setContent(e.target.innerText);
        };
    }, []);
    let javascript = Compiler_1.compileSample(content, "sample", true);
    let isError = typeof javascript !== "string";
    return (react_1.default.createElement("div", { className: "CodeSample" },
        react_1.default.createElement("div", { className: "description" }, props.description),
        react_1.default.createElement("div", { className: "samples" },
            react_1.default.createElement(CodeEditor_1.default, { onInput: onInput }, props.children),
            react_1.default.createElement(CodeViewer_1.default, { source: content, debug: true }),
            react_1.default.createElement(CodeViewer_1.default, { source: content, debug: false }))));
}
exports.default = CodeSample;
