"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[270],{w9K1:function(e,t,o){o.d(t,{p:function(){return TogetherCommentPopupContext}});var i=o("BGKE"),n=o("aZjv"),a=o("F12M");let TogetherCommentPopupContext=e=>{let{children:t}=e;return(0,i.tZ)(a.hA,{children:(0,i.tZ)(n.I_,{defaultParams:{action:"comment"},children:t})})};TogetherCommentPopupContext.displayName="TogetherCommentPopupContext"},F12M:function(e,t,o){o.d(t,{$S:function(){return v},J9:function(){return u},Kg:function(){return C},O0:function(){return r},OT:function(){return h},Q1:function(){return b},Uu:function(){return g},VO:function(){return c},VZ:function(){return f},YJ:function(){return p},e8:function(){return s},hA:function(){return l},kS:function(){return d},kx:function(){return y},qT:function(){return m},tR:function(){return x}});var i=o("rBCA"),n=o("uuQu"),a=o("iBNF");let l=(0,i.Z)("div",{target:"egqqgcb0"})(".popup-comment-danger{.popup-frame{> [data-open='true'][data-type='confirm']{z-index:600;}}}.post-reaction{padding:8px 16px;}"),r=(0,i.Z)("div",{target:"egqqgcb1"})("position:fixed;z-index:100;top:0;height:100%;display:flex;flex-direction:column;width:100vw;max-width:436px;right:0;box-shadow:0px 24px 32px rgba(0,0,0,0.04),0px 16px 24px rgba(0,0,0,0.04),0px 4px 8px rgba(0,0,0,0.04),0px 0px 1px rgba(0,0,0,0.04);",n.M.mbDown,"{left:0;max-width:100vw;}background:white;overflow-y:scroll;::-webkit-scrollbar{display:none;}.create-edit-container{width:100%;background:white;flex:1;overflow-y:auto;.create-post-popup-container{",n.M.mbDown,"{padding:0;}}}"),d=(0,i.Z)("div",{target:"egqqgcb2"})("display:flex;width:100%;height:60px;flex-shrink:0;align-items:center;justify-content:center;border-bottom:1px solid ",a.r.colors.neutral100,";background-color:white;padding:12px 24px;gap:16px;justify-content:space-between;",n.M.mbUp,"{max-width:436px;}.comment-popup-back-button{position:absolute;left:16px;.button-back{line-height:10px;width:24px;height:24px;img{width:1rem;height:1rem;}}}"),c=(0,i.Z)("div",{target:"egqqgcb3"})("cursor:pointer;"),s=(0,i.Z)("div",{target:"egqqgcb4"})("width:100%;flex:1;overflow-y:auto;background:",a.r.colors.neutral50,";"),m=(0,i.Z)("div",{target:"egqqgcb5"})("display:flex;justify-content:space-between;margin-bottom:12px;cursor:pointer;min-height:40px;.button-reply-comment{width:40px;height:40px;padding:10px;line-height:0;display:flex;justify-content:center;align-items:center;&[data-size='md']{padding:10px;line-height:0;}}.input-reply-icon{width:24px;height:24px;margin-top:auto;margin-bottom:auto;margin-right:8px;}.input-reply-comment{margin-right:8px;margin-top:auto;margin-bottom:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.5;color:",a.r.colors.gray400,";}svg{top:25px;width:20px;height:20px;}"),p=(0,i.Z)("div",{target:"egqqgcb6"})("display:flex;padding:0 8px;flex:1;border:solid 1px ",a.r.colors.gray200,";border-radius:",a.r.borderRadius,";margin-left:8px;/* set min width here to prevent overflow horizontal */\n min-width:0;&[data-is-focus]{padding:0 0 0 8px;border-color:",a.r.colors.primaryBase,";box-shadow:0px 0px 2px 2px ",a.r.colors.primary200,";}"),u=(0,i.Z)("div",{target:"egqqgcb7"})("width:100%;padding:16px;background:white;",n.M.mbUp,"{max-width:436px;}.join-or-login{--text-color:var(--custom-color,#262626);color:var(--text-color);font-size:14px;line-height:22px;",n.M.mbUp,"{font-size:16px;line-height:24px;}a{color:",a.r.colors.primaryActive,";cursor:pointer;text-decoration:none;}}"),g=(0,i.Z)("div",{target:"egqqgcb8"})("height:100%;&[data-current-tab='popular']{padding:1rem 0 0 0;}&[data-current-tab='allComments']{padding:1rem 0 0 0;}.view-more-button{width:100%;}.most-engaging-wrapper .see-more-comments{padding:12px 0 !important;margin-top:4px;}"),v=(0,i.Z)("div",{target:"egqqgcb9"})("display:grid;grid-gap:15px;padding:1rem;"),h=(0,i.Z)("div",{target:"egqqgcb10"})("display:flex;flex-direction:column;align-items:center;justify-content:center;padding-left:16px;padding-right:16px;text-align:center;height:100%;.empty-comment-icon{width:80px;height:80px;}.title{margin-top:32px;color:",a.r.colors.gray800,";}.description{margin-top:8px;color:",a.r.colors.gray500,";}.login-button{margin-top:36px;background-color:#fff;}"),f=(0,i.Z)("div",{target:"egqqgcb11"})("display:flex;flex-direction:column;align-items:center;.description{color:",a.r.colors.gray500,";}.login-button{border-color:",a.r.colors.primaryActive,";margin-top:16px;color:",a.r.colors.primaryActive,";}"),y=(0,i.Z)("div",{target:"egqqgcb12"})("overflow:hidden;flex:1;display:flex;flex-direction:column;.tab-comment-popup{z-index:10;width:100%;padding-left:1rem;",n.M.mbUp,"{max-width:426px;}background-color:white;li{div{p{font-size:13px;font-weight:600;}}&[data-is-tab-active='true']{border-bottom-width:2px;div{p{font-weight:700;}}}}}"),b=(0,i.Z)("div",{target:"egqqgcb13"})(),x=(0,i.Z)("div",{target:"egqqgcb14"})("display:flex;"),C=(0,i.Z)("div",{target:"egqqgcb15"})("display:flex;flex-direction:column;/* align-items:center;*/\n justify-content:center;")},RHJW:function(e,t,o){o.r(t),o.d(t,{TogetherCommentPopup:function(){return TogetherCommentPopup}});var i=o("BGKE"),n=o("q1tI"),a=o("LgdP"),l=o("DEkF"),r=o("xOoI"),d=o("mihF"),c=o("ohJh"),s=o("dDsW"),m=o("a5vB"),p=o("09QT"),u=o("/tR3"),g=o("oQBk"),v=o("YwJy"),h=o("raAP"),f=o("hXNO"),y=o("rIrU"),b=o("CF0j"),x=o("o0qI"),C=o("tjQ2"),Z=o("aNTj"),E=o("Fo2T"),P=o("zPX9"),k=o("uDqF"),w=o("Zr8O"),T=o("nXqV"),_=o("ECoa"),B=o("F12M");let CardCommentSkeleton=()=>(0,i.BX)(B.Q1,{children:[(0,i.BX)(B.tR,{children:[(0,i.tZ)(_.Z,{circle:!0,height:32,width:32,style:{marginRight:"10px"}}),(0,i.BX)(B.Kg,{children:[(0,i.tZ)(_.Z,{height:10,width:100}),(0,i.tZ)(_.Z,{height:10,width:60})]})]}),(0,i.tZ)(_.Z,{style:{marginTop:"8px"},count:5})]});var M=o("8wjV");let CommentDetail=e=>{let{post:t,openEditPostPopup:o,cityId:a}=e,{setCareType:l,setOpenQuickBookingDrawer:d,setData:c}=(0,w.B)(e=>e,m.X),[u,v]=(0,n.useState)(!1),[h,y]=(0,n.useState)(t||null),[b,x]=(0,n.useState)(!1),{formatMessage:C}=(0,s.Z)(),Z=(0,f.d)(),_=[{label:C({id:"commentPopup.choicePopover.latest",defaultMessage:"Latest"}),value:"newest"},{label:C({id:"commentPopup.choicePopover.oldest",defaultMessage:"Oldest"}),value:"oldest"}],[S,A]=(0,n.useState)({label:C({id:"commentPopup.choicePopover.latest",defaultMessage:"Latest"}),value:"newest"}),[I,O]=(0,n.useState)([]),D=(0,n.useRef)(null),[N,L]=(0,n.useState)({current:0,first:1,last:1,next:1,prev:1,total_items:0,items_per_page:10}),fetchMoreComments=async(e,t)=>{if(!u&&(null==h?void 0:h.id)){v(!0);try{var o,i,n,a;let l=await (0,p.d)(g.y.TOGETHER.GET_TOGETHER_POST_COMMENT,{params:{postId:h.id,sort:t||"newest",page:void 0!==e?e:N.next}},"together");1===e?O((null==l?void 0:null===(a=l.data)||void 0===a?void 0:null===(n=a.comments)||void 0===n?void 0:null===(i=n.map)||void 0===i?void 0:i.call(n,E.d.formatComment))||[]):O(e=>{var t,o,i;return e.concat((null==l?void 0:null===(i=l.data)||void 0===i?void 0:null===(o=i.comments)||void 0===o?void 0:null===(t=o.map)||void 0===t?void 0:t.call(o,E.d.formatComment))||[])}),L(null==l?void 0:null===(o=l.data)||void 0===o?void 0:o.pagination)}catch(e){console.log(e)}v(!1)}},fetchPost=async e=>{var t;let o=await (0,p.d)(g.y.TOGETHER.GET_TOGETHER_POST_DETAIL,{params:{idOrSlug:e}},"together");(null==o?void 0:null===(t=o.data)||void 0===t?void 0:t.id)&&(y(E.d.formatPost(null==o?void 0:o.data)),x(e=>!e))};if((0,n.useEffect)(()=>{fetchMoreComments(1)},[null==h?void 0:h.id]),(0,n.useEffect)(()=>{(null==t?void 0:t.id)&&fetchPost(t.id)},[t.id]),!h)return(0,i.tZ)(P.L,{});let handleMakeAppointment=async(e,t)=>{if(e){let t=await (0,p.d)(g.y.CARE.GET_DOCTOR_DETAIL,{params:{id:e}},"care"),o=t._data.doctor,i={cityId:a||0,specialty:o.specialties[0],doctor:o,hospital:o.hospital_branch};l(T.y.DOCTOR),c(i),d(!0)}if(t){var o,i,n,r,s,m;let e=await (0,p.d)(g.y.CARE.GET_HOSPITAL_DETAIL,{params:{id:t}},"care"),u=e._data.branch,v=await (0,p.d)(g.y.CARE.GET_BRANCH_DETAIL,{params:{id:t,type:u.total_available_doctor>0?"doctor":"service"}},"care"),h=null==v?void 0:null===(o=v._data)||void 0===o?void 0:o.searches;if(null==h?void 0:h[0]){if(u.total_available_doctor>0){let e={cityId:a||0,specialty:h[0].specialties_transform[0],doctor:h[0],hospital:h[0].hospital_branch};l(T.y.DOCTOR),c(e),d(!0)}else if(u.total_available_service>0){let e={cityId:a||0,serviceType:{id:h[0].service_id,name:h[0].name,logo:h[0].logo,slug:h[0].slug},service:{id:null===(i=h[0].hospital_branch)||void 0===i?void 0:i.id,name:null===(n=h[0].hospital_branch)||void 0===n?void 0:n.name,logo:null===(r=h[0].hospital_branch)||void 0===r?void 0:r.logo,price:null===(s=h[0].hospital_branch)||void 0===s?void 0:s.price,priceUnit:(null===(m=h[0].hospital_branch)||void 0===m?void 0:m.price_unit)||"",serviceId:h[0].id}};l(T.y.SERVICE),c(e),d(!0)}}}};return(0,i.tZ)(B.kx,{children:(0,i.tZ)(B.e8,{children:(0,i.BX)(B.Uu,{children:[(0,i.tZ)(r.C,{hasQuickBookingEnable:!0,handleMakeAppointment:handleMakeAppointment,post:{...h,isPin:!1},style:{marginBottom:8},verticalReactions:!0,onCommentCountClick:()=>{var e;return null===(e=D.current)||void 0===e?void 0:e.scrollIntoView()},onDeletePost:()=>!1,onEditPost:()=>o&&o(h),onPostCommentSuccess:e=>{(null==S?void 0:S.value)==="oldest"?O(t=>t.concat(e)):O(t=>[e].concat(t))}},"".concat(h.id,"-").concat(b)),u?(0,i.tZ)("div",{style:{padding:"1rem"},children:(0,i.BX)(B.$S,{children:[(0,i.tZ)(CardCommentSkeleton,{}),(0,i.tZ)(CardCommentSkeleton,{}),(0,i.tZ)(CardCommentSkeleton,{})]})}):(null==I?void 0:I.length)?(0,i.BX)(i.HY,{children:[(0,i.tZ)("div",{className:"sort-container",ref:D,children:(0,i.tZ)(k.L,{value:null==S?void 0:S.value,onChange:e=>{e!==(null==S?void 0:S.value)&&(A(_.find(t=>t.value===e)),fetchMoreComments(1,e))},className:"label-sorting",leftLabel:Z?(null==S?void 0:S.label)||"":C({id:"commentPopup.comment.count",defaultMessage:"{count} comments"},{count:h.commentsCount}),rightLabel:Z?C({id:"commentPopup.choicePopover.sort",defaultMessage:"Sort"}):(null==S?void 0:S.label)||"",choices:_})}),(0,i.BX)("div",{style:{padding:"0 1rem 1rem"},children:[I.map(e=>(0,i.tZ)(r.b,{hasQuickBookingEnable:!0,handleMakeAppointment:handleMakeAppointment,className:"post-comment",post:h,comment:e,style:{marginBottom:8},onDeleteComment:()=>{O(t=>t.filter(t=>t.id!==e.id)),L(e=>({...e,total_items:e.total_items-1}))},refetchComment:async e=>{O(t=>{let o=t.findIndex(t=>t.id===e.id);return t.splice(o,1,e),t.slice()})},disableShortenContent:!0},e.id)),N.currentfetchMoreComments(N.current+1),className:"view-more-button",children:C({id:"commentPopup.comment.seeMoreComments",defaultMessage:"See {count} more comments"},{count:N.current+1===N.last?N.total_items-N.items_per_page*N.current:N.items_per_page})}):null]})]}):null]})})})};var S=o("MmHG"),A=o("iBNF"),I=o("dxY4"),O=o("bVHi"),D=o("PXQd"),N=o("g/tz");let CommentList=e=>{let{articleId:t,openCreatePostPopup:o,openEditPostPopup:a,openPostDetail:d,cityId:c}=e,u=(0,h.U)(),[v,f]=(0,n.useState)(!1),{currentArticle:b,setTotalComment:Z}=(0,C.WM)(e=>({currentArticle:e.currentArticle,setTotalComment:e.setTotalComment,totalComment:e.totalComment}),m.X),{formatMessage:P}=(0,s.Z)(),k=[{name:P({id:"commentPopup.tabs.all"}),key:"allComments",dataEventCategory:"Ask Doctor",dataEventAction:"All Post Click",dataEventLabel:u},{name:P({id:"commentPopup.tabs.popular"}),key:"popular",dataEventCategory:"Ask Doctor",dataEventAction:"Trending Post Click",dataEventLabel:u}],[_,L]=(0,n.useState)(k[0]),{state:q}=(0,n.useContext)(x.I)||{},{setCareType:X,setOpenQuickBookingDrawer:R,setData:G}=(0,w.B)(e=>e,m.X),{userInfo:z}=q||{},U=!!(null==z?void 0:z.id),[H,j]=(0,n.useState)([]),[V,Q]=(0,n.useState)(null),fetchMorePosts=async e=>{if(t&&!v){f(!0);try{var o,i,n,a;let l=await (0,p.d)(g.y.TOGETHER.GET_TOGETHER_POST_LIST,{params:{articleId:String(t),sortBy:"allComments"===_.key?"newest":"popularity",page:void 0!==e?e:(null==V?void 0:V.next)||1,ignoreCache:1}},"together");1===e?j((null==l?void 0:null===(a=l.data)||void 0===a?void 0:null===(n=a.posts)||void 0===n?void 0:null===(i=n.map)||void 0===i?void 0:i.call(n,E.d.formatPost))||[]):j(e=>{var t,o,i;return e.concat((null==l?void 0:null===(i=l.data)||void 0===i?void 0:null===(o=i.posts)||void 0===o?void 0:null===(t=o.map)||void 0===t?void 0:t.call(o,E.d.formatPost))||[])}),Q(null==l?void 0:null===(o=l.data)||void 0===o?void 0:o.pagination)}catch(e){console.log(e)}f(!1)}};(0,n.useEffect)(()=>{(null==b?void 0:b.id)===t&&V&&Z((null==V?void 0:V.total_items)||0)},[null==V?void 0:V.total_items,null==b?void 0:b.id,t]),(0,n.useEffect)(()=>{(null==b?void 0:b.id)===t&&fetchMorePosts(1)},[_.key,t,null==b?void 0:b.id]);let goToLogin=()=>{var e,t;(0,N.p0)(u+"?commentsExpanded=1","","articlecomment",(null==b?void 0:null===(e=b.primaryCategory)||void 0===e?void 0:e.permalink)||(null==b?void 0:null===(t=b.categories[0])||void 0===t?void 0:t.permalink)||void 0)},handleMakeAppointment=async(e,t)=>{if(e){let t=await (0,p.d)(g.y.CARE.GET_DOCTOR_DETAIL,{params:{id:e}},"care"),o=t._data.doctor,i={cityId:c||0,specialty:o.specialties[0],doctor:o,hospital:o.hospital_branch};X(T.y.DOCTOR),G(i),R(!0)}if(t){var o,i,n,a,l,r;let e=await (0,p.d)(g.y.CARE.GET_HOSPITAL_DETAIL,{params:{id:t}},"care"),d=e._data.branch,s=await (0,p.d)(g.y.CARE.GET_BRANCH_DETAIL,{params:{id:t,type:d.total_available_doctor>0?"doctor":"service"}},"care"),m=null==s?void 0:null===(o=s._data)||void 0===o?void 0:o.searches;if(null==m?void 0:m[0]){if(d.total_available_doctor>0){let e={cityId:c||0,specialty:m[0].specialties_transform[0],doctor:m[0],hospital:m[0].hospital_branch};X(T.y.DOCTOR),G(e),R(!0)}else if(d.total_available_service>0){let e={cityId:c||0,serviceType:{id:m[0].service_id,name:m[0].name,logo:m[0].logo,slug:m[0].slug},service:{id:null===(i=m[0].hospital_branch)||void 0===i?void 0:i.id,name:null===(n=m[0].hospital_branch)||void 0===n?void 0:n.name,logo:null===(a=m[0].hospital_branch)||void 0===a?void 0:a.logo,price:null===(l=m[0].hospital_branch)||void 0===l?void 0:l.price,priceUnit:(null===(r=m[0].hospital_branch)||void 0===r?void 0:r.price_unit)||"",serviceId:m[0].id}};X(T.y.SERVICE),G(e),R(!0)}}}},F="".concat(u).concat(u.includes("?")?"&":"?","action=comment");return(0,i.BX)(B.kx,{children:[H&&(null==H?void 0:H.length)>0&&(0,i.tZ)(D.m,{initialTab:0,onChange:e=>L(k[e]),tabContent:k,className:"tab-comment-popup"}),(0,i.tZ)(B.e8,{children:(0,i.tZ)(B.Uu,{"data-current-tab":_.key,children:v?(0,i.BX)(B.$S,{children:[(0,i.tZ)(CardCommentSkeleton,{}),(0,i.tZ)(CardCommentSkeleton,{}),(0,i.tZ)(CardCommentSkeleton,{})]}):(null==H?void 0:H.length)?(0,i.BX)(i.HY,{children:[H.map(e=>(0,i.tZ)(r.C,{hasQuickBookingEnable:!0,handleMakeAppointment:handleMakeAppointment,post:{...e,isPin:!1},showMostEngaging:!0,verticalReactions:!0,style:{marginBottom:8},onDeletePost:()=>fetchMorePosts(),onEditPost:()=>a&&a(e),onMostEngagingCommentClick:()=>{d&&d(e)},onSaveUnsaveSuccess:()=>{fetchMorePosts(1)},onCommentCountClick:()=>d&&d(e),onPostCommentSuccess:()=>d&&d(e)},e.id)),V&&V.currentfetchMorePosts(V.current+1),className:"view-more-button",children:P({id:"commentPopup.morePost",defaultMessage:"View {count} more posts"},{count:V.current+1===V.last?V.total_items-V.items_per_page*V.current:V.items_per_page})}):null]}):(0,i.BX)(B.OT,{children:[(0,i.tZ)("img",{className:"empty-comment-icon",src:"".concat(y.Nr,"/speak1.svg"),alt:"0 comments",loading:"lazy"}),(0,i.tZ)(l.H,{tag:"h3",className:"title",children:P(U?{id:"commentPopup.loggedIn.title"}:{id:"commentPopup.emptyComment.title"})}),(0,i.tZ)(S.T,{size:"p3",className:"description",children:P({id:"commentPopup.emptyComment.description"})}),!U&&(0,i.tZ)(M.B,{size:"lg",variant:"secondary",color:A.r.colors.primaryActive,className:"login-button",onClick:goToLogin,"data-event-category":"Comments","data-event-action":"Join Button","data-event-label":u,children:P({id:"commentPopup.sigupButton.joinHelloSite"})})]})})}),(0,i.tZ)(B.J9,{children:!U&&H&&(null==H?void 0:H.length)>0&&(null==H?void 0:H.length)<6?(0,i.BX)(B.VZ,{children:[(0,i.tZ)(S.T,{size:"p3",className:"description",children:P({id:"commentPopup.fewComment.p1"})}),(0,i.tZ)(S.T,{size:"p3",className:"description",children:P({id:"commentPopup.fewComment.p2"})}),!U&&(0,i.tZ)(M.B,{size:"lg",variant:"tertiary",className:"login-button pointer-event-child-none",onClick:goToLogin,"data-event-category":"Ask Doctor","data-event-action":"Join Asking Question","data-event-label":u,children:P({id:"commentPopup.sigupButton.joinTheDisscussion"})})]}):(0,i.BX)(i.HY,{children:[(0,i.BX)(B.qT,{"data-event-category":"Ask Doctor","data-event-action":"Write Question Click","data-event-label":u,onClick:()=>{U?null==o||o():F&&(y.Ew?O.u.getState().triggerLogin({returnUrl:F}):window.location.href=F)},children:[U&&(0,i.tZ)(I.U,{avatar:null==z?void 0:z.avatar,username:null==z?void 0:z.name,style:{width:40,height:40}}),(0,i.BX)(B.YJ,{"data-is-loggedin":U||void 0,children:[(0,i.tZ)("img",{className:"input-reply-icon",src:"/svg/icon-edit.svg",alt:"reply",loading:"lazy"}),(0,i.tZ)("div",{className:"input-reply-comment",children:P({id:"commentPopup.startANewPost",defaultMessage:"Start a new post"})})]})]}),!U&&(0,i.tZ)("p",{className:"join-or-login",children:P({id:"commentPopup.comment.loginOrSignup.toJoinDiscuss",defaultMessage:"{joinUsWithLink} or {signInWithLink} to join the discussion"},{joinUsWithLink:(0,i.tZ)("a",{"data-event-category":"Comments","data-event-action":"Join Link","data-event-label":u,href:F,onClick:e=>{e.preventDefault(),F&&(y.Ew?O.u.getState().triggerLogin({returnUrl:F}):window.location.href=F)},children:P({id:"commentPopup.comment.loginOrSignup.joinUs",defaultMessage:"Join us"})}),signInWithLink:(0,i.tZ)("a",{"data-event-category":"Comments","data-event-action":"Login Link","data-event-label":u,href:F,onClick:e=>{e.preventDefault(),F&&(y.Ew?O.u.getState().triggerLogin({returnUrl:F}):window.location.href=F)},children:P({id:"commentPopup.comment.loginOrSignup.logIn",defaultMessage:"Log in"})})})})]})})]})};var L=o("FaaI");let TogetherCommentPopup=e=>{let{articleId:t,categories:o,articleSlug:E,defaultCommentsWithReplies:P}=e,{state:{userInfo:k}}=(0,n.useContext)(x.I),{setIsCommentPopupOpen:w,isCommentPopupOpen:T}=(0,C.WM)(e=>({setIsCommentPopupOpen:e.setIsCommentPopupOpen,isCommentPopupOpen:e.isCommentPopupOpen}),m.X),[_,M]=(0,n.useState)(),S=null==E?void 0:E.split("/").filter(Boolean).slice(0,-1),[A,I]=(0,n.useState)([]),[O,D]=(0,n.useState)(null),{currentArticle:N}=(0,C.WM)(e=>({currentArticle:e.currentArticle})),q=T&&(null==N?void 0:N.id)===t;(0,L.h)(!!q,(e,t)=>D(t),y.XL),(0,n.useEffect)(()=>{S?Promise.all(null==S?void 0:S.map(async(e,t)=>{let i=S.slice(0,t+1).join("/"),n=o.find(e=>{var t;return(null===(t=e.permalink)||void 0===t?void 0:t.split("/").filter(Boolean).join("/"))===i});if(n)return n;{var a,l;let e=await (0,p.d)(g.y.CATEGORY.GET_CATEGORY_DETAIL,{params:{slug:i}});if(null==e?void 0:null===(l=e.data)||void 0===l?void 0:null===(a=l.category)||void 0===a?void 0:a.term_id)return(0,u.DG)(e.data.category)}})).then(e=>I(e.filter(Boolean))):I(o.sort((e,t)=>{let o=e.permalink.split("/").length-1,i=t.permalink.split("/").length-1;return o>i?1:oe.slug).join("/")]);let X=(0,h.U)(),[R,G]=(0,n.useState)("comment-list"),[z,U]=(0,n.useState)(void 0),[H,j]=(0,n.useState)(void 0),{formatMessage:V}=(0,s.Z)(),Q=(0,n.useRef)(null),F=(0,f.d)(),W=(0,n.useRef)();(0,n.useEffect)(()=>{Z.E.mutate(()=>{document.body.classList.toggle("noscroll",q&&F),q?(G("comment-list"),U(void 0),j(void 0),document.querySelectorAll('div[id^="spotx_content_container"]').forEach(e=>{e.parentElement&&(e.parentElement.style.display="none")})):document.querySelectorAll('div[id^="spotx_content_container"]').forEach(e=>{e.parentElement&&(e.parentElement.style.display="block")})})},[q]);let handleClose=()=>{"create-edit"===R?M({thumbnail:"/svg/icon-cancel.svg",title:V({id:"commentPopup.createPost.confirmCloseTitle",defaultMessage:"Are you sure?"}),description:V({id:"commentPopup.createPost.confirmCloseDescription",defaultMessage:"If you discard now, you’ll lose this post"}),acceptText:V({id:z?"commentPopup.discardPostEdit":"commentPopup.discardPost",defaultMessage:z?"Discard changes":"Discard post"}),cancelText:V({id:"commentPopup.keepEditing",defaultMessage:"Keep editing"}),onAccept:async()=>{w(!1),M(void 0)}}):w(!1)};return(0,i.BX)(v.G,{isOpen:q,type:"profile",onClose:handleClose,id:"popup-".concat(t),className:"comment-popup",children:[(0,i.tZ)("div",{style:{display:"none"},children:(0,i.tZ)("div",{className:"comment-list",children:null==P?void 0:P.map(e=>{var t,o,n,a,l,d;return(0,i.BX)("div",{children:[(0,i.BX)("a",{href:"/community/".concat(null===(t=e.comment.community)||void 0===t?void 0:t.slug,"/").concat(e.comment.slug,"/"),children:["img: ",e.comment.bannerImage,(0,i.tZ)("br",{}),"author: ",e.comment.isAnonymous?"":null===(o=e.comment.author)||void 0===o?void 0:o.name,(0,i.tZ)("br",{}),"detail: ",e.comment.description,(0,i.tZ)("br",{}),"time: ",e.comment.postTime,(0,i.tZ)("br",{}),"reply: ",e.comment.commentsCount,(0,i.tZ)("br",{}),"likes: ",e.comment.likesCount]}),(0,i.BX)("a",{href:"/community/".concat(null===(n=e.comment.community)||void 0===n?void 0:n.slug,"/"),children:["community: ",null===(a=e.comment.community)||void 0===a?void 0:a.name]}),(0,i.tZ)("br",{}),null===(l=e.comment.topics)||void 0===l?void 0:l.map(t=>{var o;return(0,i.BX)("a",{href:"/community/".concat(null===(o=e.comment.community)||void 0===o?void 0:o.slug,"/").concat(null==t?void 0:t.slug),children:["topic: ",t.name]},t.id)}),(0,i.tZ)("div",{className:"comment-replies",children:null===(d=e.replies)||void 0===d?void 0:d.map(t=>(0,i.tZ)(r.b,{hasQuickBookingEnable:!0,className:"post-comment",comment:t,post:e.comment},t.id))})]},e.comment.id)})})}),(0,i.tZ)(B.O0,{ref:Q,children:q&&(0,i.BX)(i.HY,{children:[_&&(0,i.tZ)(d.P,{onClose:()=>M(void 0),..._}),(0,i.BX)(B.kS,{children:["comment-list"!==R&&(0,i.tZ)("div",{className:"comment-popup-back-button",children:(0,i.tZ)(a.B,{color:"transparent",size:"sm",className:"button-back",onClick:()=>{"create-edit"===R?M({thumbnail:"/svg/icon-cancel.svg",title:V({id:"commentPopup.createPost.confirmCloseTitle",defaultMessage:"Are you sure?"}),description:V({id:"commentPopup.createPost.confirmCloseDescription",defaultMessage:"If you discard now, you’ll lose this post"}),acceptText:V({id:z?"commentPopup.discardPostEdit":"commentPopup.discardPost",defaultMessage:z?"Discard changes":"Discard post"}),cancelText:V({id:"commentPopup.keepEditing",defaultMessage:"Keep editing"}),onAccept:async()=>{G("comment-list"),M(void 0)}}):G("comment-list")},children:(0,i.tZ)("img",{src:"".concat(y.Nr,"/back-icon.svg"),alt:"",loading:"lazy"})})}),(0,i.tZ)(l.H,{tag:"h6",style:{width:"70%",textAlign:"center",flex:1},fontWeight:"semibold",children:"create-edit"===R?z?V({id:"commentPopup.title.updatePost",defaultMessage:"Update post"}):V({id:"commentPopup.title.newPost",defaultMessage:"New post"}):V({id:"commentPopup.title",defaultMessage:"Comments"})}),(0,i.tZ)(B.VO,{onClick:handleClose,children:(0,i.tZ)("img",{"data-event-category":"Comments","data-event-action":"Close","data-event-label":X,src:"".concat(y.Nr,"/close.svg"),alt:"",loading:"lazy"})})]}),"comment-list"===R&&(0,i.tZ)(CommentList,{articleId:t,openCreatePostPopup:()=>{G("create-edit"),U(void 0)},openEditPostPopup:e=>{G("create-edit"),U(e)},openPostDetail:e=>{G("comment-detail"),j(e)},cityId:null==O?void 0:O.id},String(q)),"comment-detail"===R&&H&&(0,i.tZ)(CommentDetail,{openEditPostPopup:e=>{G("create-edit"),U(e)},post:H,cityId:null==O?void 0:O.id}),"create-edit"===R&&(0,i.tZ)("div",{className:"create-edit-container",children:(0,i.tZ)(c.a,{forceSelectCommunity:{name:A[0].name,mappedCategoryId:Number(A[0].termId)},forceSelectTopics:A.slice(1).map(e=>({name:e.name,mappedCategoryId:Number(e.termId)})),articleId:String(t),onClose:()=>{var e;(null===(e=W.current)||void 0===e?void 0:e.id)?(G("comment-detail"),j(W.current)):G("comment-list"),W.current=void 0},optionalTopic:!0,editPostData:z,noFetchTopic:!0,onPostCreatedEdited:e=>W.current=e,hideTopicList:!0,showAskDoctorOptions:-1!==b.MN.indexOf(y.ENV.NEXT_PUBLIC_DEPLOY_LOCALE||""),selectAskDoctor:!0,userInfo:k,className:"create-post-popup-container"})})]})})]})}},smZU:function(e,t,o){o.d(t,{B:function(){return VideoListing}});var i=o("BGKE"),n=o("q1tI"),a=o("+4HH"),l=o("qQsD"),r=o("wp0n"),d=o("Eso5"),c=o("KeOA"),s=o("OAL+"),m=o("hXNO"),p=(0,o("/npG").k)(e=>({root:{".videos-ad-block":{margin:0}},inner:{[e.fn.smallerThan("sm")]:{display:"flex",flexDirection:"column",alignItems:"center",gap:16}},adsLayout:{display:"flex",justifyContent:"space-between",gap:24,[e.fn.smallerThan("sm")]:{flexDirection:"column",gap:16}}}));let VideoListing=e=>{let{videos:t=[],layout:o="grid",showAds:u=!0,adUnitPath:g,title:v,styles:h,classNames:f,dataTrackingName:y="",dataEventCategory:b,...x}=e,C=(0,m.d)(),{classes:Z,theme:E}=p(void 0,{name:"HeaderBanner",styles:h,classNames:f}),P=(0,n.useMemo)(()=>C?4:"grid"===o?8:u?8:16,[C]),k=(0,n.useMemo)(()=>t.slice(0,P),[P]);return(0,i.tZ)(d.x,{className:Z.root,...x,children:"grid"===o?(0,i.tZ)(c.M,{cols:C?1:4,children:k.map((e,t)=>(0,i.tZ)(a.V,{data:e,dataEventCategory:b,dataEventAction:"".concat(y," Click ").concat(t+1)},String(t)))}):(0,i.BX)(d.x,{className:Z.inner,children:[u&&C&&g&&(0,i.BX)(i.HY,{children:[v&&(0,i.tZ)(r.T,{size:"h3",as:"h2",sx:{alignSelf:"flex-start"},children:v}),(0,i.tZ)(l.A,{wrapperProps:{my:"1rem",mx:"auto"},adUnitPath:g,size:[[300,250],[300,600]],divId:"videos-top-banner-mobile",pos:["TopBanner"],className:"videos-ad-block"})]}),u?(0,i.BX)(d.x,{className:Z.adsLayout,children:[(0,i.tZ)(s.K,{sx:{gap:16,[E.fn.largerThan("sm")]:{gap:40}},children:k.map((e,t)=>(0,i.tZ)(a.V,{data:e,layout:"horizon",dataEventCategory:b,dataEventAction:"".concat(y," Click ").concat(t+1)},String(t)))}),!C&&g&&(0,i.tZ)(l.A,{adUnitPath:g,size:[[300,250],[300,600]],divId:"videos-top-banner-desktop",pos:["TopBanner"],className:"videos-ad-block"})]}):(0,i.tZ)(c.M,{cols:C?1:2,sx:{gap:16,rowGap:16,[E.fn.largerThan("sm")]:{gap:40,rowGap:40}},children:k.map((e,t)=>(0,i.tZ)(a.V,{data:e,layout:"horizon",dataEventCategory:b,dataEventAction:"".concat(y," Click ").concat(t+1)},String(t)))})]})})}},UiH9:function(e,t,o){o.d(t,{E:function(){return VideoList}});var i=o("BGKE"),n=o("q1tI"),a=o("iBNF"),l=o("MmHG"),r=o("2rpi"),d=o("fdQd"),c=o("Eso5"),s=o("hXNO"),m=o("rBCA"),p=o("uuQu"),u=o("DEkF");let g=(0,m.Z)("div",{target:"el5129k0"})("margin-block:40px;",p.M.mbDown,"{margin-left:-16px;margin-right:-16px;}&[data-slide='2']{margin-block:0;display:flex;gap:24px;> div{width:100%;}}"),v=(0,m.Z)(d.a,{target:"el5129k1"})(".mantine-Carousel-indicators{top:calc(100% + 1rem);}.mantine-Carousel-indicator{width:8px;height:8px;border-width:0;opacity:1;background-color:",null===a.r||void 0===a.r?void 0:a.r.colors.neutral200,";&[data-active]{background-color:",null===a.r||void 0===a.r?void 0:a.r.colors.primaryBase,";}.mantine-Carousel-control[data-inactive]{opacity:0;cursor:'default';}}"),h=(0,m.Z)(u.H,{target:"el5129k2"})("margin-block:20px;padding-left:16px;border-left:5px solid ",null===a.r||void 0===a.r?void 0:a.r.colors.primaryBase,";"),VideoList=e=>{let{videos:t,title:o,description:m,slideToShow:p=1.2,isAutoPlay:u=!1,...f}=e,y=(0,s.d)();return(null==t?void 0:t.length)&&0!==t.length?1===t.length?(0,i.BX)(g,{...f,children:[o&&(n.isValidElement(o)?o:(0,i.tZ)(h,{tag:"h2",color:a.r.colors.secondaryBase,children:o})),m&&(0,i.tZ)(l.T,{size:"p3",style:{marginBottom:"16px"},children:m}),(0,i.tZ)(r.S,{url:t[0].videoUrl||"",autoPlay:u})]}):2!==t.length||y?(0,i.BX)(g,{...f,children:[o&&(n.isValidElement(o)?o:(0,i.tZ)(h,{tag:"h2",color:a.r.colors.secondaryBase,children:o})),m&&(0,i.tZ)(l.T,{size:"p3",style:{marginBottom:"16px"},children:m}),(0,i.tZ)(v,{slidesToShow:p,slideGap:y?16:24,withIndicators:!0,controlSize:32,controlsOffset:5,draggable:!1,speed:500,children:t.map((e,t)=>(0,i.tZ)(d.a.Slide,{children:(0,i.tZ)(r.S,{url:e.videoUrl||"",autoPlay:u})},t))})]}):(0,i.BX)(c.x,{my:16,children:[o&&(n.isValidElement(o)?o:(0,i.tZ)(h,{tag:"h2",color:a.r.colors.secondaryBase,style:{marginBlock:24},children:o})),m&&(0,i.tZ)(l.T,{size:"p3",style:{marginBottom:"16px"},children:m}),(0,i.tZ)(g,{"data-slide":"2",...f,children:t.map((e,t)=>(0,i.tZ)(r.S,{url:(null==e?void 0:e.videoUrl)||"",autoPlay:u},t))})]}):null}},OnW6:function(e,t,o){var i=o("BGKE"),n=o("q1tI"),a=o("dDsW"),l=o("SDUi"),r=o("2su4"),d=o("P5LW"),c=o("rIrU"),s=o("XSSD"),m=o("Mtck");t.Z=()=>{let{formatMessage:e}=(0,a.Z)(),{locale:t}=(0,d.h)(),[o,p]=(0,n.useState)({footerInfo:{},dataNavMenuContent:{}}),fetchData=async()=>{let e=await Promise.all([(0,s._)(),(0,m.O)(t)]),[o,i]=e;p({footerInfo:(null==o?void 0:o.data)||null,dataNavMenuContent:i||{}})};return(0,n.useEffect)(()=>{fetchData()},[]),(0,i.tZ)(r.x,{title:e({id:"home.seoTitle"}),description:e({id:"home.seoDescription"}),image:c.CX[t].HOMEPAGE_IMAGE,SEOData:{title:e({id:"404.title"}),description:e({id:"404.description"})},footerInfo:null==o?void 0:o.footerInfo,dataNavMenuContent:null==o?void 0:o.dataNavMenuContent,children:(0,i.tZ)(l.T,{})})}}}]);