(window.webpackJsonp=window.webpackJsonp||[]).push([[69],{29577:function(e,t,o){"use strict";o.r(t),function(e){o.d(t,"default",(function(){return b}));var s,r=o(2),n=o.n(r),a=o(2351),i=o(5942),l=o(5963),m=o(10115),d=o(10113),c=o(2824),h=o.n(c),p=o(10116),C=o(7394),u=o(11230),S=o(10117),f=o(6134),g=o(6130);let b=Object(a.observer)(s=class extends r.Component{constructor(e){super(e),this.state={loading:!0,loadError:!1,hasError:!1,isOpenFilterSelected:!0,isResolvedFilterSelected:!1,isScrollable:!0},this.rightOverlayModalRef=null,this.parseError=this.parseError.bind(this),this.handleRetry=this.handleRetry.bind(this),this.setCommentDrawerRef=this.setCommentDrawerRef.bind(this),this.stopScroll=this.stopScroll.bind(this),this.handleClose=this.handleClose.bind(this)}async componentDidMount(){this.setState({loading:!0,loadError:!1}),p.default.handleAnalytics("api","view","api"),m.default.getComments({model:this.props.contextData.commentModel,modelId:this.props.contextData.commentModelId}).then((()=>{requestIdleCallback((()=>{Object(i.getStore)("CommentStore").setLoaded(!0),this.setState({loading:!1,loadError:!1})}))})).catch((e=>{this.setState({loading:!1,loadError:!0})}));let e=this.props.contextData.commentModelId,{addComment:t,deleteComment:o,resolveComment:s}=await Object(S.fetchPermissions)(["addComment","deleteComment","resolveComment"],e,f.MODEL_TYPE.API);this.setState({addCommentPermission:t,deleteCommentPermission:o,resolveCommentPermission:s})}componentDidUpdate(){if(!this.state.isResolvedFilterSelected){const t=Object(i.getStore)("CommentStore"),o=t.find(t.activeCommentId),s=Object(i.getStore)("AnnotationStore").find(e.get(o,"annotationId"));e.get(s,"status.resolved")&&this.handleResolvedFilter()}}parseError(e){return e.isFriendly?e.message:""}handleRetry(){return this.setState({loading:!0,loadError:!1}),m.default.getComments({model:this.props.contextData.commentModel,modelId:this.props.contextData.commentModelId}).then((()=>{this.setState({loading:!1,loadError:!1})})).catch((e=>{this.setState({loading:!1,loadError:!0})}))}setCommentDrawerRef(e){this.commentDrawerRef=e,this.commentDrawerRef&&this.forceUpdate()}stopScroll(e){this.setState({isScrollable:!e})}handleClose(){this.props.onClose&&this.props.onClose(),g.default.removeCommentQueryParam()}render(){let t,{commentModel:o,commentModelId:s,schemaId:r}=this.props.contextData||{};t=e.filter(Object(i.getStore)("CommentStore").values,(e=>e.model===o&&e.modelId===s));const a=e.sortBy(e.filter(t,(e=>!e.anchor||e.anchor===`${o}/${s}`)),"createdAt")||[],m=this.props.contextData.model.name,c=Object(i.getStore)("CurrentUserStore")||{},p=Object(i.getStore)("TeamUserStore"),S=e.reduce(p.values,((e,t)=>(e[t.id]={name:t.name,id:t.id,username:t.username,email:t.email,profilePicUrl:t.profilePicUrl,roles:t.roles},e)),{}),f=Object.values(S),g=!Object(i.getStore)("SyncStatusStore").isSocketConnected,b=l.default.isUserAdmin(c),D=(e.reduce((t||[]).reverse(),((e,t)=>(e.includes(t.annotationId)||e.push(t.annotationId),e)),[]),Object(i.getStore)("CommentStore"));D.find(D.activeCommentId),D.setActiveCommentId;let E=e.reduce(t||[],((t,o)=>{let s=o&&o.anchor&&e.get(o.anchor.split("/"),"[3]"),r=(this.props.contextData.versions||[]).filter((t=>s===e.get(t,"schema[0]"))),n=e.get(r,"[0].id");return n&&(t[o.annotationId]={version:n}),t}),{});return g&&this.state.loading?n.a.createElement(n.a.Fragment,null,n.a.createElement(C.ContextBarViewHeader,{onClose:this.props.onClose,title:"Comments"}),n.a.createElement(u.default,{origin:"context-bar"})):n.a.createElement("div",{className:h()({"comment-drawer-container":!0,"no-scroll":!this.state.isScrollable}),ref:this.setCommentDrawerRef},n.a.createElement(C.ContextBarViewHeader,{onClose:this.handleClose,title:"Comments"}),n.a.createElement("div",{className:"comment-drawer"},n.a.createElement(d.default,{editor:e.get(this.props.contextData,"editor"),comments:t,requestComments:a,isOpenFilterSelected:!0,addCommentPermission:this.state.addCommentPermission,deleteCommentPermission:this.state.deleteCommentPermission,isAdmin:b,isOffline:g,loading:this.state.loading,loadError:this.state.loadError,hasError:this.state.hasError,teamUsers:f,teamUsersMap:S,onRetry:this.handleRetry,user:c,title:m,stopScroll:this.stopScroll,commentRef:this.commentDrawerRef,commentLinkDisabled:e.get(this.props.contextData,"commentLinkDisabled"),model:"api",modelId:e.get(this.props.contextData,"commentModelId"),commentLinkParams:E,origin:"contextBar",anchor:e.get(this.props.contextData,"anchor")})))}})||s}.call(this,o(2751))}}]);