import{g as j,cp as X,u as x,bP as N,M as k,h as U,j as P,l as v,X as B,q as m,w as L,y as i,n as A,B as D,C as V,al as z,aJ as T,ag as ee,cq as te,ai as M,_ as Y,ab as I,cr as ae,cs as G,ct as oe,cl as E,ap as Z,R as se,ak as ie,aI as ne,a7 as le,K as re,o as ce,aQ as ue,W as de,cu as K,T as pe,F as W,A as H,$ as he,at as me,aP as ge,d as q}from"./dashboard-practitioner-6249e5a1.js";(function(){try{var d=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(d._sentryDebugIds=d._sentryDebugIds||{},d._sentryDebugIds[a]="f7371d32-7d0d-42bb-9bad-24a9893fe631",d._sentryDebugIdIdentifier="sentry-dbid-f7371d32-7d0d-42bb-9bad-24a9893fe631")}catch{}})();const fe=j({__name:"ServicesField",setup(d){const a=X(),{smAndUp:p}=x(),o=N(),e=l=>{l&&o.autocompleteSearchServices(o.searchService)};k(()=>o.searchService,l=>{o.alreadySearchWithSelectedCity=!1});function s(l){o.searchService=l.id}const n=U(!1),h=P(()=>o.listAutocompleteService.length===0);return k(()=>o.searchLocation,(l,t)=>{!!l&&h.value?n.value=!0:h.value&&(n.value=!1)}),k(()=>o.listAutocompleteService,(l,t)=>{0<o.listAutocompleteService.length&&(n.value=!0)}),(l,t)=>(v(),B(M,null,[m(T,z({id:"search-service-field"},i(a),{modelValue:i(o).searchService,"onUpdate:modelValue":[t[0]||(t[0]=r=>i(o).searchService=r),i(o).autocompleteSearchServices],"bg-color":i(p)?"transparent":"white",class:[{"w-50":i(p)},"search-field"],label:l.$t("heroSection.searchPlaceholder1"),placeholder:l.$t("heroSection.searchPlaceholder1"),clearable:"",flat:"","hide-details":"","prepend-inner-icon":"mdi-magnify","single-line":"",variant:"solo",autocomplete:"off","onUpdate:focused":e}),{"append-inner":L(()=>[i(o).loadingServices?(v(),A(D,{key:0,icon:"",size:"small",variant:"text",loading:i(o).loadingServices},null,8,["loading"])):V("",!0)]),_:1},16,["modelValue","bg-color","class","label","placeholder","onUpdate:modelValue"]),m(te,{modelValue:n.value,"onUpdate:modelValue":t[1]||(t[1]=r=>n.value=r),activator:"#search-service-field","max-height":"300px"},{default:L(()=>[0<i(o).listAutocompleteService.length?(v(),A(ee,{key:0,items:i(o).listAutocompleteService,"onClick:select":s,slim:"",density:"compact"},null,8,["items"])):V("",!0)]),_:1},8,["modelValue"])],64))}});const J=Y(fe,[["__scopeId","data-v-bfc5e379"]]),ye=I(),O=ae("autocomplete-location",()=>{const d=U([]),a=U(!1),p=U(null),o=P(()=>Object.prototype.hasOwnProperty.call(p.value,"value")&&Object.prototype.hasOwnProperty.call(p.value,"label")&&Object.prototype.hasOwnProperty.call(p.value.value,"city")&&p.value.value.city),e=(h,{layers:l,country:t}={})=>{const r=E(),u={text:h};return t&&(u["boundary.country"]=t),l&&(u.layers=l),r.storedLocationIsEmpty||(u["focus.point.lat"]=r.getLat(),u["focus.point.lon"]=r.getLon()),u},s=G(async h=>{if(!h){a.value=!1;return}try{const l=await ye.getAutocompleteSuggestionsPlaces(h,[]);d.value=l}catch(l){throw new Error(`Error fetching data: ${l}`)}finally{a.value=!1}},200),n=G(async(h,{layers:l,country:t}={})=>{if(!h)return[];a.value=!0;try{const r=await oe(e(h,{layers:l,country:t})),{data:u}=r,F=u.features.map(y=>{var C,$,c,g;return{label:y.properties.label,value:{label:y.properties.label,country:y.properties.country,addressLine:y.properties.name,postalCode:y.properties.postalcode,city:y.properties.locality,latitude:($=(C=y.geometry)==null?void 0:C.coordinates[1])==null?void 0:$.toString(),longitude:(g=(c=y.geometry)==null?void 0:c.coordinates[0])==null?void 0:g.toString()}}});d.value=F}catch(r){console.error(`Error fetching data: ${r}`)}finally{a.value=!1}},100);return{autocompleteLocationList:d,loadingLocation:a,selectedLocation:p,hasCityProp:o,autocompleteLocationRequest:n,autocompleteRequest:s}}),ve=j({__name:"LocationField",props:{displayIcon:{type:Boolean,default:!0},displayCompact:{type:Boolean,default:!1}},setup(d){const a=X(),{smAndUp:p}=x(),o=N(),e=E(),s=O(),n=U(!1);Z(),k(()=>o.searchLocation,(t,r)=>{le(()=>{h(),o.searchLocation&&0<s.autocompleteLocationList.length&&(n.value=!0),s.autocompleteLocationList.length===0&&(n.value=!1),o.alreadySearchWithSelectedCity=!1})}),k(()=>s.autocompleteLocationList,t=>{t.length>0&&(n.value=!0)});const h=()=>{(s.autocompleteLocationList.length===0||!o.searchLocation)&&(n.value=!1)};async function l(t){const r=I();if(typeof t=="string"&&t.length>0&&(o.searchLocation=t,s.selectedLocation=null),t?n.value=!0:n.value=!1,!t)s.autocompleteLocationList=[];else if(typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")){t=t,t.value=await r.getFormatedAddressFromPlace(t.value);const u=t;e.updateStoredLocation({...u.value,coords:{latitude:Number(u.value.latitude),longitude:Number(u.value.longitude)}}),s.selectedLocation=u,o.searchLocation=u.label||null;return}else typeof t=="string"&&await s.autocompleteRequest(t)}return(t,r)=>(v(),A(ne,z({"no-filter":"",density:d.displayCompact?"compact":"default",modelValue:i(o).searchLocation,"onUpdate:modelValue":r[1]||(r[1]=u=>i(o).searchLocation=u)},i(a),{items:i(s).autocompleteLocationList,loading:i(s).loadingLocation,"bg-color":i(p)?"transparent":"white",class:[{"w-50":i(p)},"location-field"],label:t.$t("heroSection.searchPlaceholder2"),placeholder:t.$t("heroSection.searchPlaceholder2"),"no-data-text":t.$t("heroSection.noAddressFound"),"hide-no-data":!n.value,variant:"solo","prepend-inner-icon":d.displayIcon?"mdi-map-marker-radius-outline":"",flat:"","hide-details":"",clearable:"","single-line":"","item-title":"label","item-value":"value","return-object":"","auto-select-first":!0,autocomplete:"none","onUpdate:search":l,"onUpdate:modelValue":r[2]||(r[2]=u=>l(u))}),{"append-inner":L(()=>[i(e).loading||i(s).loadingLocation?(v(),A(D,{key:0,icon:"",size:"small",variant:"text",loading:i(e).loading||i(s).loadingLocation},null,8,["loading"])):V("",!0)]),append:L(()=>[m(ie,{text:"Utiliser ma localisation",location:"bottom"},{activator:L(({props:u})=>[m(D,z(u,{class:"z-100 mr-2",size:"small",icon:"mdi-crosshairs",variant:"text",onClick:r[0]||(r[0]=se(()=>{i(e).loading=!0,i(s).selectedLocation=null,i(e).askGeolocation()},["prevent","stop"]))}),null,16)]),_:1})]),_:1},16,["density","modelValue","items","loading","bg-color","class","label","placeholder","no-data-text","hide-no-data","prepend-inner-icon"]))}});const Q=Y(ve,[["__scopeId","data-v-b7e593ba"]]);re();const Le=async d=>d?d.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"):"",Se={key:1,class:"d-flex flex-column align-stretch w-100 ga-4 mb-8"},_e=j({__name:"MainSearchBar",setup(d){const a=Z(),{smAndUp:p,mdAndUp:o}=x(),e=N(),s=E(),n=O(),h=I();k(()=>a.fullPath,async(c,g)=>{e.isInitializing=!0,e.listPractitioners=[];const R=a.params.disicplineSlug??"",b=a.params.city??"",S=a.query.lon??"",f=a.query.lat??"",_=a.query.address??"";if(a.params.city){await n.autocompleteRequest(a.params.city);const w=await h.getFormatedAddressFromPlace(n.autocompleteLocationList[0].value);n.selectedLocation={...n.selectedLocation,label:w.addressLine,value:w},s.updateStoredLocation({...w,coords:{latitude:Number(w.latitude),longitude:Number(w.longitude)}}),S&&f&&(s.storedLocation={...s.storedLocation,coords:{latitude:w.latitude,longitude:w.longitude}})}else S&&f&&(s.storedLocation={...s.storedLocation,coords:{latitude:f,longitude:S}});_&&(s.storedLocation={...s.storedLocation,address:_}),e.searchService||(e.searchService=R),e.searchLocation||(e.searchLocation=b||null),await e.findYourPractitioner(),e.isInitializing=!1},{immediate:!0});const l=P(()=>s.getLat()),t=P(()=>s.getLon()),r=P(()=>parseFloat(n.selectedLocation.value.latitude)),u=P(()=>parseFloat(n.selectedLocation.value.longitude)),F=async()=>{let c=l.value,g=t.value;const R=e.searchService,b=await Le(R);if(!["SearchPage","DisciplineSearchPage"].includes(q.currentRoute.value.name)){if(!e.searchLocation&&!e.searchService){await q.push({name:"SearchPage"});return}if(e.searchLocation&&!e.searchService){let f={lat:s.getLat(),lon:s.getLon()};s.storedLocationIsEmpty||(f.address=s.storedLocation.city),await q.push({name:"SearchPage",query:f});return}if(!e.searchLocation&&e.searchService){await q.push({name:"DisciplineSearchPage",params:{disciplineSlug:b}});return}}let S="";n.selectedLocation&&n.hasCityProp&&(S=n.selectedLocation.value.city,c=r.value,g=u.value,s.updateStoredLocation({city:n.selectedLocation.value.city,coords:{latitude:c,longitude:g}})),e.searchLocation&&!S&&(S=e.searchLocation);try{let f="";b&&S?f=`/${encodeURIComponent(b)}/${encodeURIComponent(S.toLowerCase())}`:b&&!e.searchLocation&&(f=`/${encodeURIComponent(b)}`);const _={};c&&e.searchLocation&&(_.lat=c),g&&e.searchLocation&&(_.lon=g),e.searchLocation&&(_.address=e.searchLocation),await q.push({path:f,query:_})}catch(f){console.error("Error",f)}},y=P(()=>["SearchPage","DisciplineCitySearchPage","DisciplineSearchPage"].includes(a.name)&&e.loadingFind),C=c=>c&&typeof c=="string"?c.charAt(0).toUpperCase()+c.slice(1):"",$=async()=>{let c=!1;typeof a.params.disciplineSlug=="string"&&(e.searchService=C(a.params.disciplineSlug),c=!0);const g=E();return g.storedLocationIsEmpty||(e.searchLocation=g.storedLocation.city),typeof a.params.city=="string"&&(e.searchLocation=C(a.params.city),c=!0),a.query.lat&&(e.latitude=Number(a.query.lat),c=!0),a.query.lon&&(e.longitude=Number(a.query.lon),c=!0),a.query.address&&(e.searchLocation=C(a.query.address),c=!0),c};return ce(async()=>{await $()}),(c,g)=>(v(),B(M,null,[i(p)?(v(),A(ge,{key:0,class:"px-6"},{default:L(()=>[m(me,{justify:i(a).name==="Home"?"start":"center"},{default:L(()=>[m(ue,{color:"white",width:"100%",height:"50px",rounded:"xl",class:"px-2 d-flex align-center justify-center mb-lg-10",style:de({maxWidth:i(a).name==="Home"?"900px":"100%"})},{default:L(()=>[m(J,{onKeydown:K(F,["enter"])}),m(pe,{thickness:"2",vertical:"",inset:"",class:"mx-2"}),m(Q,{onKeydown:K(F,["enter"])}),m(D,{color:"blue","append-icon":"mdi-chevron-right",icon:!i(o),size:i(o)?"default":38,loading:y.value,onClick:F},{default:L(()=>[i(o)?(v(),B(M,{key:0},[W(H(c.$t("searchPage.searchButton")),1)],64)):V("",!0),i(o)?V("",!0):(v(),A(he,{key:1,icon:"mdi-chevron-right"}))]),_:1},8,["icon","size","loading"])]),_:1},8,["style"])]),_:1},8,["justify"])]),_:1})):V("",!0),i(p)?V("",!0):(v(),B("div",Se,[m(J),m(Q),m(D,{style:{height:"48px","font-size":"18px","letter-spacing":"normal"},color:"blue-darken-1",class:"mt-1","append-icon":"mdi-chevron-right",loading:y.value,onClick:F},{default:L(()=>[W(H(c.$t("searchPage.searchButton")),1)]),_:1},8,["loading"])]))],64))}});export{_e as _};
//# sourceMappingURL=MainSearchBar.vue_vue_type_script_setup_true_lang-8e00bb33.js.map