"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Test = void 0;
var tslib_1 = require("tslib");
var React = require("react");
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var Test_Grid_1 = require("./Test.Grid");
var KEY = {
    EDITOR: 'ui.datagrid/editor',
};
function fromStorage(key, defaultValue) {
    var value = localStorage.getItem(key);
    return (value === undefined ? defaultValue : value);
}
var Test = (function (_super) {
    tslib_1.__extends(Test, _super);
    function Test() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {};
        _this.unmounted$ = new rxjs_1.Subject();
        _this.state$ = new rxjs_1.Subject();
        return _this;
    }
    Test.prototype.componentDidMount = function () {
        var _this = this;
        var state$ = this.state$.pipe(operators_1.takeUntil(this.unmounted$));
        state$.subscribe(function (e) { return _this.setState(e); });
        var editor = fromStorage(KEY.EDITOR, this.editorType);
        this.state$.next({ editor: editor });
        state$.subscribe(function () {
            localStorage.setItem(KEY.EDITOR, _this.editorType);
        });
    };
    Test.prototype.componentWillUnmount = function () {
        this.unmounted$.next();
        this.unmounted$.complete();
    };
    Object.defineProperty(Test.prototype, "editorType", {
        get: function () {
            return this.state.editor || 'debug';
        },
        enumerable: false,
        configurable: true
    });
    Test.prototype.render = function () {
        return React.createElement(Test_Grid_1.TestGrid, { editorType: this.editorType, left: true });
    };
    return Test;
}(React.PureComponent));
exports.Test = Test;
