"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DIM_TIMEOUT_T = exports.DEFAULT_STYLE = void 0;
const addListener_1 = require("../../../../../client/addListener");
const color_1 = require("../../../../../client/color");
const component_1 = require("../../../../../client/component");
const custom_1 = require("../../../../../client/event/custom");
const parentElement_1 = require("../../../../../client/platform/web/parentElement");
const theme_1 = require("../../../../../client/theme");
const Component_1 = __importDefault(require("../../../../platform/component/app/PhoneKeyboard/Component"));
const Component_2 = __importDefault(require("../GUIControl/Component"));
exports.DEFAULT_STYLE = {};
exports.DIM_TIMEOUT_T = 3000;
class GUIControlKeyboard extends component_1.Component {
    constructor($props, $system) {
        super($props, $system);
        this._background_color = () => {
            const { $theme } = this.$context;
            const backgroundColor = (0, color_1.setAlpha)((0, theme_1.themeBackgroundColor)($theme), 0.75);
            return backgroundColor;
        };
        this._refresh_color = () => {
            const backgroundColor = this._background_color();
            this._content.setProp('keyStyle', {
                backgroundColor,
            });
        };
        const { style = {} } = this.$props;
        const root = new Component_2.default({
            icon: 'keyboard',
            style: {},
            width: 312,
            height: 210,
            x: 48,
            y: 48,
            _x: 12,
            collapsed: true,
        }, this.$system);
        root.preventDefault('mousedown');
        root.preventDefault('touchdown');
        this._root = root;
        const keyboard = new Component_1.default({
            style: {},
        }, this.$system);
        root.registerParentRoot(keyboard);
        this._content = keyboard;
        const $element = (0, parentElement_1.parentElement)($system);
        this.$element = $element;
        this.$slot = root.$slot;
        this.$unbundled = false;
        this.$primitive = true;
        this.setSubComponents({
            root,
            keyboard,
        });
        this.registerRoot(root);
    }
    onPropChanged(prop, current) { }
    onMount() {
        this._context_unlisten = (0, addListener_1.addListener)(this.$context, (0, custom_1.makeCustomListener)('themechanged', () => {
            this._refresh_color();
        }));
        this._refresh_color();
    }
    onUnmount() {
        this._context_unlisten();
    }
}
exports.default = GUIControlKeyboard;
//# sourceMappingURL=Component.js.map