"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[941],{OW1g:function(e,t,o){o.d(t,{C:function(){return CardPost},S:function(){return SourceList},V:function(){return VerifiedTag},a:function(){return CardPostPopoverMore},b:function(){return CardReply},c:function(){return CardReplyPopover}});var i=o("jU2Y"),l=o("q1tI"),n=o("Z7lc"),a=o("Kc+B"),r=o("I+LS"),d=o("ns0B"),s=o.n(d),c=o("ZoFl"),p=o("IBlu"),m=o("EMcA"),u=o("aZjv"),v=o("MVZo"),g=o("zSOq"),h=o("rBCA"),b=o("mvp5"),y=o("iBNF"),w=o("clRx"),f=o("IQVP"),x=o("LXTC"),E=o("JRDJ"),k=o("G/kx"),C=o("VyfR"),_=o("HcSX"),I=o("VgQr"),S=o("vWP/"),T=o("VLUI"),R=o("h84G"),P=o("MZpI"),N=o("QaGV"),M=o("bpvy"),j=o("DZnh"),O=o("GhNX"),A=o("b0sY"),D=o("XqqO"),z=o("xrdX"),$="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none'%3e%3cpath fill='%233E3F58' d='M5 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2M19 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2M12 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2'/%3e%3c/svg%3e",B="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='3' height='13' fill='none'%3e%3ccircle cx='1.583' cy='6.417' r='1.25' fill='%23595959' transform='rotate(90 1.583 6.417)'/%3e%3ccircle cx='1.583' cy='1.417' r='1.25' fill='%23595959' transform='rotate(90 1.583 1.417)'/%3e%3ccircle cx='1.583' cy='11.417' r='1.25' fill='%23595959' transform='rotate(90 1.583 11.417)'/%3e%3c/svg%3e",V="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3e%3cpath stroke='%23737373' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.75' d='M2 4h12'/%3e%3cpath stroke='%23737373' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M5.333 4V2.667a1.333 1.333 0 0 1 1.334-1.334h2.666a1.334 1.334 0 0 1 1.334 1.334V4m2 0v9.333a1.334 1.334 0 0 1-1.334 1.334H4.667a1.334 1.334 0 0 1-1.334-1.334V4zM6.667 7.333v4M9.333 7.333v4'/%3e%3c/svg%3e";let CardPostPopoverMore=({authorEmail:e,onDeletePost:t,shareUrl:o,post:n,className:a="",popoverClassName:d="",onEditPost:s})=>{let{data:{locale:h,userInfo:b,env:{isMarryBaby:y}}}=(0,l.useContext)(v.T),{t:w}=(0,r.u)(),[f,x]=(0,l.useState)(!1),[E,k]=(0,l.useState)(!1),[C,_]=(0,l.useState)(!1),{authActionWrapper:I}=(0,u.iV)(),S=e&&(null==b?void 0:b.email)&&e===String(null==b?void 0:b.email);return l.createElement("div",{className:a,onClick:e=>{e.preventDefault(),e.stopPropagation()}},C&&l.createElement(c.S,{url:o,text:null==n?void 0:n.title,onClose:()=>_(!1)}),E&&l.createElement(c.P,{thumbnail:p.C.getAssetPath("trash-bin.svg"),isThumbnailIcon:!0,title:w("popup.deletePost.title"),description:w("popup.deletePost.description"),acceptText:w("popup.deletePost.accept"),cancelText:w("popup.deletePost.cancel"),onAccept:()=>(0,i.a)(void 0,void 0,void 0,function*(){if((null==n?void 0:n.id)&&!f){x(!0);try{let e=yield(0,c.h)({id:n.id,locale:h});(null==e?void 0:e.status)===1&&(null==t||t())}catch(e){}x(!1)}}),onClose:()=>k(!1)}),l.createElement(g.b,{className:d,toggleButtonContent:l.createElement("img",{src:y?$:B,loading:"lazy"}),position:"bottom",align:"end",buttonProps:{isLoading:f},data:S?{isShowheader:!1,type:"list",list:[{icon:"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3e%3cpath stroke='%23595959' stroke-linecap='round' stroke-linejoin='round' d='M7.17 3.236H2.995a1.193 1.193 0 0 0-1.193 1.192v8.35a1.193 1.193 0 0 0 1.193 1.192h8.35a1.193 1.193 0 0 0 1.192-1.192V8.603'/%3e%3cpath stroke='%23595959' stroke-linecap='round' stroke-linejoin='round' d='M11.643 2.341a1.265 1.265 0 0 1 1.789 1.79L7.766 9.795l-2.385.596.596-2.385z'/%3e%3c/svg%3e",label:w("actionPopover.edit"),onClick:s},{icon:V,label:w("actionPopover.delete"),onClick:()=>{I(()=>k(!0))}}]}:{isShowheader:!1,type:"list",list:[{icon:c.i,label:w("morePopover.report"),subTree:{title:w("morePopover.report.title"),description:w("morePopover.report.description"),isShowheader:!0,type:"list",list:Object.keys(m.R).map(e=>({label:m.R[e].label,reason:m.R[e].reportReasonText,reasonValue:e})).map(e=>({label:w(e.label),subTree:{title:w("morePopover.reportSubmit.title"),description:w("morePopover.reportSubmit.description"),isShowheader:!0,type:"jsx",jsxRenderer:t=>l.createElement(c.b,{reason:e.reasonValue,reasonText:w(e.reason),postId:null==n?void 0:n.id,onClose:()=>t&&t(!1)})}}))}}]}}))},L=h.Z.div` position: relative; margin-bottom: 24px; background: white; border-radius: ${y.r.borderRadius}; a { text-decoration: none; } ${b.M.mbDown} { margin-bottom: 8px; } &.flat-top { border-top-left-radius: 0; border-top-right-radius: 0; } .post-pin { padding: 0.5rem 1rem; border-radius: ${y.r.borderRadius} 6px 0 0; } .post-author { display: flex; align-items: center; justify-content: space-between; &.comment { padding-right: 2.6rem; } .author-avatar-wrapper { width: 40px; height: 40px; font-size: 20px; ${b.M.mbDown} { width: 32px; height: 32px; font-size: 16px; } } } .post-content-link-wrapper { color: inherit; cursor: pointer; .post-content-title { padding: 1rem 1rem 0; word-break: break-word; } } .social-preview-wrapper.has-image { margin-bottom: 5px; } .social-preview-wrapper, .image-preview-wrapper, .link-preview-wrapper { width: 100%; &[data-is-reply='true'] { padding-right: 1rem; padding-left: 1rem; } } .post-topics { padding: 0 1rem; } .post-reaction { background: none; border-radius: 0 0 6px 6px; &.hide-top-border { ::before { display: none; } } } .most-engaging-wrapper { padding: 1rem; cursor: pointer; .author-avatar-wrapper { width: 2rem; height: 2rem; font-size: 1rem; } .see-more-comments { width: 100%; padding: 12px 0 0; text-align: unset; } } &[data-most-engaging='true'] { border: none; ${b.M.mbDown} { margin: 1rem; border: 1px solid #e4e8ec; } } .top-divider { border-color: #e4e8ec; } .popover { .popover-menu__btn { display: flex; width: 1.5rem; height: 1rem; align-items: center; justify-content: center; padding: 0; background: transparent; &:hover { background-color: transparent; } } .popover-menu__content { &.--position-bottom { &.--align-end { &::before { right: 12.5px; } } } } } &[data-is-marrybaby='true'] { border: 1px solid #f3f3f3; border-radius: 1rem; /* shadow */ box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.08); .image-preview-wrapper, .link-preview-wrapper { padding-right: 1rem; padding-left: 1rem; } .popover { .popover-menu__btn { width: 24px; height: 24px; ${b.M.mbDown} { width: 18px; height: 18px; } } .popover-menu__content { &.--position-bottom { &.--align-end { &::before { right: 1rem; } width: 350px; ${b.M.mbDown} { max-width: calc(320px - 2rem); } } } } } .most-engaging-wrapper { position: relative; padding: 0; &::before { position: absolute; z-index: 5; top: 0; left: 50%; width: calc(100% - 2rem); height: 1px; background: #f3f3f3; content: ' '; transform: translateX(-50%); } } ${b.M.mbDown} { margin-bottom: 12px; } } `;var Z="data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3e%3cpath stroke='%23595959' stroke-linecap='round' stroke-linejoin='round' d='M12 13.333 8 10.37l-4 2.963V3.852c0-.314.12-.616.335-.838.214-.222.505-.347.808-.347h5.714c.303 0 .594.125.808.347s.335.524.335.838z'/%3e%3c/svg%3e";let CardReplyPopover=({onDeleteComment:e,commentId:t,className:o="",popoverClassName:n=""})=>{let{data:{env:{isMarryBaby:a},locale:d},action:{pushNotifications:s}}=(0,l.useContext)(v.T),{t:p}=(0,r.u)(),[m,h]=(0,l.useState)(!1),{authActionWrapper:b}=(0,u.iV)();return l.createElement("div",{className:o,onClick:e=>{e.preventDefault(),e.stopPropagation()}},m&&l.createElement(c.P,{thumbnail:"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='17' fill='none'%3e%3cg stroke='%23737373' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' clip-path='url(%23a)'%3e%3cpath d='M2 4.008h12m-8.667 0V2.675a1.333 1.333 0 0 1 1.334-1.333h2.666a1.333 1.333 0 0 1 1.334 1.333v1.333m2 0v9.334a1.333 1.333 0 0 1-1.334 1.333H4.667a1.333 1.333 0 0 1-1.334-1.333V4.008zm-6 3.334v4m2.666-4v4'/%3e%3c/g%3e%3cdefs%3e%3cclipPath id='a'%3e%3cpath fill='white' d='M0 .008h16v16H0z'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",isThumbnailIcon:!0,title:p("popup.deleteComment.title"),description:p("popup.deleteComment.description"),acceptText:p("popup.deletePost.accept"),cancelText:p("popup.deletePost.cancel"),onAccept:()=>(0,i.a)(void 0,void 0,void 0,function*(){var o;if(!t)return;let i=yield(0,c.j)({id:t,locale:d});(null==i?void 0:i.status)===1?(e&&e(),s({title:"",message:p("notification.success"),type:"success"})):s({title:"",message:(null===(o=null==i?void 0:i.messages)||void 0===o?void 0:o[0])||p("notification.failure"),type:"danger"})}),onClose:()=>h(!1)}),l.createElement(g.b,{position:"bottom",align:"end",data:{isShowheader:!1,type:"list",list:[{icon:V,label:p("actionPopover.delete"),onClick:()=>{b(()=>{h(!0)})}}]},className:n,toggleButtonContent:l.createElement("img",{src:a?$:B,loading:"lazy"}),buttonProps:{}}))},G=h.Z.div` .add-link { color: ${y.r.colors.primaryBase}; } `,U=h.Z.div` margin: 16px 0; background: ${y.r.colors.yellow50}; padding: 5px 10px; border-radius: 2px; .icon { display: inline-block; vertical-align: middle; margin-right: 6px; } `,F=h.Z.div` display: flex; align-items: center; gap: 8px; `,H=h.Z.div` padding: 8px 16px; `,Q=h.Z.div` margin-bottom: 12px; width: 100%; `,X=h.Z.div``,K=h.Z.div` margin-bottom: 16px; `,W=h.Z.div` display: flex; flex-wrap: wrap; row-gap: 16px; ${b.M.tdUp} { align-items: center; column-gap: 24px; } `,q=h.Z.a` display: flex; align-items: center; gap: 16px; ${b.M.mbDown} { width: 100%; justify-content: space-between; } `,Y=h.Z.div` display: flex; align-items: center; gap: 16px; `,J=h.Z.div` border-radius: ${y.r.borderRadius}; overflow: hidden; width: 48px; height: 48px; img { object-fit: cover; width: 100%; height: 100%; } `,RecommentCategories=({categories:e})=>{let{t}=(0,r.u)(),{data:{locale:o,env:{isMarryBaby:i}}}=(0,l.useContext)(v.T),n=(0,D.g)(o,i);return l.createElement(X,null,l.createElement(K,null,l.createElement(a.H,{tag:"h6",as:"h5"},t("cardReply.recommentCategories.heading"))),l.createElement(W,null,e.map(e=>l.createElement(q,{href:n+e.permalink,key:String(e.termId),target:"_blank"},l.createElement(Y,null,l.createElement(J,null,l.createElement("img",{src:e.featureImage||p.C.getAssetPath(i?"mb-logo.svg":"/logo/logomark.png"),alt:e.displayName,loading:"lazy"})),l.createElement(O.T,{size:"s3",weight:"bold"},e.displayName)),l.createElement(T.Z,{size:20,color:y.r.colors.gray400})))))},ee=h.Z.a` padding: 12px 0; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid ${y.r.colors.neutral100}; text-decoration: none; &:first-child { border-top: 0; } `,SourceItem=({postTitle:e,articleReviewed:t,modifiedTime:o,href:i})=>{let{t:n}=(0,r.u)(),a=(()=>{let{expert:e,editor:o,is_author:i}=t;if(e){let t={name:e.display_name,role:"expert",avatar:e.avatar};return i?Object.assign({title:n("articleAuthor.title.written-by")},t):"expert"===e.role?Object.assign({title:n("articleAuthor.title.expert")},t):Object.assign({title:n("articleAuthor.title.medical")},t)}if(o)return{title:n("articleAuthor.title.fact-check"),name:o.display_name,avatar:o.avatar}})();return l.createElement(ee,{href:i,title:e,target:"_blank"},l.createElement(O.T,{size:"s3",as:"h5",weight:"bold"},e),l.createElement("div",null,l.createElement(E.C,{avatar:null==a?void 0:a.avatar,avatarProps:{size:32},name:null==a?void 0:a.name,role:null==a?void 0:a.role,hideBackground:!0},l.createElement(E.C.SubTextRow,null,l.createElement(E.C.SubText,null,null==a?void 0:a.title," ",l.createElement("span",{style:{color:y.r.colors.gray800}},null==a?void 0:a.name)),l.createElement(E.C.SubDivider,null),l.createElement(E.C.SubText,null,o)))))};var et={header:"F4mmgSy",chevron:"A7QrQ7A"};let SourceList=e=>{var{listUrl:t,hideSourceList:o,categorySlug:d,editMode:s,collapseSource:c,onListChange:m,isMarryBaby:u}=e,g=(0,i._)(e,["listUrl","hideSourceList","categorySlug","editMode","collapseSource","onListChange","isMarryBaby"]);let{t:h}=(0,r.u)(),[b,x]=(0,l.useState)(t||[]),[E,k]=(0,l.useState)([]),[C,_]=(0,l.useState)([]),[I,T]=(0,l.useState)(!1);(0,l.useEffect)(()=>{o||(0,i.a)(void 0,void 0,void 0,function*(){T(!0);let e=b.map(e=>{let t=new URL(e),o=String(t.pathname).split("/").filter(e=>""!=e),i=t.origin,l=-1!==i.search("marrybaby.vn");return{isMarrySite:l,path:o[o.length-1],href:e}}),t=[...e.map(e=>(0,v.c)(e.isMarrySite?(0,v.s)(f.D9.GET_PREVIEW_ARTICLE,{fullSlug:e.path},!0):(0,v.g)(f.D9.GET_PREVIEW_ARTICLE,{fullSlug:e.path},!0),"GET"))],o=yield Promise.all(t);k(o.map((t,o)=>{var i,l;return(null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.post)&&Object.assign(Object.assign({},(0,w.b)(null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.post)),{href:e[o].href})}).filter(Boolean)),T(!1)})},[]),(0,l.useEffect)(()=>{!o&&(null==E?void 0:E.length)===0&&d&&(0,i.a)(void 0,void 0,void 0,function*(){var e;let t=yield(0,v.c)(u?(0,v.s)(f.D9.GET_CATEGORY_OR_ARTICLE_DETAIL,{fullSlug:d},!0):(0,v.g)(f.D9.GET_CATEGORY_OR_ARTICLE_DETAIL,{fullSlug:d},!0),"GET");(null==t?void 0:t.data)&&_([(0,w.h)(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.category)])})},[E]);let handleRemoveItem=e=>{x(t=>{let o=[...t];return o.splice(e,1),o}),k(t=>{let o=[...t];return o.splice(e,1),o})};return(0,l.useEffect)(()=>{null==m||m(b)},[b]),l.createElement("div",Object.assign({},g),!s&&l.createElement(U,null,l.createElement("img",{className:"icon",src:p.C.getAssetPath("warning.svg"),alt:"warning",style:{marginBottom:"3px",width:"18px"},loading:"lazy"}),l.createElement(O.T,{size:"s3",as:"span",dangerouslySetInnerHTML:{__html:h("cardReply.disclaimer")}})),o?null:I?l.createElement(A.L,null):E.length>0||s?l.createElement(G,null,l.createElement(M.U,{defaultValue:!c&&"accordion",styles:{control:{borderRadius:"inherit",'&[aria-expanded="false"]':{borderBottom:0}},chevron:{width:"32px",height:"32px"},content:{padding:0,borderBottom:0,borderTop:`1px solid ${y.r.colors.neutral100}`},item:{marginBottom:"16px",borderTopLeftRadius:"8px",borderTopRightRadius:"8px",border:`1px solid ${y.r.colors.neutral100}`,borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px","&[data-active]":{borderBottomLeftRadius:0,borderBottomRightRadius:0}}},chevron:l.createElement("div",{className:et.chevron},l.createElement(R.Z,{color:y.r.colors.gray600,size:20}))},l.createElement(M.U.Item,{value:"accordion"},l.createElement(M.U.Control,null,l.createElement("div",{className:et.header},l.createElement(a.H,{as:"h4",tag:"h6"},h("cardReply.source")))),l.createElement(M.U.Panel,null,l.createElement(H,null,(E||[]).map((e,t)=>l.createElement(F,{key:String(t)},"object"==typeof e?l.createElement(SourceItem,Object.assign({},e)):l.createElement(Q,null,l.createElement(j.I,{style:{width:"100%"},name:"source-list",value:e||"",size:"sm",onChange:e=>{x(o=>{let i=[...o];return i[t]=e,i}),k(o=>{let i=[...o];return i[t]=e,i})}})),s&&l.createElement(n.B,{size:"md",color:"transparent",icon:l.createElement(P.Z,null),onClick:()=>handleRemoveItem(t)}))),s&&l.createElement(n.B,{className:"add-link",color:"transparent",size:"md",icon:l.createElement(S.Z,{color:y.r.colors.primaryBase,size:18}),onClick:()=>{x(e=>[...e,""]),k(e=>[...e,""])}},"Add source")))))):l.createElement(RecommentCategories,{categories:C}))},eo=h.Z.div` position: relative; margin-bottom: 0; background: white; border-radius: ${y.r.borderRadius}; .verify-tag { margin-top: 12px; } .post-author { &.with-popover { padding-right: 2.6rem; } .author-avatar-wrapper { width: 40px; height: 40px; font-size: 20px; ${b.M.mbDown} { width: 32px; height: 32px; font-size: 16px; } } } .image-preview-wrapper, .link-preview-wrapper { width: 100%; &[data-is-reply='true'] { padding-right: 1rem; padding-left: 1rem; } } .post-reaction { background: none; border-radius: 0 0 6px 6px; } &[data-is-reply='true'] { > .post-author .author-avatar-wrapper { width: 20px; height: 20px; font-size: 10px; } } &[data-is-reply='false'] { border: 1px solid #e4e8ec; } .expert-wrapper { width: 100%; } &[data-has-booking='true'] { display: grid; .post-author { background-color: ${y.r.colors.primary50}; } .btn-wrapper { padding: 0 16px; .btn-booking { width: 100%; margin: 12px 0; } } } .comment-reply-wrapper { padding: 0 1rem; .more-cmt { .chevron-right { height: 1rem; width: 1rem; vertical-align: middle; } } } .top-divider { border-color: #e4e8ec; } .popover { position: absolute; top: 1.5rem; right: 1rem; .popover-menu__btn { display: flex; width: 1rem; height: 1rem; align-items: center; justify-content: center; padding: 0; background: transparent; &:hover { background-color: transparent; } .popover-menu__content { &.--position-bottom { &.--align-end { &::before { right: 12.5px; } } } } } } &[data-is-marrybaby='true'] { &[data-is-reply='false'] { border: none; } .image-preview-wrapper, .link-preview-wrapper { padding-right: 1rem; padding-left: 1rem; } .popover { .popover-menu__btn { width: 24px; height: 24px; } } margin-left: 56px; ${b.M.mbDown} { margin-left: 40px; } > .post-author { margin-left: -56px; ${b.M.mbDown} { margin-left: -40px; } .author-info { align-items: center; display: flex; align-items: center; .author-info-top { width: 100%; } .author-info-text-wrapper { justify-content: space-between; } } .author-avatar-wrapper { width: 40px; height: 40px; font-size: 20px; ${b.M.mbDown} { width: 24px; height: 24px; font-size: 12px; } } } &[data-is-reply] { > .post-author { .author-avatar-wrapper { width: 40px; height: 40px; font-size: 20px; ${b.M.mbDown} { width: 24px; height: 24px; font-size: 12px; } } } } .comment-reply-wrapper { padding-right: 0; padding-left: 0; } .post-reaction { &::after { position: absolute; bottom: 0; left: 50%; width: calc(100% - 2rem); height: 1px; background: #f3f3f3; content: ' '; transform: translateX(-50%); } } .post-content-wrapper { padding-top: 0; padding-bottom: 0; ${b.M.mbDown} { padding-left: 0.5rem; } } ${b.M.mbDown} { margin-bottom: 12px; } } `,ei=(0,h.Z)(SourceList)` margin-top: 12px; padding: 0.5rem 1rem 1rem; `,VerifiedTag=({userId:e,avatar:t,name:o,role:i,title:a,className:d})=>{let{t:s}=(0,r.u)(),[c,p]=(0,l.useState)(!1);return l.createElement(l.Fragment,null,l.createElement(n.B,{className:`-dzIuHr ${d}`,color:"success",size:"xs",onClick:()=>p(!0),style:{padding:"5px 8px",marginBottom:"12px",borderRadius:"4px"}},l.createElement("span",{className:"text"},l.createElement(N.Z,{isSolid:!0,size:18,color:y.r.colors.green800,className:"icon"}),s("cardReply.verifyBy",{name:`${o||""}`}))),l.createElement(E.c,{open:c,onClose:()=>p(!1),profileModalProps:{zIndex:1e3}},l.createElement(k.a,{authorProps:{userId:e,avatar:t,name:o,role:i,title:a},hideQuestionTab:!0})))},CardReply=({className:e,style:t,comment:o,type:a="comment",level:d=0,replyingId:s,onPostCommentSuccess:p,post:m,onDeleteComment:h,refetchComment:b,hasQuickBookingEnable:y,handleMakeAppointment:w,cardAuthorProps:_,maxChars:S=600,disableShortenContent:T})=>{var R,P,N,M,j,O,A,D,$,B,V,L,Z;let{data:{locale:G,userInfo:U,env:{isMarryBaby:F}}}=(0,l.useContext)(v.T),{t:H}=(0,r.u)(),[Q,X]=(0,l.useState)(o||null),{id:K,countLikes:W,content:q,replies:Y=[],images:J=[],author:ee,liked:et,link:el,mentionedUser:en,mentions:ea}=Q,{text:er,replyingTo:ed}=(0,c.k)(q),{authActionWrapper:es}=(0,u.iV)({_joinCommunityIds:[null===(R=null==m?void 0:m.community)||void 0===R?void 0:R.id],_joinTopicIds:null===(P=null==m?void 0:m.topics)||void 0===P?void 0:P.map(e=>e.id)}),[ec,ep]=(0,l.useState)(4),em=null!=U&&!!U.id&&(null==Y?void 0:Y.some(e=>e.author.id===U.id)),addNewReply=e=>{X(t=>{if(!t.replies.find(t=>t.id===e.id)){t.replies.unshift(e);let o=Object.assign(Object.assign({},t),{replies:t.replies.slice(),countReplies:t.countReplies+1});return b&&b(o),o}return t})},[eu,ev]=(0,l.useState)(!1),eg=(0,l.useMemo)(()=>"comment"===a&&Y&&0!=Y.length?Y.sort((e,t)=>{let o=new Date(e.createdAt).getTime(),i=new Date(t.createdAt).getTime();return o>i?-1:o{var e,t;(null==ee?void 0:ee.hospitalId)&&(e=ee.hospitalId,(0,i.a)(void 0,void 0,void 0,function*(){var t;let o=yield(0,v.c)((0,v.b)(f.tC.GET_HOSPITAL_INFO,{hospital_branch_id:e,website_url:z.v[G]}),"get");(null===(t=null==o?void 0:o._data)||void 0===t?void 0:t.branch)&&eC(null==o?void 0:o._data.branch)})),(null==ee?void 0:ee.doctorId)&&(t=ee.doctorId,(0,i.a)(void 0,void 0,void 0,function*(){var e;let o=yield(0,v.c)((0,v.b)(f.tC.GET_DOCTOR_INFO,{doctorId:t,website_url:z.v[G]}),"get");(null===(e=null==o?void 0:o._data)||void 0===e?void 0:e.doctor)&&eI(null==o?void 0:o._data.doctor)}))},[ee.hospitalId,ee.doctorId]);let eS=(null==e_?void 0:e_.valid_outpatient)||(null==e_?void 0:e_.valid_telemedicine),eT=((null==ek?void 0:ek.total_available_service)||(null==ek?void 0:ek.total_available_doctor))>0,eR=y&&(eS||eT),eP=(null===(M=null==Q?void 0:Q.author)||void 0===M?void 0:M.type)==="chatbot";return l.createElement(u.I_,{defaultParams:{_joinCommunityIds:[null===(j=null==m?void 0:m.community)||void 0===j?void 0:j.id],_joinTopicIds:null===(O=null==m?void 0:m.topics)||void 0===O?void 0:O.map(e=>e.id)}},l.createElement(eo,{className:e,style:t,"data-is-reply":!!d,"data-is-marrybaby":F,"data-has-booking":eR},"reply"===a&&l.createElement(I.D,{className:"top-divider",type:"solid"}),l.createElement("div",{style:{padding:"16px 16px 0"}},l.createElement(E.C,Object.assign({avatar:ef,name:ey,username:ew,timeText:null==m?void 0:m.createdTime,community:null==m?void 0:m.community,className:`post-author ${eb?"with-popover":""}`,type:a,userId:null==ee?void 0:ee.id,role:ex,expertId:null==ee?void 0:ee.partnerId,title:null==ee?void 0:ee.title,doctorId:null==ee?void 0:ee.doctorId,hospitalId:null==ee?void 0:ee.hospitalId,hasQuickBooking:eR,handleMakeAppointment:w,isAnonymous:(null==Q?void 0:Q.isAnonymous)||!!(null==m?void 0:m.isAnonymous)&&(null===(A=null==m?void 0:m.author)||void 0===A?void 0:A.username)===(null==ee?void 0:ee.username),hideBackground:eP,userType:null==ee?void 0:ee.type},_)),!!(null==Q?void 0:Q.isVerify)&&!(null==Q?void 0:Q.isOppose)&&l.createElement(VerifiedTag,{title:null===(D=null==Q?void 0:Q.userVerify)||void 0===D?void 0:D.title,name:null===($=null==Q?void 0:Q.userVerify)||void 0===$?void 0:$.name,userId:null===(B=null==Q?void 0:Q.userVerify)||void 0===B?void 0:B.id,role:null===(V=null==Q?void 0:Q.userVerify)||void 0===V?void 0:V.role,avatar:null===(L=null==Q?void 0:Q.userVerify)||void 0===L?void 0:L.avatar,className:"verify-tag"})),l.createElement(k.P,{className:"post-content-wrapper",replyingTo:ed,mentionedUser:en,description:er,mentions:eE,maxChars:S,disableShortenContent:T}),l.createElement("span",null),l.createElement("span",null),J&&J.length>0?l.createElement("div",{key:"image-preview",className:"image-preview-wrapper","data-is-reply":!0},l.createElement(C.a,{images:J,authorName:null==ee?void 0:ee.username})):null,(!J||0===J.length)&&el?l.createElement("div",{key:"link-preview",className:"link-preview-wrapper","data-is-reply":!0},l.createElement(x.C,{url:el})):null,"most-engaging"!==a?l.createElement(l.Fragment,null,eP&&l.createElement(ei,{listUrl:null==Q?void 0:Q.source,categorySlug:null==Q?void 0:Q.categorySlug}),l.createElement(g.C,{type:g.c.reply,loveCount:W,replyCount:eh,className:"post-reaction",liked:et,isReplied:em,hideCommentIcon:"reply"===a||eP,hasShare:!1,onCommentClick:()=>es(()=>ev(e=>!e)),onCommentCountClick:()=>es(()=>{ev(!0)}),onLikeClick:()=>es(()=>(0,i.a)(void 0,void 0,void 0,function*(){if(K){let e=yield(0,c.l)({commentId:K,setLike:!et,locale:G});1===e.status&&X(e=>Object.assign(Object.assign({},e),{liked:!et,countLikes:e.countLikes+(et?-1:1)}))}}))}),eu&&l.createElement(c.I,{replyingId:s||Q.id,replyToName:ey,isReply:!0,onClose:()=>ev(!1),onPostSuccess:e=>{"reply"===a?p&&p(e):addNewReply(e)},post:m,replyingUser:ee}),"comment"===a&&Y&&Y.length>0?l.createElement("div",{className:"comment-reply-wrapper"},null===(Z=null==eg?void 0:eg.slice(0,ec))||void 0===Z?void 0:Z.map(e=>l.createElement(CardReply,{key:e.id,comment:e,type:"reply",className:"comment-reply-item",level:d+1,replyingId:K,onPostCommentSuccess:addNewReply,post:m,onDeleteComment:()=>{X(t=>Object.assign(Object.assign({},t),{replies:t.replies.filter(t=>t.id!==e.id),countReplies:t.countReplies-1}))},handleMakeAppointment:w,hasQuickBookingEnable:y})),eh>ec&&l.createElement(l.Fragment,null,l.createElement(I.D,{className:"top-divider",type:"solid"}),l.createElement(n.B,{className:"more-cmt",size:"lg",color:"ghost",onClick:()=>ep(e=>e+4)},H("comment.seeMoreReplies",{count:eh-ec}),l.createElement("img",{className:"chevron-right",src:"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'%3e%3cpath stroke='%232D87F3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 12 4-4-4-4'/%3e%3c/svg%3e",loading:"lazy"})))):null):null,eb&&l.createElement(CardReplyPopover,{onDeleteComment:h,className:"popover",commentId:Q.id})))},getMostEngagingComment=(e,t)=>(0,i.a)(void 0,void 0,void 0,function*(){var o,i,l;let n=yield(0,v.t)((0,v.f)(f.yy.COMMENT.LIST,{postId:e,_locale:t,sort:"popularity",perPage:1,withoutReply:1}),"GET");return null===(l=null===(i=null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.comments)||void 0===i?void 0:i.map(w.g))||void 0===l?void 0:l[0]}),CardPost=({className:e,style:t,hideViewMoreComment:o,showMostEngaging:d,onCommentClick:p,onCommentCountClick:h,onMostEngagingCommentClick:b,onPostCommentSuccess:y,disableCardLink:w,disableShortenContent:I,onDeletePost:S,onEditPost:T,post:R,mostEngagingComment:P,onDeleteComment:N,showInputComment:M,InlineCommentsComponent:j,hasQuickBookingEnable:O,handleMakeAppointment:A,onSaveUnsaveSuccess:D,cardAuthorProps:z,verticalReactions:$=!1})=>{let[B,V]=(0,l.useState)(R),[G,U]=(0,l.useState)(!1),[F,H]=(0,l.useState)(P),{community:Q,topics:X,author:K,slug:W,isPin:q,liked:Y,photos:J,mentions:ee,title:et,description:eo,previewUrl:ei,likesCount:el,commentsCount:en,id:ea,commented:er}=B,{data:{locale:ed,togetherUserId:es,userInfo:ec,env:{isMarryBaby:ep,togetherBasePath:em}},action:{pushNotifications:eu}}=(0,l.useContext)(v.T),ev=!!(null==ec?void 0:ec.id),{t:eg}=(0,r.u)(),[eh,eb]=(0,l.useState)(M),ey=`${em}/${(null==Q?void 0:Q.slug)||"_"}/${W||""}`,ew=`${(0,v.l)(ed)}${ey}`,{authActionWrapper:ef}=(0,u.iV)((null==Q?void 0:Q.slug)?{_joinCommunityIds:[Q.id],_joinTopicIds:null==X?void 0:X.map(e=>e.id)}:void 0),[ex,eE]=(0,l.useState)(!1);(0,l.useEffect)(()=>{eb(M)},[M]);let ek=(null==K?void 0:K.name)||(null==K?void 0:K.username)||"",eC=(null==K?void 0:K.username)||(null==K?void 0:K.name)||"",e_=null==K?void 0:K.avatar,eI=(null==B?void 0:B.isAnonymous)?void 0:null==K?void 0:K.role,[eS,eT]=(0,l.useState)(null),[eR,eP]=(0,l.useState)(null);(0,l.useEffect)(()=>{var e,t;(null==K?void 0:K.hospitalId)&&(e=K.hospitalId,(0,i.a)(void 0,void 0,void 0,function*(){var t;let o=yield(0,v.c)((0,v.b)(f.tC.GET_HOSPITAL_INFO,{hospital_branch_id:e,website_url:v.m[ed]}),"get");(null===(t=null==o?void 0:o._data)||void 0===t?void 0:t.branch)&&eT(null==o?void 0:o._data.branch)})),(null==K?void 0:K.doctorId)&&(t=K.doctorId,(0,i.a)(void 0,void 0,void 0,function*(){var e;let o=yield(0,v.c)((0,v.b)(f.tC.GET_DOCTOR_INFO,{doctorId:t,website_url:v.m[ed]}),"get");(null===(e=null==o?void 0:o._data)||void 0===e?void 0:e.doctor)&&eP(null==o?void 0:o._data.doctor)}))},[K.hospitalId,K.doctorId]);let eN=(null==eR?void 0:eR.valid_outpatient)||(null==eR?void 0:eR.valid_telemedicine),eM=((null==eS?void 0:eS.total_available_service)||(null==eS?void 0:eS.total_available_doctor))>0;(0,l.useEffect)(()=>{(0,i.a)(void 0,void 0,void 0,function*(){if(ea&&en&&d&&!(null==P?void 0:P.id)){let e=yield getMostEngagingComment(ea,ed);H(e)}})},[ea,ed,en,d,null==P?void 0:P.id]),(0,l.useEffect)(()=>{H(P)},[null==P?void 0:P.id]);let onDeleteComment=e=>(0,i.a)(void 0,void 0,void 0,function*(){if(en>1&&(null==F?void 0:F.id)&&(null==F?void 0:F.id)===(null==e?void 0:e.id)){let e=yield getMostEngagingComment(ea,ed);H(e)}V(e=>Object.assign(Object.assign({},e),{commentsCount:e.commentsCount-1})),N&&N(e)});return l.createElement(u.I_,{defaultParams:(null==Q?void 0:Q.slug)?{_joinCommunityIds:[Q.id],_joinTopicIds:null==X?void 0:X.map(e=>e.id)}:void 0},G&&l.createElement(c.S,{url:ew,avatar:m.a,text:et,onClose:()=>U(!1)}),l.createElement(L,{className:e,style:t,"data-is-marrybaby":ep},q?l.createElement(g.a,{className:"post-pin"}):null,l.createElement("div",{style:{position:"relative",padding:"1rem 1rem 0"}},l.createElement(E.C,Object.assign({avatar:e_,name:ek,username:eC,url:w?void 0:ey,community:Q,timeText:null==B?void 0:B.createdTime,className:"post-author",role:eI,userId:null==K?void 0:K.id,expertId:null==K?void 0:K.partnerId,doctorId:null==K?void 0:K.doctorId,hospitalId:null==K?void 0:K.hospitalId,title:null==K?void 0:K.title,hasQuickBooking:O&&(eN||eM),handleMakeAppointment:A,"data-testid":"name",isAnonymous:!!(null==B?void 0:B.isAnonymous),extendEle:l.createElement(CardPostPopoverMore,{authorEmail:String(null==K?void 0:K.email),onDeletePost:S,shareUrl:ew,post:B,className:"popover",onEditPost:T})},z))),l.createElement("a",{href:w?void 0:ey,className:"post-content-link-wrapper"},et&&l.createElement(a.H,{className:"post-content-title",as:"h2",tag:"h5",fontWeight:"bold","data-testid":"Title of the Post"},s()(et)),l.createElement(k.P,{className:"post-content-wrapper",description:eo,disableShortenContent:I,mentions:ee,"data-testid":"Content of the Post"})),l.createElement("span",null),l.createElement("span",null),l.createElement("div",{key:"tag-topic"},X&&X.length>0?l.createElement(g.T,{topics:X,className:"post-topics"}):null),l.createElement("div",{key:"social-preview"},(null==B?void 0:B.introUrl)?l.createElement("div",{className:`social-preview-wrapper ${(null==J?void 0:J.length)?"has-image":""}`},l.createElement(_.S,{url:B.introUrl,image:B.bannerImage})):null),l.createElement("div",{key:"image-preview"},(null==J?void 0:J.length)?l.createElement("div",{className:"image-preview-wrapper"},l.createElement(C.a,{images:J,authorName:null==K?void 0:K.name,isSensitive:!!(null==B?void 0:B.isSensitive)})):null),l.createElement("div",{key:"link-preview"},(null==B?void 0:B.introUrl)||(null==J?void 0:J.length)||null==ei||!ei.url?null:l.createElement("div",{className:"link-preview-wrapper"},l.createElement(x.C,{title:ei.title,url:ei.url,image:ei.image}))),l.createElement(g.C,{isMarryBaby:ep,type:g.c.post,loveCount:el,replyCount:en,className:`post-reaction ${(null==J?void 0:J.length)||(null==ei?void 0:ei.url)?"hide-top-border":""}`,liked:ex?!Y:Y,isReplied:er,isSaved:(null==B?void 0:B.bookmarked)||!1,onCommentClick:()=>ef(()=>{p?p():eb(e=>!e)}),onCommentCountClick:()=>{ef(()=>{ep?eb(!0):h?h():w||(window.location.href=ey)})},onShareClick:()=>{U(!0)},onLikeClick:()=>(0,i.a)(void 0,void 0,void 0,function*(){ef(()=>(0,i.a)(void 0,void 0,void 0,function*(){if(ea&&!ex){eE(!0);try{let e=yield(0,c.m)({id:ea,locale:ed});(null==e?void 0:e.status)!==1?eu((0,c.g)(eg)):V(e=>Object.assign(Object.assign({},e),{likesCount:(e.likesCount||0)+(e.liked?-1:1),liked:!e.liked}))}catch(e){eu((0,c.g)(eg))}eE(!1)}}))}),onSaveClick:()=>{ef(()=>(0,i.a)(void 0,void 0,void 0,function*(){if((null==ec?void 0:ec.id)&&(null==B?void 0:B.id)){if(null==B?void 0:B.bookmarked){let e=yield(0,v.e)((0,v.f)(f.yy.BOOKMARK.DELETE,{_locale:ed}),"DELETE",{headers:{"Content-Type":"application/json"},data:{post_id:String(B.id)}});(null==e?void 0:e.status)===1?(eu({title:"",message:eg("post.remove.success"),type:"success",displayIcon:Z}),null==D||D()):eu({title:"",message:eg("post.remove.failed"),type:"danger",displayIcon:Z})}else{let e=yield(0,v.e)((0,v.f)(f.yy.BOOKMARK.CREATE,{_locale:ed}),"POST",{headers:{"Content-Type":"application/json"},data:{user_id:es||ec.id,post_id:B.id}});(null==e?void 0:e.status)===1?(eu({title:"",message:eg("post.save.success"),type:"success",displayIcon:"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23595959'%3e%3cpath stroke='%23595959' stroke-linecap='round' stroke-linejoin='round' d='M12 13.333 8 10.37l-4 2.963V3.852c0-.314.12-.616.335-.838.214-.222.505-.347.808-.347h5.714c.303 0 .594.125.808.347s.335.524.335.838z'/%3e%3c/svg%3e"}),null==D||D()):eu({title:"",message:eg("post.save.failed"),type:"danger",displayIcon:Z})}}}))},onGoToUrl:e=>{let t=e?`${ew}${e}`:ew;ev?window.location.href=t:ef(()=>window.location.href=t)},showingMostEngaging:!!(d&&(null==F?void 0:F.id)),isVertical:$}),eh&&l.createElement(c.I,{isMainCmt:!M,onClose:()=>eb(!1),onPostSuccess:e=>{0!==en||(null==F?void 0:F.id)||H(e),V(e=>Object.assign(Object.assign({},e),{commentsCount:e.commentsCount+1,commented:!0})),y&&y(e)},post:B}),d&&(null==F?void 0:F.id)?l.createElement("div",{className:"most-engaging-wrapper",onClick:e=>{b?(e.stopPropagation(),b()):window.location.href=ey}},l.createElement(CardReply,{hasQuickBookingEnable:O,handleMakeAppointment:A,comment:F,post:B,onDeleteComment:()=>{onDeleteComment&&onDeleteComment(F)},className:"most-engaging-comment",type:"most-engaging",key:F.id,cardAuthorProps:z}),en>1&&!o&&l.createElement(n.B,{className:"see-more-comments",color:"ghost",size:"md"},eg("comment.seeMoreComments",{count:en-1}))):null,j))}}}]);