import React from"react";import{makeId}from"./utils.js";class FormComponent extends React.Component{constructor(){super(...arguments),this.raiseEvent=(e,t)=>{var s;return null===(s=this.props.host)||void 0===s?void 0:s.post(e,{name:this.props.name,value:t})},this.setProperty=(e,t)=>{const s=this.props.host;var n=this.props.name;s.assignElementProperty(n,e,t)},this.setValue=e=>this.setProperty("value",e)}get elementRegistration(){const e=this.props["host"];if(isFormRenderer(e))return e.getElementRegistration(this.element)}get element(){const{host:e,name:t}=this.props;if(t)return e.find(t)}prepare(){var e;void 0===this.id&&(this.id=makeId()),this.enabled=!0;const t=this.props.host;return!1===t.enabled&&(this.enabled=!1),void 0!==this.element&&(void 0!==(e=t.find(this.element.section))&&!1===e.enabled&&(this.enabled=!1),!1===this.element.enabled&&(this.enabled=!1)),this.element}render(){return this.props.host.renderVisual(this)}}class FormElement extends FormComponent{componentDidMount(){const e=this.props;e.host.refs[e.name]=this}componentDidUpdate(){const e=this.props;e.host.refs[e.name]=this}componentWillUnmount(){const e=this.props;e.host.refs[e.name]=void 0}}function isFormRenderer(e){return!!e&&"function"==typeof e.getElementRegistration}export{FormComponent,FormElement};