import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { ObserveState } from "../../CommonUI/StateManagement/ObserveState";
import styled from "styled-components";
export class ObserableData {
    constructor(innerComponent, context, validations) {
        this.innerComponent = innerComponent;
        this.context = context;
    }
}
export class XRuntimeWrapper extends React.Component {
    render() {
        const valueName = Reflect.get(this.props.innerComponent, 'valueName');
        const id = this.props.innerComponent.id;
        if (valueName) {
            return (_jsx(ObserveState, { listenTo: this.props.context.runtimeContext, control: () => this.renderControl(), properties: [valueName, id] }, void 0));
        }
        else {
            return this.props.innerComponent.render();
        }
    }
    renderControl() {
        const id = this.props.innerComponent.id;
        const hideControls = this.props.context.runtimeContext.hideControls;
        if (hideControls.indexOf(id) >= 0)
            return null;
        const disabledControls = this.props.context.runtimeContext.disabledControls;
        if (disabledControls.indexOf(id) >= 0) {
            return (_jsx(StyledFieldSet, Object.assign({ disabled: true }, { children: this.props.innerComponent.render() }), void 0));
        }
        return this.props.innerComponent.render();
    }
}
const StyledFieldSet = styled.fieldset `
    border: none;
    margin: 0px;
    padding: 0px;
`;
//# sourceMappingURL=XRuntimeWrapper.js.map