1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8267],{8267:function(t,o,e){e.r(o),e.d(o,{default:function(){return p},sortDoctorsByNearestHospital:function(){return h}});var l=e(5893),a=e(7294),n=e(4292),i=e(5973),c=e(8960),r=e(6887),s=e(1163),u=e(8926),d=e(4200),m=e(9808);function p(t){let{title:o,filterWrapper:e,doctorList:p,useElasticSearch:v=!0,hospitalData:f,interestQuery:b}=t;var g,y;const[S,x]=(0,a.useState)(null),[j,k]=(0,a.useState)(null),[N,w]=(0,a.useState)(null),[E,L]=(0,a.useState)({}),[C,M]=(0,a.useState)("byTitle"),[T,I]=(0,a.useState)(null),A=(0,s.useRouter)(),{query:O}=A,P=null!==b&&void 0!==b?b:O.interests;var z;const _=null!==(z=p.initialVisibleItems)&&void 0!==z?z:9,[V,q]=(0,a.useState)(_),{t:D}=(0,r.$G)("common"),F=null===(g=p.doctors)||void 0===g?void 0:g.filter((t=>t.name)).map((t=>t.name)),J=async t=>{try{const o=await fetch("/api/doctors/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({filters:{...E,interests:t?null:null!==P&&void 0!==P?P:null,name:null!==t&&void 0!==t?t:null},isStrict:!0,size:V,location:T,sortOption:C,culture:"tr"===A.locale?"tr":"en-US"})});if(!o.ok)throw new Error("Elasticsearch error: ".concat(o.statusText));const e=await o.json();if(x(e.total),localStorage.setItem("doc_info","docCount=".concat(JSON.stringify(e.total),"&page=").concat(A.asPath)),"nearest"===C&&T){const t=h(e.doctors,T);return void k(t)}k(e.doctors)}catch(o){console.error("Error fetching doctors:",o),k(null),x(null)}},Z=async t=>{try{const o=await fetch("/api/doctors/filters/",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({filters:{...E,interests:t?null:null!==P&&void 0!==P?P:null,name:null!==t&&void 0!==t?t:null},culture:"tr"===A.locale?"tr":"en-US"})});if(!o.ok)throw new Error("Elasticsearch error: ".concat(o.statusText));const e=await o.json();w(e.hospitals)}catch(o){console.error("Error fetching doctors:",o),w(null)}};(0,a.useEffect)((()=>{v?(Z(),J()):F&&F.length>0&&(Z(F),J(F))}),[A]),(0,a.useEffect)((()=>{P&&v&&(q(_),Z(),J())}),[P]),(0,a.useEffect)((()=>{v?J():F&&F.length>0&&J(F)}),[E,V,C]);var B;return j&&j.length>0&&(0,l.jsxs)("div",{className:"container py-7 lg:pb-16 lg:pt-0",id:"doctors",children:[(0,l.jsx)(n.Z,{as:"p",weight:"semibold",className:"mb-4 text-h-sub1 text-navy700 lg:text-h4",children:o}),(0,l.jsx)(i.default,{className:"p-0",...e,dropdownFilters:[{label:D("common:locationLabel"),id:"location",mobileCta:{cancelLabel:D("common:cancelLabel"),submitLabel:D("common:applyLabel")},options:[{label:D("common:allHospitalsLabel"),value:"all"},...null!==(B=null===N||void 0===N?void 0:N.map((t=>({label:t.key,value:t.key}))))&&void 0!==B?B:[]]}],onSelect:t=>{if(t.location){if("all"===t.location[0].value)return void L({hospital:void 0});L({hospital:t.location[0].value})}},locationPicker:{label:D("common:locationPickerLabel"),onClick:t=>{(t=>{if(M("nearest"),I(t),t&&j){const o=h(j,t);k(o)}})(t)}}}),(0,l.jsx)("div",{className:"mt-4 grid h-full grid-cols-1 gap-6 pb-10 md:grid-cols-2 lg:grid-cols-3 lg:pb-0",children:j&&(null===(y=(0,c.z)(j,D))||void 0===y?void 0:y.slice(0,V).map(((t,o)=>{const e=t.location.locations.map((t=>{const o=null===f||void 0===f?void 0:f.find((o=>o.hospitalName===t.label));return(null===o||void 0===o?void 0:o.hospitalImage)?{...t,image:{src:"".concat("https://yenicms.acibadem.com.tr").concat(null===o||void 0===o?void 0:o.hospitalImage),alt:t.label}}:t}));return(0,l.jsx)(u.Z,{...t,location:{...t.location,locations:e},href:t.href,className:"min-h-full",layout:"grid"},"".concat(o,"-doctor"))})))}),j&&S&&S>V&&(0,l.jsx)(d.Z,{justify:"center",className:"lg:mt-8",children:(0,l.jsxs)(m.z,{variant:"primary",color:"gray",size:"large",onClick:()=>{q(Math.min(V+9,S))},icon:{position:"right",name:"chevron-down"},children:[D("common:showMoreLabel")," ",S&&" (".concat(S-V,")")]})})]})}function h(t,o){return t.map((t=>{var e,l;const a=null!==(l=null===t||void 0===t||null===(e=t.hospitals)||void 0===e?void 0:e.map((t=>{const e=null===t||void 0===t?void 0:t.latitude,l=null===t||void 0===t?void 0:t.longitude;return null==e||null==l?1/0:function(t,o,e,l){const a=t=>t*Math.PI/180,n=a(t),i=a(e),c=a(e-t),r=a(l-o),s=Math.sin(c/2)*Math.sin(c/2)+Math.cos(n)*Math.cos(i)*Math.sin(r/2)*Math.sin(r/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(o.latitude,o.longitude,e,l)})))&&void 0!==l?l:[1/0];return{doctor:t,distance:Math.min(...a)}})).sort(((t,o)=>t.distance-o.distance)).map((t=>t.doctor))}},8960:function(t,o,e){e.d(o,{z:function(){return l}});const l=(t,o,e,l)=>{const a="https://yenicms.acibadem.com.tr";return t.map((t=>{var n;let i=t.hospitals.map((t=>{var o;return{label:t.name,href:t.route,location:null===(o=t.name)||void 0===o?void 0:o.split(" ")[0],image:{src:"".concat(a).concat(t.image)}}}));var c;let r=null!==(c=null===(n=t.units)||void 0===n?void 0:n.map((t=>t.name)))&&void 0!==c?c:[];if(e&&(i=[...i.filter((t=>t.label===e)),...i.filter((t=>t.label!==e))]),l)if("string"===typeof l){const t=r.findIndex((t=>t===l));t>-1&&(r=[r[t],...r.slice(0,t),...r.slice(t+1)])}else if(Array.isArray(l)){const t=[];l.forEach((o=>{const e=r.findIndex((t=>t===o));e>-1&&!t.includes(r[e])&&t.push(r[e])}));const o=r.filter((o=>!t.includes(o)));r=[...t,...o]}return{variant:"vertical",personnelCode:t.personnelCode,name:[t.doctorTitle,t.doctorName,t.doctorSurname].join(" "),branch:r,experience:{icon:"book-closed",label:t.totalExperienceYears},location:{icon:"marker-pin",locations:i,dialogTitle:""},image:{src:"".concat(a).concat(t.profilImage),alt:t.doctorName},cta:{label:o("common:appointmentButtonLabel"),href:t.route},href:t.route,availableDate:{icon:"clock",date:"",time:""},isVideoCallAvailable:{falseLabel:o("common:notAvailableForVideoCallLabel"),trueLabel:o("common:availableForVideoCallLabel"),icon:"video-recorder"}}}))}}}]);
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.