(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,961572,(e,t,s)=>{var a=e.r(758629),i=e.r(268829),r=e.r(713266),o=e.r(448684),n=e.r(379858),h=e.r(613272),d=e.r(734274),l=e.r(75299),c=Object.prototype.hasOwnProperty;t.exports=function(e){if(null==e)return!0;if(n(e)&&(o(e)||"string"==typeof e||"function"==typeof e.splice||h(e)||l(e)||r(e)))return!e.length;var t=i(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(d(e))return!a(e).length;for(var s in e)if(c.call(e,s))return!1;return!0}},193432,943029,805513,e=>{"use strict";let t,s=Object.freeze({TAG:"tag",TAG_SEARCH:"tag-search",FEED:"feed",GRAPHFEED:"graph-feed",PROFILE:"profile",FORUM:"forum",COMMUNITY:"community",FACT:"fact",FACT_USER:"fact_user"});e.s(["f",0,s],193432);var a,i=e.i(391398),r=e.i(145246),o=e.i(191788);e.i(966278);var n=e.i(318398),h=e.i(455404),d=e.i(961572),l=e.i(949125),c=e.i(131254),f=e.i(705004);let m=new String(".end-of-page.jsx-cf87d0f085393ae9{text-align:center;color:var(--text-light-2);margin-top:20px}");m.__hash="cf87d0f085393ae9";let x=({text:e="--- Hết nội dung ---"})=>(0,i.jsxs)("div",{className:`jsx-${m.__hash} end-of-page`,children:[(0,i.jsx)("span",{className:`jsx-${m.__hash}`,children:e}),(0,i.jsx)(r.default,{id:m.__hash,children:m})]});e.s(["f",0,x],943029);var p=e.i(318892),u=e.i(395659),g=e.i(174659),j=e.i(910474),b=e.i(58026);let _=new String(".recommended-channels.jsx-fd5ea811fd11fa8f .channels.jsx-fd5ea811fd11fa8f{flex-wrap:wrap;justify-content:space-between;display:flex}.item.jsx-fd5ea811fd11fa8f{width:100%;margin:8px 0;display:flex}@media (width>=576px){.item.jsx-fd5ea811fd11fa8f{width:48%}}.item.jsx-fd5ea811fd11fa8f:last-child{margin-bottom:0}.item.jsx-fd5ea811fd11fa8f .title.jsx-fd5ea811fd11fa8f{font-size:14px;font-weight:700}.item.jsx-fd5ea811fd11fa8f .title.jsx-fd5ea811fd11fa8f:hover{color:var(--color-accent-dark)}.item.jsx-fd5ea811fd11fa8f .sub-title.jsx-fd5ea811fd11fa8f{margin:6px 0;font-weight:700}.item.jsx-fd5ea811fd11fa8f .description.jsx-fd5ea811fd11fa8f{color:var(--color-light-action-box-text)}.thumbnail.jsx-fd5ea811fd11fa8f{width:85px;margin-right:15px}.text.jsx-fd5ea811fd11fa8f{flex:1 1 0}");_.__hash="fd5ea811fd11fa8f";let v=[{id:1,title:"Video Tinh tế",description:"Các video review sản phẩm, hướng dẫn, kinh nghiệm",thumbnail:b.default,link:"https://youtube.com/tinhte"},{id:2,title:"Xe Tinh tế",description:"Thông tin, thủ thuật, mẹo mặt về xe máy, xe hơi",thumbnail:j.default,link:"https://tinhte.vn/xe"},{id:3,title:"Camera Tinh tế",description:"Camera và camera phone, vào đây hết nhé anh em",thumbnail:g.default,link:"https://tinhte.vn/camera"},{id:4,title:"Audio Tinh tế",description:"Âm nhạc, tai nghe, loa và mọi thứ về âm thanh",thumbnail:u.default,link:"https://tinhte.vn/audio"}],y=({channels:e})=>(0,i.jsxs)("div",{className:`jsx-${_.__hash} recommended-channels`,children:[(0,i.jsx)("h2",{className:`jsx-${_.__hash} section-heading`,children:"Các kênh thú vị khác"}),(0,i.jsx)("div",{className:`jsx-${_.__hash} channels`,children:e.map(e=>(0,i.jsxs)("a",{href:e.link,className:`jsx-${_.__hash} item`,children:[(0,i.jsx)("div",{className:`jsx-${_.__hash} thumbnail`,children:(0,i.jsx)("img",{src:e.thumbnail,alt:e.title,className:`jsx-${_.__hash}`})}),(0,i.jsxs)("div",{className:`jsx-${_.__hash} text`,children:[(0,i.jsx)("div",{className:`jsx-${_.__hash} title`,children:e.title}),(0,i.jsx)("div",{className:`jsx-${_.__hash} sub-title`,children:e.subTitle}),(0,i.jsx)("div",{className:`jsx-${_.__hash} description`,children:e.description})]})]},e.id))}),(0,i.jsx)(r.default,{id:_.__hash,children:_})]});y.defaultProps={channels:v};let k=n.f.ApiConsumer(y);var w=e.i(724383),T=e.i(377330),N=e.i(962525),S=e.i(565715),$=e.i(913083),P=o,C=e.i(730943),I=e.i(827808),F=e.i(661655),R=e.i(199184),A=e.i(769907);function M(){return(M=Object.assign.bind()).apply(null,arguments)}let D=function(e){return o.createElement("svg",M({xmlns:"http://www.w3.org/2000/svg",width:19,height:18,viewBox:"0 0 19 18"},e),a||(a=o.createElement("path",{fill:"#4B4F56",fillRule:"evenodd",d:"M9.03 0C4.033 0 0 4.02 0 9s4.033 9 9.03 9 9.03-4.02 9.03-9-4.033-9-9.03-9m2.974 5a1 1 0 1 1 0 2A1 1 0 0 1 11 6c-.017-.553.448-1 1.004-1m1.688 8h-9.34c-.27 0-.434-.254-.31-.487l3.347-6.338c.124-.233.496-.233.62 0L9.993 9.92c.124.233.496.233.62 0l.682-1.287c.124-.234.496-.234.62 0l2.087 3.88a.343.343 0 0 1-.31.488"})))},U=new String('.thread-form.jsx-2df470b33f5b5e8a{border:1px solid var(--color-light-1);border-radius:3px;overflow:hidden}.thread-form-actions.jsx-2df470b33f5b5e8a{background-color:var(--color-fill-1)}.thread-form-action.jsx-2df470b33f5b5e8a{color:var(--color-accent-dark);cursor:pointer;vertical-align:middle;padding:12px;font-weight:700}.thread-form-action.jsx-2df470b33f5b5e8a>span.jsx-2df470b33f5b5e8a{vertical-align:middle;display:inline-block}.thread-form-action.jsx-2df470b33f5b5e8a .action-label.jsx-2df470b33f5b5e8a{color:var(--color-dark-0);margin-right:5px}.thread-form-body.jsx-2df470b33f5b5e8a{box-sizing:border-box;background-color:#fff;border-top:1px solid #e2e2e2;padding:11px;position:relative}.thread-form-body.jsx-2df470b33f5b5e8a:before{content:"";border-bottom:8px solid #e2e2e2;border-left:6px solid #0000;border-right:6px solid #0000;width:0;height:0;position:absolute;top:-8px;left:55px;overflow:visible}.thread-form-body.jsx-2df470b33f5b5e8a:after{content:"";border-bottom:7px solid #fff;border-left:5px solid #0000;border-right:5px solid #0000;width:0;height:0;position:absolute;top:-7px;left:56px;overflow:visible}@media only screen and (width<=63.99em){.thread-form-body.jsx-2df470b33f5b5e8a:before{left:28.5px}.thread-form-body.jsx-2df470b33f5b5e8a:after{left:29.5px}}.thread-form-content-container.jsx-2df470b33f5b5e8a{flex:1}.thread-form-content-container.jsx-2df470b33f5b5e8a textarea{box-sizing:border-box;resize:none;width:100%;min-height:40px;box-shadow:none;background:0 0;border:none;outline:none;padding:12px 0;font-size:16px;line-height:1.5;transition:min-height .3s ease-in-out;overflow:hidden}.thread-form-content-container.jsx-2df470b33f5b5e8a input[type=checkbox]{appearance:checkbox}.thread-form-avatar.jsx-2df470b33f5b5e8a{width:40px;margin-right:13px}.thread-form-avatar.jsx-2df470b33f5b5e8a img.jsx-2df470b33f5b5e8a{background-color:#aaa;border-radius:50%;width:100%;display:block;overflow:hidden}.thread-form-author.jsx-2df470b33f5b5e8a{display:none}.thread-form-footer.jsx-2df470b33f5b5e8a{box-sizing:border-box;background-color:#fff;border-top:1px solid #e2e2e2;width:100%;padding:9px 11px 11px;display:none}.thread-form-submit.jsx-2df470b33f5b5e8a{color:var(--color-light-0);cursor:pointer;text-transform:uppercase;background-color:var(--color-accent-dark);border-radius:4px;margin-left:12px;padding:7px 15px;font-size:14px;font-weight:700}.thread-form-error.jsx-2df470b33f5b5e8a{color:red;font-size:12px}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-author.jsx-2df470b33f5b5e8a{font-size:14px;font-weight:700;display:block}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-content.jsx-2df470b33f5b5e8a{min-height:80px;padding-top:5px}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-footer.jsx-2df470b33f5b5e8a{align-items:center;display:flex}.thread-form-cancel.jsx-2df470b33f5b5e8a{color:#757575;cursor:pointer;font-size:14px}.post-to-forum.jsx-2df470b33f5b5e8a{margin-left:5px}.post-to-forum.jsx-2df470b33f5b5e8a:hover{cursor:pointer}@media only screen and (width>=64em){.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-actions.jsx-2df470b33f5b5e8a,.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-body.jsx-2df470b33f5b5e8a,.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-footer.jsx-2df470b33f5b5e8a{z-index:9999}.thread-form-bg.jsx-2df470b33f5b5e8a{content:"";opacity:0;z-index:200;pointer-events:none;background-color:#000;transition:all .3s ease-in-out;position:fixed;inset:0}.thread-form.focused.jsx-2df470b33f5b5e8a .thread-form-bg.jsx-2df470b33f5b5e8a{opacity:.5;pointer-events:all}.thread-form-cancel.jsx-2df470b33f5b5e8a{display:none}}.thread-form-pic.jsx-2df470b33f5b5e8a{display:none}@media only screen and (width<=63.99em){.thread-form.jsx-2df470b33f5b5e8a{margin-top:-1px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused){border:none}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-actions.jsx-2df470b33f5b5e8a{display:none}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-body.jsx-2df470b33f5b5e8a{border-radius:3px;margin-top:8px;padding:5px 11px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-pic.jsx-2df470b33f5b5e8a{color:#757575;align-items:center;padding:0 5px;display:flex}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-pic.jsx-2df470b33f5b5e8a i.jsx-2df470b33f5b5e8a{margin-bottom:4px}.thread-form.jsx-2df470b33f5b5e8a:not(.focused) .thread-form-avatar.jsx-2df470b33f5b5e8a{align-items:center;padding-bottom:5px;display:flex}}');U.__hash="2df470b33f5b5e8a";class E extends P.Component{constructor(e){super(e),this.state={files:[],content:"",focused:!1,loading:!1,thread_id:null,post_id:null,error:"",fullsizeImage:!1,forum_id:null,forum_title:""},this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.showFilePicker=this.showFilePicker.bind(this),this.onNewImages=this.onNewImages.bind(this),this.onSizeTypeChanged=this.onSizeTypeChanged.bind(this),this.prepareThreadToSubmit=this.prepareThreadToSubmit.bind(this),this.resetForm=this.resetForm.bind(this),this.onBackgroundClick=this.onBackgroundClick.bind(this),this.changeForumToPost=this.changeForumToPost.bind(this),this.removeFile=this.removeFile.bind(this)}componentDidMount(){let{id:e,edittingThread:t}=this.props;if(this.setState({forum_id:e}),t){let e=[];t.firstPost.attachments&&(e=t.firstPost.attachments.map(e=>({image:e.links.thumbnail||e.links.permalink,attachment_id:e.attachment_id}))),this.setState({focused:!0,content:t.firstPost.postBody,post_id:t.firstPostId,files:e},()=>{C.default.findDOMNode(this.contentTextarea).value=this.state.content})}}componentDidUpdate(e){let{subForums:t}=this.props;t!==e.subForums&&t.length>0&&this.setState({forum_id:t[0].id})}onBackgroundClick(){this.state.post_id||this.blur()}onSizeTypeChanged(e){this.setState({fullsizeImage:e})}onNewImages(e){this.setState({files:this.state.files.concat(e)})}removeFile(e){let{files:t}=this.state;t[e].shouldUpload?t[e].shouldUpload=!1:t[e].shoudDelete=!0,this.setState({})}showFilePicker(){this.focus(),this.imagePicker.show()}blur(){this.setState({focused:!1}),this.props.onBlur&&this.props.onBlur()}focus(){this.setState({focused:!0}),C.default.findDOMNode(this.contentTextarea).focus()}changeForumToPost(e){let{subForums:t}=this.props,{target:{value:s}}=e,a=t.find(e=>e.id===parseInt(s,10));this.setState({forum_id:parseInt(s,10),forum_title:a.title})}submitPromise(e){return this.state.post_id?this.submitEditPost():this.submitThread(e,this.state.content,this.state.thread_id,this.state.post_id,this.state.files,this.state.fullsizeImage)}prepareThreadToSubmit(){if(this.state.loading)return;if(this.setState({loading:!0,error:""}),!this.state.content)return void this.setState({loading:!1,error:"Vui lòng không để nội dung trống"});let e=this.state.content.split("\n")[0];if(e.length>100){for((e=e.slice(0,100).split(/ /)).pop();e.join(" ").length>97;)e.pop();e=`${e.join(" ")}...`}this.submitPromise(e).then(e=>{if(this.state.post_id){let t={...this.props.edittingThread};this.props.edittingThread.firstPost=(0,F.U)(e,t)}this.resetForm()}).catch(e=>{this.setState({error:e,loading:!1})})}async submitThread(e,t,s,a,i,r){let o=new A.f(this.props.api),n=this.state.forum_id,h=null;try{return h=await o.uploadAttachments(i,s,a,n,r),this.props.api.post({uri:"threads",params:{forum_id:n,thread_title:e,post_body:t}}).catch(e=>{console.log(e),h&&o.deleteAttachments(h,n),this.setState({error:e.toString()})}).then(e=>{if(e.errors)h&&o.deleteAttachments(h,n),this.setState({error:e.errors.toString()});else{let{forum_title:t}=this.state,s={...e.thread,forum:{forum_title:t,forum_id:e.thread.forum_id}};this.props.newThread(s)}})}catch(e){h&&o.deleteAttachments(h,n),this.setState({error:e.toString()})}return!1}submitEditPost(){let e={thread_id:this.state.thread_id,post_body:this.state.content};return this.props.api.put({uri:`posts/${this.state.post_id}`,params:e}).then(({post:e,errors:t})=>{if(t)throw Error(t.toString());return e}).catch(e=>{throw console.log(e),Error(e.toString())})}resetForm(){this.setState({focused:!1,loading:!1,content:"",files:[]}),C.default.findDOMNode(this.contentTextarea).value="",this.blur()}render(){let{user:e,subForums:t}=this.props,{focused:s,post_id:a,content:o,files:n,error:h}=this.state;return(0,i.jsxs)("div",{ref:e=>{this.threadForm=e},onFocus:()=>{this.setState({focused:!0})},className:`jsx-${U.__hash} thread-form ${s?" focused":""}`,children:[(0,i.jsx)("div",{onClick:this.onBackgroundClick,onKeyDown:this.onBackgroundClick,className:`jsx-${U.__hash} thread-form-bg`}),(0,i.jsxs)("div",{className:`jsx-${U.__hash} thread-form-actions box`,children:[(0,i.jsx)("div",{onClick:this.focus,onKeyDown:this.focus,className:`jsx-${U.__hash} thread-form-action`,children:(0,i.jsx)("span",{className:`jsx-${U.__hash}`,children:a?"Sửa bài viết":"Tạo câu hỏi/ bài viết"})}),(0,i.jsxs)("div",{onClick:this.showFilePicker,onKeyDown:this.showFilePicker,className:`jsx-${U.__hash} thread-form-action`,children:[(0,i.jsx)("span",{className:`jsx-${U.__hash} action-label`,children:(0,i.jsx)(D,{})}),(0,i.jsx)("span",{className:`jsx-${U.__hash}`,children:"Thêm ảnh"})]}),t.length>0&&(0,i.jsxs)("div",{className:`jsx-${U.__hash} thread-form-action`,children:[(0,i.jsx)("span",{className:`jsx-${U.__hash} action-label`,children:"Trong:"}),(0,i.jsx)("select",{onChange:this.changeForumToPost,className:`jsx-${U.__hash} post-to-forum`,children:t.map(e=>(0,i.jsx)("option",{value:e.id,className:`jsx-${U.__hash}`,children:e.title},e.id))})]})]}),(0,i.jsxs)("div",{className:`jsx-${U.__hash} thread-form-body box`,children:[e?(0,i.jsx)("div",{className:`jsx-${U.__hash} thread-form-avatar`,children:(0,i.jsx)("img",{alt:e.name,src:e.avatar,className:`jsx-${U.__hash}`})}):(0,i.jsx)("div",{className:`jsx-${U.__hash}`}),(0,i.jsxs)("div",{className:`jsx-${U.__hash} thread-form-content-container`,children:[(0,i.jsx)("div",{className:`jsx-${U.__hash} thread-form-author`,children:e?e.name:""}),(0,i.jsx)(I.f,{placeholder:"Bạn có muốn hỏi hay chia sẻ gì không"+(e?`, ${e.name}?`:"?"),ref:e=>{this.contentTextarea=e},defaultValue:o,onChange:e=>{this.setState({content:e.target.value})}}),(0,i.jsx)(R.f,{files:n,ref:e=>{this.imagePicker=e},onSizeTypeChanged:this.onSizeTypeChanged,onNewImages:this.onNewImages,removeFile:this.removeFile})]}),(0,i.jsx)("div",{onClick:this.showFilePicker,onKeyDown:this.showFilePicker,className:`jsx-${U.__hash} thread-form-pic`,children:(0,i.jsx)("i",{"aria-hidden":"true",className:`jsx-${U.__hash} fa fa-picture-o`})})]}),(0,i.jsxs)("div",{className:`jsx-${U.__hash} thread-form-footer box middle-xs`,children:[(0,i.jsx)("div",{style:a?{display:"block"}:{},onClick:this.blur,onKeyDown:this.blur,className:`jsx-${U.__hash} thread-form-cancel`,children:"Huỷ"}),(0,i.jsx)("div",{style:{flex:1},className:`jsx-${U.__hash}`}),(0,i.jsx)("div",{className:`jsx-${U.__hash} thread-form-error`,children:h}),(0,i.jsx)("div",{onClick:this.prepareThreadToSubmit,onKeyDown:this.prepareThreadToSubmit,className:`jsx-${U.__hash} thread-form-submit`,children:a?"Lưu":"Đăng"})]}),(0,i.jsx)(r.default,{id:U.__hash,children:U})]})}}E.defaultProps={subForums:[]},E.apiFetchesWithAuth={user:{uri:"users/me",success:e=>(0,S.U)(e.user||{}),error:()=>{}}};let z=n.f.ApiConsumer(E);var B=e.i(363872),L=e.i(203828),O=o,H=e.i(886328),V=e.i(770267),K=e.i(437994),X=e.i(612683),q=e.i(693084),G=e.i(241427),W=e.i(310717),Y=e.i(490839),J=e.i(535044),Q=e.i(867507),Z=e.i(618488),ee=e.i(723661),et=e.i(501584),es=e.i(634529),ea=e.i(566573),ei=e.i(6788),er=e.i(298299),eo=e.i(532123),en=e.i(588076),eh=e.i(574186),ed=e.i(659497),el=e.i(456310),ec=e.i(94432);let ef=o.default.createContext("thread_self_session"),em=async(e,t)=>{let{stats:s}=t,a=!t.isLiked;return await e[a?"post":"del"]({uri:`/posts/${t.id}/likes`}),{...t,isLiked:a,stats:{...s,like:s.like+(a?1:-1)}}};var ex=o,ep=e.i(659967),eu=e.i(34026);let eg=e=>new Promise(t=>{let s=new window.Image;s.onload=()=>{t(s)},s.src=e});var ej=o;let eb=new String(".loading-spinner.jsx-a969af87b94bc3ad{color:var(--color-accent-dark);opacity:.7;justify-content:center;align-items:center;font-size:50px;display:flex;position:absolute;inset:0}");eb.__hash="a969af87b94bc3ad";class e_ extends ej.default.Component{constructor(e){super(e),this.state={loaded:!1}}UNSAFE_componentWillMount(){this.loadAttachmentImage()}async loadAttachmentImage(){let{attachment:e,onImageLoaded:t}=this.props,s=await eg(e.links.permalink);t&&t(s),this.setState({loaded:!0})}render(){let{attachment:e}=this.props,{loaded:t}=this.state,s=e.links.thumbnail?e.links.permalink:"";return(0,i.jsxs)("div",{style:{backgroundImage:`url(${s||eu.default})`},className:`jsx-${eb.__hash} image`,children:[!t&&(0,i.jsx)("span",{className:`jsx-${eb.__hash} loading-spinner`,children:(0,i.jsx)("i",{className:`jsx-${eb.__hash} fas fa-circle-notch fa-spin`})}),!s&&(0,i.jsx)("span",{className:`jsx-${eb.__hash} no-thumb-hint`,children:"Nhấn để xem ảnh gốc"}),(0,i.jsx)(r.default,{id:eb.__hash,children:eb})]})}}let ev=new String(".image-masonry.jsx-c7a5230df8c34e05{flex-wrap:wrap;margin-left:-2.5px;margin-right:-2.5px;display:flex}.image-masonry.jsx-c7a5230df8c34e05 .image{cursor:pointer;background-position:50%;background-repeat:no-repeat;background-size:cover;padding-top:100%;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .no-thumb-hint{text-align:center;justify-content:center;align-items:flex-end;padding:3px;font-size:12px;display:flex;position:absolute;inset:0}.image-masonry.jsx-c7a5230df8c34e05 .image-wrapper.jsx-c7a5230df8c34e05{width:100%}.image-masonry.jsx-c7a5230df8c34e05 .single-tile.jsx-c7a5230df8c34e05{cursor:pointer;padding:2.5px;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .single-tile.jsx-c7a5230df8c34e05 .image{border-top:1px solid var(--border-light);border-bottom:1px solid var(--border-light);padding-top:56.25%}.image-masonry.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05{box-sizing:border-box;width:33.3%;padding:2.5px;position:relative}.image-masonry.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05 .more.jsx-c7a5230df8c34e05{color:#fff;pointer-events:none;background:#00000073;justify-content:center;align-items:center;font-size:36px;font-weight:700;display:flex;position:absolute;inset:2.5px}.image-masonry.big-top.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05:first-child,.image-masonry.big-top.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05:nth-child(2){width:50%}.image-masonry.single-row.jsx-c7a5230df8c34e05 .image-tile.jsx-c7a5230df8c34e05{flex:1;width:auto}img.single-img{border-top:1px solid var(--border-light);border-bottom:1px solid var(--border-light)}");ev.__hash="c7a5230df8c34e05";class ey extends ex.default.Component{constructor(e){super(e),this.state={shouldCropSingleTile:null,imageAttachments:[],nonImageAttachments:[],loadedImageHash:{}}}componentDidMount(){this.preprocessAttachments(this.props.attachments)}onAttachmentClick(e){return()=>{this.props.onAttachmentClick(e)}}onImageLoaded(e){this.setState({loadedImageHash:{...this.state.loadedImageHash,[e.attachment_id]:!0}},this.checkAllImagesLoaded)}checkAllImagesLoaded(){let{onAllImagesLoaded:e}=this.props;if(!e)return;let{loadedImageHash:t,imageAttachments:s}=this.state;s.every(e=>t[e.attachment_id])&&e()}preprocessAttachments(e){if(!e)return;let t=/\.(jpg|gif|png|jpeg|bmp|tiff)$/i,s=[],a=[];e.forEach(e=>{t.test(e.filename)?s.push(e):a.push(e)}),this.checkSingleTile(s),this.setState({imageAttachments:s,nonImageAttachments:a,loadedImageHash:{}})}checkSingleTile(e){let t=null,s=null;if(!e)return;let a=e.filter(e=>!e.attachment_is_inserted);1===a.length&&([t]=a,s=e.findIndex(e=>e===t),this.loadSingleImageAttachment(t)),this.setState({singleTile:t,singleTileIndex:s})}async loadSingleImageAttachment(e){let t=await eg(e.links.permalink),s=t.height/t.width>=1;this.setState({shouldCropSingleTile:s}),this.onImageLoaded(e)}renderTile(e){return(0,i.jsx)(e_,{attachment:e,onImageLoaded:()=>{this.onImageLoaded(e)}})}renderSingleTile(e,t){let{loadedImageHash:s}=this.state,a=s[e.attachment_id],o=null;return o=e.links.thumbnail?a?this.state.shouldCropSingleTile?this.renderTile(e):(0,i.jsx)("img",{className:"full-width single-img",src:e.links.permalink,alt:e.filename,title:e.filename,onLoad:()=>this.onImageLoaded(e)}):(0,i.jsxs)("div",{children:["Đang tải ảnh...",(0,i.jsx)(ep.f,{busy:!0,color:"var(--color-accent-dark)"})]}):(0,i.jsxs)("div",{children:[(0,i.jsx)("img",{className:"full-width single-img",src:eu.default,alt:e.filename}),(0,i.jsx)("span",{className:"no-thumb-hint",children:"Nhấn để xem ảnh gốc"})]}),(0,i.jsxs)("button",{onClick:this.onAttachmentClick(t),className:`jsx-${ev.__hash} single-tile image-wrapper`,children:[o,(0,i.jsx)(r.default,{id:ev.__hash,children:ev})]})}renderTiles(e,t){let s=0;return e.map((a,o)=>a.attachment_is_inserted||s>=t?null:(s+=1,(0,i.jsxs)("button",{onClick:this.onAttachmentClick(o),className:`jsx-${ev.__hash} image-tile`,children:[this.renderTile(a),s===t&&e.length>t&&(0,i.jsxs)("span",{className:`jsx-${ev.__hash} more`,children:["+",e.length-t]}),(0,i.jsx)(r.default,{id:ev.__hash,children:ev})]},a.attachment_id)))}render(){let{singleRow:e}=this.props,{imageAttachments:t,nonImageAttachments:s,singleTile:a,singleTileIndex:o}=this.state,n=this.props.maxSize||5,h="";return e?h="single-row":(2===t.length||t.length>3)&&(h="big-top"),(0,i.jsxs)(ex.Fragment,{children:[s.length>0&&(0,i.jsx)("div",{style:{padding:12},className:`jsx-${ev.__hash}`,children:s.map(e=>(0,i.jsx)("div",{className:`jsx-${ev.__hash}`,children:(0,i.jsxs)("a",{href:e.links.permalink,style:{color:"var(--color-link)"},className:`jsx-${ev.__hash}`,children:[(0,i.jsx)("i",{style:{marginRight:4},className:`jsx-${ev.__hash} far fa-file`}),e.filename]})},e.attachment_id))}),(0,i.jsx)("div",{className:`jsx-${ev.__hash} image-masonry ${h}`,children:a?this.renderSingleTile(a,o):this.renderTiles(t,n)}),(0,i.jsx)(r.default,{id:ev.__hash,children:ev})]})}}var ek=e.i(281312),ew=e.i(158586);e.i(189500);let eT="/feature-pages/threads/sticky",eN=(0,H.default)(({innerRef:e})=>(0,i.jsx)("div",{className:"mark-read-marker",ref:e})),eS={content:{border:"none",backgroundColor:"var(--post-background)",maxWidth:"600px",width:"95%",top:"20%",left:"50%",right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}};class e$ extends O.default.Component{constructor(e){super(e),this.addPost=this.addPost.bind(this);let{thread:t}=this.props;this.state={thread:t,readMore:!1,loadMore:t.latestPosts.length{this.markThreadAsRead(e)},1500)}resetTimer(){this.timer&&clearTimeout(this.timer)}trackThreadRead(e){let{api:t,requestType:a,community:i,pageNumber:r}=this.props,o=new eh.U(t),n="foru";a===s.FEED||a===s.GRAPHFEED?n="foru":a===s.COMMUNITY?n="community":a===s.PROFILE&&(n="profile");let h=[{key:"thread_id",value:e},{key:"source_feature",value:n},{key:"foru_page_number",value:r||1}];i&&a===s.COMMUNITY&&h.push({key:"community_id",value:i.fpId}),t.onAuthenticated(()=>{o.trackEvent(el.f.ForU_Thread_Read,t.getUserId(),h),o.trackPageView(ed.f.ThreadView_Detail,t.getUserId(),h)})}markThreadAsRead(e){let{api:t}=this.props;t.post({uri:"/tinhte/threads/thread-reads",params:{thread_id:e}}).catch(e=>console.log("Failed to mark thread as read. "+e)),ga("send","pageview"),this.trackThreadRead(e)}toggleCommunityStickyThread(){let{api:e,community:t}=this.props,{thread:s}=this.state,a="post";s.isSticky&&(a="del"),e[a]({uri:eT,params:{fp_id:t.fpId,thread_id:s.id}}).then(()=>{this.setState({thread:{...s,isSticky:!s.isSticky}})}).catch(e=>console.log("Failed to stick thread: "+e))}removeCommunityThread(){let{api:e,community:t}=this.props,{thread:s}=this.state;e.del({uri:eT,params:{fp_id:t.fpId,thread_id:s.id}}).then(()=>{this.setState({thread:{...s,isDeleted:!0}})}).catch(e=>console.log("Failed to remove thread from community: "+e))}deleteThread(){let{api:e}=this.props,{thread:t}=this.state;e.del({uri:`/threads/${t.id}`}).then(()=>{this.setState({thread:{...t,isDeleted:!0},showDeleteConfirmationModal:!1})}).catch(e=>console.log("Failed to delete thread"+e))}toogleDeleteConfirmationModal(){let{showDeleteConfirmationModal:e}=this.state;this.setState({showDeleteConfirmationModal:!e})}loadMorePosts(e){let{postLink:t}=e,{api:s}=this.props;s.get({uri:t,headers:{"Api-Post-Tree":1},params:{limit:5,order:"natural_reverse"}}).then(t=>{let{posts:s,links:a=null}=t,{next:i=""}=a||{},r=(0,F.e)(e,s.map(t=>(0,F.U)(t,e)));this.showMorePost(r,i)}).catch(e=>console.log("Failed to load more posts. "+e))}showMorePost(e,t){let{thread:s}=this.state,{latestPosts:a}=s,i=(0,K.default)([...a,...e],"id"),r=i.reduce((e,t)=>e+t.postRepliesDetail.length,0)+i.length;this.setState({thread:{...s,postLink:t,latestPosts:i},loadMore:r{"tinhtefact"===e.tag&&(l=!0,d=!1)}),e.firstPost.isThreadBackground&&(d=!1),e)?e.userIsIgnored?(0,i.jsx)("div",{}):(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} thread`,children:[(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} main-thread`,children:[(0,i.jsxs)("div",{id:e.id,className:`jsx-${ek.f.__hash} header`,children:[(0,i.jsx)(Y.f,{user:e.author,thread:e,userRank:e.firstPost.posterRank.rankName,postedSince:e.since}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} thread-controls`,children:[e.isSticky&&(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} sticky-icon`,children:(0,i.jsx)("button",{onClick:()=>this.toggleCommunityStickyThread(),className:`jsx-${ek.f.__hash} sticky-icon-button`,children:(0,i.jsx)(en.f,{})})}),(0,i.jsx)(es.f,{position:"right",menuItems:(0,i.jsxs)(O.Fragment,{children:[(0,i.jsx)("a",{href:e.link,className:`jsx-${ek.f.__hash}`,children:"Xem chi tiết"}),e&&e.permissions.edit&&(0,i.jsx)("button",{onClick:()=>{this.props.editThread(e)},className:`jsx-${ek.f.__hash}`,children:"Sửa"}),e&&e.permissions.delete&&(0,i.jsx)("button",{onClick:()=>this.toogleDeleteConfirmationModal(),className:`jsx-${ek.f.__hash}`,children:"Xóa"}),o&&o.isVisitor&&(0,i.jsx)("button",{onClick:()=>this.onStickProfileThread(e.id),className:`jsx-${ek.f.__hash}`,children:"Ghim bài"}),n&&(0,i.jsxs)(O.Fragment,{children:[e.fpPermissions.delete&&(0,i.jsx)("button",{onClick:()=>this.removeCommunityThread(),className:`jsx-${ek.f.__hash}`,children:"Xóa khỏi cộng đồng"}),(e.fpPermissions.stick||e.fpPermissions.unstick)&&(0,i.jsx)("button",{onClick:()=>this.toggleCommunityStickyThread(),className:`jsx-${ek.f.__hash}`,children:"Ghim bài"})]})]})}),e.isDeleted&&(0,i.jsx)(eo.f,{className:"deleted-marker"})]})]}),(0,i.jsx)(eN,{onEnterViewport:()=>this.startTimer(e.id),onLeaveViewport:()=>this.resetTimer()}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} body visible-xs`,children:[(0,i.jsx)("a",{href:e.link.replace("https://tinhte.vn",""),className:`jsx-${ek.f.__hash} content-mobile`,children:e.firstPost.isThreadBackground?(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} thread-with-background-container`,children:(0,i.jsx)(W.f,{firstPost:e.firstPost})}):(0,i.jsx)(q.f,{body:e.firstPost.bodyHtml,author:e.firstPost.author.name})}),(0,i.jsx)(ew.f,{thread:e,post:e.firstPost}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} thread-react`,children:[ec.q.map(e=>{let t=h&&h.reaction&&h.reaction.userReactionId===e,s=h&&h.reaction&&h.reaction.postReactions[e]||0;return(0,i.jsx)(O.Fragment,{children:(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} react-item`,children:[(0,i.jsx)(Z.f,{commentMode:!1,post:h,onReact:this.onReact,reactionButtonId:e}),(0,i.jsx)("span",{className:`jsx-${ek.f.__hash} ${t?"reacted-text":""}`,children:s})]})},`${e}`)}),(0,i.jsxs)("a",{href:e.link,className:`jsx-${ek.f.__hash} react-item`,children:[(0,i.jsx)(ei.f,{}),(0,i.jsx)("span",{className:`jsx-${ek.f.__hash}`,children:e.stats.comment})]}),(0,i.jsx)("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${e.link}`,rel:"noopener noreferrer",target:"_blank",className:`jsx-${ek.f.__hash} react-item`,children:(0,i.jsx)(er.f,{})})]})]}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} body hidden-xs`,children:[d&&(0,i.jsx)("h4",{className:`jsx-${ek.f.__hash} thread-title`,children:(0,i.jsx)("a",{href:e.link,className:`jsx-${ek.f.__hash}`,children:e.title})}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} `+(`thread-content ${l?"tinhtefact":""}`+(this.state.readMore?" open":"")||""),children:[!e.firstPost.isThreadBackground&&(0,i.jsx)(O.Fragment,{children:l?(0,i.jsx)(G.f,{thread:e}):(0,i.jsx)("div",{ref:e=>{this.threadBody=e},className:`jsx-${ek.f.__hash}`,children:(0,i.jsx)(q.f,{body:e.firstPost.bodyHtml,author:e.firstPost.author.name})})}),e.firstPost.isThreadBackground&&(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} thread-with-background-container`,children:(0,i.jsx)(W.f,{firstPost:e.firstPost})})]}),this.state.threadHeight>400&&(0,i.jsx)("div",{onClick:this.showFullContent,onKeyDown:this.showFullContent,className:`jsx-${ek.f.__hash} read-more`,children:"...Xem thêm"})]}),!l&&!e.firstPost.isThreadBackground&&e.firstPost.attachments&&e.firstPost.attachments.length>0&&(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} image-masonry-wrapper hidden-xs`,children:(0,i.jsx)(ey,{attachments:e.firstPost.attachments,onAttachmentClick:this.viewAttachment})}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} statistic hidden-xs`,children:[(0,i.jsx)(ee.f,{commentMode:!1,totalReaction:this.state.totalReaction,post:e.firstPost}),e.stats.comment>0&&(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash}`,children:[(0,i.jsx)("span",{className:`jsx-${ek.f.__hash}`,children:(0,i.jsx)(X.f,{value:e.stats.comment})})," bình luận"]})]}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} action-bar no-user-select hidden-xs`,children:[ec.q.map(e=>(0,i.jsx)(Z.f,{commentMode:!1,post:h,onReact:this.onReact,reactionButtonId:e},`${e}`)),(0,i.jsx)("a",{href:e.link,className:`jsx-${ek.f.__hash} action no-user-select`,children:(0,i.jsx)("span",{className:`jsx-${ek.f.__hash} icon`,children:(0,i.jsx)(ei.f,{})})}),(0,i.jsx)("a",{href:`https://www.facebook.com/sharer/sharer.php?u=${e.link}`,rel:"noopener noreferrer",target:"_blank",className:`jsx-${ek.f.__hash} action no-user-select`,children:(0,i.jsx)("span",{className:`jsx-${ek.f.__hash} icon`,children:(0,i.jsx)(er.f,{})})})]}),a?(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} comment-box hidden-xs`,children:(0,i.jsx)(Q.f,{ref:e=>{this.postReply=e},api:this.props.api,postToReply:h,user:a,addPost:this.addPost})}):(0,i.jsx)("div",{className:`jsx-${ek.f.__hash}`})]}),e.latestPosts&&e.latestPosts.length>0&&(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} comments hidden-xs`,children:[(0,i.jsx)(J.f,{user:a,posts:e.latestPosts}),s&&(0,i.jsx)("div",{className:`jsx-${ek.f.__hash} more-comments`,children:(0,i.jsx)("button",{onClick:()=>this.loadMorePosts(e),className:`jsx-${ek.f.__hash}`,children:"Xem thêm bình luận..."})})]}),t&&(0,i.jsxs)(V.default,{isOpen:t,ariaHideApp:!1,style:eS,children:[(0,i.jsx)("h2",{className:`jsx-${ek.f.__hash} modal-title`,children:"Bạn có chắc chắn muốn xóa bài này không? Xóa là mất luôn đó nha!"}),(0,i.jsxs)("div",{className:`jsx-${ek.f.__hash} modal-controls`,children:[(0,i.jsx)("button",{onClick:()=>this.deleteThread(),className:`jsx-${ek.f.__hash} modal-button yes`,children:"Xóa"}),(0,i.jsx)("button",{onClick:()=>this.setState({showDeleteConfirmationModal:!1}),className:`jsx-${ek.f.__hash} modal-button`,children:"Không"})]})]}),(0,i.jsx)(r.default,{id:ek.f.__hash,children:ek.f})]}):(0,i.jsx)("div",{})}}let eP=(0,et.f)(n.f.ApiConsumer(((t=e=>(0,i.jsx)(ef.Consumer,{children:({session:t,user:s,utils:a})=>(0,i.jsx)(e$,{...e,session:t,user:s,threadSelfUtils:a})})).displayName=t.name,t)),{errorMsg:"Lỗi social thread stream"});var eC=o;let eI=new String(".image-overlay.jsx-32e3f23e7b0f919a{opacity:1;z-index:2;justify-content:center;align-items:center;transition:opacity .3s ease-in-out;display:flex;position:fixed;inset:0}@media (width>=1001px){.image-overlay.jsx-32e3f23e7b0f919a{padding-left:15%}}.image-overlay.hidden.jsx-32e3f23e7b0f919a,.image-overlay.hidden.jsx-32e3f23e7b0f919a .jsx-32e3f23e7b0f919a{pointer-events:none;opacity:0}.image-overlay.jsx-32e3f23e7b0f919a .bg.jsx-32e3f23e7b0f919a{background:#000c;position:absolute;inset:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a{position:relative}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image.jsx-32e3f23e7b0f919a{background:#fff}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image.jsx-32e3f23e7b0f919a img.jsx-32e3f23e7b0f919a{max-width:80vw;max-height:80vh;display:block}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:0;pointer-events:none;justify-content:space-between;align-items:center;transition:opacity .3s ease-in-out;display:flex;position:absolute;inset:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{color:#fff;text-shadow:2px 2px 2px #000;cursor:pointer;padding:10px;font-size:24px;position:absolute;top:0;right:0}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a{color:#fff;text-shadow:2px 2px 2px #000;cursor:pointer;padding:10px;font-size:24px}@media (width>=48em){.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a,.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a{padding:20px}}.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:1}.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a,.image-overlay.focused.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{pointer-events:all}@media (width>=48em){.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a{opacity:1}.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a .image-nav.jsx-32e3f23e7b0f919a,.image-overlay.jsx-32e3f23e7b0f919a .content.jsx-32e3f23e7b0f919a:hover .image-overlay-navs.jsx-32e3f23e7b0f919a .image-overlay-close.jsx-32e3f23e7b0f919a{pointer-events:all}}");eI.__hash="32e3f23e7b0f919a";class eF extends eC.default.Component{constructor(e){super(e),this.state={imageFocused:!0},this.toggleImageFocused=this.toggleImageFocused.bind(this),this.keyHandler=(({esc:e,left:t,right:s})=>a=>{switch(a.keyCode){case 27:e();break;case 37:t();break;case 39:s()}})({left:this.onImageSwitch(-1),right:this.onImageSwitch(1),esc:this.props.onClose})}componentDidMount(){window.$(window.document).on("keyup",this.keyHandler)}componentWillUnmount(){window.$(window.document).off("keyup",this.keyHandler)}onImageSwitch(e){return()=>{let t=this.props.viewingIndex+e;t=Math.min(t=Math.max(t,0),this.props.attachments?this.props.attachments.length-1:0),this.props.onImageSwitch(t)}}toggleImageFocused(){this.setState({imageFocused:!this.state.imageFocused})}render(){let{viewingIndex:e,attachments:t}=this.props,s=t?t[e]:null,a=t&&e0&&(0,i.jsx)("button",{onClick:this.onImageSwitch(-1),className:`jsx-${eI.__hash} image-nav`,children:(0,i.jsx)("i",{"aria-hidden":"true",className:`jsx-${eI.__hash} fa fa-chevron-left`})}),(0,i.jsx)("div",{className:`jsx-${eI.__hash}`}),a&&(0,i.jsx)("button",{onClick:this.onImageSwitch(1),className:`jsx-${eI.__hash} image-nav`,children:(0,i.jsx)("i",{"aria-hidden":"true",className:`jsx-${eI.__hash} fa fa-chevron-right`})})]})]}),(0,i.jsx)(r.default,{id:eI.__hash,children:eI})]})}}var eR=e.i(758568);let eA=e=>{let t=(e.data||e.threads).map($.U),s=(0,eR.default)(e,"sticky_threads",[]).map($.U),a=[];s.length>0&&s.forEach(e=>{a.push({...e,isSticky:!0})});let i=(0,eR.default)(e,"links",null);return{newThreads:[...a,...t],nextPage:(0,eR.default)(i,"next",null)}},eM=e=>{let t=(e.data||e.facts).map($.U),s=(0,eR.default)(e,"links",null);return{newThreads:t,nextPage:(0,eR.default)(s,"next",null)}},eD=e=>({newThreads:[],error:e&&e.message?e.message:"Có lỗi khi tải bài viết"}),eU=new String(".main.jsx-79523f40e962430c{margin-bottom:0}@media (width>=768px){.main.jsx-79523f40e962430c{margin-bottom:12px}}.interfered-block.jsx-79523f40e962430c{margin:12px 0;padding:12px 10px}@media (width>=576px){.interfered-block.jsx-79523f40e962430c{padding-left:20px;padding-right:20px}}@media (width>=768px){.interfered-block.jsx-79523f40e962430c{padding-left:0;padding-right:0}}.loading-container.jsx-79523f40e962430c{justify-content:center;margin:20px 0;display:flex}.loading-container.jsx-79523f40e962430c svg{fill:inherit}.threads.jsx-79523f40e962430c .primaryContent a,.threads.jsx-79523f40e962430c .primaryContent a *{color:var(--color-accent-dark)}.threads.jsx-79523f40e962430c .LinkExpander.expanded{display:block}");eU.__hash="79523f40e962430c";var eE=e.i(566709);let ez=new String(".facts-container.jsx-9f8ccfc7430bdcb9{-webkit-scroll-snap-type:y mandatory;-ms-scroll-snap-type:y mandatory;scroll-snap-type:y mandatory;scroll-behavior:smooth;touch-action:pan-y;overscroll-behavior-y:contain;scrollbar-width:none;height:100vh;scroll-padding-top:1px;overflow:hidden auto}.facts-container.jsx-9f8ccfc7430bdcb9::-webkit-scrollbar{display:none}");ez.__hash="9f8ccfc7430bdcb9";let eB=({threads:e,onMoreThread:t,onNewThread:s})=>{let a=(0,o.useRef)(null),[n,h]=(0,o.useState)(e?e[0]:null),d=(0,o.useCallback)(()=>{n&&window.history.replaceState({},"",`#${n.id}`)},[n]);return(0,o.useEffect)(()=>{d()},[d]),(0,o.useEffect)(()=>{n&&e.findIndex(e=>e.id===n.id)===e.length-2&&t()},[n,e]),(0,i.jsxs)("div",{ref:a,className:`jsx-${ez.__hash} facts-container`,children:[e.map((e,t)=>(0,i.jsx)(eE.U,{thread:e,observerOptions:{root:a.current},onInView:h,showHeader:0===t,onNewThread:s},e.id)),(0,i.jsx)(r.default,{id:ez.__hash,children:ez})]})};class eL extends o.default.Component{constructor(e){super(e),this.state={threads:[],pageNumber:0,nextPage:null,loading:!0,attachmentViewer:{viewingIndex:null,attachments:null},edittingThread:null,endResult:!1},this.onImageSwitch=this.onImageSwitch.bind(this),this.onImageClose=this.onImageClose.bind(this),this.loadMore=this.loadMore.bind(this),this.session={updateThreadInSession:this.updateThreadInSession.bind(this),updatePostInSession:this.updatePostInSession.bind(this)},this.utils={viewAttachment:this.viewAttachment.bind(this)},this.editThread=this.editThread.bind(this),this.stickThread=this.stickThread.bind(this),this.handleInfinityScroll=this.handleInfinityScroll.bind(this),this.onStickProfileThread=this.onStickProfileThread.bind(this)}componentDidMount(){let{api:e}=this.props;e.onAuthenticated(()=>{this.loadMore()}),B.isMobile||window.addEventListener("scroll",(0,c.default)(()=>{this.handleInfinityScroll()},1e3))}componentDidUpdate(e){let{id:t,api:s,newThread:a,paramVal:i,tinhteFact:r}=this.props;if((0,d.default)(a)||a===e.newThread)t!==e.id&&s&&s.onAuthenticated(()=>{this.setState({threads:[],nextPage:null}),this.loadMore()});else{let{threads:e}=this.state,t=[{...(0,$.U)(a),posts:[]},...e];this.setState({threads:t})}let o=window.location.hash?window.location.hash.replace("#",""):null;o&&setTimeout(()=>{let e=document.getElementById(o);e&&(r&&B.isMobile?e.scrollIntoView({behavior:"instant",block:"start"}):(e.scrollIntoView({block:"center"}),window.history.replaceState("",document.title,window.location.pathname+window.location.search)))},0);let n=i.userProfile?i.userProfile.id:null,h=e.paramVal.userProfile?e.paramVal.userProfile.id:null,{forumId:c}=i,f=e.paramVal?e.paramVal.forumId:null;(h&&n&&!(0,l.default)(n,h)||!(0,l.default)(c,f))&&this.resetComponentState()}onImageSwitch(e){this.viewAttachment(this.state.attachmentViewer.attachments,e)}onImageClose(){this.viewAttachment(null,null)}onStickProfileThread(e){this.props.stickProfileThread(e)}resetComponentState(){this.setState({threads:[],pageNumber:0,nextPage:null,loading:!0,attachmentViewer:{viewingIndex:null,attachments:null},edittingThread:null,endResult:!1},()=>this.loadMore())}stickThread(e){this.props.stickThread&&this.props.stickThread(e)}editThread(e){this.setState({edittingThread:e})}loadMore(){let{api:e,requestType:t,paramVal:a,router:i}=this.props,r=i.query&&i.query.user_id,{threads:o,nextPage:n,pageNumber:d}=this.state;if(console.log("ThreadStream loadMore: ",d,r),!e)return;this.setState({loading:!0});let l=t;l===s.FACT&&r&&(l=s.FACT_USER),((e,t,a=10,i,r,o)=>{let n=null,h="",d=!1,l=(0,$.X)("content.");if(t)n=t;else{let t={limit:a,page:1,non_mod_only:1,order:"thread_create_date_reverse",fields_include:l};switch(i){case s.FACT_USER:h="/tinhte-facts/users",t={page:1,limit:a||5,user_id:o,_bdImageApiThreadThumbnailWidth:"200",_bdImageApiThreadThumbnailHeight:"sw",fields_include:l};break;case s.FACT:h="/tinhte-facts";break;case s.FEED:e.getUserId(),h="users/me/neo-feeds";break;case s.FORUM:h=`tinhte/node-new-threads?node_id=${r}`;break;case s.PROFILE:let c,f;c=r.userProfile.id,f=r.forumId,h=`users/${c}/threads?forum_id=${f}`;break;case s.TAG:h=`search/tagged?tag=${r}`,d=!0;break;case s.COMMUNITY:h=`feature-pages/threads?fp_id=${r}`,l=(0,$.X)("content.",["fp_permissions"]);break;case s.TAG_SEARCH:h=`search/?tag=${r&&r.tagText||""}&q=${r&&r.term||""}`,l=(0,$.Y)("content."),d=!0;break;default:return Promise.reject(Error("Missing component's request type and parameter's value"))}n={uri:h,params:t,headers:{"Api-Post-Tree":1}}}return d?t?e.get(n).then(eA,eD):e.post(n).then(eA,eD):e.get(n).then(i===s.FACT||i===s.FACT_USER?eM:eA,eD)})(e,n,15,l,a,r).then(({newThreads:e,error:t,nextPage:s})=>{if(t)this.setState({loading:!1,endResult:!0}),h.c.error(t);else{let t=e.filter(e=>!o.some(t=>t.id===e.id)),a=[...o,...t];this.setState({threads:a,loading:!1,nextPage:s,endResult:!s,pageNumber:d+1},()=>{})}}).catch(e=>{this.setState({loading:!1,endResult:!0}),h.c.error("Có lỗi khi tải bài viết"),console.log(e)})}saveThreadsToSession(){let{threads:e,nextPage:t,loading:s}=this.state,a={state:{threads:e,nextPage:t,loading:s},last_load_time:parseInt(new Date().getTime()/1e3,10)};window.sessionStorage.setItem("threadSelf",JSON.stringify(a))}updateThreadInSession(e){if(!window.sessionStorage.getItem("threadSelf"))return;let t=this.state.threads.find(t=>t.id===e.id);t&&(Object.assign(t,e),this.saveThreadsToSession())}updatePostInSession(e){if(!window.sessionStorage.getItem("threadSelf"))return;let t=this.state.threads.find(t=>t.id===e.thread.id);if(!t)return;let s=null;if(e.postReplyTo&&e.postReplyTo!==t.firstPostId){let a=t.posts.find(t=>t.id===e.postReplyTo);a.postRepliesDetail&&(s=a.postRepliesDetail.find(t=>t.id===e.id))}else s=t.posts.find(t=>t.id===e.id);s&&Object.assign(s,e),this.saveThreadsToSession()}viewAttachment(e,t){this.setState({attachmentViewer:{attachments:e,viewingIndex:t}})}handleInfinityScroll(){let{threads:e,endResult:t}=this.state;if(!t){let t=document.querySelector(".load-more-marker");if(t&&e.length>0){let e=t.offsetTop+t.clientHeight;window.pageYOffset+window.innerHeight>e&&this.loadMore()}}}render(){let{user:e,community:t,requestType:s,paramVal:a,tinhteFact:n,onNewThread:h}=this.props,{attachmentViewer:d,loading:l,threads:c,edittingThread:m,endResult:u,pageNumber:g}=this.state,{attachments:j,viewingIndex:b}=d;return n&&B.isMobile?(0,i.jsxs)(o.Fragment,{children:[0===c.length&&!l&&(0,i.jsx)(p.f,{children:(0,i.jsx)("a",{href:"/following-community",target:"_blank",className:`jsx-${eU.__hash} btn`,children:"Tìm hiểu tag"})}),l&&(0,i.jsx)("div",{className:`jsx-${eU.__hash} loading-container`,children:(0,i.jsx)(f.default,{type:"cylon",color:"#00bad6",width:100})}),(0,i.jsx)(eB,{threads:c,onMoreThread:this.loadMore,onNewThread:h}),(0,i.jsx)(r.default,{id:eU.__hash,children:eU})]}):(0,i.jsxs)("div",{className:`jsx-${eU.__hash}`,children:[0===c.length&&!l&&(0,i.jsx)(p.f,{children:(0,i.jsx)("a",{href:"/following-community",target:"_blank",className:`jsx-${eU.__hash} btn`,children:"Tìm hiểu tag"})}),(0,i.jsxs)(ef.Provider,{value:{session:this.session,user:e,utils:this.utils},children:[(0,i.jsxs)("div",{className:`jsx-${eU.__hash} threads items`,children:[c.length>0&&c.map((e,r)=>(0,i.jsxs)(o.Fragment,{children:[m&&m.id===e.id?(0,i.jsx)(z,{edittingThread:e,onBlur:()=>{this.editThread(null)}}):(0,i.jsx)(eP,{thread:e,userProfile:a&&a.userProfile,editThread:this.editThread,community:t,requestType:s,pageNumber:g,stickProfileThread:this.onStickProfileThread}),2===r&&(0,i.jsxs)("div",{className:`jsx-${eU.__hash} interfered-block visible-md`,children:[" ",(0,i.jsx)(w.f,{})]}),(2===r||r>10&&r%5==0)&&(0,i.jsx)("div",{className:`jsx-${eU.__hash} interfered-block`,children:(0,i.jsx)(T.f,{adLayoutKey:"-6c+du+k-3x+d5",adSlot:"3460318925"})}),6===r&&(0,i.jsxs)("div",{className:`jsx-${eU.__hash} interfered-block`,children:[" ",(0,i.jsx)(N.f,{})]}),10===r&&(0,i.jsxs)("div",{className:`jsx-${eU.__hash} interfered-block`,children:[" ",(0,i.jsx)(k,{})]})]},e.id)),u?(0,i.jsx)(x,{}):(0,i.jsx)("div",{className:`jsx-${eU.__hash} load-more-marker`})]}),(0,i.jsx)("div",{className:`jsx-${eU.__hash} main`,children:(0,i.jsx)(eF,{onImageSwitch:this.onImageSwitch,onClose:this.onImageClose,attachments:j,viewingIndex:b})})]}),l&&(0,i.jsx)("div",{className:`jsx-${eU.__hash} loading-container`,children:(0,i.jsx)(f.default,{type:"cylon",color:"#00bad6",width:100})}),(0,i.jsx)(r.default,{id:eU.__hash,children:eU})]})}}eL.apiFetchesWithAuth={user:{uri:"users/me",success:e=>(0,S.U)(e.user||{})}};let eO=n.f.ApiConsumer((0,L.withRouter)(eL));e.s(["f",0,eO],805513)}]);