1(self.webpackChunkmarmalade=self.webpackChunkmarmalade||[]).push([[386,2610,4520,4746,5451],{4746:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s});class s extends Classy{constructor(){super(),this.checkURL="/api/crm_check?query=",this.xhr=new XMLHttpRequest,this["check:success"]=1,this["check:error"]=1}post(e,t,a){e+=t;this.xhr.abort(),this.xhr=new XMLHttpRequest,this.xhr.open("POST",e,!0),this.xhr.onload=()=>{200<=this.xhr.status&&this.xhr.status<300?this.success(this.xhr.responseText,a):this.error(this.xhr.responseText,a)},this.xhr.onerror=()=>{this.error(this.xhr.responseText,a)},this.xhr.send(),this.callback("post")}check(e){this.post(this.checkURL,e,"check"),this.callback("check")}success(e,t){this.callback(t+":success",e)}error(e,t){this.callback(t+":error",e)}reset(){this.events={}}}},2610:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s});class s extends Classy{constructor(){super(),this.searchURL="/api/nzbn_search?query=",this.checkURL="/api/nzbn_check?query=",this.xhr=new XMLHttpRequest,this["search:success"]=1,this["search:error"]=1,this["check:success"]=1,this["check:error"]=1}post(e,t,a){e+=t;this.xhr.abort(),this.xhr=new XMLHttpRequest,this.xhr.open("POST",e,!0),this.xhr.onload=()=>{200<=this.xhr.status&&this.xhr.status<300?this.success(this.xhr.responseText,a):this.error(this.xhr.responseText,a)},this.xhr.onerror=()=>{this.error(this.xhr.responseText,a)},this.xhr.send(),this.callback("post")}search(e){this.post(this.searchURL,e,"search"),this.callback("search")}check(e){this.post(this.checkURL,e,"check"),this.callback("check")}success(e,t){this.callback(t+":success",e)}error(e,t){this.callback(t+":error",e)}reset(){this.events={}}}},4520:(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});let s=["id","legend","pathway","pathways","progress","recipients","email_subject","email_template","email_content","api_response","pathway_name","pathway_type","pathway_forks","pathway_title","pathway_content","pathway_nzbn_name","pathway_fieldsets","pathway_information","pathway_summary_fields","submission_heading"],r={CLIENT_ID:"client_id",ID:"id",BLOCK_ID:"block_id",PATH:"path",EVENT:"event",TITLE:"title",CHOICE:"choice"},i="triage_form",n={start:"start",back:"back",choice:"choice",submit:"submit"};class o extends Classy{constructor(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};let a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(super(),"object"!=typeof e)throw new Error("Data must be an object");if("object"!=typeof a)throw new Error("Structure must be an object");this.data=e,this.progress=[this.data],this.clientID=this.getClientID(),this.id=1,this.started=!1,this.trackingObject=this.getExampleTrackingData(),this.structure=s.reduce((e,t)=>(e[t]=a[t]||t,e),{})}getClientID(){var t=(Math.floor(Date.now()+Math.random()*Date.now())+Math.random().toString(36).substr(2,9)).split("");for(let e=t.length-1;0<e;e--){var a=Math.floor(Math.random()*(e+1));[t[e],t[a]]=[t[a],t[e]]}return t.join("")}getEventTypes(){return Object.keys(n).map(e=>i+"_"+n[e])}getExampleTrackingData(){return this.generateTrackingData({title:"Example Title",choice:"Example Choice",path:"/example/path"})}getCurrentProgress(){return{step:this.progress.length,data:this.progress[this.progress.length-1]}}generateTrackingData(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return{[r.CLIENT_ID]:this.clientID,[r.ID]:""+this.id||"1",[r.BLOCK_ID]:this.data.blockID||"TriageFormBlockID",[r.PATH]:e.path||window.location.pathname,[r.EVENT]:i+"_"+(e.event||n.start),[r.TITLE]:e.title||null,[r.CHOICE]:e.choice||null,...e}}render(){let a=this.structure,s=this.progress[this.progress.length-1];var e=s[a.pathway_forks]||[];let i=s[a.api_response]||{};
1Object.keys(i).forEach(e=>{let t=i[e];t.callback=()=>{this.id=t[a.id],-1===this.progress.indexOf(t)&&this.progress.push(t),this.render()}}),1===this.progress.length&&!1===this.started&&this.track(n.start),this.started=!0,this.callback("render",{step:this.progress.length,id:s[a.id],pathway_type:s[a.pathway_type],pathway_title:s[a.pathway_title],pathway_content:s[a.pathway_content],pathway_name:s[a.pathway_name],pathway_nzbn_name:s[a.pathway_nzbn_name],pathway_fieldsets:s[a.pathway_fieldsets],legend:s[a.legend],pathways:s[a.pathways],progress:s[a.progress],recipients:s[a.recipients],email_subject:s[a.email_subject],email_template:s[a.email_template],email_content:s[a.email_content],pathway_information:s[a.pathway_information],pathway_summary_fields:s[a.pathway_summary_fields]||[],api_response:i,submission_heading:s[a.submission_heading],pathway_forks:e.map(t=>({...t,callback:()=>{var e=t[a.pathway];if(!e)throw new Error(`Branch key "${e}" does not exist.`);this.id=e[a.id],this.track(n.choice,{[r.TITLE]:s[a.pathway_title],[r.CHOICE]:t.pathway.title}),-1===this.progress.indexOf(e)&&this.progress.push(e),this.render()}}))})}track(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};window.dataLayer&&(e=this.generateTrackingData({event:i+"_"+e,...t}),window.dataLayer.push(e))}get(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return t[e]||t[this.structure[e]]||null}back(){if(this.progress.length<=1)return this.restart();this.track(n.back),this.progress.pop(),this.render(),this.callback("back")}submit(){this.track(n.submit,{[r.TITLE]:this.progress[this.progress.length-1][this.structure.questionTitle]}),this.callback("submit")}}},5451:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s});class s extends Classy{constructor(){super(),this.index=0,this.progress=[],this.fieldsets={},this.elements=[]}goto(a){return new Promise((e,t)=>{this.fieldsets[a]||"number"==typeof a&&this.progress[a]&&(a=this.progress[a]),this.fieldsets[a]?(this.callback("goto",this.fieldsets[a]),this.index=this.progress.indexOf(a),e(this.fieldsets[a])):t()})}trim(){var e=this.progress.slice(this.index+1);e.forEach(e=>{this.progress.pop(),this.remove(e)}),this.update(),this.callback("trim",{removed:e,progress:this.progress})}update(){return this.elements=[],Object.keys(this.fieldsets).forEach(e=>{this.elements.push(this.fieldsets[e].element)}),this.callback("update",this.elements),this.elements}add(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return t.id?t.element?(this.progress.push(e=t.id),this.fieldsets[e]=t,this.update(),this.callback("add",t),t):console.error("You must provide an element for the fieldset."):console.error("You must provide an ID for the fieldset.")}remove(e){var t=this.fieldsets[e];return delete this.fieldsets[e],this.callback("remove",t),t}back(){0<this.index&&(this.index--,this.goto(this.progress[this.index]),this.callback("back",this.progress[this.index]))}next(){this.index<this.progress.length-1&&(this.index++,this.goto(this.progress[this.index]),this.callback("next",this.progress[this.index]))}}},386:(e,t,a)=>{a.r(t);var t=a(4746),s=a(2610),i=a(4652),M=a(5451),r=a(4520);let S="triage_customer_type",n="Timestamp",o="custom_triage_field_recipients",l="custom_triage_field_email_subject",d="custom_triage_field_email_template",c="custom_triage_field_email_content",N="custom_triage_field_nzbn_lookup",I="custom_triage_field_nzbn_result";let D="custom_triage_field_acceptance",O="custom_triage_field_rating",j="custom_triage_field_comments";window.TriageForms;let h="/api/triage_submit",p=new XMLHttpRequest;function u(e,t){e=0<arguments.length&&void 0!==e?e:{},t=1<arguments.length?t:void 0;e.button.disabled=!e.success,e.success&&t.destroy(),t.message=t.addHTML('<p class="message"></p>'),t.message.className="message",t.message.innerHTML=e.message,t.message.classList.add(e.success?"success":"error"),window.pagesense=window.pagesense||[],window.pagesense.push(["trackEvent","TriageSubmit"])}function m(e,t){let{TriageForm:a,TriageNavigator:s}=t;e.button.disabled=!0,a.addHiddenInput({id:n,name:n,value:""+(t=new Date).getFullYear()+String(t.getMonth()+1).padStart(2,"0")+String(t.getDate()).padStart(2,"0")+String(t.getHours()).padStart(2,"0")+String(t.getMinutes()).padStart(2,"0")+String(t.getSeconds()).padStart(2,"0")+String(t.getMilliseconds()).padStart(3,"0")}),p.abort(),p.open("POST",h,!0),p.setRequestHeader("Content-Type","application/json"),p.onload=()=>
1{if(200<=p.status&&p.status<300){let t="";try{t=JSON.parse(p.responseText).data.message}catch(e){t="Thank you for your submission.",console.error("Error parsing response",e)}s.submit(),u({button:e.button,success:!0,message:t},a)}else console.error("Error",p.responseText),u({button:e.button,success:!1,message:"There was an error submitting the form. Please try again."},a)},p.onerror=()=>{console.error("Error",p.responseText),u({button:e.button,success:!1,message:"There was an error submitting the form. Please try again."},a)},p.send(a.getJSONString())}window.CRMLookup=new t.default,window.NZBNLookup=new s.default,[...document.querySelectorAll(".js-default-triage")].forEach(s=>{var e=s.id.split("_").pop();fetch("/api/get_triage_data?id="+e).then(e=>e.json()).then(e=>{{var a=s;e=JSON.parse(e.data);let w={form:a.querySelector(".js-default-triage__form"),content:a.querySelector(".js-default-triage__content"),summary:a.querySelector(".js-default-triage__summary"),decisions:a.querySelector(".js-default-triage__decisions"),first_step:a.querySelector(".js-default-triage__first-step")},y=a.querySelector(".js-default-triage__progress"),k=new i.default({id:a.id+"_Form",novalidate:!0}),v=new M.default,L=new r.default({blockID:a.id,...e},{id:"id",legend:"legend",pathway:"pathway",pathways:"pathways",progress:"progress",recipients:"recipients",email_subject:"email_subject",email_template:"email_template",email_content:"email_content",api_response:"api_response",pathway_name:"name",pathway_type:"type",pathway_forks:"forks",pathway_title:"title",pathway_content:"content",pathway_nzbn_name:"nzbn_name",pathway_fieldsets:"fieldsets",pathway_information:"information",pathway_summary_fields:"summary_fields",submission_heading:"submission_heading"}),T=k.addHiddenInput({id:o,name:o}),x=k.addHiddenInput({id:l,name:l}),C=k.addHiddenInput({id:d,name:d}),E=k.addHiddenInput({id:c,name:c}),H={},t=()=>{w.decisions.innerHTML="",Object.keys(H).forEach((e,t)=>{e=H[e];0===t?(w.first_step.innerHTML="",e&&(w.first_step.innerHTML=`<span class="triage-form__decision">${e}</span>`)):e&&(w.decisions.innerHTML+=`<span class="triage-form__decision">${e}</span>`)})};k.on("validate",e=>{e.valid||(e=document.querySelector(`[name="${e.invalidated[0]}"]`).parentNode,window.ScrollController.scrollTo(Meteora.offset(e).y-200))}),k.on("submit",e=>m(e,{TriageForm:k,TriageSteps:v,TriageNavigator:L})),v.on("goto",e=>{let t=e.element;e=e.FieldsetSteps;e&&e.goto(e.index),v.elements.forEach(e=>{e.classList.toggle("current-step",e===t)})}),v.on("back",()=>L.back()),v.on("trim",e=>{e.removed.forEach(e=>{H[e]&&delete H[e]}),t()}),v.on("remove",e=>e.element.remove()),L.on("render",f=>{let b="PathID_"+f.id;a.setAttribute("data-step",f.step),t(),v.goto(b).catch(()=>{v.trim();let d=f.pathway_forks,c=f.pathway_fieldsets.sort((e,t)=>e.sort-t.sort),h=k.addGroup(b),p=new M.default;var e=0<c.length;let u=0<v.progress.length;var a="crm"===f.pathway_type,s="nzbn"===f.pathway_type,l="choice"===f.pathway_type;let i="content"===f.pathway_type,m="submission"===f.pathway_type,g=(p.on("goto",e=>{let t=e.element;var a=L.get("pathway_content",e.data);let s=Math.max(Meteora.offset(t).y-100,0);y&&(y.style.width=e.data.progress+"%"),a?i?k.addHTML(a,b):w.content.innerHTML=a:w.content.innerHTML="",w.summary.classList.toggle("hidden",!m),p.elements.forEach(e=>{e.classList.toggle("current-step",e===t)}),setTimeout(()=>{window.scrollY>s&&window.ScrollController.scrollTo(s)},100)}),c.forEach((e,t)=>{var a=e.fields;let i=document.createElement("fieldset");var s=document.createElement("button"),r=document.createElement("button"),n=0===t,o=t===c.length-1,l=0<d.length;i.id="Fieldset_"+e.id,s.innerHTML="Next",r.innerHTML="Back",s.classList.add("button","b-secondary","triage-form__next"),r.classList.add("button","triage-form__back"),p.add({id:i.id,element:i,data:e}),0===t&&p.goto(i.id),h.appendChild(i),a.sort((e,t)=>e.sort-t.sort),a.forEach(e=>{var t;if("information"===e.type)t=k.addHTML('<div class="triage-form__information">'+e.information+"</div>",b),i.appendChild(t);else if("heading"===e.type)t=k.addHTML('<span class="triage-form__heading">'+e.heading+"</span>",b),i.appendChild(t);else{e.find_value&&(t=k.getFieldByName(e.find_value))&&(e.value=t.getValue());let s=k.parse(e,b);if("checkbox"===e.type||"radio"===e.type){let a=!1;e.options.forEach((e,t)=>{t=s.options[t];(e.description||e.notes)&&(a=!0),t.setLabel(`
2 <span class="label">${e.label||""}</span> 3 <span class="description">${e.description||""}</span> 4 <span class="notes">${e.notes||""}</span> 5 `)}),a&&s.field.classList.add("emphasis")}""!=e.tooltip&&(console.log("field",s),t=k.addTooltip(e.tooltip),s.field.insertBefore(t.container,s.label.nextElementSibling)),i.appendChild(s.field)}}),n&&!u||(i.appendChild(r),r.addEventListener("click",e=>e.preventDefault()),n?r.addEventListener("click",()=>v.back()):r.addEventListener("click",()=>p.back())),o&&!l&&!m||(i.appendChild(s),s.addEventListener("click",e=>{e.preventDefault(),k.validate(i)&&p.next()}))}),document.createElement("fieldset")),_=(g.id=`Fieldset_ID_${f.id}_Forks`,h.appendChild(g),document.createElement("button"));var t=document.createElement("button");let r=document.createElement("button");if(_.innerHTML="Next",t.innerHTML="Back",r.innerHTML="Submit",_.classList.add("triage-form__next","button","b-secondary"),t.classList.add("triage-form__back","button"),r.classList.add("triage-form__submit","button","action"),l){if(d.length){let s=k.addOptionset(f,b);g.appendChild(s.field),f.pathway_information&&(l=k.addHTML('<div class="triage-form__information">'+f.pathway_information+"</div>",b),g.appendChild(l,b)),g.appendChild(_),d.sort((e,t)=>e.sort-t.sort),d.forEach(a=>{a.options.sort((e,t)=>e.sort-t.sort),a.options.forEach(e=>{var t=s.addOption({...e,attributes:{required:!0}});t.setLabel(` 6 <span class="label">${e.label||""}</span> 7 <span class="description">${e.description||""}</span> 8 <span class="notes">${e.notes||""}</span> 9 `),t.on("change",()=>{H[b]=e.summary_text,_.setAttribute("data-pathway",a.value),_.callback=a.callback})}),s.field.classList.add("emphasis")})}_.addEventListener("click",e=>{e.preventDefault(),k.validate(g)&&_.callback&&"function"==typeof _.callback&&_.callback()})}if(s){let t=null,a="",s=k.addTextInput({id:N,type:"text",label:f.legend,name:N,attributes:{required:!0,placeholder:"Search for your business",title:"Search for your business"}},b),i=k.addOptionset({id:"custom_triage_field_nzbn_result",legend:"Select your business from the list below",type:"radio",attributes:{required:!0}},b),r=k.addHiddenInput({id:S,name:S},b),n=k.addHiddenInput({id:f.pathway_name,name:f.pathway_name},b),o=k.addHiddenInput({id:f.pathway_nzbn_name,name:f.pathway_nzbn_name},b);_.disabled=!0,g.appendChild(r.field),i.on("change",e=>{var[e,t]=e.split(": ");n.setValue(t),o.setValue(e)}),window.NZBNLookup.reset(),window.NZBNLookup.on("search",()=>{s.field.classList.add("loading")}),window.NZBNLookup.on("check",()=>{w.form.classList.add("loading")}),window.NZBNLookup.on("search:success",e=>{e=JSON.parse(e).data,s.field.classList.remove("loading"),i.empty(),e.items.forEach((e,t)=>{5<=t||((t=i.addOption({id:I+"__"+t,name:I,value:e.entityName+": "+e.nzbn})).setLabel(` 10 <span class="label">${e.entityName}</span> 11 <span class="description">NZBN: ${e.nzbn}</span> 12 `),t.field.classList.add("nzbn"))}),i.field.classList.add("emphasis"),i.on("change",()=>{_.disabled=!i.getValue()})}),window.NZBNLookup.on("check:success",e=>{var e=JSON.parse(e).data,t=e.result||"false";w.form.classList.remove("loading"),r.setValue(e[S]||"New Customer"),f.api_response[t].callback()}),window.NZBNLookup.on("check:error",()=>{f.nzbn.false.callback()}),s.on("change",e=>{if(clearTimeout(t),_.disabled=!0,""===e)return i.empty();t=setTimeout(()=>{a!==e&&(a=e,window.NZBNLookup.search(e))},500)}),g.appendChild(s.field),g.appendChild(i.field),f.pathway_information&&(l=k.addHTML('<div class="triage-form__information">'+f.pathway_information+"</div>",b),g.appendChild(l,b)),g.appendChild(_),_.addEventListener("click",e=>{e.preventDefault(),window.NZBNLookup.check(encodeURIComponent(i.getValue()))})}if(a){let t=k.addTextInput({id:f.pathway_name,type:"text",label:f.legend,name:f.pathway_name,attributes:{required:!0,placeholder:"Your business name",title:"Enter your business name"}},b),a=k.addHiddenInput({id:S,name:S},b);_.disabled=!0,g.appendChild(a.field),g.appendChild(t.field),window.CRMLookup.reset(),window.CRMLookup.on("check",()=>{w.form.classList.add("loading")}),window.CRMLookup.on("check:success",e=>{var e=JSON.parse(e).data,t=e.result||"false";w.form.classList.remove("loading"),a.setValue(e[S]||"New Customer"),f.api_response[t].callback()}),window.CRMLookup.on("check:error",()=>{f.nzbn.false.callback()}),t.on("change",e=>{_.disabled=""===e}),f.pathway_information&&(s=k.addHTML('<div class="triage-form__information">'+f.pathway_information+"</div>",b),g.appendChild(s,b)),g.appendChild(_),_.addEventListener("click",e=>{e.preventDefault(),window.CRMLookup.check(t.getValue())})}if(m){var{terms_label:l,terms_content:a,reviews_label:s,comments_label:n}=window.submissions_fields,o=f.pathway_summary_fields;let e=null;let t=null;f.submission_heading&&(e=k.addHTML('<span class="triage-form__heading">'+f.submission_heading+"</span>",b)),l=k.addOptionset({id:D,name:D,type:"checkbox",attributes:{required:!0},options:[{value:"true",label:l||"I accept the terms and conditions"}]},b),a&&(t=k.addHTML('<div class="triage-form__help">'+a+"</div>"));a=k.addStarRating({id:O,name:O,legend:s||"How would you rate this form?",attributes:{required:!0}},b),s=k.addTextareaInput({id:j,name:j,label:n||"Comments"},b);e&&g.appendChild(e),g.appendChild(l.field),t&&g.appendChild(t),g.appendChild(a.field),g.appendChild(s.field),f.pathway_information&&(n=k.addHTML('<div class="triage-form__information">'+f.pathway_information+"</div>",b),g.appendChild(n,b)),g.appendChild(r),T.setValue(f.recipients??""),x.setValue(f.email_subject??""),C.setValue(f.email_template??""),E.setValue(f.email_content??""),w.summary.innerHTML="",o.forEach(e
12=>{let t=k.getFieldByName(e.name),a=document.createElement("span");if(t){a.classList.add("triage-form__summary");let e=()=>{a.innerHTML=t.getValue(),a.style.display=""===t.getValue()?"none":""};t.on("change",()=>e()),e(),w.summary.appendChild(a)}}),r.addEventListener("click",e=>{e.preventDefault(),k.validate(g)&&k.submit({button:r})})}(e||u)&&(g.appendChild(t),t.addEventListener("click",e=>e.preventDefault()),c.length?t.addEventListener("click",()=>p.back()):t.addEventListener("click",()=>v.back())),p.add({id:g.id,element:g,data:f}),c.length||p.goto(g.id),v.add({id:b,element:h,data:f,FieldsetSteps:p}),v.goto(b).catch(e=>console.error(e))})}),w.form.appendChild(k.element),w.form.classList.remove("loading"),L.render()}})})}}]); 13//# sourceMappingURL=46813c37662e817ee213.js.map
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.