(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{1145:function(e,t,n){"use strict";var o=n(17),r=n(0),a=n(91),i=n.n(a),s=n(21),c=n(192),m=n(15),l=n(176);function d(e){return e.reduce((function(e,t){var n;return[].concat(Object(m.a)(e),Object(m.a)(null!==(n=t.stickers)&&void 0!==n?n:[]))}),[])}var u=function(){return window.zh_emoticon?Promise.resolve(d(window.zh_emoticon)):Object(l.loadScript)("https://unpkg.zhimg.com/@cfe/emoticon@1.2.2/lib/emoticon.js").then((function(){return window.zh_emoticon?d(window.zh_emoticon):[]}))},p=n(1);t.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.alwaysShow,n=void 0!==t&&t;return function(e){return i()((function(t){var a=Object(p.useState)(!1),i=Object(o.a)(a,2),m=i[0],l=i[1];return Object(p.useEffect)((function(){Object(c.c)()?l(!0):u().then((function(e){Object(c.e)(Object(s.camelizeKeys)(e)),l(!0)})).catch((function(){l(!0)}))}),[]),(m||n)&&Object(r.b)(e,Object.assign({},t))}),e)}}},1221:function(e,t,n){"use strict";n.d(t,"a",(function(){return P}));var o=n(22),r=n.n(o),a=n(24),i=n.n(a),s=n(25),c=n.n(s),m=n(27),l=n.n(m),d=n(16),u=n.n(d),p=n(77),h=n.n(p),f=n(1),v=n(6),C=n.n(v),b=n(11),O=n(3);function j(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=u()(e);if(t){var r=u()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return l()(this,n)}}var g=function(e){c()(n,e);var t=j(n);function n(){var e;r()(this,n);for(var o=arguments.length,a=new Array(o),i=0;i0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Array.from({length:t},(function(t,n){return n+e}))},P=function(e){c()(n,e);var t=y(n);function n(){return r()(this,n),t.apply(this,arguments)}return i()(n,[{key:"render",value:function(){var e,t=this.props,n=t.onSelect,o=t.className,r=t.clickCallback,a=this.props.current,i=this.props.total,s=r&&(e=r,function(){e.apply(void 0,arguments)})||n,c=function(e,t){var n="...";return t<=5?R(1,t):e>t-3?[1,n].concat(h()(R(t-3,3)),[t]):e<=3?[1].concat(h()(R(2,3)),[n,t]):[1,n].concat(h()(R(e-Math.floor(1.5),3)),[n,t])}(a,i);return Object(O.c)("div",{className:C()("Pagination",o)},a>1&&a<=i&&Object(O.c)(g,{className:"PaginationButton-prev",onSelect:s,text:"上一页",page:a-1}),c.map((function(e,t){return"number"==typeof e?Object(O.c)(g,{onSelect:s,text:e,page:e,key:t,isCurrent:a===e}):Object(O.c)("button",{disabled:!0,key:t,className:"PaginationButton PaginationButton--ellipsis"},e)})),a>0&&a500&&a>t&&r<0)}}),100);return window.addEventListener("scroll",e),function(){e.cancel(),window.removeEventListener("scroll",e)}}),[n]),Object(i.c)(d,null,{from:{opacity:0,left:f},enter:{opacity:1,left:f},leave:{opacity:0,left:f}}).map((function(e){var n=e.item,o=e.key,a=e.props;return n&&Object(r.c)(i.a.button,{style:a,onClick:t,className:"CommentCollapseButton",children:["收起评论",Object(r.b)(s.a,{center:!0})]},o)}))}},1342:function(e,t,n){var o=n(722),r=n(325),a=n(454),i=Math.max,s=Math.min;e.exports=function(e,t,n){var c=null==e?0:e.length;if(!c)return-1;var m=c-1;return void 0!==n&&(m=a(n),m=n<0?i(c+m,0):s(m,c-1)),o(e,r(t,3),m,!0)}},1358:function(e,t,n){"use strict";n.r(t);var o=n(32),r=n(7),a=n(8),i=n(9),s=n(10),c=n(5),m=n(0),l=n(1),d=n(2),u=n.n(d),p=n(45),h=n(13),f=n(23),v=n(6),C=n.n(v),b=n(361),O=n(1342),j=n.n(O),g=n(90),y=n(1221),R=n(58),P=n(35),I=n(54),N=n(133),k=n(37),w=n(81),D=n(519),L=n(1145),S=n(192),F=function(e){return Object.assign({},e,{richText:Object(S.d)(e.content)})},T=n(657),A=n(1223),B=n(520),x=n(1224),E=n(536),V=n(4),M=n(11);function q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}var _=function(e){Object(i.a)(n,e);var t=q(n);function n(){var e;Object(r.a)(this,n);for(var o=arguments.length,a=new Array(o),i=0;i2;(s?n:o)({commentId:a}),s&&e.setState(Object(V.a)({},"hide_".concat(a),!0))},e.handleRef=function(t){var n=e.props.onRef;"function"==typeof n&&n(t)},e}return Object(a.a)(n,[{key:"render",value:function(){var e=this.props,t=e.comment,n=t.id,o=t.childCommentCount,r=e.isFetching,a=e.className,i=this.state["hide_".concat(n)],s=o<=5&&o>2?"展开其他 ".concat(o-2," 条回复"):"查看全部 ".concat(o," 条回复");return Object(m.c)("div",{className:a,ref:this.handleRef,children:[!i&&Object(m.b)("div",{className:"CommentMoreReplyButton",children:Object(m.b)(M.c,{preset:"plain",onClick:this.handleClick,children:s})}),r&&Object(m.b)(g.a,{className:"CommentMoreReplyButton",small:!0})]})}}]),n}(l.Component);function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}_.propTypes={comment:u.a.object.isRequired,isFetching:u.a.bool,onShowConversation:u.a.func,loadRestComments:u.a.func};var W=function(e){Object(i.a)(n,e);var t=z(n);function n(){var e;Object(r.a)(this,n);for(var o=arguments.length,a=new Array(o),i=0;i2,W=A.map((function(e){return y.comments[e]})).map(F),U=!S&&x>2&&!P,H=(z&&g[L]||{isFetching:!1}).isFetching;return Object(m.c)(l.Fragment,{children:[Object(m.b)("li",{className:C()({"NestComment--rootCommentNoChild":!q,"NestComment--rootComment":q}),children:Object(m.b)(E.a,{comment:I,status:c,type:n,parent:a,canOperate:b,commentNeedsReview:i,onShowConversation:s,ownerAuthorIsOrg:r,onLike:d,onReply:N,onFeature:k,onDelete:u,onCollapse:p,onDislike:h,onApprove:f,onReject:v,commentPattern:O,rootCommentId:L,byComment:R,isReverseAndStatusOpen:P,hasRecommend:M,showCollapsed:D},V)},V),q&&W.map((function(e){var t=e.id,o=e.featured,l=o?"".concat(t,"_featured"):"".concat(t),C=!o&&w.includes("".concat(t,"_featured"));return Object(m.b)("li",{className:"NestComment--child",children:Object(m.b)(E.a,{comment:e,status:c,type:n,parent:a,canOperate:b,commentNeedsReview:i,onShowConversation:s,ownerAuthorIsOrg:r,onLike:d,onReply:N,onFeature:k,onDelete:u,onCollapse:p,onDislike:h,onApprove:f,onReject:v,commentPattern:O,rootCommentId:L,hasRecommend:C,showCollapsed:D},l)},l)})),U&&Object(m.b)(_,{comment:I,isFetching:H,onShowConversation:s,loadRestComments:this.loadRestComments})]})}}]),n}(l.Component),U=Object(f.compose)(Object(h.connect)(null,{loadConversation:b.h}))(W);function H(e){var t=e.id,n=e.replyTo,o=e.isConversation;if(e.isNotification)return{type:"notification"};if(o)return{type:"conversation"};if(!n)return{type:"comment"};var r=n.featured,a=n.replyToAuthor,i=n.id;return t===i&&r?a?{type:"replyToSubFeatured"}:{type:"replyToFeatured"}:t!==i||a?t!==i&&a?{type:"replyToSubCommon"}:{type:"comment"}:{type:"replyToCommon"}}function J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}var K=function(e){Object(i.a)(n,e);var t=J(n);function n(){var e;Object(r.a)(this,n);for(var o=arguments.length,a=new Array(o),i=0;i0;return e.lastFeaturedIndex=0,t.length>0&&t.forEach((function(o,i){if(r||!o.collapsed){var u=t[i-1];o.collapsed&&(u&&u.collapsed||l.push(e.renderCollapsedDivider()),n)||(i===a&&l.push(Object(m.b)("div",{className:"NestComment-nextSiblings--noBorder"},"NestComment-nextSiblings--noBorder")),d&&0===i&&-1!==a&&l.push(Object(m.c)("div",{className:"CommentListV2-header-divider",children:["精选评论(",s,")"]},"divider-featured")),l.push(e.renderComment(o)),i===a&&(e.lastFeaturedIndex=i,l.push(Object(m.c)("div",{className:"CommentListV2-header-divider",children:["评论(",c,")"]},"divider-comment"))))}})),l},e.renderCollapsedComments=function(){var t=e.props,n=t.collapsedComments,o=t.isDrained,r=t.parent,a=(r=void 0===r?{}:r).collapsedCounts;return!o||a<=0?[]:n.map((function(t){return e.renderComment(t)}))},e.renderComments=function(t){return t.map(e.renderComment)},e.renderCollapsedDivider=function(){var t=e.props,n=t.isDrained,o=t.parent.collapsedCounts;return!n||o<=0?[]:e.state.collapsed?Object(m.b)("div",{className:"CommentListV2-action",children:Object(m.c)("div",{className:"CommentListV2-expendCollapseButton",children:[Object(m.c)("span",{onClick:e.handleOpenCollapsed,children:[Object(R.formatNumber)(o)," 条评论被折叠"]}),"(",Object(m.b)("a",{href:"//www.zhihu.com/question/52029856/answer/128623557",target:"_blank",rel:"noopener noreferrer",children:"为什么?"}),")"]})},"collapsed"):Object(m.c)("div",{className:"CommentListV2-divider",children:[Object(m.b)("div",{className:"CommentListV2-dividerLine"}),Object(m.c)("div",{className:"CommentListV2-dividerText",children:[Object(R.formatNumber)(o)," 条评论被折叠(",Object(m.b)("a",{href:"//www.zhihu.com/question/52029856/answer/128623557",target:"_blank",rel:"noopener noreferrer",children:"为什么?"}),")"]})]},"divider-collapsed")},e.renderCollapsedInfiLoader=function(){var t=e.state.collapsed;if(t)return[];var n=e.props.collapsedInfo,o=void 0===n?{}:n,r=o.isFetching,a=void 0!==r&&r,i=o.isPrevDrained,s=void 0!==i&&i,c=o.isDrained,l=void 0!==c&&c;return Object(m.b)(g.b,{className:"CommentListV2",onRef:function(t){e.listEl=t},isLocal:!0,isLoading:a,isPrevDrained:s,isDrained:l,onLoad:function(n){return e.load(e.props,n,!t)},placeholder:Object(m.b)(g.a,{className:"CommentItem",small:!0}),children:e.renderCollapsedComments()})},e.renderPatternContent=function(t){var n=e.props,o=n.isFetching,r=n.parent.adminClosedComment,a=n.byComment,i=n.status,s=n.order,c=n.totals,l=n.showPackupButton,d=n.handlePackupButton,u=Math.ceil(c/20),p=e.state.current;return r?null:o?Object(m.b)(A.a,{}):Object(m.c)("div",{ref:e.commentsWithPaginationElRef,children:[Object(m.b)("div",{className:"CommentListV2",children:"normal"===s&&"open"===i?e.renderNormalComments(t):e.renderComments(t)}),u>1&&Object(m.b)(y.a,{className:"CommentsV2-pagination",current:p,total:u,onSelect:e.handlePageSelect}),!a&&e.renderCollapsedDivider(),!a&&e.renderCollapsedInfiLoader(),l&&Object(m.b)(x.a,{onClick:d,commentsElRef:e.commentsWithPaginationElRef})]})},e.renderModalContent=function(t){var n=e.props,o=n.collapsedInfo,r=n.parent.adminClosedComment,a=n.status,i=n.order,s=n.byComment,c=e.state.collapsed,l=c?e.props:o,d=l.isFetching,u=void 0!==d&&d,p=l.isDrained,h=void 0!==p&&p,f=l.isPrevDrained,v=void 0!==f&&f;return h&&t.length<=0||r?Object(m.b)("div",{className:"CommentsV2-empty",children:Object(m.c)(D.d,{children:[Object(m.b)(D.a,{}),Object(m.b)("div",{children:"还没有评论"})]})}):Object(m.c)(g.b,{className:"CommentListV2",onRef:function(t){e.listEl=t},isLocal:!0,isLoading:u,isPrevDrained:v,isDrained:h,onLoad:function(t){return e.load(e.props,t,!c)},placeholder:Object(m.b)(g.a,{className:"CommentItemV2",small:!0}),getContainer:function(e){return e},children:["normal"===i&&"open"===a?e.renderNormalComments(t):e.renderComments(t),!s&&e.renderCollapsedDivider(),!s&&e.renderCollapsedComments()]})},e.renderCommentEdit=function(){var t=e.props,n=t.parent,o=n.canComment,r=(o=void 0===o?{status:!0}:o).status,a=o.reason,i=n.author,s=(i=void 0===i?{isOrg:!1}:i).isOrg,c=n.type,l=n.id,d=n.adminClosedComment,u=n.questionType,p=t.byComment,h=t.autoFocus,f=t.commentNeedsReview,v=t.zaInfo,b=d?"当前内容暂时无法评论":a,O=h&&!p;return r&&!d?Object(m.b)(T.a,{className:"CommentsV2-footer",type:c,id:l,commentNeedsReview:f,onSubmit:e.addComment,autoFocus:O,ownerAuthorIsOrg:s,ownerAuthorIsBrand:"commercial"===u,zaInfo:v}):Object(m.b)("div",{className:C()("CommentsV2-disabledText"),children:Object(m.b)("div",{className:"CommentsV2-disabledReason",children:b})})},e}return Object(a.a)(n,[{key:"loadCommentPermission",value:function(e,t){var n=this.props,o=n.loadAnswerCommentPermission,r=n.loadArticleCommentPermission;switch(e){case"answer":return o(t);case"article":return r(t);default:return null}}},{key:"componentDidMount",value:function(){var e=this.props,t=e.commentPattern,n=e.parent.adminClosedComment,o=e.stickers,r=e.loadStickers,a=e.getCommentWithPicPermission,i=e.commentWithPicPermission,s=e.currentUser;n||"bottom"!==t||this.loadByPagination(this.state.current),!o.length&&r(),void 0===i.commentWithPic&&s&&a()}},{key:"componentWillReceiveProps",value:function(e){var t=this.props,n=t.order,o=t.status,r=t.targetComment,a=t.commentPattern;n===e.order&&o===e.status||("bottom"===a?(this.setState({current:1}),this.loadByPagination(1,e)):this.load(e),this.setState({collapsed:!0}));var i=e.targetComment;i!==r&&i&&this.setState({collapsed:i.collapsed})}},{key:"componentWillUnmount",value:function(){Object(P.d)(P.b)}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,o=t.comments,r=t.commentPattern,a=t.commentInputPosition,i=t.isAuthor,s=t.parent,c=s.author,l=(c=void 0===c?{isOrg:!1}:c).isOrg,d=s.commentPermission,u=s.reviewingCounts,p=s.commentCount,h=s.adminClosedComment,f=t.totals,v=t.status,b=t.order,O=t.onStatusChange,j=t.onOrderChange,g=t.targetLink,y=t.shouldReverse,R=t.permission.canBrandAdminEdit,P="censor"===d&&(i||R),I=P?{isCommentReviewer:P,onStatusChange:O,status:v,reviewingCounts:u}:{status:v};return Object(m.c)("div",{className:C()("CommentsV2 CommentsV2--withEditor",{"CommentsV2-withPagination":"bottom"===r},n),ref:function(t){e.commentsElement=t},children:[Object(m.b)(B.a,Object.assign({commentCount:void 0!==p?p:f,shouldReverse:y,commentClosed:h,targetLink:g,order:b,onOrderChange:j,commentPattern:r,isOrg:l},I)),"top"===a&&this.renderCommentEdit(),"bottom"===r?this.renderPatternContent(o):this.renderModalContent(o),"bottom"===a&&this.renderCommentEdit()]})}}]),n}(l.Component);K.propTypes={type:u.a.string,parent:u.a.object.isRequired,targetLink:u.a.node,commentNeedsReview:u.a.bool,byComment:u.a.oneOfType([u.a.number,u.a.string]),commentPattern:u.a.string,commentInputPosition:u.a.oneOf(["top","bottom"]),showPackupButton:u.a.bool,handlePackupButton:u.a.func,onPaginationClick:u.a.func,autoFocus:u.a.bool,shouldReverse:u.a.bool},K.contextTypes={authRequired:u.a.func.isRequired},K.defaultProps={commentInputPosition:"bottom",showPackupButton:!0,autoFocus:!0,shouldReverse:!0};var G=Object(f.compose)(Object(h.connect)((function(e,t){var n=t.parent,o=t.parent,r=o.type,a=o.id,i=t.status,s=t.order,c=t.byComment,m=t.commentPattern,l=t.notificationId,d=e.entities,u=e.commentsV2,p=u.conversation,h=u.stickers,f=void 0===h?[]:h,v=u.commentWithPicPermission,C=u.notificationsComments,b=u.parent,O=d.comments[c],g=u.pagination;"reviewing"===i&&(g=u.reviewing);var y="reverse"===s&&"open"===i;y&&(g=u.reverse);var R="".concat(r,"_").concat(a),P=[],I=u.collapsed[R]||{};I.ids&&I.ids.length>0&&(P=I.ids.map((function(e){return d.comments[e]}))),l&&(g=C,R=l);var N=g[R]||{isPrevDrained:!1,isFetching:!1,isDrained:!1,ids:[]},D=N.isFetching,L=N.isPrevDrained,S=N.isDrained,T=N.ids,A=N.newIds,B=void 0===A?[]:A,x=N.totals,E="bottom"!==m?T:B,V=E.map((function(e){return d.comments[e]})).map(F),M=j()(E,(function(e){return String(e).includes("_featured")}));return{currentUser:Object(k.b)(e),isFetching:D,isPrevDrained:L,isDrained:S,totals:l?V.length:x,collapsedInfo:I,collapsedComments:P,targetComment:O,conversation:p,entities:d,stickers:f,lastFeaturedIndex:M,comments:V,isReverseAndStatusOpen:y,commentWithPicPermission:v,ids:E,parent:Object.assign({},n,b[R]),permission:Object(w.l)(e)}}),{loadComments:b.g,loadConversation:b.h,addComment:b.a,loadStickers:b.k,clearNotification:P.d,getCommentWithPicPermission:b.f,loadNotificationComments:b.j,loadAnswerCommentPermission:I.k,loadArticleCommentPermission:N.c}),Object(L.a)())(K),Q=n(15),X=n(51),Y=n(164),Z=n.n(Y),$=n(225),ee=n.n($),te=n(53),ne=n(1034);function oe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}var re=function(e){Object(i.a)(n,e);var t=oe(n);function n(){var e;Object(r.a)(this,n);for(var o=arguments.length,a=new Array(o),i=0;i0){var a=t[0].featured,i=!1;t.forEach((function(s,c){if(o||!s.collapsed){var l=t[c-1];if(!s.collapsed||(l&&l.collapsed||r.push(e.renderCollapsedDivider()),!n)){r.push(e.renderComment(s));var d=t[c+1];a&&!i&&s.featured&&(!d||!d.featured)&&(i=!0,e.lastFeaturedIndex=c,r.push(Object(m.c)("div",{className:"CommentList-divider",children:[Object(m.b)("div",{className:"CommentList-dividerLine"}),Object(m.c)("div",{className:"CommentList-dividerText",children:["以上为精选评论",Object(m.b)(g.a,{className:"CommentList-questionMark","data-tooltip":"精选评论包含回答作者推荐的评论和部分高赞评论",center:!0,size:16})]})]},"divider-featured")))}}}))}return r},e.renderCollapsedComments=function(){var t=[],n=e.props.collapsedComments;return e.state.collapsed||!n||n.length<=0?[]:(t.push(n.map((function(t){return e.renderComment(t)}))),t)},e.renderComments=function(t){return t.map(e.renderComment)},e.renderCollapsedDivider=function(){var t=e.props,n=t.isDrained,o=t.parent.collapsedCounts;return!n||o<=0?[]:e.state.collapsed?Object(m.b)("div",{className:"CommentList-action",children:Object(m.c)("div",{className:"CommentList-expendCollapseButton",children:[Object(m.c)("span",{onClick:e.handleOpenCollapsed,children:[Object(N.formatNumber)(o)," 条评论被折叠"]}),"(",Object(m.b)("a",{href:"//www.zhihu.com/question/52029856/answer/128623557",target:"_blank",rel:"noopener noreferrer",children:"为什么?"}),")"]})},"collapsed"):Object(m.c)("div",{className:"CommentList-divider",children:[Object(m.b)("div",{className:"CommentList-dividerLine"}),Object(m.c)("div",{className:"CommentList-dividerText",children:[Object(N.formatNumber)(o)," 条评论被折叠(",Object(m.b)("a",{href:"//www.zhihu.com/question/52029856/answer/128623557",target:"_blank",rel:"noopener noreferrer",children:"为什么?"}),")"]})]},"divider-collapsed")},e.renderCollapsedInfiLoader=function(){var t=e.state.collapsed;if(t)return[];var n=e.props.collapsedInfo,o=(n=void 0===n?{}:n).isFetching,r=n.isPrevDrained,a=n.isDrained;return Object(m.b)(R.b,{className:"CommentList",onRef:function(t){e.listEl=t},isLocal:!0,isLoading:o,isPrevDrained:r,isDrained:a,onLoad:function(n){return e.load(e.props,n,!t)},placeholder:Object(m.b)(R.a,{className:"CommentItem",small:!0}),children:e.renderCollapsedComments()})},e.renderPatternContent=function(t){var n=e.props,o=n.isFetching,r=n.parent.adminClosedComment,a=n.byComment,i=n.status,s=n.order,c=n.totals,l=n.showPackupButton,d=n.handlePackupButton,u=Math.ceil(c/20),p=e.state.current;return r?null:o?Object(m.b)(A.a,{}):Object(m.c)("div",{ref:e.commentsWithPaginationElRef,children:[Object(m.b)("div",{className:"CommentList",children:"normal"===s&&"open"===i?e.renderNormalComments(t):e.renderComments(t)}),u>1&&Object(m.b)(P.a,{className:"comments-pagination",current:p,total:u,onSelect:e.handlePageSelect}),!a&&e.renderCollapsedDivider(),!a&&e.renderCollapsedInfiLoader(),l&&Object(m.b)(x.a,{onClick:d,commentsElRef:e.commentsWithPaginationElRef})]})},e.renderModalContent=function(t){var n=e.props,o=n.collapsedInfo,r=n.parent.adminClosedComment,a=n.status,i=n.order,s=n.byComment,c=e.state.collapsed,l=c?e.props:o,d=l.isFetching,u=l.isDrained,p=l.isPrevDrained;if(u&&t.length<=0||r)return Object(m.b)("div",{className:"Comments-empty",children:Object(m.c)(S.d,{children:[Object(m.b)(S.a,{}),Object(m.b)("div",{children:"还没有评论"})]})});var h={getContainer:function(e){return e}};return Object(m.c)(R.b,Object.assign({className:"CommentList",onRef:function(t){e.listEl=t},isLocal:!0,isLoading:d,isPrevDrained:p,isDrained:u,onLoad:function(t){return e.load(e.props,t,!c)},placeholder:Object(m.b)(R.a,{className:"CommentItem",small:!0})},h,{children:["normal"===i&&"open"===a?e.renderNormalComments(t):e.renderComments(t),!s&&e.renderCollapsedDivider(),!s&&e.renderCollapsedComments()]}))},e.renderCommentEdit=function(t){var n=e.props,o=n.parent,r=o.canComment,a=(r=void 0===r?{status:!0}:r).status,i=r.reason,s=o.author,c=(s=void 0===s?{isOrg:!1}:s).isOrg,l=o.type,d=o.id,u=o.adminClosedComment,p=o.questionType,h=n.byComment,f=n.autoFocus,C=n.commentNeedsReview,O=u?"当前内容暂时无法评论":i,j=f&&!h;return a&&!u?Object(m.b)(F.a,Object.assign({className:"Comments-".concat("top"===t?"top":"footer"),type:l,id:d,commentNeedsReview:C,onSubmit:e.addComment,autoFocus:j,ownerAuthorIsOrg:c,ownerAuthorIsBrand:"commercial"===p},"top"===t&&{preset:"default",onClick:function(e){b.a.trackEvent(e.target,{id:3905})}})):"top"!==t&&Object(m.b)("div",{className:v()("Comments-disabledText",{"Comments-disabledText--fixed":void 0}),children:Object(m.b)("div",{className:"Comments-disabledReason",children:O})})},e.renderBottomButton=function(){var t=e.props.params,n=t.id,o=t.answerId,r=Boolean(o);return Object(m.b)("div",{className:"Comments-footer CommentEditor--normal",children:Object(m.b)(I.c,{className:"CommentEditor-startCommentButton",preset:"primary",color:"blue",onClick:function(){return Object(y.b)(Object(k.a)(r?{type:"answer",id:o}:{type:"question",id:n},{utm_content:"comment_area"}),{zaProps:{id:3906}})},children:"打开 App 参与站内讨论"})})},e}return Object(a.a)(n,[{key:"componentDidMount",value:function(){var e=this.props,t=e.byComment,n=e.commentPattern,o=e.parent.adminClosedComment,r=this.state.current;t&&this.scrollToTarget(),"bottom"!==n||o||this.loadByPagination(r)}},{key:"componentWillReceiveProps",value:function(e){var t=this.props,n=t.order,o=t.status,r=t.targetComment,a=t.commentPattern;n===e.order&&o===e.status||("bottom"===a?(this.setState({current:1}),this.loadByPagination(1,e)):this.load(e),this.setState({collapsed:!0}));var i=e.targetComment;!r&&i&&this.setState({collapsed:!i.collapsed})}},{key:"componentDidUpdate",value:function(e){!e.comments.length&&this.props.comments.length&&this.props.byComment&&this.scrollToTarget()}},{key:"componentWillUnmount",value:function(){this.props.dispatch(Object(w.d)(w.b))}},{key:"scrollToTarget",value:function(){var e=this.targetCommentEl,t=this.listEl;if(t&&e){var n=e.getBoundingClientRect(),o=n.top,r=n.height,a=t.getBoundingClientRect(),i=a.top,s=a.height;this.listEl.scrollTop+=o-i-(s-r)/2,e.classList.add("CommentItem--highlighted"),setTimeout((function(){return e.classList.remove("CommentItem--highlighted")}),2e3),e.tabIndex=-1,e.focus()}}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,o=t.isAuthor,r=t.comments,a=t.commentPattern,i=t.commentInputPosition,s=t.parent,c=s.author,l=(c=void 0===c?{isOrg:!1}:c).isOrg,d=s.commentPermission,u=s.reviewingCounts,p=s.commentCount,h=s.adminClosedComment,f=t.totals,C=t.status,b=t.order,O=t.onStatusChange,j=t.onOrderChange,g=t.targetLink,y=r.filter((function(e){return!e.isDelete})),R="censor"===d&&o,P=R?{isCommentReviewer:R,onStatusChange:O,status:C,reviewingCounts:u}:{status:C},I=v()({Comments:!0,"Comments--withEditor":!0,"Comments-withPagination":"bottom"===a},n);return Object(m.c)("div",{className:I,ref:function(t){e.commentsElement=t},children:[Object(m.b)(B.a,Object.assign({commentCount:void 0!==p?p:f,commentClosed:h,targetLink:g,order:b,onOrderChange:j,commentPattern:a,isOrg:l,options:this.renderCommentEdit("top")},P)),"top"===i&&this.renderCommentEdit(),"bottom"===a?this.renderPatternContent(y):this.renderModalContent(y),"bottom"===i&&this.renderCommentEdit()]})}}]),n}(p.Component);M.propTypes={type:d.a.string,parent:d.a.object.isRequired,targetLink:d.a.node,commentNeedsReview:d.a.bool,byComment:d.a.oneOfType([d.a.number,d.a.string]),commentPattern:d.a.string,commentInputPosition:d.a.oneOf(["top","bottom"]),showPackupButton:d.a.bool,handlePackupButton:d.a.func,onPaginationClick:d.a.func,autoFocus:d.a.bool},M.contextTypes={authRequired:d.a.func.isRequired},M.defaultProps={commentInputPosition:"bottom",showPackupButton:!0,autoFocus:!0};var q=Object(h.connect)((function(e,t){var n=t.parent,o=t.parent,r=o.type,a=o.id,i=t.status,s=t.order,c=t.byComment,m=t.commentPattern,l=e.entities,d=e.comments,u="".concat(r,"_").concat(a),p=d.parent,h=d.pagination;"reviewing"===i&&(h=d.reviewing),"reverse"===s&&"open"===i&&(h=d.reverse);var f=[],v=d.collapsed[u]||{};v.ids&&v.ids.length>0&&(f=v.ids.map((function(e){return l.comments[e]})));var C=h[u]||{isPrevDrained:!1,isFetching:!1,isDrained:!1,ids:[]},b=C.isFetching,O=C.isPrevDrained,j=C.isDrained,g=C.ids,y=C.newIds,R=void 0===y?[]:y;return{isFetching:b,isPrevDrained:O,isDrained:j,totals:C.totals,comments:("bottom"!==m?g:R).map((function(e){return l.comments[e]})),collapsedInfo:v,collapsedComments:f,targetComment:l.comments[c],parent:Object.assign({},n,p[u])}}))(M),_=n(51),z=n(53);function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}var U=function(e){Object(i.a)(n,e);var t=W(n);function n(e,o){var a;return Object(r.a)(this,n),(a=t.call(this,e,o)).load=a.load.bind(Object(_.a)(a)),a.addComment=o.authRequired(a.addComment.bind(Object(_.a)(a)),void 0,w.b),a}return Object(a.a)(n,[{key:"componentDidMount",value:function(){this.load()}},{key:"load",value:function(){this.props.dispatch(Object(C.f)(this.props.commentId))}},{key:"addComment",value:function(e,t){var n=this.props,o=n.parent,r=o.type,a=o.id,i=n.commentId,s=n.dispatch,c=[r,a,e,t.id,i];return s(C.a.apply(void 0,c))}},{key:"render",value:function(){var e,t,n,o=this.props,r=o.onItemLike,a=o.onItemDelete,i=o.onItemFeature,s=o.onItemApprove,c=o.onItemCollapse,l=o.onItemDislike,d=o.onNavBack,u=o.canOperateItem,p=o.isFetching,h=o.comments,f=o.commentNeedsReview,v=o.openComment.collapsed,C=o.parent,b=o.parent.canComment,O=(b=void 0===b?{status:!0}:b).status,j=b.reason,g=o.commentPattern,y=o.commentId,P=this.context.currentUser;return Boolean(P&&h.find((function(e){return e.author&&e.author.member.urlToken===P.urlToken})))&&(t=(e=h.filter((function(e){return e.author&&e.author.member.urlToken!==P.urlToken})))[e.length-1]),p&&!h.length?n=Object(m.b)(R.a,{className:"CommentItem",small:!0}):h.length&&(n=h.map((function(e,t){return Object(m.b)(T.a,{isConversation:!0,commentNeedsReview:f,canOperate:u,parent:C,comment:e,onLike:r,onDelete:a,onFeature:i,onApprove:s,onCollapse:c,onDislike:l,collapsedShown:v},t)}))),"bottom"===g?Object(m.b)(z.b,{size:"fullPage",onClose:d,children:Object(m.c)("div",{className:"Comments",children:[Object(m.b)(B.a,{isConversation:!0,commentPattern:g}),Object(m.b)("div",{className:"CommentList",children:n})]})}):Object(m.c)("div",{className:"Comments",children:[Object(m.b)(B.a,{isConversation:!0,onNavBack:d}),Object(m.b)("div",{className:"CommentList",children:n}),t&&(O?Object(m.b)(F.a,{id:y,type:"conversation",className:"Comments-footer",replyTo:t,commentNeedsReview:f,onSubmit:this.addComment}):Object(m.b)("div",{className:"Comments-disabledText",children:j}))]})}}]),n}(p.Component);U.propTypes={commentId:d.a.number.isRequired,type:d.a.string,parent:d.a.object.isRequired,commentNeedsReview:d.a.bool},U.contextTypes={currentUser:d.a.object,authRequired:d.a.func.isRequired};var H=Object(h.connect)((function(e,t){var n=t.commentId,o=e.entities.comments,r=e.comments.conversation[n]||{isFetching:!1,isDrained:!1,ids:[]};return{isFetching:r.isFetching,isDrained:r.isDrained,comments:r.ids.map((function(e){return o[e]})),openComment:o[n]}}))(U),J=n(75);function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=Object(c.a)(e);if(t){var r=Object(c.a)(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return Object(s.a)(this,n)}}var G=function(e){Object(i.a)(n,e);var t=K(n);function n(e){var o;Object(r.a)(this,n),(o=t.call(this,e)).state={openedCommentId:null,status:"open",order:"normal"},o.like=function(e,t){var n=o.props,r=n.onItemLike,a=n.dispatch;r&&r(e,t),a(Object(C.j)(e))},o.collapse=function(e){var t=o.props,n=t.dispatch,r=t.parent;n(Object(C.g)(e,r.type,r.id))},o.dislike=function(e){return o.props.dispatch(Object(C.h)(e))},o.approve=function(e){var t=o.props,n=t.dispatch,r=t.parent,a=t.type;n(Object(C.b)(e,r.type||a,r.id))},o.handleStatusChange=function(e){o.setState({status:e})},o.handleOrderChange=function(e,t){o.props.onOrderChange&&o.props.onOrderChange(e,t),o.setState({order:e})};var a=e.parent,i=e.dispatch;return o.feature=function(e,t){return i(Object(C.i)(e,a.id,a.type,t))},o.delete=function(e){return i(Object(C.d)(e,a.type,a.id))},o.showConversation=function(e){return o.setState({openedCommentId:e})},o.showComments=function(){return o.setState({openedCommentId:null})},o}return Object(a.a)(n,[{key:"componentDidMount",value:function(){var e=this.props.onMount;e&&e(this.domNode)}},{key:"render",value:function(){var e=this,t=this.props,n=t.className,r=t.containerClassName,a=t.parent,i=t.commentPattern,s=t.type,c=t.parent,l=(c=void 0===c?{}:c).commentPermission,d=c.relationship,u=void 0===d?{}:d,p=c.author,h=void 0===p?{}:p,f=t.needLoadCommentPermission,C=Object(o.a)(t,["className","containerClassName","parent","commentPattern","type","parent","needLoadCommentPermission"]),b=this.context.currentUser,O=void 0===u.isAuthor?b&&h.urlToken&&b.urlToken===h.urlToken:u.isAuthor,j="censor"===l&&!O,g="answer"===s||"article"===s,y=this.state,R=y.openedCommentId,P=y.status,I=y.order,N={commentNeedsReview:j,parent:a,type:s,canOperateItem:g,onShowConversation:this.showConversation,onItemLike:this.like,onItemFeature:this.feature,onItemDelete:this.delete,onItemCollapse:this.collapse,onItemDislike:this.dislike,onItemApprove:this.approve};return Object(m.c)("div",{className:v()("Comments-container",r),ref:function(t){return e.domNode=t},children:[Object(m.b)(q,Object.assign({},C,N,{commentPattern:i,className:v()(n,{"Comments--hidden":R&&"bottom"!==i}),order:I,status:P,onStatusChange:this.handleStatusChange,onOrderChange:this.handleOrderChange,needLoadCommentPermission:f,isAuthor:O})),R&&Object(m.b)(H,Object.assign({},C,N,{commentPattern:i,commentId:R,onNavBack:this.showComments}))]})}}]),n}(p.Component);G.propTypes={type:d.a.string.isRequired,parent:d.a.object.isRequired,onOrderChange:d.a.func,onItemLike:d.a.func,isAuthor:d.a.bool,onMount:d.a.func},G.defaultProps={type:"answer"},G.contextTypes={currentUser:d.a.object,authRequired:d.a.func.isRequired};t.default=Object(u.compose)(Object(h.connect)(),Object(J.a)(null))(G)}}]); //# sourceMappingURL=column.comments-modals.85cdd6e27cb828157e15.js.map