import{r as t,h as i,g as s}from"./p-3ba9c73c.js";import{l as e}from"./p-2b74e80e.js";import{E as h}from"./p-b72d14f0.js";const n=class{constructor(i){t(this,i),this.question="",this.required=!1,this.multiline=!1,this.min=null,this.max=null,this.answer="",this.hasAnswer=!!this.answer,this.labelQuestion="Formulate your question",this.labelRequired="Required",this.labelMultiline="Multiline",this.labelMin="Min",this.labelMax="Max",this.labelHasAnswer="Answer",this.labelAnswer="",this.placeholderAnswer="Formulate the correct answer",this._link=e(this,this.handleInput),this._question=this._link("question"),this._required=this._link("required"),this._multiline=this._link("multiline"),this._min=this._link("min"),this._max=this._link("max"),this._answer=this._link("answer"),this._hasAnswer=this._link("hasAnswer")}handleInput(t,i){const s=i.target;if(!s)return;const{value:e}=s;"answer"!==t||e||(this.hasAnswer=!1),"hasAnswer"!==t||e||(this.answer=""),"multiline"===t&&(this.hasAnswer=!1,this.answer=""),i.cancelBubble=!0,this[t]=e,this.value=this.updateValue({[t]:e}),this.el.dispatchEvent(new Event("input",{bubbles:!0}))}updateValue(t={}){return Object.assign({},{question:this.question,required:this.required,multiline:this.multiline,min:this.min,max:this.max,answer:this.answer,hasAnswer:this.hasAnswer},t)}componentDidLoad(){this.value=this.updateValue(),this.el.dispatchEvent(new Event("input",{bubbles:!0}))}render(){const{multiline:t}=this;return i(h,{question:this._question,required:this._required},i("bce-input",Object.assign({type:"switch"},this._multiline)),i("bce-input",Object.assign({type:"number"},this._min)),i("bce-input",Object.assign({type:"number"},this._max)),i("bce-input",Object.assign({type:"switch"},this._hasAnswer)),this.hasAnswer&&i("bce-input",Object.assign({type:t?"textarea":"text"},this._answer)))}get el(){return s(this)}};export{n as bce_element_input_template};