var Y=Object.defineProperty;var Z=(t,l,o)=>l in t?Y(t,l,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[l]=o;var S=(t,l,o)=>(Z(t,typeof l!="symbol"?l+"":l,o),o);import{S as ee,d as te}from"./Speechbubble-5374d34d.js";import{d as q,o as s,n as v,w as d,c as _,b as I,t as $,j as T,m as le,A,_ as z,k as M,r as g,u as G,G as E,Y as U,a as h,V as L,F,l as O,B as N,M as j,I as R,f as P,a1 as ae,X,a3 as se,Q as ne,e as W,aH as oe}from"./index-207e8178.js";import{c as ue,j as K}from"./checkTypingFunction-087f80ba.js";import{S as re}from"./Searchbar-7510e744.js";import{g as ie}from"./string-79822fd4.js";import{V as ce,a as de,l as ve,i as pe,g as fe}from"./VForm-0fd17bdf.js";const he={key:0},ge=["for"],ye={key:1},me={key:2},be={key:0},ke={key:1},we={key:3},Ce=q({__name:"DialogueSpeechbubble",props:{value:String,direction:{type:String,default:"right"},withClear:{type:Boolean,default:!1},labelId:String,resultCount:{type:Number,default:void 0},alternative:String},setup(t){return(l,o)=>(s(),v(ee,{direction:t.direction,class:"bubble-width"},{default:d(()=>[t.labelId?(s(),_("span",he,[I("label",{for:t.labelId},$(t.value),9,ge)])):t.resultCount&&t.resultCount>0?(s(),_("span",ye,[T(" Ik heb "),I("button",{class:"text-cta_blue text-decoration-underline result-count",role:"button",tabindex:"0",onClick:o[0]||(o[0]=e=>l.$emit("search"))},$(t.resultCount)+" "+$(t.resultCount===1?"resultaat":"resultaten"),1),T(" gevonden. "),I("span",null,$(t.value),1)])):t.resultCount===0?(s(),_("span",me,[T(" Ik heb niets gevonden met "),I("strong",null,$(t.value),1),T(". "),t.alternative?(s(),_("span",be,[T(" Bedoel je misschien "),I("strong",null,$(t.alternative),1),T("? ")])):(s(),_("span",ke,"Gebruik een andere zoekterm of sla deze vraag over."))])):(s(),_("span",we,$(t.value),1)),t.withClear?(s(),v(le,{key:4,class:"ml-5",color:"primary",onClick:o[1]||(o[1]=e=>l.$emit("clear")),"aria-label":"wis dit antwoord"},{default:d(()=>[T(" mdi-close ")]),_:1})):A("",!0)]),_:1},8,["direction"]))}});const D=z(Ce,[["__scopeId","data-v-f123fd00"]]),_e={class:"width-bar"},Se=500,H=3,xe=q({__name:"DialogueQuestionSearch",props:{question:{type:Object,required:!0},index:{type:Number,default:0}},emits:["skip","clear","change"],setup(t,{emit:l}){const o=t,e=M("$piwik"),r=g(o.question),y=g(""),m=g(G()),b=g(Se),x=g(-1),B=g(H),V=g([]),n=E(()=>{const p=r.value.answers;if(p.length===0)return"";const u=p[p.length-1];return u.alternative?u.alternative:u.value});U(n,p=>{y.value=p}),U(y,p=>{const u=ie(p,H);if(u===null){V.value=[];return}k(u)});const i=()=>{r.value.skipped=!0,r.value.answers.push({label:"",value:"Ik sla deze vraag over"}),e("conversation","click","skip-program-about"),l("skip")},a=p=>{r.value.answers.splice(p),l("clear")},f=()=>{r.value.answers.push({label:"",value:y.value??""}),e("conversation","search",y.value??""),l("change")},k=async p=>{const u=te(async()=>{if(!(p.length<B.value))try{V.value=await ue.getAutoComplete(p)}catch{V.value=[]}},x.value,b.value)();x.value=u.newTimeoutId,await u.debouncedFunction};return(p,u)=>(s(),_("div",null,[r.value.show?(s(),v(P,{key:0,"justify-end":"",class:"dialogue-question mb-5"},{default:d(()=>[h(L,{cols:"12"},{default:d(()=>[h(D,{value:r.value.question,direction:"left",class:"mb-5"},null,8,["value"])]),_:1}),(s(!0),_(F,null,O(r.value.answers,(c,w)=>(s(),v(L,{cols:"12",key:w},{default:d(()=>[c.value!==""?(s(),v(L,{key:0,cols:"12",class:"d-flex align-end justify-end"},{default:d(()=>[h(D,{labelId:"zoekveld",class:"mb-5",value:c.value,withClear:!0,onClear:C=>a(w)},null,8,["value","onClear"])]),_:2},1024)):A("",!0),w===r.value.answers.length-1&&r.value.isAnswered()?A("",!0):(s(),v(D,{key:1,alternative:c.alternative,value:c.value,resultCount:c.resultCount,direction:"left",onSearch:u[0]||(u[0]=C=>p.$emit("change")),class:"mb-5 mt-5"},null,8,["alternative","value","resultCount"]))]),_:2},1024))),128)),r.value.resultCount===0?(s(),v(L,{key:0,cols:"12",class:"d-flex align-end justify-end"},{default:d(()=>[I("div",{class:N(["d-flex",m.value.lgAndUp?"flex-row align-center":m.value.md?"flex-column align-end":m.value.sm?"flex-row align-center":m.value.xs?"flex-column align-end":""])},[I("div",_e,[h(re,{id:"zoekveld",modelValue:y.value,"onUpdate:modelValue":u[1]||(u[1]=c=>y.value=c),placeholder:r.value.placeholder,autocompleteList:V.value,onSearch:f,disabledWhenEmpty:!0},null,8,["modelValue","placeholder","autocompleteList"])]),h(j,{key:"pass-zoekterm",id:"pass-zoekterm",class:"ma-1 py-6 dialogue-button",onClick:i},{default:d(()=>[T(" Sla deze vraag over "),h(R,{icon:"caret-right"})]),_:1})],2)]),_:1})):A("",!0)]),_:1})):A("",!0)]))}});const $e=z(xe,[["__scopeId","data-v-8f69758b"]]),Te=q({__name:"DialogueQuestionSelection",props:{question:{type:Object,required:!0},resultCount:Number},emits:["clear","change","search","skip","getCounts"],setup(t,{emit:l}){const e=g(t.question),r=M("$piwik"),y=g(G()),m=g([]),b=E(()=>e.value.show),x=E(()=>e.value.skipText??"Sla deze vraag over"),B=()=>{e.value.skipped=!0,e.value.answers.push({label:x.value,value:[]}),r("conversation","click",`skip-${e.value.property}`),l("skip")},V=n=>{e.value.answers.push(n),r("conversation","click",`${n.label}-${n.value}`),l("change")};return U(b,()=>{m.value.splice(0),e.value.show&&l("getCounts",e.value)}),(n,i)=>e.value.show?(s(),v(P,{key:0,"justify-end":"",class:"dialogue-question"},{default:d(()=>[h(L,{cols:"12"},{default:d(()=>[h(D,{value:e.value.question,resultCount:t.resultCount,direction:"left",onSearch:i[0]||(i[0]=a=>n.$emit("search")),class:"mb-5"},null,8,["value","resultCount"])]),_:1}),h(L,{cols:"12",class:"d-flex align-end justify-end"},{default:d(()=>{var a,f;return[e.value.isAnswered()?(s(),v(D,{key:0,value:(a=e.value.getLastAnswer())==null?void 0:a.label,class:"mb-5",withClear:!0,onClear:i[1]||(i[1]=k=>n.$emit("clear"))},null,8,["value"])):(s(),_("div",{key:1,class:N(["d-flex",y.value.lgAndUp?"flex-row align-center":y.value.md?"flex-column align-end":y.value.sm?"flex-row align-center":y.value.xs?"flex-column align-end":""])},[e.value.isAnswered()?(s(),v(D,{key:0,value:(f=e.value.getLastAnswer())==null?void 0:f.label,direction:"left",withClear:!0,class:"mb-5",onClear:i[2]||(i[2]=k=>n.$emit("clear"))},null,8,["value"])):(s(),v(ae,{key:1,name:"list",tag:"div",class:"dialogue-question-answers d-flex justify-end align-start flex-wrap"},{default:d(()=>[(s(!0),_(F,null,O(e.value.possibleAnswers,k=>(s(),v(j,{class:N(["button ma-1 answer",k.value?"selected":""]),ripple:!1,key:k.label,disabled:!k.resultCount,id:k.label+"-selection",onClick:p=>V(k)},{default:d(()=>[T($(k.label),1)]),_:2},1032,["class","disabled","id","onClick"]))),128)),e.value.isAnswered()?A("",!0):(s(),v(j,{key:"pass-"+e.value.property,id:"pass-"+e.value.property,class:"button ma-1 answer",ripple:!1,onClick:B},{default:d(()=>[T($(x.value)+" ",1),h(R,{icon:"caret-right"})]),_:1},8,["id"]))]),_:1}))],2))]}),_:1})]),_:1})):A("",!0)}});const Ae=z(Te,[["__scopeId","data-v-60102f3c"]]),Le={style:{width:"215px"}},Be={class:"mb-1 font-weight-black",for:"locationInput"},Ve=q({__name:"DialogueQuestionLocation",props:{question:{type:Object,required:!0},resultCount:Number,submitButtonText:{type:String,required:!0},skipButtonText:{type:String,required:!0},textFieldLabel:{type:String,required:!0}},emits:["skip","change","search"],setup(t,{emit:l}){const e=g(t.question),r=M("$piwik"),y=g(G()),m=g(),b=g(""),x=g([]),B=g(!1),V=g(),n=g([]);X(async()=>{try{const c=await K.getListOfCityNames();Array.isArray(c)&&(n.value=c)}catch(c){x.value.push(c)}});const i=c=>{switch(e.value.property){case"location":return e.value.answers[c].value.search_term;case"postcode":return e.value.answers[c].value;default:return""}},a=()=>{b.value.length>0&&k()},f=c=>{c.target.blur(),u(c)},k=async()=>{if(m.value){const{valid:c}=await m.value.validate();return c}return!1},p=()=>{l("skip"),r("conversation","click","location-anywhere")},u=async c=>{if(c.preventDefault(),!await k())return;const C=fe(b.value);if(!(!C||C===void 0)){B.value=!0;try{await K.getLocation(b.value,C),e.value.property==="location"?(e.value.answers.push({label:"location",value:{search_term:b.value,distance:0}}),r("conversation","click","location-nearby")):e.value.property==="postcode"&&e.value.answers.push({label:"postcode",value:b.value}),l("change")}catch(Q){x.value.push(Q)}finally{B.value=!1}}};return(c,w)=>e.value.show?(s(),v(P,{key:0,class:"dialogue-question"},{default:d(()=>[e.value?(s(),v(L,{key:0,cols:"12"},{default:d(()=>[h(D,{value:e.value.question,resultCount:t.resultCount,direction:"left",onSearch:w[0]||(w[0]=C=>c.$emit("search")),class:"mb-5"},null,8,["value","resultCount"])]),_:1})):A("",!0),(s(!0),_(F,null,O(e.value.answers,(C,Q)=>(s(),v(L,{cols:"12",key:Q},{default:d(()=>[i(Q)!==""?(s(),v(L,{key:0,cols:"12",class:"d-flex align-end justify-end"},{default:d(()=>[h(D,{direction:"left",value:i(Q),class:"mb-10"},null,8,["value"])]),_:2},1024)):A("",!0),e.value.resultCount===0?(s(),v(L,{key:1,cols:"12"},{default:d(()=>[h(D,{value:"Ik heb niets gevonden dicht bij deze postcode. Kies voor 'Opleidingen overal' of typ een andere postcode in.",class:"mb-10",direction:"left"})]),_:1})):A("",!0)]),_:2},1024))),128)),h(L,{cols:"12"},{default:d(()=>[h(ce,{"validate-on":"submit lazy",class:"input-filter d-flex justify-end",style:{width:"100%"},onSubmit:u,ref_key:"locationForm",ref:m,"fast-fail":""},{default:d(()=>[I("div",Le,[I("label",Be,$(t.textFieldLabel),1),h(de,{id:"locationInput",ref_key:"locationInput",ref:V,dense:"","auto-select-first":"",style:{width:"100%"},"bg-color":"white",placeholder:"1234, 1234AB of Leiden",density:"compact",modelValue:b.value,"onUpdate:modelValue":w[1]||(w[1]=C=>b.value=C),variant:"solo",flat:"",onBlur:w[2]||(w[2]=C=>a()),onKeydown:w[3]||(w[3]=se(ne(C=>f(C),["prevent"]),["enter"])),rules:W(ve),items:n.value,"custom-filter":W(pe)},null,8,["modelValue","rules","items","custom-filter"])]),I("div",{class:N(y.value.lgAndUp?"d-flex mt-7 flex-row":"d-flex mt-7 flex-column")},[h(j,{id:"dialogue-submit-location",class:"button my-0 mx-1 mb-1 py-5",onClick:w[4]||(w[4]=C=>u(C)),loading:B.value,ripple:!1},{default:d(()=>[T($(t.submitButtonText),1)]),_:1},8,["loading"]),h(j,{id:"dialogue-skip-location",class:"button my-0 mx-1 mb-1 py-5",onClick:p},{default:d(()=>[T($(t.skipButtonText)+" ",1),h(R,{icon:"caret-right"})]),_:1})],2)]),_:1},512)]),_:1})]),_:1})):A("",!0)}});const Ie=z(Ve,[["__scopeId","data-v-02330117"]]),De={class:"dialogue-manager"},Ue=q({__name:"DialogueManager",props:{questions:{type:Array,required:!0}},emits:["change","search","getCounts","location","scrollToBottom","showAllResultsButtonUpdate"],setup(t,{emit:l}){const e=g(t.questions),r=(n,i=!1)=>{const a=e.value[n],f=e.value[n+1];l("change",a,f,i)},y=n=>{const i=e.value[n],a=e.value[n+1];l("location",i,a)},m=n=>{const i=e.value[n];l("search",i)},b=n=>{for(let i=n;i<=e.value.length-1;i++){const a=e.value[i];a.skipped=!1,a.query&&delete a.query,a.resultCount=0,i!==n&&(a.answers=[],a.show=!1)}l("showAllResultsButtonUpdate",n),l("scrollToBottom")},x=n=>{const i=e.value[n];i.skipped=!0,r(n)},B=n=>{const i=e.value.indexOf(n),a=e.value[i-1];if(a)return a.resultCount},V=n=>{l("getCounts",n)};return X(()=>{e.value.length>1&&(e.value[0].show=!0)}),(n,i)=>(s(),_("div",De,[(s(!0),_(F,null,O(e.value,(a,f)=>{var k,p;return s(),_("div",{key:a.property},[a.property==="zoekargument"?(s(),v($e,{key:0,question:a,onClear:u=>b(f),onChange:u=>r(f,!0),onSkip:u=>x(f)},null,8,["question","onClear","onChange","onSkip"])):a.property==="type_subsidie"||a.property==="type_aanvrager"||a.property==="status_gebruiker"||a.property==="niveau"||a.property==="soort_diploma"?(s(),v(Ae,{key:1,question:a,resultCount:B(a),onClear:u=>b(f),onChange:u=>r(f),onSearch:u=>m(f),onSkip:u=>x(f),onGetCounts:V},null,8,["question","resultCount","onClear","onChange","onSearch","onSkip"])):a.property==="location"||a.property==="postcode"?(s(),v(Ie,{key:2,question:a,resultCount:B(a),submitButtonText:((k=a.buttonText)==null?void 0:k.submit)??"submit",skipButtonText:((p=a.buttonText)==null?void 0:p.skip)??"skip",textFieldLabel:a.inputLabel??"label",onChange:u=>y(f),onSearch:u=>m(f),onSkip:u=>x(f)},null,8,["question","resultCount","submitButtonText","skipButtonText","textFieldLabel","onChange","onSearch","onSkip"])):A("",!0)])}),128))]))}});function Me(t,l,o){const e=l.indexOf(oe(t)),r=J(o),y=Qe(e,l,r);if(!y)return;const m=J(y);if(t&&t.answers.length>0&&!t.skipped){const b=t.answers[t.answers.length-1].value;m[t.property]=b}return m}function J(t){return JSON.parse(JSON.stringify(t))}function Qe(t,l,o){if(t&&t>0&&l[t-1])return l[t-1].query;if(t===0)return o;if(!t){let e=o;return l.forEach(r=>{r.query&&(e=r.query)}),e}}class Ge{constructor(l){S(this,"answers");S(this,"show");S(this,"skipped");S(this,"resultCount");S(this,"query");S(this,"possibleAnswers");S(this,"property");S(this,"question");S(this,"buttonText");S(this,"inputLabel");S(this,"placeholder");S(this,"skipText");this.options=l,this.buttonText=l.buttonText,this.inputLabel=l.inputLabel,this.placeholder=l.placeholder,this.possibleAnswers=l.possibleAnswers,this.property=l.property,this.question=l.question,this.answers=[],this.show=!1,this.skipped=!1,this.resultCount=0,this.skipText=l.skipText}isAnswered(){return this.skipped||this.answers.length>0&&this.resultCount>0}getLastAnswer(){if(this.answers.length!==0)return this.answers[this.answers.length-1]}setResultCount(l){if(this.resultCount=l,!this.skipped){const o=[...this.answers];o[o.length-1].resultCount=l,this.answers=o}}setAlternative(l){if(!this.skipped){const o=[...this.answers];o[o.length-1].alternative=l,this.answers=o}}}export{Ge as D,Ue as _,J as d,Me as g};