PageSourceSearch

https://constructor.tech/assets/ch-BubConstructorForm-CwtsesUN.js

js constructor.tech collected 2026-09-24 11:17:09 UTC 10,495 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ch-BaseField-D44cyf1j.js","assets/app-index-CXQob2hh.js","assets/app-index-SWungaUD.css","assets/ex-BaseField-WeLd2_IF.css"])))=>i.map(i=>d[i]);
2import{_ as p,o,c as a,e as c,F as h,h as d,t as _,g as v,n as f,w as x,D as E,a as b,b as w,f as S,E as T,G as V,H as C,I as y,J as g,K as F,m as q,l as L,r as A}from"./app-index-CXQob2hh.js";const M=q(()=>L(()=>import("./ch-BaseField-D44cyf1j.js"),__vite__mapDeps([0,1,2,3]))),H=["text","email","url","phone","select","textarea"],B={name:"BubConstructorForm",components:{BaseField:M},props:{block:{type:Object,required:!0},contained:{type:Boolean,required:!1,default:!0}},setup(){return{idSuffix:F()}},data(){return{form:null,loaded:!1,loadFailed:!1,formValues:{},consent:{required:!1,subscription:!1},fieldErrors:{},fieldValidity:{},showErrors:!1,hasErrors:!1,formError:"",isSubmitting:!1,submitted:!1,nickname:"",formStartedAt:0}},computed:{ref(){return this.block?.field_constructor_form||null},wrapperClass(){return this.ref?.form_class||""},formName(){return this.ref?.name||"constructor_form"},fields(){return Array.isArray(this.form?.fields)?this.form.fields:[]},submitLabel(){return this.form?.submit_label||"Submit"},messages(){return this.form?.messages||{}},consentTexts(){return this.form?.consent||{}},redirectUrl(){const e=String(this.form?.redirect_url||"").trim();return e.startsWith("/")||/^https?:\/\//i.test(e)?e:""},errorTexts(){const e=this.form?.messages?.errors||{};return{generic:e.generic||"Something went wrong. Please check the form and try again.",field_required:e.field_required||"This field is required.",field_invalid:e.field_invalid||"Please enter a valid value."}}},watch:{"ref.payload_url"(e){typeof window>"u"||(this.submitted=!1,this.form=null,this.loaded=!1,this.loadFailed=!1,e&&this.fetchPayload())}},mounted(){typeof window>"u"||(this.formStartedAt=Date.now(),this.fetchPayload())},methods:{async fetchPayload(){const e=this.ref?.payload_url;if(!e){this.loadFailed=!0;return}const r=3;for(let n=1;n<=r;n+=1)try{const l=await fetch(e,{method:"GET",headers:{Accept:"application/json"},credentials:"same-origin"});if(!l.ok)throw new Error("HTTP "+l.status);const t=(await l.json())?.form||null;if(!t)throw new Error("Empty form payload");this.form=t,this.initValues(),this.loaded=!0,this.loadFailed=!1;return}catch{if(n===r){this.loadFailed=!0;return}await new Promise(s=>{setTimeout(s,n*600)})}},initValues(){const e={};for(const r of this.fields)r?.name&&(e[r.name]=r.type==="checkboxes"?[]:"");this.formValues=e},usesBaseField(e){return H.includes(e?.type)},baseFieldData(e){const r={field_name:e.name,type:e.type,label:e.label,class:this.widthClass(e),options:e.options||[],validation:this.mapValidation(e.validation)};return e.type==="select"&&(r.options=[{key:"",label:e.label},...e.options||[]]),r},widthClass(e){const r=Number(e?.width)||100;return r<=33?"fw33":r<=50?"fw50":"fw100"},mapValidation(e){switch(e){case"chars":return 1;case"chars_digits":return 2;default:return 0}},cfFieldId(e){return"cf_"+this.idSuffix+"_"+(e?.name||"")},consentId(e){return"cf_consent_"+this.idSuffix+"_"+e},toggleConsent(e){this.consent={...this.consent,[e]:!this.consent[e]}},setValue(e,r){this.formValues={...this.formValues,[e]:r},this.fieldErrors[e]&&(this.fieldErrors={...this.fieldErrors,[e]:""})},setValidity(e){const r=e?.name;r&&(this.fieldValidity={...this.fieldValidity,[r]:!!e.isValid})},toggleCheckbox(e,r){const n=Array.isArray(this.formValues[e])?[...this.formValues[e]]:[],l=n.indexOf(r);l===-1?n.push(r):n.splice(l,1),this.setValue(e,n)},isEmpty(e){return Array.isArray(e)?e.length===0:e==null||String(e).trim()===""},validate(){let e=!0;const r={};for(const n of this.fields){if(!n?.name)continue;const l=this.formValues[n.name];if(n.required&&this.isEmpty(l)){e=!1,r[n.name]=this.errorTexts.field_required;continue}!this.isEmpty(l)&&this.fieldValidity[n.name]===!1&&(e=!1,r[n.name]=this.errorTexts.field_invalid)}return this.consentTexts.processing_text&&!this.consent.required&&(e=!1),this.fieldErrors=r,e},onFormStart(){try{g("FormStart",{form_id:this.form?.name||String(this.ref?.form_id||""),ctform_id:String(this.form?.ctform_id||"")})}catch{}}
2,async submitForm(){if(typeof window>"u"||this.isSubmitting||!this.form)return!1;if(!this.validate())return this.showErrors=!0,this.hasErrors=!0,!1;this.showErrors=!1,this.hasErrors=!1,this.formError="";const e=T(),r={values:{...this.formValues},consent:{required:!!this.consent.required,subscription:!!this.consent.subscription},nickname:this.nickname,token_ts:this.form.antispam?.ts||0,token_sig:this.form.antispam?.sig||"",page_url:typeof location<"u"?location.href:"",page_name:typeof document<"u"?document.title:"",langcode:this.ref?.langcode||"",event_id:e,ct_sid:C()||void 0,ct_vid:V()||void 0};this.isSubmitting=!0;try{const n=await fetch("/api/v2/form/"+this.ref.form_id+"/submit",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(r)});if(!n.ok){this.hasErrors=!0;try{y("SubmitError",{form_id:this.form?.name||String(this.ref?.form_id||""),ctform_id:String(this.form?.ctform_id||""),reason:"http_"+n.status})}catch{}return!1}const l=await n.json();if(l?.valid===!1){const s={};for(const[t,m]of Object.entries(l.errors||{}))s[t]=Array.isArray(m)?m.join(" "):String(m);return Object.keys(s).length===0&&(this.formError=l.message||""),this.fieldErrors={...this.fieldErrors,...s},this.hasErrors=!0,this.showErrors=!0,!1}this.submitted=!0;try{const s=String(this.form?.name||"").toLowerCase();["subscribe","newsletter"].some(t=>s.includes(t))||g("SubmitApplication",{form_id:this.form?.name||String(this.ref?.form_id||""),ctform_id:String(this.form?.ctform_id||"")},{eventId:e,skipCollector:!0})}catch{}this.redirectUrl&&window.location.assign(this.redirectUrl)}catch{this.hasErrors=!0;try{y("SubmitError",{form_id:this.form?.name||String(this.ref?.form_id||""),ctform_id:String(this.form?.ctform_id||""),reason:"network"})}catch{}}finally{this.isSubmitting=!1}return!1}}},I=["innerHTML"],N=["innerHTML"],P={key:0,class:"form-title t-h2"},j=["innerHTML"],D=["name"],O={class:"vbub-field-nickname","aria-hidden":"true"},U=["for"],G=["id"],J={class:"cf-field-label ui-label"},z={key:0,class:"required"},K={class:"cf-options"},R=["name","value","checked","onChange"],W=["value","checked","onChange"],Y={key:0,class:"error-text t-small-strong"},Q={key:0,class:"form-consent"},X=["id","checked"],Z=["for","innerHTML"],$=["id","checked"],ee=["for","innerHTML"],te=["innerHTML"],re={key:1,class:"error-text error-notice t-small-strong"},se={class:"vbub-actions"},ie=["value","disabled"];function ne(e,r,n,l,s,t){const m=A("BaseField");return o(),a("div",{class:f({container:n.contained})},[c("div",{class:f(["bub-form-wrapper",t.wrapperClass])},[s.submitted?(o(),a(h,{key:0},[t.messages.submit_title?(o(),a("h2",{key:0,class:"form-title t-h2",innerHTML:t.messages.submit_title},null,8,I)):d("",!0),t.messages.submit_text?(o(),a("div",{key:1,class:"form-description t-body",innerHTML:t.messages.submit_text},null,8,N)):d("",!0)],64)):s.loaded?(o(),a(h,{key:1},[s.form.title?(o(),a("h2",P,_(s.form.title),1)):d("",!0),s.form.intro?(o(),a("div",{key:1,class:"form-description t-body",innerHTML:s.form.intro},null,8,j)):d("",!0),c("form",{name:t.formName,class:f(["vbub-form",{"show-errors":s.showErrors}]),onSubmit:r[5]||(r[5]=v((...i)=>t.submitForm&&t.submitForm(...i),["prevent"])),onFocusinOnce:r[6]||(r[6]=(...i)=>t.onFormStart&&t.onFormStart(...i))},[c("div",O,[c("label",{for:t.formName+"_nickname"},"Nickname",8,U),x(c("input",{id:t.formName+"_nickname","onUpdate:modelValue":r[0]||(r[0]=i=>s.nickname=i),type:"text",name:"nickname",tabindex:"-1",autocomplete:"off"},null,8,G),[[E,s.nickname]])]),(o(!0),a(h,null,b(t.fields,i=>(o(),a(h,{key:i.name},[t.usesBaseField(i)?(o(),w(m,{key:0,field:t.baseFieldData(i),error:"","validation-error":s.fieldErrors[i.name],"form-suffix":l.idSuffix,"model-value":s.formValues[i.name],"onUpdate:modelValue":u=>t.setValue(i.name,u),onValidity:t.setValidity},null,8,["field","validation-error","form-suffix","model-value","onUpdate:modelValue","onValidity"])):(o(),a("div",{key:1,class:f(["cf-field",{"has-error":!!s.fieldErrors[i.name]}])},[c("span",J,[S(_(i.label),1),i.required?(o(),a("span",z,"*")):d("",!0)]),c("div",K,[(o(!0),a(h,null,b(i.options||[],u=>(o(),a("label",{key:u.key,class:"cf-option t-body-compact"}
2,[i.type==="radio"?(o(),a("input",{key:0,type:"radio",name:t.cfFieldId(i),value:u.key,checked:s.formValues[i.name]===u.key,onChange:k=>t.setValue(i.name,u.key)},null,40,R)):(o(),a("input",{key:1,type:"checkbox",value:u.key,checked:(s.formValues[i.name]||[]).includes(u.key),onChange:k=>t.toggleCheckbox(i.name,u.key)},null,40,W)),c("span",null,_(u.label),1)]))),128))]),s.fieldErrors[i.name]?(o(),a("div",Y,_(s.fieldErrors[i.name]),1)):d("",!0)],2))],64))),128)),t.consentTexts.processing_text||t.consentTexts.subscription_text?(o(),a("div",Q,[t.consentTexts.processing_text?(o(),a("div",{key:0,class:f(["form-consent-item",{checked:s.consent.required,"has-error":s.showErrors&&!s.consent.required}])},[c("span",{class:"fake-checkbox",onClick:r[1]||(r[1]=i=>t.toggleConsent("required"))}),c("input",{type:"checkbox",class:"form-consent-item-checkbox",id:t.consentId("required"),checked:s.consent.required,onChange:r[2]||(r[2]=i=>t.toggleConsent("required"))},null,40,X),c("label",{for:t.consentId("required"),class:"ui-label",innerHTML:t.consentTexts.processing_text},null,8,Z)],2)):d("",!0),t.consentTexts.subscription_text?(o(),a("div",{key:1,class:f(["form-consent-item",{checked:s.consent.subscription}])},[c("span",{class:"fake-checkbox",onClick:r[3]||(r[3]=i=>t.toggleConsent("subscription"))}),c("input",{type:"checkbox",class:"form-consent-item-checkbox",id:t.consentId("subscription"),checked:s.consent.subscription,onChange:r[4]||(r[4]=i=>t.toggleConsent("subscription"))},null,40,$),c("label",{for:t.consentId("subscription"),class:"ui-label",innerHTML:t.consentTexts.subscription_text},null,8,ee)],2)):d("",!0),t.consentTexts.description?(o(),a("div",{key:2,class:"form-consent-description t-caption",innerHTML:t.consentTexts.description},null,8,te)):d("",!0)])):d("",!0),s.hasErrors?(o(),a("div",re,_(s.formError||t.errorTexts.generic),1)):d("",!0),c("div",se,[c("input",{type:"submit",class:"bub-link btn-yellow ui-button",value:t.submitLabel,disabled:s.isSubmitting},null,8,ie)])],42,D)],64)):d("",!0)],2)],2)}const ae=p(B,[["render",ne]]);export{ae as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.