1import{a as z,c2 as W,C as l,y as K,j as i,G as R,H as E,m as r,F as p,A as I,ai as X,v as j,bI as Z,V as M,f as $,aC as ee,I as x,q as se,aR as oe,n as ae,c as te,o as ne,a4 as re,P as le,x as q,R as ce,r as ie,t as c,k as V,l as L,W as de,$ as me}from"./DCZpLbfX.js";import{_ as ue}from"./CDDwdNXp.js";import{C as B}from"./Dmg1BHEm.js";import{C as U}from"./CFnCeirA.js";import{u as pe}from"./DKKt7D0f.js";import"./DDCG22E6.js";import"./CsW4ISlC.js";import"./C_uLhifZ.js";import"./Cjt7tYGB.js";import"./BRGiC7k9.js";import"./Dwld-FvF.js";import"./BWeUtDzT.js";import"./CXR9HQeG.js";import"./BWNk5nxS.js";import"./qXnCCcVa.js";import"./CVugGi9Y.js";import"./CWbbbNyH.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"f89d455ce9c6e94060068617214014e5c7f6696c"};var d=new s.Error().stack;d&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[d]="1eaf8cc7-19cf-4e34-86d6-60584e0f4446",s._sentryDebugIdIdentifier="sentry-dbid-1eaf8cc7-19cf-4e34-86d6-60584e0f4446")}catch{}})();const fe=["for","onMouseover"],D=z({__name:"CdlRatingInput",props:{name:{type:String,required:!0},value:{type:Number,default:0},id:{type:String,required:!0}},emits:["update:modelValue"],setup(s,{emit:d}){const f=d,e=W(),u=l(e.modelValue);K(()=>e.modelValue,()=>{u.value=e.modelValue});const w=m=>{e.modelValue||(u.value=m)},v=()=>{e.modelValue||(u.value=null)},g=(m,b)=>{m.target.checked&&f("update:modelValue",b)};return(m,b)=>(r(),i("div",{class:"inline-flex items-center text-2xl text-th-primary-var",onMouseleave:v},[(r(),i(R,null,E(5,o=>p("label",{key:o,class:"px-2 cursor-pointer",for:`rating-input-${s.id}-${o}`,onMouseover:y=>w(o)},[I(j(Z),X({id:`rating-input-${s.id}-${o}`,name:s.name,class:"absolute w-0 h-0 overflow-hidden opacity-0",type:"radio",value:o,checked:o===s.value,onChange:y=>g(y,o)},{ref_for:!0},m.$attrs),null,16,["id","name","value","checked","onChange"]),I(ue,{name:"star",class:M({"text-th-primary":o<=j(u)})},null,8,["class"])],40,fe)),64))],32))}}),F=l(null),ve=()=>{const s="/api/nps/getSurvey",d="/api/nps/saveSurvey",f="/api/nps/saveAnswers",e=l(null),u=l(!1),w=l(!1),v=l(""),g=async t=>{u.value=!0;try{const a=new URLSearchParams;a.append("f",t.f),a.append("c",t.c),a.append("m",t.m);const S={method:"GET"},h=await(await fetch(s+"?"+a.toString(),S)).json();h.data?.success?(w.value=o(h),e.value=h.data?.results?.Questions,v.value=h.data?.results?.Header.FirstQuestion,F.value=""):F.value="common.error.generic"}catch(a){throw F.value="common.error.generic",a}finally{u.value=!1}},m=async t=>{try{const a=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return F.value="",a}catch(a){F.value="common.error.generic",console.error("saveGlobalScore",a)}},b=async t=>{try{const a=await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return F.value="",a}catch(a){F.value="common.error.generic",console.error("saveAnswers",a)}},o=t=>!1;return{validNpsParams:t=>!!(typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"m")&&Object.prototype.hasOwnProperty.call(t,"f")&&Object.prototype.hasOwnProperty.call(t,"c")),alreadyAnswered:o,fetchSurvey:g,saveGlobalScore:m,saveAnswers:b,questions:e,questionsLoading:u,hasAlreadyAnswered:w,firstQuestionForm:v}},ye={name:"NpsPage",components:{CdlButton:B,CdlRatingInput:D,VeeForm:ee,CdlLoader:U},setup(){const s=se(),{send:d}=oe(),{t:f}=ae(),{defineHeadTags:e}=pe(),{validNpsParams:u,fetchSurvey:w,saveAnswers:v,saveGlobalScore:g,questions:m,questionsLoading:b,hasAlreadyAnswered:o,firstQuestionForm:y}=ve(),t=l(null),a=l(!1),S=l({global_score:0}),k=l({}),h=l(!0),_=l(""),A=l(!1),P=l(""),C=q(()=>S.value.global_score?S.value.global_score:parseInt(s.query.n)),H=q(()=>{let n="";if(C.value)switch(C.value){case 1:n="nps.form.commentary-note.very-unsatisfied";break;case 2:n="nps.form.commentary-note.unsatisfied";break;case 4:n="nps.form.commentary-note.satisfied";break;case 5:n="nps.form.commentary-note.very-satisfied";break;default:n="nps.form.commentary-note.moderately-satisfied"}return n}),Q=()=>{d({message:f("nps.errors.missing-answers"),type:"danger"})},G=async()=>{try{a.value=!0;const n={id:P.value,score:S.value.global_score};(await g(n)).status!==201?_.value="common.error.generic":(_.value="",A.value=!0),setTimeout(()=>{const{top:T}=t.value.$el.getBoundingClientRect();window.scrollTo({top:window.scrollY+T-40,behavior:"smooth"})},0)}catch{_.value="common.error.generic"}finally{a.value=!1}},J=async()=>{try{a.value=!0;const n={id:P.value,score:C.value,responses:k.value},N=await v(n);if(N.status!==201){const{errors:T}=await N.json();_.value=T||"common.error.generic"}else _.value="",re({name:le.Home}),setTimeout(()=>{d({id:Symbol("nps_form_success"),message:f("nps.form.success-message"),type:"success",icon:"check",persist:!0})},1e3)}catch{_.value="common.error.generic"}finally{a.value=!1}},Y=ce();e(()=>({metaTags:{title:f("nps.banner.first-line")}})),te(()=>{Y?.trackView("nps",window.location.pathname,{env:{template:"nps"}})});const O=l(!1);return ne(async()=>{try{a.value=!0,h.value=u(s.query),h.value&&(P.value=s.query.f,S.value.global_score=s.query.n?parseInt(s.query.n,10):null,await w(s.query))}catch{_.value="common.error.generic"}finally{a.value=!1,O.value=!0}}),{firstForm:S,secondFormElement:t,secondFormResponses:k,errorMessage:_,loading:a,isMounted:O,questions:m,validParams:h,questionsLoading:b,hasAlreadyAnswered:o,commentaryNote:H,firstQuestionForm:y,note:C,firstFormSucceed:A,handleSecondNpsSubmit:J,handleFirstNpsSubmit:G,onInputChange:(n,N)=>{k.value={...k.value,[n]:N}},onInvalidSubmit:Q}}},ge={class:"w-full px-4 pb-4 text-center md:pb-8"},be={class:"px-8 py-8 bg-center bg-cover viewport-width lg:py-16",style:{"background-image":"url(/nps/Slider-NPS-desktop.jpg)"}},he={class:"mx-auto px-4 py-8 bg-white border border-black max-w-[450px]",style:{"box-shadow":"0 0 0 10px #fff"}},_e={key:0,class:"mt-8 font-bold text-th-danger"},we={key:1,class:"mt-8"},Se={key:2,class:"mt-8"},Fe={class:"py-8 text-xl"},Ie={key:0,class:"mt-2"},ke={class:"mb-10"},Ne={key:1,class:"mb-4 font-bold text-th-danger"},Ve={class:"grid gap-4 mb-10 md:grid-cols-2"},Ce={class:"pt-8 pb-2 text-lg"},Pe=["onUpdate:modelValue","name"],Te={key:0,class:"mb-4 font-bold text-th-danger"};function xe(s,d,f,e,u,w){const v=D,g=B,m=ie("VeeForm"),b=U;return r(),i("div",ge,[I(b,{id:"nps-page",loading:e.questionsLoading,"loader-class":"mx-auto mt-10"},{default:x(()=>[e.isMounted?(r(),i(R,{key:0},[p("div",be,[p("h1",he,c(s.$t("nps.banner.first-line"))+" "+c(s.$t("nps.banner.second-line")),1)]),e.validParams?e.hasAlreadyAnswered?(r(),i("p",we,c(s.$t("nps.form.success-message")),1)):(r(),i("div",Se,[I(m,{id:"firstNpsForm",class:M({"opacity-30":e.firstFormSucceed}),onSubmit:e.handleFirstNpsSubmit,onInvalidSubmit:e.onInvalidSubmit},{default:x(()=>[p("p",Fe,c(e.firstQuestionForm),1),I(v,{id:"global",modelValue:e.firstForm.global_score,"onUpdate:modelValue":d[
10]||(d[0]=o=>e.firstForm.global_score=o),name:"global-score",rules:"required|nps-note"},null,8,["modelValue"]),e.note?(r(),i("p",Ie,c(e.note)+"/5",1)):V("",!0),p("p",ke,c(s.$t(e.commentaryNote)),1),e.errorMessage&&!e.firstFormSucceed?(r(),i("p",Ne,c(s.$t(e.errorMessage)),1)):V("",!0),I(g,{type:"submit",label:s.$t("nps.form.confirm"),disabled:e.firstFormSucceed,loading:!e.firstFormSucceed&&e.loading},null,8,["label","disabled","loading"])]),_:1},8,["class","onSubmit","onInvalidSubmit"]),e.firstFormSucceed?(r(),L(m,{key:0,id:"secondNpsForm",ref:"secondFormElement",class:"pt-8",onSubmit:e.handleSecondNpsSubmit,onInvalidSubmit:e.onInvalidSubmit},{default:x(()=>[p("p",null,c(s.$t("nps.form.first-form-taken-message")),1),p("p",null,c(s.$t("nps.form.second-form.tell-more-question")),1),p("div",Ve,[(r(!0),i(R,null,E(e.questions,o=>(r(),i("div",{key:o.Id,class:M({"md:col-span-2":o.Type!==0})},[p("p",Ce,c(o.Label),1),o.Type===0?(r(),L(v,{key:0,id:o.Id,modelValue:e.secondFormResponses[o.Id],"onUpdate:modelValue":y=>e.secondFormResponses[o.Id]=y,name:`question-${o.Id}`,rules:"required|nps-note"},null,8,["id","modelValue","onUpdate:modelValue","name"])):de((r(),i("textarea",{key:1,"onUpdate:modelValue":y=>e.secondFormResponses[o.Id]=y,class:"w-full p-2 border",name:`question-${o.Id}`,rows:"3"},null,8,Pe)),[[me,e.secondFormResponses[o.Id]]])],2))),128))]),e.errorMessage&&e.firstFormSucceed?(r(),i("p",Te,c(s.$t(e.errorMessage)),1)):V("",!0),I(g,{type:"submit",label:s.$t("nps.form.finished"),loading:e.firstFormSucceed&&e.loading},null,8,["label","loading"])]),_:1},8,["onSubmit","onInvalidSubmit"])):V("",!0)])):(r(),i("div",_e,[p("p",null,c(s.$t("nps.error.first-line")),1),p("p",null,c(s.$t("nps.error.second-line")),1)]))],64)):V("",!0)]),_:1},8,["loading"])])}const Ke=$(ye,[["render",xe]]);export{Ke 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.