define("wml!SitesCommon/OpenLeadForm/Form",["Compiler/IR","i18n!SitesCommon","Controls/LoadingIndicator","Controls/validate","Controls/SuggestInput","Controls/input","Controls/checkbox","Controls/markup","SitesCommon/Button"],(function(e,t){"use strict";function o(){return this}var a="undefined"===typeof window,n=["_validators","_suggestValue","_onChoose","_suggestChangedHandler","_onFocus","_suggestSource","_suggestFilter","_suggestNavigation","_name","_phone","_phoneInputCallback","_sendAgreement","_agreementChangedHandler","_submit","_onDeactivatedHandler","withoutPaddings","_options","pb-56 pb-xm-40 pb-sm-32","submit","deactivated","withInnInput","inn","choose","valueChanged","focusIn","focusOut","name","agreement","mb-8","mb-40 mb-xm-32 mb-sm-24","phone","sendAgreement","splice","GTMSubmitButtonId","buttonCaption","click","buttonStyle","hideMsg"];return e.g({v:1,m:"wml!SitesCommon/OpenLeadForm/Form",d:e.d(["Controls/LoadingIndicator","Controls/validate","Controls/SuggestInput","Controls/input","Controls/checkbox","Controls/markup","SitesCommon/Button"],Array.prototype.slice.call(arguments,2)),t:[e.c(((e,t)=>[e.C(t,"ws:Controls/SuggestInput",{K:"0_0_0_0_0_0_0_0_0_0_",A:{class:"sbisru-Form__input"},E:{"on:valuechanged":[{value:"valueChanged",originalName:"bind:value",viewController:t.v,data:t.d,handler:e.B(t,4),isControl:true,bindValue:"_suggestValue"},{value:n[3],originalName:n[23],viewController:t.v}],"on:choose":[{value:n[2],originalName:n[22],viewController:t.v}],"on:focusin":[{value:n[4],originalName:n[24],viewController:t.v,args:[true]}],"on:focusout":[{value:n[4],originalName:n[25],viewController:t.v,args:[false]}],meta:{isControl:true,context:o,handler:e.M(t,1)}},O:{esc:false,value:e.m(t,5),name:"inn",source:e.m(t,6),filter:e.m(t,7),navigation:e.m(t,8),placeholder:"название или ИНН вашей организации",borderVisibility:"partial",searchParam:"Реквизиты",minSearchLength:3,displayProperty:"Название",fontSize:"3xl",inlineHeight:"3xl",fontWeight:"normal",closeButtonVisible:false,suggestTemplate:{templateName:"wml!SitesCommon/OpenLeadForm/suggestList"},footerTemplate:{templateName:"wml!SitesCommon/OpenLeadForm/suggestFooter"},suggestPopupOptions:{actionOnScroll:"close",direction:{horizontal:"center"}}},g:true,m:"attribute",b:["suggestTemplate","footerTemplate","suggestPopupOptions"],i:0})])),e.c(((e,a)=>[e.C(a,{library:"Controls/input",module:["Text"]},{K:"0_0_0_0_0_1_0_0_0_",A:{class:"sbisru-Form__input sbisru-Form__name","aria-label":t("sbisru_Lead_placeholder-name","OpenForm")},E:{"on:valuechanged":[{value:"valueChanged",originalName:"bind:value",viewController:a.v,data:a.d,handler:e.B(a,10),isControl:false,bindValue:"_name"}],meta:{isControl:false,context:o,handler:e.M(a,1)}},O:{value:e.m(a,11),name:"name",borderVisibility:"partial",maxLength:100,trim:true,fontSize:"3xl",inlineHeight:"3xl",fontWeight:"normal",placeholder:t("sbisru_Lead_placeholder-name","OpenForm")},g:true,m:"attribute",i:2})])),e.c(((e,a)=>[e.C(a,{library:"Controls/input",module:["Phone"]},{K:"0_0_0_0_0_2_0_0_0_",A:{class:"sbisru-Form__input sbisru-Form__phone","aria-label":t("sbisru_Lead_placeholder-phone","OpenForm")},E:{"on:valuechanged":[{value:"valueChanged",originalName:"bind:value",viewController:a.v,data:a.d,handler:e.B(a,14),isControl:false,bindValue:"_phone"}],meta:{isControl:false,context:o,handler:e.M(a,1)}},O:{value:e.m(a,15),borderVisibility:"partial",placeholder:t("sbisru_Lead_placeholder-phone","OpenForm"),trim:true,onlyMobile:true,fontSize:"3xl",inlineHeight:"3xl",fontWeight:"normal",inputCallback:e.m(a,16)},g:true,m:"attribute",i:3})])),e.c(((e,t)=>[e.m(t,21)?[e.C(t,{library:"Controls/markup",module:["Decorator"]},{K:"0_0_0_0_0_3_0_0_0_0_0_0_",O:{value:e.m(t,17)},g:true,m:"attribute"})]:[e.P(t,e.m(t,17),{K:"0_0_0_0_0_3_0_0_0_0_1_0_",g:true,m:"attribute"})]]),"caption"),e.c(((e,t)=>[e.C(t,{library:"Controls/checkbox",module:["Checkbox"]},{K:"0_0_0_0_0_3_0_0_0_",A:{class:"sbisru-Form__agreement sbisru-Form__agreement--offset pb-24"},E:{"on:valuechanged":[{value:"valueChanged",originalName:"bind:value",viewController:t.v,data:t.d,handler:e.B(t,19),isControl:false,bindValue:"_sendAgreement"},{value:n[12],originalName:n[23],viewController:t.v}],meta:{isControl:false,context:o,handler:e.M(t,1)}},O:{esc:false,value:e.m(t,20),name:"agreement",caption:e.o(t,3,5)},g:true,m:"attribute",i:6})])),e.c(((e,l)=>[e.g(l,"form",{K:"0_0_0_0_0_",A:{class:"sbisru-Form "+e.e(e.x(l,0))},E:a?{}:{"on:submit":[{value:n[13],originalName:n[18],viewController:l.v}],"on:deactivated":[{value:n[14],originalName:n[19],viewController:l.v}],meta:{isControl:false,context:o,handler:e.M(l,1)}},r:true},[e.m(l,2)?[e.g(l,"div",{K:"0_0_0_0_0_0_0_",A:{class:"sbisru-Form__item mb-16"}},[e.C(l,{library:"Controls/validate",module:["InputContainer"]},{K:"0_0_0_0_0_0_0_0_",O:{esc:false,validators:e.m(l,3),content:e.o(l,0,1)}})])]:e.t(),e.g(l,"div",{K:"0_0_0_0_0_1_",A:{class:"sbisru-Form__item mb-16"}},[e.C(l,{library:"Controls/validate",module:["InputContainer"]},{K:"0_0_0_0_0_1_0_",O:{esc:false,validators:e.m(l,9),content:e.o(l,1,2)}})]),e.g(l,"div",{K:"0_0_0_0_0_2_",A:{class:"sbisru-Form__item "+e.e(e.x(l,12))}},[e.C(l,{library:"Controls/validate",module:["InputContainer"]},{K:"0_0_0_0_0_2_0_",O:{esc:false,validators:e.m(l,13),content:e.o(l,2,4)}})]),e.m(l,17)?[e.C(l,{library:"Controls/validate",module:["InputContainer"]},{K:"0_0_0_0_0_3_0_",O:{esc:false,validators:e.m(l,18),content:e.o(l,4,7)}})]:e.t(),e.g(l,"div",{K:"0_0_0_0_0_4_",A:{class:"sbisru-Form__item-button sbisru-Form__button--gap ws-flexbox ws-align-items-center ws-flex-wrap"}},[e.C(l,"ws:SitesCommon/Button",{K:"0_0_0_0_0_4_0_",A:{class:"sbisru-Form__button--width","gtm-submit-id":e.e(e.m(l,22)),"aria-label":e.e(e.m(l,23))},E:{"on:click":[{value:n[13],originalName:n[35],viewController:l.v}],meta:{isControl:true,context:o,handler:e.M(l,1)}},O:{disabled:e.m(l,24),caption:e.m(l,23),style:e.m(l,25)}}),e.m(l,26)?[e.g(l,"span",{K:"0_0_0_0_0_4_1_0_",A:{class:"sbisru-Form__msg ml-8 ml-xm-4 ml-sm-0"}},[e.t(t("sbisru_Lead_msg","OpenForm"),"0_0_0_0_0_4_1_0_0_")])]:e.t()])])])),e.c(((e,t)=>[e.C(t,{library:"Controls/validate",module:["Controller"]},{K:"0_0_0_",O:{esc:false,name:"formController",content:e.o(t,5,8)},g:true,m:"attribute"})])),e.r(((e,o)=>[e.C(o,"ws:Controls/LoadingIndicator",{K:"0_",O:{esc:false,name:"loadingIndicator",message:t("sbisru_Lead_send-try"),overlay:"default",delay:"200",content:e.o(o,6,8)},m:"attribute",c:true})]))],p:n.slice(0,15),e:[(e,t)=>!e.g(t,[n[16],n[15]])?n[17]:"",function(e,t,o,a,n,l){return e.g(this,[l])},(e,t)=>e.g(t,[n[16],n[20]]),(e,t)=>e.g(t,[n[0]])&&e.g(t,[n[0],n[21]]),(e,t,o,a,n,l)=>e.s(t,["_suggestValue"],l),(e,t)=>e.g(t,[n[1]]),(e,t)=>e.g(t,[n[5]]),(e,t)=>e.g(t,[n[6]]),(e,t)=>e.g(t,[n[7]]),(e,t)=>e.g(t,[n[0]])&&e.g(t,[n[0],n[26]]),(e,t,o,a,n,l)=>e.s(t,["_name"],l),(e,t)=>e.g(t,[n[8]]),(e,t)=>e.g(t,[n[16],n[27]])?n[28]:n[29],(e,t)=>e.g(t,[n[0]])&&e.g(t,[n[0],n[30]]),(e,t,o,a,n,l)=>e.s(t,["_phone"],l),(e,t)=>e.g(t,[n[9]]),(e,t)=>e.g(t,[n[10]]),(e,t)=>e.g(t,[n[16],n[27]]),(e,t)=>e.g(t,[n[0]])&&e.g(t,[n[0],n[31]]),(e,t,o,a,n,l)=>e.s(t,["_sendAgreement"],l),(e,t)=>e.g(t,[n[11]]),(e,t)=>e.g(t,[n[16],n[27],n[32]]),(e,t)=>e.g(t,[n[16],n[33]]),(e,t)=>e.g(t,[n[16],n[34]]),(e,t)=>!e.g(t,[n[11]]),(e,t)=>e.g(t,[n[16],n[36]]),(e,t)=>!e.g(t,[n[16],n[37]])],i:[[[5]],[[5,8]],[[11]],[[15]],[[15,16]],[[17],[21]],[[20]],[[17],[20,21]],[[0],[2,3],[5,9],[11,13],[15,18],[20,26]]]})}));
define("SitesCommon/OpenLeadForm",["require","exports","UI/Base","Controls/validate","wml!SitesCommon/OpenLeadForm/Form","SitesCommon/LeadForm/Agreement","Types/source","Application/Env","SitesCommonExt/Region/Manager","SitesCommonExt/Helpers/seoHelpers","SitesCommon/OpenLeadForm/validators","i18n!SitesCommon","SitesCommon/Opener","SitesCommon/input","Antibot/Validation","SitesCommon/helpers/appliedStatistics","SitesCommon/OpenLeadForm/validators","css!SitesCommon/OpenLeadForm/Form"],(function(e,t,s,o,n,i,r,a,l,m,h,d,c,u,g,p){"use strict";Object.defineProperty(t,"__esModule",{value:true});const _=429;class f extends s.Control{constructor(){super(...arguments),this._template=n,this._antibotValidation=g,this._blocked=false,this._name="",this._phone="",this._sendAgreement=false,this._source=null,this._inn={orgInn:"",orgKpp:"",orgName:""},this._suggestValue="",this._suggestFocus=false,this._hasErrors=false,this._phoneInputCallback=e=>{if(e.value.length<=2)return{value:"+7",displayValue:"+7",position:2};if(/^\+[^78]/.test(e.value))return{value:"+7"+e.value.replace(/^\+/,""),displayValue:"+7"+e.displayValue.replace(/^\+/,""),position:e.position};return e}}_beforeMount(){this._source=new r.SbisService({endpoint:{contract:"Feedback",address:"/service/"}}),this._suggestSource=new r.SbisService({keyProperty:"Лицо",endpoint:{address:"/sbisru/service/",contract:"Контрагент"},binding:{query:"List"}}),this._suggestNavigation={source:"page",view:"infinity",sourceConfig:{pageSize:10}},this._suggestFilter={get"Регион"(){return a.cookie.get("s3reg")},searchAllIfNull:true,"ПоНазванию":true,"ПоРеквизитам":true}}async send(){let t=this._options.comment?this._options.comment+"\n\n":"",s=a.cookie.get("cntxad")&&decodeURIComponent(a.cookie.get("cntxad"));const o=s&&s.match(/CPA:\saffise\s([^.]+)/)?s.match(/CPA:\saffise\s([^.]+)/).pop():null,n=s&&s.match(/CPA:\scityads\s([^.]+)/)?s.match(/CPA:\scityads\s([^.]+)/).pop().split("|"):null;if(n)s=s.replace(/CPA:\scityads\s[^.]+/,"CPA: cityads "+n[0]);const i=a.cookie.get("s3reg"),r=i?l.getRegionByKey(i):null;if(!this._options.notSendRegionComment&&r)t+=`Регион: ${r.key} ${r.name}\n`;if(s)t+=`${s}\n`;t+=`Источник лида: ${location.host}${location.pathname}`,t+=location.search.replace(/^(\?promo[^&\s]*)[^\s]*|[?&=\S]+/,"$1");const h={requestType:"lead",comment:this._options.leadTheme,description:t,person:this._name,phone:this._phone,orgInn:this._inn.orgInn,orgKpp:this._inn.orgKpp,orgName:this._inn.orgName,client_time:Math.floor((new Date).getTime()/1e3),client_tz:Math.floor((new Date).getTimezoneOffset()),conversionId:m.getCRMconversionId()};if(this._options.course&&this._options.course.length>0)h.AdditionalFields={"Выберите курс":this._options.course};if(this._options.sendSEOInfo)h.UTM=m.getSEOInfo(),h.URL=`${location.host}${location.pathname}`,h.REFERRER=document.referrer;if(!this._options.notSendRegionComment&&r)h.UserConds={"Регион":r.key};try{const t=(await this._source.call("Create",{data:h})).getRawData(),s=parseInt(t,10);if(s){if(!this._options.hideSubmitDialog)Promise.all([new Promise(((t,s)=>{e(["wml!SitesCommon/LeadForm/succes"],t,s)})),new Promise(((t,s)=>{e(["css!SitesCommon/LeadForm/LeadForm"],t,s)}))]).then((()=>{c.default.open({opener:this,template:"wml!SitesCommon/LeadForm/succes",options:{message:this._options.succesMessage}})}));if(m.sendTrackingSeoToCRM(s,"Лид"),m.sendGTMCustomEvent("sendFormGTM"),(0,p.sendStats)(this._options.appliedStatsSend),o)m.loadScriptCPA(o);if(n)m.loadScriptCPA(n[1],n[0])}else{if(!t.match(/^(ошибка|error)/i))throw new Error(t);this._sendErrorHandler(t,t)}}catch(e){throw e}}_toogleBlockRequest(e){this._children.loadingIndicator[e?"show":"hide"](),this._blocked=e}_setValidators(){this._validators={name:[()=>o.isRequired.call(this,{value:this._name})],phone:[()=>o.isRequired.call(this,{value:this._phone}),()=>h.isPhone.call(this,{value:this._phone})],inn:[()=>this._inn.orgInn&&u.isInn.call(this,this._inn.orgInn)||!this._inn.orgInn||"Нужно ввести или выбрать значение из списка"],sendAgreement:[()=>o.isRequired.call(this,{value:this._sendAgreement?true:""})]}}_removeValidators(){if(!this._validators)return;this._validators=null,this._children.formController.setValidationResult(null,{hideInfoBox:true}),this._notify("closeInfoBox",[],{bubbling:true}),this._notify("close",[],{bubbling:true})}async _submit(e){if(e.preventDefault(),this._blocked)return;if(!this._validators)this._setValidators();const t=await this._children.formController.submit();if(t instanceof Error||t.hasErrors)return;try{this._toogleBlockRequest(true),await this.send(),this._suggestValue="",this._sendAgreement=false,this._inn={orgInn:"",orgKpp:"",orgName:""},this._name="",this._phone=""}catch(e){if(e.status!==_)this._sendErrorHandler(e,d("sbisru_Lead_send-error"));this._hasErrors=true}finally{if(this._toogleBlockRequest(false),!this._hasErrors)this._notify("formSent")}}_sendErrorHandler(t,s){a.logger.warn("SitesCommon/LeadForm: Ошибка при отправке заявки:",t),Promise.all([new Promise(((t,s)=>{e(["wml!SitesCommon/LeadForm/error"],t,s)})),new Promise(((t,s)=>{e(["css!SitesCommon/LeadForm/LeadForm"],t,s)}))]).then((()=>{c.default.open({opener:this,template:"wml!SitesCommon/LeadForm/error",options:{message:s}})}))}_onDeactivatedHandler(){this._removeValidators()}_agreementChangedHandler(e,t){this._sendAgreement=t}_stopPropagation(e){e.stopPropagation()}_setData({orgInn:e="",orgKpp:t="Нет",orgName:s=""}){this._inn={orgInn:e,orgKpp:t,orgName:s}}_onChoose(e,t){this._suggestValue=t.get("Название"),this._setData({orgInn:t.get("ИНН"),orgKpp:t.get("КПП"),orgName:t.get("Название")})}_suggestChangedHandler(e,t){this._suggestValue=t,this._setData({orgInn:this._suggestValue,orgKpp:"",orgName:""})}_onFocus(e,t){this._suggestFocus=t}static getDefaultOptions(){return{leadTheme:"",comment:"",GTMSubmitButtonId:"bottom",buttonCaption:d("sbisru_Lead_submit-caption","OpenForm"),buttonStyle:"secondary",agreement:i.default,sendSEOInfo:true,notSendRegionComment:false}}}Object.defineProperty(f,"defaultProps",{enumerable:true,configurable:true,get:()=>f.getDefaultOptions()}),t.default=f}));