"use strict";(self.webpackChunkLHCReactAPP=self.webpackChunkLHCReactAPP||[]).push([[536],{3536:function(t,e,n){n.r(e);var a,i=n(7154),s=n.n(i),r=n(4575),c=n.n(r),u=n(3913),o=n.n(u),l=n(1506),d=n.n(l),b=n(2205),f=n.n(b),h=n(8585),p=n.n(h),v=n(9754),m=n.n(v),y=n(9713),k=n.n(y),x=n(7294),C=n(6458),g=n(6512),Q=(n(2137),n(488)),_=n.n(Q),E=n(7139);var R=(0,C.$j)((function(t){return{chatwidget:t.chatwidget}}))(a=function(t){f()(i,t);var e,n,a=(e=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,a=m()(e);if(n){var i=m()(this).constructor;t=Reflect.construct(a,arguments,i)}else t=a.apply(this,arguments);return p()(this,t)});function i(t){var e;return c()(this,i),e=a.call(this,t),k()(d()(e),"state",{currentQuestion:1,is_valid:null,collectedData:{},collectedQuestion:[]}),e}return o()(i,[{key:"abstractClick",value:function(t,e,n){var a=this.state.collectedData,i=this.state.collectedQuestion,s=!1;"plain"==t["data-inline"]?""!=n.target.value&&(s=!0,a[t.name]=n.target.value):(s=!0,a[t.name]=t.value),!0===s&&-1===i.indexOf(e.seq)?i.push(e.seq):!1===s&&-1!==i.indexOf(e.seq)&&i.splice(i.indexOf(e.seq),1),this.setState({collectedData:a,collectedQuestion:i})}},{key:"submitSurvey",value:function(){var t=this;this.state.collectedData.survey_id=this.props.survey_id,this.state.collectedData.chat_id=this.props.chatwidget.getIn(["chatData","id"]),this.state.collectedData.hash=this.props.chatwidget.getIn(["chatData","hash"]),(0,g.q0)(this.state.collectedData).then((function(e){var n={is_valid:e.data.is_valid};n.feedback_text=e.data.result,t.setState(n)}))}},{key:"render",value:function(){var t=this,e=this.props.t,n=1,a=0;return(0,Q.domToReact)(this.props.surveyOptions,{replace:function(t){t.attribs&&"voteoption"===t.name&&a++}}),x.createElement("div",null,!1===this.state.is_valid&&_()(this.state.feedback_text,{replace:function(e){if(e.attribs&&e.name&&"button"===e.name)return x.createElement("button",s()({type:"button"},e.attribs,{onClick:function(e){return t.setState({is_valid:null})}}))}}),!0===this.state.is_valid&&x.createElement("div",null,_()(this.state.feedback_text)),!0!==this.state.is_valid&&(0,Q.domToReact)(this.props.surveyOptions,{replace:function(i){if(i.attribs&&"voteoption"===i.name){var r=t.state.currentQuestion!=n?"d-none":"";n++;var c=1==i.attribs["is-required"]&&-1===t.state.collectedQuestion.indexOf(i.attribs.seq),u="d-block pt-3"+(1==a?" text-center":""),o="btn btn-outline-secondary btn-sm"+(a>1?" float-end":"")+" btn-survey-submit";return x.createElement("div",s()({},i.attribs,{className:r}),(0,Q.domToReact)(i.children,{replace:function(e){if(e.attribs){if(e.name&&"input"===e.name&&e.attribs.type&&"radio"==e.attribs.type){var n=Object.assign({},e.attribs);return x.createElement("input",s()({type:"radio"},e.attribs,{onChange:function(e){return t.abstractClick(n,i.attribs,e)}}))}if(e.name&&"textarea"===e.name)return n=Object.assign({},e.attribs),x.createElement("textarea",s()({style:{height:"55px"}},e.attribs,{onChange:function(e){return t.abstractClick(n,i.attribs,e)}}))}}}),x.createElement("div",{className:u},t.state.currentQuestion>1&&x.createElement("input",{type:"button",className:"btn btn-outline-secondary btn-sm btn-survey-prev",onClick:function(e){return t.setState({currentQuestion:t.state.currentQuestion-1})},value:e("button.back"),name:"Prev"}),a>t.state.currentQuestion&&x.createElement("input",{disabled:c,type:"button",className:"btn btn-outline-secondary btn-sm float-end btn-survey-next",onClick:function(e){return t.setState({currentQuestion:t.state.currentQuestion+1})},value:e("button.next"),name:"Next"}),a==t.state.currentQuestion&&x.createElement("input",{disabled:c,type:"button",className:o,onClick:function(e){return t.submitSurvey()},value:e("button.submit"),name:"Submit"})))}}}))}}]),i}(x.Component))||a;e.default=(0,E.Z)()(R)}}]);
//# sourceMappingURL=536.daa69d70da79b79bc1ec.js.map