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