"use strict";(self.webpackChunkhhgHealthCareV1=self.webpackChunkhhgHealthCareV1||[]).push([[7213],{97213:function(e,t,a){a.d(t,{B:function(){return $e}});var i=a(73884),o=a.n(i),l=a(26662),n=a(51387),s=a(94858),c=a(36814),r=a(6596),d=a(48085),p=a(39530),u=a(86566),h=a(50315),g=a(14677),m=a(25793),b=a(50864),y=a(73827),f=a(42060),x=a(40279),v=a(88933),w=a(44396),S=a(67771),C=a(38221),E=a.n(C),k=a(54508),L=a(11851),O=a(35291),j=a(29209),I=a(35674),$=a(98255),M=a(62976),A=a(66780),R=a(13916),T=a(9714),P=a(4095),F=a(24991);const D=L.A.div``,B=L.A.div` background-color: ${O.w.colors.neutral50}; padding-bottom: 1px; ${j.M.mbDown} { padding: 0; } `,_=(0,L.A)(I.C)` padding: 0 16px; ${j.M.mbDown} { padding: 0; } `,K=L.A.div` padding: 24px 56px; border-radius: 16px; background-color: ${O.w.colors.white}; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.04), 0px 0px 2px 0px rgba(0, 0, 0, 0.06), 0px 4px 8px 0px rgba(0, 0, 0, 0.04); ${j.M.mbDown} { padding: 16px; border-radius: 0; } .flex-search-input { flex-direction: row; ${j.M.mbDown} { flex-direction: column; } } `,N={"en-PH":3,"tl-PH":2,"id-ID":3,"vi-VN":2,"zh-TW":0,"ms-MY":2,"th-TH":2},z={isMobile:!1,isDebug:!1,navigateTo:null,geoLocationPermission:"unset",geoLocationCoordinates:null,focused:"none",focusedSpecialty:"none",searchLocationKeywords:"",searchSpecialtyKeywords:"",searchKeywords:"",selectedLocation:null,selectedSpecialty:null,defaultCity:null,initialCities:[],cities:[],searchResults:{},initialSearchResults:{},isLoadingCities:!1,isLoadingSearchResults:!1,isMobileModalOpened:!1,initialSelectedCity:null,autoCompleteDisabled:!1,inputSearchPlaceholder:"",locale:"vi-VN",allSpecialties:[],popularKeys:[]};var q;function G(e){const{selectedLocation:t,searchLocationKeywords:a}=e;return t&&a!==t.name?Object.assign(Object.assign({},e),{searchLocationKeywords:t.name}):e}function V(e,t){var a,i;switch(e.isDebug&&console.log("bookingSearchBarV3",{action:t,state:e}),t.type){case q.NavigateTo:return Object.assign(Object.assign({},e),{navigateTo:t.payload,focused:"none",isMobileModalOpened:!1});case q.ClickOutsideInputLocation:return"location"!==e.focused?e:G(Object.assign(Object.assign({},e),{focused:"none"}));case q.ClickOutsideInputSpecialty:return"specialty"!==e.focused?e:G(Object.assign(Object.assign({},e),{focused:"none"}));case q.ClickOutsideInputSearch:return"search"!==e.focused?e:Object.assign(Object.assign({},e),{focused:"none"});case q.ClickOutsideInputSearchSpecialty:return"search"!==e.focusedSpecialty?e:Object.assign(Object.assign({},e),{focusedSpecialty:"none"});case q.FocusInputLocation:{const t=Object.assign(Object.assign({},e),{focused:"location"});return(null===(a=e.selectedLocation)||void 0===a?void 0:a.id)===k.a&&(t.searchLocationKeywords=""),t}case q.FocusInputSpecialty:{const t=Object.assign(Object.assign({},e),{focused:"specialty"});return(null===(i=e.selectedLocation)||void 0===i?void 0:i.id)===k.a&&(t.searchLocationKeywords=""),t}case q.FocusInputSearch:const o=Object.assign(Object.assign({},e),{focused:"search"});return e.isMobile?G(o):o;case q.FocusInputSearchSpecialty:return Object.assign(Object.assign({},e),{focusedSpecialty:"search"});case q.ChangeInputLocation:return Object.assign(Object.assign({},e),{searchLocationKeywords:t.payload});case q.ChangeInputSearch:{const a=t.payload;return Object.assign(Object.assign({},e),{searchKeywords:a,isLoadingSearchResults:a.trim().length>N[e.locale]})}case q.SelectCurrentLocation:return Object.assign(Object.assign({},e),{focused:"none",selectedLocation:t.payload,searchLocationKeywords:t.payload.name});case q.ClearInputLocation:return Object.assign(Object.assign({},e),{focused:"location",cities:e.initialCities,searchLocationKeywords:""});case q.ClearInputSearch:return Object.assign(Object.assign({},e),{focused:"search",searchKeywords:""});case q.SelectLocation:return Object.assign(Object.assign({},e),{focused:"none",selectedLocation:t.payload,searchLocationKeywords:t.payload.name,searchResults:{}});case q.SelectSpecialty:return Object.assign(Object.assign({},e),{focused:"none",selectedSpecialty:t.payload,searchResults:{}});case q.SelectSearchResult:return Object.assign(Object.assign({},e),{searchKeywords:t.payload.name,isMobileModalOpened:!1,focused:"none",navigateTo:t.payload.url});case q.FetchCitiesStart:return Object.assign(Object.assign({},e),{isLoadingCities:!0});case q.FetchCitiesFinish:return Object.assign(Object.assign({},e),{isLoadingCities:!1});case q.FetchSearchResultsStart:return Object.assign(Object.assign({},e),{isLoadingSearchResults:!0});case q.FetchSearchResultsFinish:return Object.assign(Object.assign({},e),{isLoadingSearchResults:!1});case q.FetchSearchResultsComplete:return Object.assign(Object.assign({},e),{searchResults:Object.assign(Object.assign({},e.searchResults),{[t.payload.key]:t.payload.searches})});case q.FetchCitiesByGeoIpComplete:{let{cities:a}=t.payload;const{default:i}=t.payload;a=a.filter((e=>e.id!==i.id)),i&&a.unshift(i),e.initialSelectedCity&&!a.find((t=>t.id===e.initialSelectedCity.id))&&a.unshift(e.initialSelectedCity);const o=Object.assign(Object.assign({},e),{defaultCity:i,initialCities:a,cities:a});return"denied"!==e.geoLocationPermission||e.initialSelectedCity||(o.selectedLocation=i,o.searchLocationKeywords=i.name),o}case q.FetchCitiesByKeywordComplete:return Object.assign(Object.assign({},e),{cities:t.payload});case q.DisplayInitialCities:return Object.assign(Object.assign({},e),{cities:e.initialCities});case q.DisplayInitialSearchResults:{const t=e.searchKeywords.trim(),a=N[e.locale],i=t.length>0&&t.length<=a;return Object.assign(Object.assign({},e),{searchResults:i?{}:e.initialSearchResults,isLoadingSearchResults:!1})}case q.UpdateInitialSearchResults:return Object.assign(Object.assign({},e),{initialSearchResults:Object.assign(Object.assign({},e.initialSearchResults),{[t.payload.key]:t.payload.searches})});case q.GrantGeoLocationPermission:return Object.assign(Object.assign({},e),{geoLocationPermission:"granted",geoLocationCoordinates:t.payload});case q.DenyGeoLocationPermission:return Object.assign(Object.assign({},e),{geoLocationPermission:"denied",geoLocationCoordinates:null});case q.OpenMobileModal:return Object.assign(Object.assign({},e),{isMobileModalOpened:!0});case q.CloseMobileModal:return Object.assign(Object.assign({},e),{isMobileModalOpened:!1});case q.UpdateInitialSearchValue:return Object.assign(Object.assign({},e),{searchKeywords:t.payload});case q.SetInputSearchPlaceholder:return Object.assign(Object.assign({},e),{inputSearchPlaceholder:t.payload});case q.FetchAllSpecialties:return Object.assign(Object.assign({},e),{allSpecialties:t.payload});case q.FetchPopularKeys:return Object.assign(Object.assign({},e),{popularKeys:t.payload});default:return e}}!function(e){e.NavigateTo="navigate to url",e.ClickOutsideInputLocation="click outside input location",e.ClickOutsideInputSearch="click outside input search",e.ClickOutsideInputSearchSpecialty="click outside input search specialty",e.ClickOutsideInputSpecialty="click outside input specialty",e.SelectCurrentLocation="select current location",e.FocusInputLocation="focus input location",e.FocusInputSearch="focus input search",e.FocusInputSearchSpecialty="focus input search specialty",e.ChangeInputLocation="change input location",e.ChangeInputSearch="change input search",e.ClearInputLocation="clear input location",e.ClearInputSearch="clear input search",e.SelectLocation="select location",e.SelectSpecialty="select specialty",e.FetchCitiesStart="fetch cities start",e.FetchCitiesFinish="fetch cities finish",e.FetchSearchResultsStart="fetch search results start",e.FetchSearchResultsComplete="fetch search results complete",e.FetchSearchResultsFinish="fetch search results finish",e.FetchCitiesByGeoIpComplete="fetch cities by geo IP finish",e.FetchCitiesByKeywordComplete="fetch cities by keyword finish",e.DisplayInitialCities="display initial cities",e.DisplayInitialSearchResults="display initial search results",e.UpdateInitialSearchResults="update initial search results",e.GrantGeoLocationPermission="grant geolocation permission",e.DenyGeoLocationPermission="deny geolocation permission",e.OpenMobileModal="open mobile modal",e.CloseMobileModal="close mobile modal",e.UpdateInitialSearchValue="update initial search value",e.SelectSearchResult="select search result",e.SetInputSearchPlaceholder="set input search placeholder",e.FocusInputSpecialty="focus input specialty",e.FetchAllSpecialties="fetch all specialty",e.FetchPopularKeys="fetch popular key by type"}(q||(q={}));const H=L.A.div` flex: 1; position: relative; ${j.M.mbDown} { width: 100%; } `,W=L.A.div` background: #f7f9fc; border-radius: 12px; height: 48px; display: flex; align-items: center; padding: 4px 12px 4px 4px; gap: 16px; ${j.M.mbDown} { height: 48px; width: 100%; } `,Y=L.A.div` display: flex; align-items: center; flex-shrink: 0; color: #8c8c8c; svg { width: 18px; height: 18px; } `,Q=L.A.div` position: absolute; top: calc(100% + 2px); width: 100%; border-radius: 4px; background: ${O.w.colors.white}; box-shadow: 0px 8px 40px 0px rgba(0, 0, 0, 0.1); z-index: 10; ${j.M.mbDown} { width: calc(100% + 64px); left: -32px; } `,U=L.A.div``;L.A.div` display: flex; justify-content: space-between; align-item: center; padding: 9px 14px 9px 22px; background: #f7f9fc; .title { color: ${O.w.colors.gray800}; font-size: 14px; font-weight: 600; line-height: 22px; } .btn-see-all { color: ${O.w.colors.blue600}; font-size: 14px; line-height: 22px; cursor: pointer; } `;const Z=L.A.div` padding: 10px 16px; max-height: 400px; overflow: auto; `,X=L.A.div` display: flex; gap: 12px; align-items: center; cursor: pointer; ${j.M.mbUp} { &:hover { background-color: ${O.w.colors.blue50}; } } .image-item { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 50%; img { object-fit: contain; width: 100%; height: 100%; border-radius: 50%; } } .infor { overflow: hidden; padding: 12px 0; flex: 1; border-bottom: 1px solid ${O.w.colors.neutral100}; .title { color: ${O.w.colors.gray800}; font-size: 16px; font-weight: 600; line-height: 24px; } .description { overflow: hidden; color: ${O.w.colors.gray600}; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 18px; display: flex; gap: 8px; align-items: center; margin-top: 5px; svg { flex: 0 0 16px; } .sub-description { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; } } } &.last-item { .infor { border-bottom: none; } } `;L.A.div` padding: 0 16px 16px; .search-detail-btn { color: ${O.w.colors.blue600}; font-size: 14px; line-height: 22px; cursor: pointer; } `;const J=({state:e,type:t,results:a,isLoading:l,typeInformation:c,dispatch:r})=>{const{t:d}=(0,S.u)(),{selectedLocation:p}=e,u=(0,i.useMemo)((()=>c[t].slug),[c,t]);return null===a?null:o().createElement(U,null,o().createElement(Z,{className:"search-results__body"},l&&o().createElement("div",{className:"skeleton-result"},Array(3).fill(void 0).map(((e,a)=>o().createElement(X,{key:t+"loading"+a,className:2===a?"last-item":""},o().createElement("div",{className:"image-item"},o().createElement(n.E,{height:48,circle:!0,mb:"xl",animate:!0})),o().createElement("div",{className:"infor"},o().createElement("div",{className:"title"},o().createElement(n.E,{height:8,mt:10,radius:"xl",animate:!0})),o().createElement("div",{className:"description"},o().createElement("div",{className:"sub-description"},o().createElement(n.E,{height:8,mt:10,radius:"xl",width:"80%",animate:!0})))))))),!l&&a&&a.length>0&&o().createElement(o().Fragment,null,a.map(((e,i)=>{var l,n;const d=a.length>4&&3===i||a.length<=4&&i===a.length-1;let h="";return"hospital"===t&&(h=(null===e||void 0===e?void 0:e.address)||""),"doctor"===t&&(h=(null===(l=null===e||void 0===e?void 0:e.specialties)||void 0===l?void 0:l.join(", "))||""),"service"===t&&(h=(null===(n=null===e||void 0===e?void 0:e.hospital_branch)||void 0===n?void 0:n.name)||""),i>=4?o().createElement(o().Fragment,null):o().createElement(X,{key:e.id,className:(0,s.A)(d?"last-item":"","result-item"),onClick:()=>(e=>{let a="";switch(t){case"service":a=`/${p.slug}/${u}/${e.slug}`;break;case"doctor":case"hospital":a=`/${u}/${e.slug}-${e.id}`}a&&r({type:q.NavigateTo,payload:a})})(e)},o().createElement("div",{className:"image-item"},o().createElement("img",{src:e.logo||e.avatar,alt:e.name})),o().createElement("div",{className:"infor"},o().createElement("div",{className:"title"},e.name),o().createElement("div",{className:"description"},c[t].icon,o().createElement("div",{className:"sub-description"},h))))}))),!l&&0===(null===a||void 0===a?void 0:a.length)&&o().createElement($.T,{size:"sm",color:O.w.colors.gray400,className:"noresult-block"},d("booking.searchBar.noResults"))))},ee=({state:e,type:t,isLoading:a,clientSlug:i,typeInformation:l,dispatch:n})=>{var s;return"search"!==e.focused?null:o().createElement(J,{type:t,state:e,results:(null===(s=e.searchResults)||void 0===s?void 0:s[t])||null,location:e.selectedLocation.name,dispatch:n,isLoading:a,typeInformation:l,clientSlug:i})},te=L.A.div` position: relative; flex-shrink: 0; ${j.M.mbDown} { width: 100%; display: flex; flex-direction: column; gap: 12px; } &.compact { ${j.M.mbDown} { width: auto; display: block; } } `,ae=L.A.div` position: absolute; top: calc(100% + 4px); left: 0; min-width: 264px; background: white; border-radius: 12px; box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.04), 0px 2px 8px 0px rgba(0, 0, 0, 0.04), 0px 10px 16px 0px rgba(0, 0, 0, 0.04); z-index: 10; overflow: hidden; &.mobile { min-width: 280px; } `,ie=L.A.div` cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 12px; outline: none; .image-item { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex-shrink: 0; img { width: 100%; height: 100%; object-fit: contain; } svg { width: 24px; height: 24px; } } .item-label { font-size: 15px; font-weight: 400; line-height: 24px; letter-spacing: -0.3px; color: ${O.w.colors.gray800}; } &:hover { background-color: ${O.w.colors.neutral50}; } &.selected { background-color: ${O.w.colors.neutral50}; } &:last-child { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; } `,oe=()=>o().createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o().createElement("path",{d:"M8.983 14.333q-1.666 0-2.833-1.166Q4.983 12 4.983 10.333v-.366a3.48 3.48 0 0 1-2.258-1.2 3.57 3.57 0 0 1-.909-2.434V3.1a.58.58 0 0 1 .175-.425.58.58 0 0 1 .425-.175h1.4v-.167a.486.486 0 0 1 .5-.5q.217 0 .36.142a.5.5 0 0 1 .14.358v1.334a.485.485 0 0 1-.5.5.484.484 0 0 1-.5-.5V3.5h-1v2.833q0 1.1.784 1.884Q4.383 9 5.483 9t1.883-.783.784-1.884V3.5h-1v.167a.485.485 0 0 1-.5.5.484.484 0 0 1-.5-.5V2.333a.486.486 0 0 1 .5-.5q.217 0 .358.142a.5.5 0 0 1 .142.358V2.5h1.4a.58.58 0 0 1 .425.175.58.58 0 0 1 .175.425v3.233q0 1.4-.908 2.434a3.5 3.5 0 0 1-2.259 1.2v.366q0 1.25.875 2.126a2.9 2.9 0 0 0 2.125.874q1.25 0 2.125-.874a2.9 2.9 0 0 0 .875-2.126V9.25a1.74 1.74 0 0 1-.858-.609 1.6 1.6 0 0 1-.342-1.008q0-.716.5-1.216t1.2-.5q.716 0 1.217.5.5.5.5 1.216 0 .567-.342 1.008t-.875.609v1.083q0 1.667-1.167 2.834-1.166 1.166-2.833 1.166m3.5-6q.3 0 .509-.208a.67.67 0 0 0 .208-.492q0-.3-.208-.508a.7.7 0 0 0-.509-.208q-.3 0-.5.208a.7.7 0 0 0-.2.508q0 .284.2.492t.5.208",fill:"#595959"})),le=()=>o().createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o().createElement("path",{d:"M6.868 9.265v.974q0 .405.284.69.284.283.69.283t.69-.284.284-.69v-.973h.973q.405 0 .69-.284a.94.94 0 0 0 .284-.689.94.94 0 0 0-.284-.69.94.94 0 0 0-.69-.284h-.973v-.974a.94.94 0 0 0-.284-.69.94.94 0 0 0-.69-.284.94.94 0 0 0-.689.284.94.94 0 0 0-.285.69v.974h-.973a.94.94 0 0 0-.69.283.94.94 0 0 0-.284.69q0 .405.284.69.285.284.69.284zm-3.46 4.868q-.581 0-.994-.413A1.36 1.36 0 0 1 2 12.725v-6.65a1.4 1.4 0 0 1 .563-1.127l4.434-3.333q.369-.282.844-.282.474 0 .846.282l4.434 3.333q.264.193.413.493.15.3.15.633v6.651q0 .58-.414.995a1.36 1.36 0 0 1-.994.413zm0-1.168h8.868q.105 0 .172-.068a.23.23 0 0 0 .068-.172v-6.65a.2.2 0 0 0-.027-.11.3.3 0 0 0-.07-.085L7.983 2.554a.2.2 0 0 0-.142-.052.2.2 0 0 0-.142.052L3.266 5.88a.3.3 0 0 0-.071.086.2.2 0 0 0-.027.108v6.651q0 .105.068.172a.23.23 0 0 0 .172.068",fill:"#595959"})),ne=()=>o().createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o().createElement("path",{d:"M8 8q.55 0 .941-.392.393-.391.392-.941 0-.55-.392-.942A1.28 1.28 0 0 0 8 5.333q-.55 0-.942.392a1.28 1.28 0 0 0-.391.942q0 .55.391.941Q7.45 8 8 8m0 4.9q2.032-1.866 3.017-3.392Q12 7.983 12 6.8q0-1.817-1.158-2.975Q9.682 2.667 8 2.667T5.158 3.825Q4 4.983 4 6.8q0 1.184.983 2.708Q5.966 11.034 8 12.9m0 1.517a.8.8 0 0 1-.5-.183q-2.433-2.151-3.633-3.992T2.667 6.8q0-2.5 1.608-3.983Q5.883 1.332 8 1.333q2.116 0 3.725 1.484T13.333 6.8q0 1.6-1.2 3.442-1.2 1.841-3.633 3.991a.8.8 0 0 1-.5.184",fill:"#8C8C8C"})),se=()=>o().createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16"},o().createElement("path",{d:"M3.833.5a3.333 3.333 0 1 0 0 6.667 3.333 3.333 0 0 0 0-6.667M10.5.5c-.92 0-1.667.746-1.667 1.667V5.5c0 .92.746 1.667 1.667 1.667h3.333c.921 0 1.667-.746 1.667-1.667V2.167C15.5 1.246 14.754.5 13.833.5zM3.833 8.833a3.333 3.333 0 1 0 0 6.667 3.333 3.333 0 0 0 0-6.667m8.334 0a3.333 3.333 0 1 0 0 6.667 3.333 3.333 0 0 0 0-6.667",fill:"#9AA2AC"})),ce=({state:e,isMobile:t,onSpecialtyClick:a,dispatch:n,isCompact:s=!1})=>{const{t:u,locale:h}=(0,S.u)(),g=(0,i.useRef)(null),m=(0,i.useRef)(null),b=(0,i.useMemo)((()=>k.L[h]),[h]),[y,f]=(0,i.useState)(""),[v,{close:C,toggle:E}]=(0,x.j)(!1);(0,w.a)(g,(()=>{C(),f(""),n({type:q.ClickOutsideInputSpecialty})}));const L=(0,i.useMemo)((()=>[{name:u("booking.searchBar.allSpecialties"),id:-1,thumbnail:"",total_doctor:0,slug:b.SPECIALTIES},...e.allSpecialties]),[e.allSpecialties,u,b.SPECIALTIES]),j=(0,i.useMemo)((()=>y.trim()?L.filter((e=>e.name.toLowerCase().includes(y.toLowerCase().trim()))):L),[L,y]),I=(0,i.useMemo)((()=>e.selectedSpecialty?e.selectedSpecialty.name:""),[e.selectedSpecialty]),$=(0,i.useCallback)((e=>{a({id:e.id,name:e.name,slug:e.slug,thumbnail:e.thumbnail||"",total_doctor:0}),C(),f("")}),[a,C]),A=(0,i.useCallback)((()=>{E(),v&&f("")}),[E,v]);return o().createElement(te,{ref:g,className:s?"compact":""},o().createElement(c.a,{onClick:A,className:v?"dropdown-trigger-open":"",sx:{cursor:"pointer",position:"relative",width:s?t?96:160:"100%",flexShrink:0}},o().createElement(r.p,{readOnly:!0,value:I,placeholder:u("booking.searchPopup.specialties"),rightSection:o().createElement(M.C,{style:{width:20,height:20}}),styles:Object.assign({input:{cursor:"pointer",outline:"none","&:focus":{outline:"none"},"&:not(.mantine-Textarea-input)":{height:s||t?40:46,fontSize:s||t?(0,d.D)(14):(0,d.D)(16),paddingLeft:s?12:16,paddingRight:30,background:s?"white":"transparent",border:s?`1px solid ${O.w.colors.gray200}`:"none",borderRadius:8,letterSpacing:"-0.2px",color:O.w.colors.gray800,textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"}},rightSection:{width:30,pointerEvents:"none"}},!s&&{wrapper:{position:"relative","&:after":{content:'""',width:"1px",height:"20px",backgroundColor:O.w.colors.neutral100,position:"absolute",right:0,top:"50%",transform:"translateY(-50%)"}}})})),v&&o().createElement(ae,{className:t?"mobile":""},o().createElement(c.a,{sx:{padding:"12px 12px 8px"}},o().createElement(r.p,{ref:m,icon:o().createElement(l.A,{size:18,color:O.w.colors.gray300}),placeholder:u("booking.searchBar.placeholder.specialty"),value:y,onChange:e=>f(e.target.value),size:"md",styles:{input:{height:40,fontSize:(0,d.D)(15),paddingLeft:36,"&::placeholder":{color:O.w.colors.gray400}},icon:{width:36}}})),o().createElement(p.F.Autosize,{mah:300},0===j.length?o().createElement(c.a,{sx:{padding:"12px 16px",color:O.w.colors.gray400,fontSize:14}},u("common.noResult")):j.map((t=>{var a,i;return o().createElement(ie,{key:t.id,tabIndex:0,role:"option","aria-selected":(null===(a=e.selectedSpecialty)||void 0===a?void 0:a.id)===t.id,className:(null===(i=e.selectedSpecialty)||void 0===i?void 0:i.id)===t.id?"selected":"",onClick:()=>$(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),$(t))}},o().createElement("div",{className:"image-item"},t.thumbnail?o().createElement("img",{src:t.thumbnail,alt:t.name}):o().createElement(se,null)),o().createElement("span",{className:"item-label"},t.name))})))))},re=(0,i.forwardRef)((({state:e,type:t,isMobile:a,isLoading:n,initalSearchValue:s,typeInformation:c,debouncedFetchSearchResults:p,trackingAttributes:u,hideSpecialtySelection:h=!1,clientSlug:g="",onSearch:m,onFocusInput:b,onEnterSearch:y,dispatch:f,onlyShowSearchBox:x,onChangeSpecialty:v},C)=>{const{t:E}=(0,S.u)(),k=(0,i.useRef)(null),L=(0,i.useRef)(null);(0,i.useImperativeHandle)(C,(()=>({focus:()=>{var e;null===(e=L.current)||void 0===e||e.focus()}})));const j=(0,i.useMemo)((()=>u?{"data-event-category":u.dataEventCategory,"data-event-action":u.dataEventAction,"data-event-label":u.dataEventLabel}:{}),[u]),I=(0,i.useMemo)((()=>"doctor"===t?E("booking.searchBar.placeholder.doctor"):"service"===t?E("booking.searchBar.placeholder.service"):"hospital"===t?E("booking.searchBar.placeholder.hospital"):"specialty"===t?E("booking.searchBar.placeholder.specialty"):""),[t,E]),$="specialty"!==t&&"service"!==t&&!h&&!x,M=(0,i.useMemo)((()=>({input:{border:"none",background:"transparent",height:"100%",fontSize:(0,d.D)(16),color:O.w.colors.gray800,padding:"0","&::placeholder":{color:O.w.colors.gray400},"&:focus":{outline:"none",boxShadow:"none"},[a?"@media (max-width: 767px)":""]:a?{fontSize:(0,d.D)(16)}:{}},wrapper:{flex:1}})),[a]);(0,w.a)(k,(()=>{!a&&f({type:q.ClickOutsideInputSearch})}));const A=(0,i.useCallback)((function(a){f({type:q.ChangeInputSearch,payload:a}),"function"!==typeof m&&(a.trim().length>N[e.locale]||s||0===a.trim().length)&&p(a.trim(),e,t,g)}),[f,e,t,s,p,g,m]),R=(0,i.useCallback)((function(e){var t;f({type:q.SelectSpecialty,payload:e}),null===v||void 0===v||v(e),!a&&(null===(t=L.current)||void 0===t||t.focus())}),[f,v]),T=(0,i.useCallback)((e=>{"Enter"===e.key&&(e.stopPropagation(),e.preventDefault(),y&&y())}),[y]);return o().createElement(H,{ref:k},o().createElement(W,null,$&&o().createElement(ce,{state:e,isMobile:a,dispatch:f,debouncedFetchSearchResults:p,onSpecialtyClick:R,isCompact:!0}),o().createElement(Y,null,o().createElement(l.A,null)),o().createElement(r.p,Object.assign({ref:L,variant:"unstyled",size:a?"md":"lg",placeholder:I,styles:M,value:e.searchKeywords,name:"search-results",autoComplete:"off",onFocus:()=>{f({type:q.FocusInputSearch}),null===b||void 0===b||b()},onChange:e=>{A(e.target.value)},onKeyDown:T},j))),!a&&"specialty"!==t&&o().createElement(Q,null,o().createElement(ee,{type:t,state:e,dispatch:f,isLoading:n,typeInformation:c,clientSlug:g})))}));re.displayName="SearchInputs";const de=e=>{var{searchInputEle:t,closeModal:a,children:i}=e,l=(0,A._)(e,["searchInputEle","closeModal","children"]);const n=(0,u.xd)();return o().createElement(T.M,Object.assign({},l,{zIndex:310,fullScreen:!0,styles:{content:{borderRadius:0,height:"100%",".search-results__body":{padding:0},".result-item":{paddingLeft:16,paddingRight:16},".noresult-block":{padding:16},".skeleton-result":{padding:16}},header:{display:"none"}}}),o().createElement(h.B,{spacing:16,sx:{paddingTop:16}},o().createElement(g.s,{align:"center",gap:12},o().createElement(R.A,{size:28,onClick:a,color:n.fn.primaryColor()}),o().createElement(c.a,{sx:{width:"100%"}},t)),i))},pe=L.A.div` position: relative; width: 240px; flex-shrink: 0; ${j.M.mbDown} { width: 100%; } `;L.A.div` position: absolute; top: calc(100% + 2px); width: 100%; border-radius: 4px; background: ${O.w.colors.white}; box-shadow: 0px 8px 40px 0px rgba(0, 0, 0, 0.1); z-index: 10; ${j.M.mbDown} { width: calc(100% + 64px); left: -32px; } `;const ue=L.A.div` position: relative; cursor: pointer; padding: 12px 18px; display: flex; align-items: center; gap: 14px; overflow: hidden; & + li::before { content: ''; position: absolute; left: 18px; right: 18px; top: 0; height: 1px; background-color: ${O.w.colors.neutral100}; } &:not([data-is-denied='true']):hover { background-color: ${O.w.colors.neutral50}; } &:last-child:hover { border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; } &:first-child:hover { border-top-right-radius: 6px; border-top-left-radius: 6px; } &[data-is-denied='true'] { cursor: not-allowed; } `,he=(0,L.A)(v.P)` width: 12px; height: 18px; flex: 0 0 12px; `,ge=(0,i.forwardRef)(((e,t)=>{var{label:a,value:i}=e,l=(0,A._)(e,["label","value"]);return o().createElement("div",Object.assign({ref:t},l),o().createElement(ue,{key:i,role:"button",tabIndex:0,"aria-label":`Select ${a} as location`,className:"location-item"},o().createElement(he,{color:O.w.colors.neutral400}),o().createElement(m.E,{size:"md"},a)))})),me=({state:e,debouncedFetchCitiesByKeyword:t,selectedLocation:a,trackingAttributes:l,onLocationClick:n,dispatch:s})=>{var c;const{t:r,locale:p}=(0,S.u)(),u=(0,i.useRef)(null),h=(0,i.useMemo)((()=>{var t;return[{name:r("booking.searchBar.allLocations"),id:k.I,slug:null===(t=k.L[p])||void 0===t?void 0:t.ALL},...e.cities]}),[e.cities,r,p]),g=(0,i.useMemo)((()=>l?{"data-event-category":l.dataEventCategory,"data-event-action":l.dataEventAction,"data-event-label":l.dataEventLabel}:{}),[l]),m=(0,i.useCallback)((function(a){s({type:q.ChangeInputLocation,payload:a}),a.trim().length>N[e.locale]?t(a.trim()):(t.cancel(),s({type:q.DisplayInitialCities}))}),[t,s,e.locale]);(0,w.a)(u,(()=>{s({type:q.ClickOutsideInputLocation})}));const y=null!==(c=null===a||void 0===a?void 0:a.id)&&void 0!==c?c:null,f=null===y?void 0:String(y);return o().createElement(pe,{ref:u},o().createElement(b.l6,Object.assign({key:null!==f&&void 0!==f?f:"no-selected-location",defaultValue:f,placeholder:r("booking.searchBar.allLocations"),searchable:!0,onSearchChange:e=>{m(e)},onFocus:()=>{s({type:q.DisplayInitialCities})},onDropdownClose:()=>{t.cancel(),s({type:q.DisplayInitialCities})},nothingFound:r("common.noResult"),maxDropdownHeight:340,dropdownPosition:"bottom",icon:o().createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o().createElement("path",{d:"M9.99908 10.8332C11.2264 10.8332 12.2213 9.83764 12.2213 8.61097C12.2213 7.3843 11.2264 6.38875 9.99908 6.38875C8.77174 6.38875 7.77686 7.3843 7.77686 8.61097C7.77686 9.83764 8.77174 10.8332 9.99908 10.8332Z",stroke:"#111111",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),o().createElement("path",{d:"M9.99919 18.0554C11.7584 17.4999 16.6659 13.611 16.6659 8.61097C16.6659 4.93097 13.6811 1.94431 9.99919 1.94431C6.3173 1.94431 3.33252 4.93097 3.33252 8.61097C3.33252 13.611 8.23996 17.4999 9.99919 18.0554Z",stroke:"#111111",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})),rightSection:o().createElement(M.C,{style:{width:20,height:20}})},g,{styles:()=>({item:{padding:0,"&[data-selected]":{"&, &:hover":{backgroundColor:"#F7F9FC",color:"inherit"},".location-item":{"&::after":{content:v.i,top:"50%",right:19,position:"absolute",transform:"translateY(-50%)"}}},"&[data-hovered]":{backgroundColor:"transparent"}},root:{width:"100%"},wrapper:{width:"100%"},input:{"&:not(.mantine-Textarea-input)":{height:48,fontSize:(0,d.D)(15),fontWeight:400,letterSpacing:"-0.3px",color:O.w.colors.gray1000,paddingLeft:44,paddingRight:40,background:"white",border:`1px solid ${O.w.colors.gray200}`,borderRadius:12}},icon:{width:44,paddingLeft:12},rightSection:{width:40,paddingRight:12},itemsWrapper:{padding:0},dropdown:{left:"0 !important",border:0,marginTop:4,borderRadius:12,overflow:"hidden",boxShadow:"0px 0px 1px 0px rgba(0, 0, 0, 0.04), 0px 2px 8px 0px rgba(0, 0, 0, 0.04), 0px 10px 16px 0px rgba(0, 0, 0, 0.04)","& ::-webkit-scrollbar":{width:"6px",height:"6px"}}}),itemComponent:ge,filter:()=>!0,onChange:e=>{if(null==e)return;const a=h.find((t=>String(t.id)===e));a&&(n(a),t.cancel(),s({type:q.DisplayInitialCities}),setTimeout((()=>{var e,t;null===(t=null===(e=u.current)||void 0===e?void 0:e.querySelector("input"))||void 0===t||t.blur()}),0))},data:h.map((e=>({value:String(e.id),label:e.name,city:e})))})))},be=L.A.div` display: flex; flex-wrap: wrap; row-gap: 8px; column-gap: 20px; ${j.M.mbDown} { margin-top: 12px; } `,ye=L.A.div` display: flex; align-items: center; border-radius: 8px; border: 1px solid ${O.w.colors.neutral100}; background: ${O.w.colors.white}; padding: 8px 12px 8px 8px; flex: 0 0 calc(33.3% - 13px); gap: 12px; cursor: pointer; &:hover { background: ${O.w.colors.blue50}; } ${j.M.tdDown} { flex: 0 0 calc(50% - 10px); } ${j.M.mbDown} { flex: 0 0 100%; border: none; } .image-item { display: flex; align-items: center; width: 40px; height: 40px; img { width: 100%; object-fit: cover; } } .infor { flex: 1; .title { color: ${O.w.colors.gray800}; font-size: 14px; font-style: normal; font-weight: 400; line-height: 22px; } .description { color: ${O.w.colors.gray600}; font-size: 12px; font-weight: 400; line-height: 18px; } } `,fe=(0,L.A)(y.c)` margin: 24px 0 !important; `,xe=L.A.div` display: flex; justify-content: center; margin-top: 24px; .show-more { border-radius: 4px; border: 1px solid ${O.w.colors.neutral200}; padding: 12px 16px; cursor: pointer; display: inline-block; color: ${O.w.colors.gray800}; font-size: 16px; font-weight: 600; line-height: 24px; ${j.M.mbDown} { width: 100%; text-align: center; } } `,ve=({state:e,isMobile:t,specialties:a,isLoading:l,dispatch:s})=>{const{t:c,locale:r}=(0,S.u)(),{selectedLocation:d}=e,p=(0,i.useMemo)((()=>k.L[r]),[r]),u=(0,i.useMemo)((()=>a.length>=9||e.searchKeywords.trim().length<=N[e.locale]),[e.searchKeywords,a]);return o().createElement(o().Fragment,null,!t&&o().createElement(fe,{color:"#E4E8EC"}),o().createElement(be,null,a.length>0&&!l&&o().createElement(o().Fragment,null,a.map(((e,t)=>t>=9?o().createElement(o().Fragment,null):o().createElement(ye,{key:e.id,onClick:()=>(e=>{let t="";e===k.S?(t=`/${d.slug}/${p.HOSPITAL}/${k.C.GSK}/`,s({type:q.ClickOutsideInputSearchSpecialty})):t=`/${d.slug}/${p.DOCTOR}/${e}`,s({type:q.NavigateTo,payload:t})})(e.slug)},o().createElement("div",{className:"image-item"},o().createElement("img",{src:e.thumbnail,alt:e.name})),o().createElement("div",{className:"infor"},o().createElement("div",{className:"title"},e.name)))))),0===a.length&&!l&&o().createElement($.T,{size:"sm",color:O.w.colors.gray400},c("booking.searchBar.noResults")),l&&Array(6).fill(void 0).map(((e,t)=>o().createElement(ye,{key:"loading"+t},o().createElement("div",{className:"image-item"},o().createElement(n.E,{height:40,animate:!0})),o().createElement("div",{className:"infor"},o().createElement("div",{className:"title"},o().createElement(n.E,{height:20,radius:"sm",animate:!0}))))))),u&&o().createElement(xe,null,o().createElement("div",{className:"show-more",onClick:()=>{const e=`/${p.SPECIALTIES}`;s({type:q.NavigateTo,payload:e})}},c("home.seeAll"))))},we=L.A.div` display: flex; gap: 5px; margin-top: 16px; flex-wrap: wrap; `,Se=L.A.div` color: ${O.w.colors.gray600}; font-size: 14px; font-weight: 600; line-height: 22px; padding: 4px 12px; background: ${O.w.colors.white}; border-radius: 32px; cursor: pointer; border: 1px solid ${O.w.colors.white}; margin-bottom: 5px; border-color: ${O.w.colors.neutral100}; background: #f7f9fc; &.view-all { border-radius: 32px; border-color: ${O.w.colors.blue50}; background: ${O.w.colors.blue50}; color: ${O.w.colors.blue600}; &:hover { border-color: ${O.w.colors.blue50}; background: ${O.w.colors.blue50}; color: ${O.w.colors.blue600}; } } &:hover { border-color: ${O.w.colors.neutral100}; background: #f7f9fc; } `,Ce=L.A.div` color: ${O.w.colors.gray600}; font-size: 14px; font-weight: 600; line-height: 22px; padding: 4px 0; background: ${O.w.colors.white}; border-radius: 32px; border: 1px solid ${O.w.colors.white}; margin-bottom: 5px; margin-right: 7px; `,Ee=({state:e,type:t,typeInformation:a,dispatch:l})=>{const{t:n}=(0,S.u)(),{selectedLocation:s}=e,c=(0,i.useMemo)((()=>a[t].slug),[a,t]);return o().createElement(we,null,o().createElement(Ce,null,n("booking.searchBar.popularKey")),e.popularKeys.map((e=>o().createElement(Se,{key:e.id,onClick:()=>{var t;(t=e).url&&(window.location.href=t.url)}},e.keyword))),o().createElement(Se,{className:"view-all",onClick:()=>{const e=`/${s.slug}/${c}`;e&&l({type:q.NavigateTo,payload:e})}},n("booking.searchBar.viewAll")))},ke=L.A.div` background: rgba(255, 255, 255, 0.64); backdrop-filter: blur(12px); border-bottom: 1px solid ${O.w.colors.neutral100}; `,Le=(0,L.A)(I.C)` padding: 0 16px; `,Oe=({currentTab:e,hideTabBookingSearch:t=[],hideSpecialtyTab:a,isMobile:l,setCurrentTab:n})=>{const{t:s}=(0,S.u)(),c=(0,i.useMemo)((()=>({root:{overflowY:l?"hidden":"initial",overflowX:l?"auto":"initial"},tabsList:{background:"rgba(255, 255, 255, 0)",borderBottom:"none",flexWrap:"nowrap",".mantine-Tabs-tab":{"&:last-child":{"&:after":{display:"none"}}}},tab:{padding:l?"12px 16px 12px 16px":"15px 40px 15px 40px",borderTop:"2px solid transparent",borderBottom:"none",margin:0,borderRadius:0,position:"relative",width:"auto",'&[data-active="true"]':{borderColor:"#2d87f3",backgroundColor:"#ffffff","&:after":{display:"none"},"&:before":{content:'""',width:"100%",height:"1px",position:"absolute",backgroundColor:"#ffffff",bottom:"-1px"}},"&:hover":{borderColor:"#2d87f3",backgroundColor:"#ffffff","&:before":{content:'""',width:"100%",height:"1px",position:"absolute",backgroundColor:"#ffffff",bottom:"-1px"}},"&:after":{content:'""',width:"1px",height:"24px",backgroundColor:"#E4E8EC",position:"absolute",right:"-1px"}},tabLabel:{color:"#595959",fontSize:l?"14px":"16px",fontWeight:600,lineHeight:l?"22px":"24px"}})),[l]),r=(0,i.useMemo)((()=>[{value:"hospital",label:s("booking.searchPopup.hospitals")},{value:"doctor",label:s("booking.searchPopup.doctors")},{value:"service",label:s("booking.searchPopup.services")},...a?[]:[{value:"specialty",label:s("booking.searchPopup.specialties")}]]),[a]),d=(0,i.useMemo)((()=>r.filter((e=>!t.includes(e.value)))||[]),[t,r]);return o().createElement(ke,{className:"booking-search-tab"},o().createElement(Le,null,o().createElement(f.t,{value:e,onTabChange:e=>{n(e)},styles:c},o().createElement(f.t.List,null,d.map((e=>o().createElement(f.t.Tab,{value:e.value,key:e.value},e.label)))))))};var je;!function(e){e.doctor="doctor",e.service="hospital_service",e.hospital="hospital_branch"}(je||(je={}));const Ie=e=>e.filter((e=>"string"===typeof e?"cacar-api"!==e:232!==(null===e||void 0===e?void 0:e.id)));const $e=({isMobile:e,careApiDomain:t,geoLocationPermission:a,geoLocationCoordinates:n,initialSelectedCity:s,initialSearchValue:r="",initTypeSearch:d="hospital",initSpecialty:p,careFrontDomain:u="/care",isDebug:h=!1,gaTrackingSearchBar:m,gaTrackingLocationSearch:b,autoCompleteDisabled:y=!1,inputSearchPlaceholder:f="",hideTabBookingSearch:C=[],hideSpecialtySelection:L=!1,hideSpecialtyTab:O=!1,hidePopularSearchKeys:j=!1,clientSlug:I="",triggerSearchWhenChangeFilter:$,routerPush:M,onGeoLocationPermissionChange:A,onChangeLocation:R})=>{var T;const{locale:G,t:H}=(0,S.u)(),W=(0,i.useRef)(null),Y=(0,i.useRef)(null),Q=(0,i.useRef)(null),U=(0,i.useRef)(null),[Z,X]=(0,i.useState)(d),{geoLocationPermission:J,geoLocationCoordinates:te}=(0,v.u)(),[ae,ie]=(0,i.useReducer)(V,z,(t=>Object.assign(Object.assign({},t),{isDebug:h,isMobile:e,geoLocationPermission:a||J||"unset",geoLocationCoordinates:n||te||null,searchKeywords:r,initialSelectedCity:s||null,selectedLocation:s||t.selectedLocation||null,searchLocationKeywords:(null===s||void 0===s?void 0:s.name)||t.searchLocationKeywords,autoCompleteDisabled:y,inputSearchPlaceholder:f,locale:G}))),{navigateTo:ce,focusedSpecialty:pe,searchKeywords:ue,geoLocationPermission:he,selectedLocation:ge,initialSelectedCity:be,searchResults:ye,isLoadingSearchResults:fe}=ae,{fetchCitiesByLocation:xe,fetchCitiesByKeyword:we,fetchSearchResults:Se,fetchAllSpecialties:Ce,fetchPopularKeys:ke}=function({dispatch:e,careApiDomain:t,locale:a="vi-VN",client:o=""}){const l=(0,i.useCallback)((function(i,o={}){const l=`${t}${i}`;return e({type:q.FetchCitiesStart}),fetch((0,v.h)(l,o,a),{method:"GET"}).then((e=>e.json())).then((e=>1===e._status&&e._data?null===e||void 0===e?void 0:e._data:(console.log("error loading cities",e),Promise.reject(e)))).finally((()=>e({type:q.FetchCitiesFinish})))}),[a]);return{fetchCitiesByLocation:(0,i.useCallback)((function({coordinates:t}){let i={};const n={};t&&(i={lat:t.lat,lng:t.lng}),"ms-MY"===a&&(n.noPaging=1);const s=[l(P.P.GET_CITY_BY_IP,Object.assign(Object.assign(Object.assign({},i),n),{hospitalActive:1,client:k.C.MSD===o?"":o}))];return"zh-TW"===a?s.push(l(P.P.GET_CITIES_LIST,{noPaging:1,hospitalActive:1,client:k.C.MSD===o?"":o})):s.push(l(P.P.GET_CITIES_LIST,{noPaging:1,hospitalActive:1})),Promise.all(s).then((([t,a])=>{const i=Object.assign({},t);if(a){const e=i.cities.map((e=>e.id));i.cities=i.cities.concat(a.cities.filter((t=>!e.includes(t.id))))}e({type:q.FetchCitiesByGeoIpComplete,payload:i})})).catch((e=>console.error("error loading cities by location",e)))}),[a,t,e]),fetchCitiesByKeyword:(0,i.useCallback)((function(t){return l(P.P.GET_CITIES_LIST,{keyword:t,client:o}).then((t=>{e({type:q.FetchCitiesByKeywordComplete,payload:t.cities})})).catch((e=>console.error("error loading cities by keyword",e)))}),[a,t,e]),fetchSearchResults:(0,i.useCallback)((function(i,l,n,s,c){const r="specialty"===n?`${t}${P.P.GET_SEARCH_SPECIALTY}`:`${t}${P.P.GET_SEARCH_V2}`;e({type:q.FetchSearchResultsStart});const{selectedLocation:d,geoLocationCoordinates:p,selectedSpecialty:u}=l;let h="";if(!d)return void e({type:q.FetchSearchResultsFinish});h=d.id===k.I?"":d.id;const g=(null===p||void 0===p?void 0:p.lat)||"",m=(null===p||void 0===p?void 0:p.lng)||"",b=(null===u||void 0===u?void 0:u.id)>0?null===u||void 0===u?void 0:u.id:"",y=i.trim().length>N[a]?i.trim():"";return fetch((0,v.h)(r,Object.assign({domain:t,searchType:n||"global",keyword:y,city:h===k.a?"":h,lat:g,lng:m,specialty_id:b,client_slug:k.C.MSD===s?"":s,msd:k.C.MSD===o?1:""},"doctor"===n&&{skipBooking:1}),a),{method:"GET",headers:{accept:"version=2.0.0.0"}}).then((e=>e.json())).then((e=>1===e._status&&e._data?null===e||void 0===e?void 0:e._data:Promise.reject(e))).then((t=>{let a=[];"specialty"!==n&&(a="doctor"===n?t.searches.map((e=>Object.assign(Object.assign({},e),{specialties:Ie((null===e||void 0===e?void 0:e.specialties)||[])}))):t.searches),"specialty"===n&&(a=Ie(y?(null===t||void 0===t?void 0:t.specialties)||[]:(null===t||void 0===t?void 0:t.default)||[])),e({type:q.FetchSearchResultsComplete,payload:{key:n,searches:a||[]}}),c&&e({type:q.UpdateInitialSearchResults,payload:{key:n,searches:a||[]}})})).catch((e=>{console.log("error loading search results",{url:r,error:e})})).finally((()=>e({type:q.FetchSearchResultsFinish})))}),[a,t,e]),fetchAllSpecialties:(0,i.useCallback)((function(){const i=`${t}${P.P.GET_SEARCH_SPECIALTY}`;return fetch((0,v.h)(i,{domain:t,searchType:"",msd:k.C.MSD===o?1:""},a),{method:"GET",headers:{accept:"version=2.0.0.0"}}).then((e=>e.json())).then((e=>1===e._status&&e._data?null===e||void 0===e?void 0:e._data:Promise.reject(e))).then((t=>{e({type:q.FetchAllSpecialties,payload:Ie(t.specialties||[])})})).catch((e=>{console.log("error loading search results",{url:i,error:e})}))}),[a,t,e]),fetchPopularKeys:(0,i.useCallback)((function(i){const o=`${t}${P.P.GET_SEARCH_POPULAR_KEY}`;return fetch((0,v.h)(o,{domain:t,searchType:je[i],sort_by:"display_order",sort_order:"asc"},a)).then((e=>e.json())).then((e=>1===e._status&&e._data?null===e||void 0===e?void 0:e._data:Promise.reject(e))).then((t=>{e({type:q.FetchPopularKeys,payload:t.popular_searches||[]})})).catch((e=>{console.log("error loading search results",{url:o,error:e})}))}),[a,t,e])}}({dispatch:ie,locale:G,careApiDomain:t,client:I}),Le=(0,i.useMemo)((()=>k.L[G]),[G]),[$e,{close:Me,open:Ae}]=(0,x.j)(!1),Re=(0,i.useMemo)((()=>Object.assign({doctor:{name:H("booking.searchPopup.doctors"),icon:o().createElement(oe,null),slug:Le.DOCTOR},service:{name:H("booking.searchPopup.services"),icon:o().createElement(le,null),slug:Le.SERVICE},hospital:{name:H("booking.searchPopup.hospitals"),icon:o().createElement(ne,null),slug:Le.HOSPITAL}},!O&&{specialty:{name:H("booking.searchPopup.specialties"),icon:o().createElement(se,null),slug:Le.SPECIALTIES}})),[Z]),Te=(0,i.useMemo)((()=>E()(we,400)),[we]),Pe=(0,i.useMemo)((()=>E()(Se,400)),[Se]),Fe=(0,i.useCallback)((function({locationSlug:e,specialtyId:t}={}){var a;Me();let i="";const{slug:o}=Re[Z];let l="";const n=k.M[G][I],s=t||(null===(a=ae.selectedSpecialty)||void 0===a?void 0:a.id)||-1,c=e||(null===ge||void 0===ge?void 0:ge.slug)||"";("doctor"===Z||"hospital"===Z)&&s>0&&(l=`&specialtyId=${s}`),i="specialty"===Z?`/${o}`:`/${c}/${o}`,n&&(i+=`/${n}`),i+=`?q=${ue}${l}`,i&&ie({type:q.NavigateTo,payload:i})}),[I,Me,Z,ie,G,ue,null===ge||void 0===ge?void 0:ge.slug,null===(T=ae.selectedSpecialty)||void 0===T?void 0:T.id,Re]),De=(0,i.useCallback)((function(e){$&&Fe({locationSlug:e.slug}),ie({type:q.SelectLocation,payload:e}),R&&R(e)}),[ie,e,R,Fe,$]);(0,w.a)(U,(()=>{!e&&ie({type:q.ClickOutsideInputSearchSpecialty})})),(0,i.useEffect)((()=>{var t;"denied"===he||be||ie({type:q.SelectLocation,payload:{name:H("booking.searchBar.allLocations"),id:k.I,slug:null===(t=k.L[G])||void 0===t?void 0:t.ALL}}),A&&A(he,ae.geoLocationCoordinates),e&&"granted"===he&&ge&&ie({type:q.FocusInputSearch}),xe({coordinates:ae.geoLocationCoordinates})}),[he]),(0,i.useEffect)((()=>{var e;const t=p||{name:H("booking.searchBar.allSpecialties"),id:-1,thumbnail:"",total_doctor:0,slug:Le.SPECIALTIES};p?(null===(e=ae.selectedSpecialty)||void 0===e?void 0:e.id)!==p.id&&ie({type:q.SelectSpecialty,payload:p}):ae.selectedSpecialty&&ae.selectedSpecialty.id===t.id||ie({type:q.SelectSpecialty,payload:t})}),[p,Le.SPECIALTIES,H]),(0,i.useEffect)((()=>{Ce()}),[]),(0,i.useEffect)((()=>{ke(Z)}),[Z]),(0,i.useEffect)((()=>{ce&&(M?M(ce):window.location.href=`${u}${ce}`)}),[ce]),(0,i.useEffect)((()=>{Se(ae.searchKeywords,ae,Z,I,!0)}),[Z]),(0,i.useEffect)((()=>{if($e&&e){const e=setTimeout((()=>{var e;null===(e=Q.current)||void 0===e||e.focus()}),150);return()=>clearTimeout(e)}}),[$e,e]);const Be={type:Z,isMobile:e,state:ae,dispatch:ie,debouncedFetchSearchResults:Pe,initalSearchValue:r,onEnterSearch:Fe,typeInformation:Re,trackingAttributes:m,isLoading:fe,hideSpecialtySelection:L||O,clientSlug:I,triggerSearchWhenChangeFilter:$,onChangeSpecialty:e=>$&&Fe({specialtyId:e.id})};return o().createElement(o().Fragment,null,o().createElement(D,{ref:W},o().createElement(Oe,{currentTab:Z,setCurrentTab:X,isMobile:e,hideTabBookingSearch:C,hideSpecialtyTab:O}),o().createElement(B,{className:"booking-search-container"},o().createElement(_,null,o().createElement(K,{className:"booking-search-content"},o().createElement("div",{ref:U},o().createElement(g.s,{gap:"12px",align:"center",className:"flex-search-input"},o().createElement(re,Object.assign({},Be,{ref:Y,onFocusInput:()=>e&&Ae()})),"specialty"!==Z&&o().createElement(me,{state:ae,isMobile:e,dispatch:ie,debouncedFetchCitiesByKeyword:Te,selectedLocation:ge,onLocationClick:De,trackingAttributes:b}),!e&&o().createElement(F.B,{size:"lg",variant:"primary",onClick:()=>Fe(),styles:{root:{height:"48px",minWidth:"120px",borderRadius:"12px"}}},H("booking.searchBar.searchButton"))),!j&&"specialty"!==Z&&ae.popularKeys.length>0&&o().createElement(Ee,{type:Z,state:ae,typeInformation:Re,dispatch:ie}),"specialty"===Z&&"search"===pe&&o().createElement(ve,{state:ae,isMobile:e,dispatch:ie,specialties:(null===ye||void 0===ye?void 0:ye.specialty)||[],isLoading:fe})))))),e&&o().createElement(de,{keepMounted:!0,opened:$e,onClose:Me,closeModal:Me,searchInputEle:o().createElement(g.s,{align:"center",gap:8},o().createElement(re,Object.assign({},Be,{onlyShowSearchBox:!0,ref:Q})),o().createElement(F.B,{variant:"primary",leftIcon:o().createElement(l.A,{size:20,color:"#fff"}),onClick:()=>Fe(),styles:{root:{borderRadius:"12px"}}}))},o().createElement(c.a,{sx:{marginLeft:-16,marginRight:-16}},o().createElement(ee,{type:Z,state:ae,dispatch:ie,isLoading:fe,typeInformation:Re,clientSlug:I}))))};L.A.div` background-color: var(--neutral50); padding: 12px 0; box-shadow: inset 0px 1px 0px #e4e8ec; > * { display: grid; grid-template-columns: 32px 1fr; align-content: center; p { font-weight: 600; } } .icon-wrapper { display: flex; align-items: center; } `}}]);