text: (this.webpackJsonptagging_interface=this.webpackJsonptagging_interface||[]).push([[0],{133:function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4goMAxI5sonxsgAACLtJREFUWMPtmHtwVNUdxz/n7t3dJLuJAUkkCiRgI6IG5ZFigtUi1VKiTIDOGKoyQwkyZIrWGUU67VBt2tEqoS2jDEWiSMVGmFGwyjCTgqJCHBJRNBCWh+S9m2ySzWafd/fuPf0jj0ayCQ/FznT8/XNnzvmd8/ue3+t8z4Xv5Xv5P5bVq1f/bwwbhkF1dTUAUkq7lHKKlHKWlPJOKeVdDofjxsH6NTU1l21LXO7CaDSqBIPBTTt37lx55swZAGbOnElubi6VlZXouh7RNG1bQUHBU9nZ2d0A+/fvZ+7cuVcWYCgUIiEhIenAgQMf7NixI9fr9WIymZBSkpycTE5ODhaLhZ6eHiZNmsSbb75JZmbmpg0bNjwjhGh3Op1kZGRcWQ86HI67y8vL9zc2Ng6Zk1KSlpaGz+cjFAqxaNEiSktLmTJlSteSJUvmLF68+Iuqqiry8vIuypZyqeCklNampqY3Ghoa4p9YCNxuN5qmIYTg1KlTTJ48mRMnTox+9dVXj61fv351Xl4eu3fv/nYBSikBcLvdO7ds2XLNiGERYuDrcDgoKSlB0zTq6+vZs2fPxhdeeOH5wsJCdu3adUG7posFJ4Sgs7Pzl2VlZU9kZWUJq9WK1+u9qIo/d+4cy5Yto6qqilAohMvlmr1q1SpjxYoVH34rHhRCIKWcXlFRUe52u5U77rgDVVW52LUej4cjR45QXFyM3+/H5XJRWVn59LPPPjv/GwM0DAMpZeKhQ4f27Nu3D8MwaGhowOl0nuflkUG2trbS3NxMaWkpmZmZ6LquuN3uuYsXL778Ku4PbV1d3fNlZWVP+v3+3rwwmdB1HSEEhiHRDYO0q5JweQIkmE0DORhvP7PZjN1u16SUrwWDwT8FAoHGt956a1gM6oXCEwqFpm7cuPFJn883YDgWi/WFHX44OYNfL8rFlGjB2xXgr29Xc6bVgxaJIoRAURSklB4hRIcQ4gNd17dv3rz5434bRUVF38iDSWVlZWerqqrGms3mrzdsLcqye6dyf172wCZCgDQMjnUn0xw009HeRnp6OtFo1FFYWHjjt37VPfbYY/e5XK7dQoj+apeA35qQGF56z9S0u2/NQOrGkHW6ruPJuIuwDhMmTEDXdcxmcyrgvVSAIxaJy+W6uQ9cE/AisFAIcdvjv1o5J3/q9XHBAZhVE5ZwO0IodHR04HA4ALz5+fmX7MFhc7AvN7YB/6ioqGgdPPe7tU+sUk0KxIYPjCpg/PhxdHR0xBobG1cBHD58+MqwmaKiIioqKgYqsfLTI6n5nD2SpJI9LNvBQk96Ls1tXVumTZu2cuvWrRQXF383dKtr4c+z7U+VnFCtLSoi/mUUiUZRLDfjSL56bs6kiQe+Uz7YAunmW6Z+mlZZMU62fTZ0GxlDj6bi+f2m49fs3ZuDEPJyASqXtchmC8VOO7yeR9Yg0iaeB85AjMnC/4ctGAcPJiOEbE5P5zsDqJfPIxYIG5hUQ/vgIOH9dYhRgwiobQze0u2E3/0XCDGhVU24cVx7+8DaKyr9BgIl069rHz+602mzSafNJn3rfivl2b1SHvunDG5/RTrtdtk/585OP9Sx9af3y7cLTZdjU71YYOryfQCJevm8B6U0toQPOUWsS0NGIhjtbgLuZoLdPuyOuv8yBwnGKEu+WYu9E+3WiL02v07GjHeQ/BtwqMv3NfXbGJVqx9Ptv/Qi6Qenl89bAGwiGrqOcTP45O+13LD/Y2LRKKGHl1BU8xFOl4cVaaMorm8f2PiwNHjYbHB6dDIpM9JJ/NkEMAmDmPQoQpxt6vS1eEJi7W3rPjp1njOGB9ivdPov88ekqtFrRyWZfoOgSEkaDbNKEFmzOd3YROSGbNKl5OT8Au7c/TYAP1FVtlmtmAArsCKsoQOvJVgJ6gbCpJD8wA8wz7oGoQoQAn9EkGyR7wl4XF2+7/SIRTL4BClmY29KgukzoYgi2vwc1ecgsmYDkD1hPA2PPooRiXDL5BvImTkTgFl9ZFZIaLaprCvNY01WKhogVAUE+N44RVd5Hb6wBW9njKRwJCID0YlCVRZdsIr7wjlGf2VelaqInHBMKj3eKB0balGf/jPdnZ0DunPWrqXZbkc4ndy3YAEADy5dCkKgAMc1nbpGH6PDMb7WCFUFajvhlU+5KqpBZ9iCFrspXN129UW1GWFW7o11hMfbNU1R3RGUU15kMMqYpiY+X79+QM+SmkqsoAC9poaCBQvIyspiSm4uAH6rwu2rckjxaNg6wwzp1IogctxD1BVESTET/qSNnm2OJc7EpKucNtvIAIMHWxtkUL+OgG4x6RHk2W6QoKoqKc89R31LSy+zVhQsq1cTaWlhdnY2Cxcu7CWFQtCtxdhR60Y92Y1FGWpGAiFVwfvyCTqfqSawtwGkHIcifpQRCAwP0Gm3Kb7XHct9rzvQjnWgt4bQvuwA0btpZmIi5x55BL1P/7bZs/nknnvg6FHWrFlDzOilYOYZadw+LR3bye5he4UOCJMY8GifLB85xBJVqMoM3Rkk8F49vtdPEvJG6Gd+UUVhQk0N7tragSXzyss5/vnnjB07FqmqKELwYWMPx6rbmNjnrXiixR8uuFAOCiB1gMMrgiBfp36JXi+nN2/ufch/tpfQR39DU+uJxgyE1Yo0IGfh9WRqBhYxfKsNA51De53ZabNlXQhg4vknHQzQpKqMeuklqt5/l5TqDaS2HWa65Qu+3PY4SnIqqklh08Em0uu6iZnEsDQqICXe+M34F3EB9lWPAqSdfx92DFKWwLUJScT+WII10do7JlTSPUc5cvwktbEw65behN068vUbAsYBcR4ODzhtNssQgH3VUxCv4szn5ZKuCEbXh4j23btC6gTTpjPrx/nYd+1m7cvHSewKY4z0j7Fv3ziSBYyP+2/mCYvlfcA2eMzf58WkITHSedHlowdBcMytXP9QGWbVRMakScx/aCXNfj/Br77CHgrFfcy7gbFCxAuxFdheFo06/wPG8+u7z0xHVgAAAABJRU5ErkJggg=="},142:function(e,t,a){e.exports=a(373)},147:function(e,t,a){},149:function(e,t,a){},154:function(e,t,a){e.exports=a.p+"static/media/redcoat-1-threshold.78b878cf.png"},181:function(e,t){},372:function(e,t,a){e.exports=a.p+"static/media/redcoat-1-grey.fd5c7c00.png"},373:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),s=a(22),o=a.n(s),i=(a(147),a(84)),l=a(13),c=a.n(l),u=a(23),m=a(33),p=a(1),d=a(2),h=a(4),g=a(3),f=(a(149),a(11)),v=a(7);var b=function(e){var t=void 0;if(document.cookie&&""!==document.cookie)for(var a=document.cookie.split(";"),n=0;n<a.length;n++){var r=a[n].trim();if(r.substring(0,e.length+1)===e+"="){t=decodeURIComponent(r.substring(e.length+1));break}}return t};function E(){var e=Object(f.g)().pathname;return Object(n.useEffect)((function(){window.scrollTo(0,0)}),[e]),null}var y=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("main",{class:"error-page"},r.a.createElement("h1",null,"404: Page not found."),r.a.createElement("p",null,"The page you were looking for does not exist."))}}]),a}(n.Component),j=a(133),k=a.n(j),C=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this.props.user;return e?r.a.createElement("div",{className:"circle-icon profile-icon "+(this.props.size||"small"),style:{background:e.profile_icon.background}},r.a.createElement("i",{className:"profile-icon-i fa fa-"+e.profile_icon.icon,style:{color:e.profile_icon.foreground}})):r.a.createElement("div",{className:"circle-icon profile-icon "+(this.props.size||"small"),style:{background:"#ddd"}})}}]),a}(n.Component),w=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(){return Object(p.a)(this,a),t.apply(this,arguments)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("nav",{id:"navbar"},r.a.createElement("div",{className:"navbar-left"},r.a.createElement("div",{id:"logo"},r.a.createElement(v.b,{to:"/"},r.a.createElement("img",{src:k.a})," ",r.a.createElement("span",{class:"text"},"Redcoat"))),this.props.user&&r.a.createElement("div",{className:"dropdown-menu"},r.a.createElement("button",null,"Projects"),r.a.createElement("ul",{className:"dropdown-menu-items"},r.a.createElement("li",null,r.a.createElement(v.b,{to:"/projects"},"Projects list")),r.a.createElement("li",null,r.a.createElement(v.b,{to:"/setup-project"},"Setup project"))))),r.a.createElement("div",{className:"navbar-centre"}),r.a.createElement("div",{className:"navbar-right"},this.props.user&&r.a.createElement("div",{className:"dropdown-menu"},r.a.createElement("button",{className:"flex"},r.a.createElement(C,{user:this.props.user}),r.a.createElement("span",null,"Logged in as ",this.props.user.username)),r.a.createElement("ul",{className:"dropdown-menu-items"},r.a.createElement("li",null,r.a.createElement(v.b,{to:"/profile"},"Profile")),r.a.createElement("li",null,r.a.createElement(v.b,{to:"/logout"},"Logout")))),!this.props.user&&r.a.createElement("div",{className:"dropdown-menu log-in"},r.a.createElement("button",null,"Not logged in"),r.a.createElement("ul",{className:"dropdown-menu-items"},r.a.createElement("li",null,r.a.createElement(v.b,{to:"/login"},"Login")),r.a.createElement("li",null,r.a.createElement(v.b,{to:"/register"},"Register")))),!this.props.loading&&r.a.createElement("div",{className:"dropdown-menu short"},r.a.createElement(v.b,{to:"/features"},"v2.0"))),!this.props.loading&&r.a.createElement("header",{className:"decorative-bar"}))}}]),a}(n.Component),N=(a(154),a(15)),O=a.n(N),S=a(19),x=(a(155),a(134)),A=a(135),I=a.n(A),P=a(139),T=a(58),M=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this,t=this.props.item,n=this.props.index,s=this.props.item.children;if(s)var o=r.a.createElement("ul",{className:this.props.open?"":"hidden"},s.map((function(t,n){return r.a.createElement(a,{key:n,item:t,open:e.props.openedItems.has(t.full_name),openedItems:e.props.openedItems,onClick:e.props.onClick,hotkeyMap:e.props.hotkeyMap,hotkeyChain:e.props.hotkeyChain,isTopLevelCategory:!1,applyTag:e.props.applyTag})})));else o="";if(this.props.hotkeyMap)var i=this.props.hotkeyMap.hasOwnProperty(this.props.item.full_name),l=i?this.props.hotkeyMap[this.props.item.full_name].join(""):"";else i=!1,l="";var c=r.a.createElement("span",{className:"inner-container"},s&&r.a.createElement("span",{className:"open-button",onClick:function(){return e.props.onClick(t.full_name)}},r.a.createElement("i",{className:"fa fa-chevron-"+(this.props.open?"up":"down")})),r.a.createElement("span",{className:"category-name"+(i?" has-hotkey":"")+(this.props.hotkeyChain===l?" hotkey-active":""),"data-hotkey-id":l,onClick:this.props.applyTag?function(){return e.props.applyTag(e.props.item.full_name)}:null},t.name));return this.props.isTopLevelCategory?this.props.draggable?r.a.createElement(T.b,{key:t.id.toString(),draggableId:t.id.toString(),index:n},(function(e,a){return r.a.createElement("li",Object.assign({ref:e.innerRef},e.draggableProps,{className:"draggable "+(a.isDragging?"dragging":"not-dragging")+" color-"+(t.colorId+1)}),r.a.createElement("div",Object.assign({},e.dragHandleProps,{className:"drag-handle-container"}),r.a.createElement("span",{className:"drag-handle"})),c,o)})):r.a.createElement("li",{className:" color-"+(t.colorId+1)},c,o):r.a.createElement("li",null,c,o)}}]),a}(n.Component);function D(e){for(var t=new Array(e.length),a=0;a<t.length;a++)t[a]=a;return t}var q=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={itemOrder:[],orderedItems:[],openedItems:new Set},n.onDragEnd=n.onDragEnd.bind(Object(m.a)(n)),n}return Object(d.a)(a,[{key:"componentDidUpdate",value:function(e,t){var a=D(this.props.items);S.a.isEqual(e.items,this.props.items)||this.setState({openedItems:new Set,orderedItems:this.props.items,itemOrder:a})}},{key:"componentWillMount",value:function(){var e=D(this.props.items);this.setState({openedItems:new Set,orderedItems:this.props.items,itemOrder:e})}},{key:"toggleCategory",value:function(e){var t=this.state.openedItems;t.has(e)?t.delete(e):t.add(e),this.setState({openedItems:t})}},{key:"onDragEnd",value:function(e){var t=this;if(e.destination){var a=function(e,t,a){var n=Array.from(e),r=n.splice(t,1),s=Object(P.a)(r,1)[0];return n.splice(a,0,s),n}(this.state.itemOrder,e.source.index,e.destination.index),n=function(e,t){for(var a=new Array(e.length),n=0;n<t.length;n++)a[n]=e[t[n]];return a}(this.props.items,a);this.props.initHotkeyMap(n,(function(){return t.setState({itemOrder:a,orderedItems:n})}))}}},{key:"render",value:function(){var e=this,t=this.state.orderedItems,a=this.state.openedItems;return r.a.createElement("div",{id:"category-hierarchy-tree",className:(this.props.visible?"":"hidden")+(this.props.displayOnly?" display-only":"")},r.a.createElement(T.a,{onDragEnd:this.onDragEnd},r.a.createElement(T.c,{droppableId:"droppable"},(function(n,s){return r.a.createElement("ul",Object.assign({},n.droppableProps,{className:"draggable-list"+(s.isDraggingOver?" dragging":""),ref:n.innerRef}),e.props.displayOnly&&r.a.createElement("li",{className:"header-row"},r.a.createElement("span",{className:"inner-container"},r.a.createElement("span",{className:"category-name"},"Entity Class"),r.a.createElement("span",{className:"description"},"Description"))),t.map((function(t,n){return r.a.createElement(M,{key:n,item:t,index:n,onClick:e.toggleCategory.bind(e),open:a.has(t.name),openedItems:e.state.openedItems,hotkeyMap:e.props.hotkeyMap,hotkeyChain:e.props.hotkeyChain,isTopLevelCategory:!0,applyTag:e.props.applyTag,draggable:e.props.draggable})})),n.placeholder)}))))}}]),a}(n.Component),F=a(137),R=a.n(F);function _(e,t){return t[e.split("/").slice(0,1)[0]]}var B=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this,t=this.props.entityClass.split("/"),a=t.length>1?"/":"";return a+=t[t.length-1],r.a.createElement("span",{className:"label tag-"+this.props.colourIdx,onClick:function(t){e.props.deleteTag(e.props.entityClass)}},r.a.createElement("span",{className:"label-name"},a))}}]),a}(n.Component),U=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={selected:!1},n.wordInnerRef=r.a.createRef(),n}return Object(d.a)(a,[{key:"deleteTag",value:function(e){this.props.deleteTag(this.props.index,e)}},{key:"componentDidUpdate",value:function(e,t){}},{key:"getHighlightedWord",value:function(){for(var e=this.props.text,t=this.props.highlighting,a="",n=0;n<e.length;n++)n===t[0]&&(a+='<span class="search-highlight">'),a+=e[n],n===t[1]&&(a+="</span>");return console.log(a),R()(a)}},{key:"render",value:function(){var e=this,t=this.props.entityClasses.length>0,a=t?" tag "+("B"===this.props.bioTag?"tag-begin":"")+(this.props.isLastInSpan?" tag-end":""):"";if(t)var n=this.props.entityClasses.map((function(t,a){return r.a.createElement(B,{deleteTag:e.deleteTag.bind(e),key:a,bioTag:e.props.bioTag,entityClass:t,colourIdx:_(t,e.props.entityColourMap)})}));else n="";var s=this.props.text;this.props.highlighting&&(s=this.getHighlightedWord());var o=t?" tag-"+_(this.props.entityClasses[0],this.props.entityColourMap):"";return r.a.createElement("span",{className:"word"+(this.props.selected?" selected":"")+a},r.a.createElement("span",{className:"word-inner"+o+(this.props.highlighting?" search-highlight":""),ref:this.wordInnerRef,onMouseUp:function(){return e.props.updateSelections(e.props.index,"up")},onMouseDown:function(){return e.props.updateSelections(e.props.index,"down")}},s),n)}}]),a}(n.Component),L=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"updateSelections",value:function(e,t){this.props.updateSelections(this.props.index,e,t)}},{key:"deleteTag",value:function(e,t){this.props.deleteTag(this.props.index,e,t)}},{key:"render",value:function(){var e=this,t=this.props.selections;function a(e){if(0===t.length)return!1;for(var a=0;a<t.length;a++){var n=t[a];if(!(n.wordEndIndex<0)&&(n.wordEndIndex>=e&&e>=n.wordStartIndex))return!0}return!1}return this.props.displayOnly?r.a.createElement("div",{className:"sentence-inner"+(this.props.displayOnly?" display-only":"")},this.props.words.map((function(t,a){return r.a.createElement(U,{key:a,index:a,text:t,entityClasses:e.props.annotations[a].entityClasses||[],bioTag:e.props.annotations[a].bioTag,entityColourMap:e.props.entityColourMap,highlighting:e.props.annotations[a].highlighting,updateSelections:function(){return null},deleteTag:function(){return null},isLastInSpan:e.props.annotations[a].isLastInSpan()})}))):r.a.createElement("div",{className:"sentence-inner"},this.props.words.map((function(t,n){return r.a.createElement(U,{key:n,index:n,text:t,selected:a(n),entityClasses:e.props.annotations[n].entityClasses||[],isLastInSpan:e.props.annotations[n].isLastInSpan(),bioTag:e.props.annotations[n].bioTag,updateSelections:e.updateSelections.bind(e),entityColourMap:e.props.entityColourMap,deleteTag:e.deleteTag.bind(e),highlighting:e.props.annotations[n].highlighting})})))}}]),a}(n.Component),W=a(199);var H=function(e){return W(e,"dd mmm")+" at "+W(e,"h:MM tt")},G=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"comment-box"},r.a.createElement("div",{className:"comment-left"},r.a.createElement("div",{className:"circle-icon profile-icon",style:{background:this.props.user_profile_icon.background}},r.a.createElement("i",{className:"profile-icon-i fa fa-"+this.props.user_profile_icon.icon,style:{color:this.props.user_profile_icon.foreground}}))),r.a.createElement("div",{className:"comment-right"},r.a.createElement("div",{className:"comment-author st"},this.props.author,r.a.createElement("span",{className:"comment-date st"},H(this.props.created_at))),!this.props.hideDocumentString&&r.a.createElement("blockquote",{className:"comment-document st"},r.a.createElement("span",{className:"document-string"},this.props.document_string),r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/annotations/curation?docId="+this.props.document_id},r.a.createElement("i",{class:"fa fa-external-link"}))),r.a.createElement("div",{className:"comment-text st st-block"},this.props.text)))}}]),a}(n.Component),J=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={comment:""},n}return Object(d.a)(a,[{key:"onSubmit",value:function(e){var t=this;e.preventDefault(),0!==this.state.comment.length&&this.props.submitComment(this.state.comment,(function(){t.setState({comment:""})}))}},{key:"setComment",value:function(e){this.setState({comment:e.target.value})}},{key:"render",value:function(){return r.a.createElement("form",{className:"comment-input-box",onSubmit:this.onSubmit.bind(this)},r.a.createElement("div",{className:"comment-box"},r.a.createElement("div",{className:"comment-left"},this.props.user_profile_icon&&r.a.createElement("div",{className:"circle-icon profile-icon",style:{background:this.props.user_profile_icon.background}},r.a.createElement("i",{className:"profile-icon-i fa fa-"+this.props.user_profile_icon.icon,style:{color:this.props.user_profile_icon.foreground}}))),r.a.createElement("div",{className:"comment-right margin-right"},r.a.createElement("div",{className:"comment-text"},r.a.createElement("textarea",{name:"comment-input",className:"comment-input",placeholder:"Write a comment...",onChange:this.setComment.bind(this),value:this.state.comment,maxlength:"200"})))),r.a.createElement("div",{className:"submit-comment-wrapper"},r.a.createElement("button",{className:"submit-comment"},r.a.createElement("i",{class:"fa fa-send"}))))}}]),a}(n.Component),Y=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=" disabled";this.props.changesMade&&(e=""),this.props.recentlySaved&&(e=" recently-saved"),this.props.saving&&(e=" saving");var t="fa-save";this.props.recentlySaved&&(t="fa-check"),this.props.saving&&(t="fa-cog fa-spin");var a="Save";return this.props.recentlySaved&&(a="Saved"),this.props.saving&&(a="Saving"),r.a.createElement("button",{className:"save-button"+e,onClick:this.props.submitAnnotations},r.a.createElement("i",{className:"fa "+t}),a)}}]),a}(n.Component),V=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{id:"tagging-progress-bar",className:this.props.show?"show":"hide"},r.a.createElement("span",{className:"progress-bar"},r.a.createElement("span",{className:"inner",style:{width:(this.props.totalPagesAvailable-1)/this.props.totalPages*100+"%"}})))}}]),a}(n.Component),Q=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={value:""},n.inputRef=r.a.createRef(),n}return Object(d.a)(a,[{key:"updateValue",value:function(e){var t=e.target.value;0===t.trim().length&&(t=""),this.setState({value:t})}},{key:"submit",value:function(e){return this.props.searchDocuments(this.state.value),O()(this.inputRef.current).blur(),e.preventDefault(),null}},{key:"render",value:function(){var e=this;return r.a.createElement("form",{className:"search-container"+(this.props.inSearchMode?" active":""),onSubmit:this.submit.bind(this)},r.a.createElement("input",{ref:this.inputRef,className:"search-bar",id:"document-search-bar",placeholder:"Search...",value:this.state.value,onChange:function(t){return e.updateValue(t)}}),r.a.createElement("button",{className:"search-button"},r.a.createElement("i",{class:"fa fa-search"})))}}]),a}(n.Component),K=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={pageNumber:null,pageNumberError:!1},n.pageInputRef=r.a.createRef(),n}return Object(d.a)(a,[{key:"clearPageNumberInput",value:function(){var e=O()(this.pageInputRef.current);e.val(""),e.blur()}},{key:"goToPage",value:function(e){var t=this;return this.clearPageNumberInput(),""===this.state.pageNumber?(this.setState({pageNumber:this.props.pageNumber}),e.preventDefault(),null):this.state.pageNumber!==parseInt(this.state.pageNumber).toString()?(this.setState({pageNumber:this.props.totalPagesAvailable},(function(){t.props.goToPage(t.state.pageNumber)})),e.preventDefault(),null):(this.state.pageNumber<1?this.setState({pageNumber:1},(function(){t.props.goToPage(t.state.pageNumber)})):this.state.pageNumber>this.props.totalPagesAvailable?this.setState({pageNumber:this.props.totalPagesAvailable},(function(){t.props.goToPage(t.state.pageNumber)})):this.props.goToPage(this.state.pageNumber),e.preventDefault(),null)}},{key:"componentDidMount",value:function(){!this.state.pageNumber&&this.props.pageNumber&&this.setState({pageNumber:this.props.pageNumber})}},{key:"componentDidUpdate",value:function(e,t){this.props.pageNumber!==e.pageNumber&&this.setState({pageNumber:this.props.pageNumber})}},{key:"changePageNumber",value:function(e){this.setState({pageNumber:e.target.value})}},{key:"render",value:function(){var e=this,t=r.a.createElement("span",{className:"group-name"},r.a.createElement("span",null,"Page ",r.a.createElement("b",null,r.a.createElement("form",{onSubmit:this.goToPage.bind(this)},r.a.createElement("input",{id:"page-input",className:"page-input"+(this.state.pageNumberError?" error":""),placeholder:this.state.pageNumber,name:"page-input",onChange:function(t){return e.changePageNumber(t)},ref:this.pageInputRef})))," of ",r.a.createElement("b",null,this.props.totalPages))),a=this.props.totalPagesAvailable===this.props.pageNumber,n=this.props.changesMade?this.props.saving?"":"Changes not saved":this.props.lastModified?"Saved on "+H(this.props.lastModified):"";return r.a.createElement("div",{id:"pagination",className:this.props.curationPage?"curation-page":""},r.a.createElement("div",{className:"page-button-container previous-page"},r.a.createElement("button",{className:1===this.props.pageNumber?" disabled":this.props.querying?"loading":"",onClick:this.props.loadPreviousPage},r.a.createElement("i",{className:"fa fa-chevron-left"}),"Prev")),r.a.createElement("div",{className:"filler-left"},r.a.createElement(Q,{inSearchMode:this.props.inSearchMode,searchDocuments:this.props.searchDocuments})),r.a.createElement("div",{className:"current-page-container"+(this.props.showingProgressBar?" progress-bar-underneath":"")},t,this.props.showDocsPerPage&&r.a.createElement("div",{className:"docs-per-page-select-container"},r.a.createElement("label",null,"Per page:"),r.a.createElement("select",{className:"docs-per-page-select",onChange:function(t){e.props.setDocsPerPage(t),O()(t.target).blur()}},this.props.docsPerPageOptions.map((function(t,a){return r.a.createElement("option",{value:t,selected:t===e.props.docsPerPage},t)})))),this.props.showSortBy&&r.a.createElement("div",{className:"docs-per-page-select-container"},r.a.createElement("label",null,"Sort by:"),r.a.createElement("select",{className:"docs-per-page-select sort-by",onChange:function(t){e.props.setSortBy(t),O()(t.target).blur()}},this.props.sortByOptions.map((function(t,a){return r.a.createElement("option",{value:t,selected:t===e.props.sortBy},"Annotations"===t?"# Annotations":t)})))),r.a.createElement(V,{show:this.props.showingProgressBar,totalPagesAvailable:this.props.totalPagesAvailable,totalPages:this.props.totalPages})),r.a.createElement("div",{className:"group-last-modified"},n),this.props.showSaveButton&&r.a.createElement("div",{className:"page-button-container "},r.a.createElement(Y,{changesMade:this.props.changesMade,recentlySaved:this.props.recentlySaved,saving:this.props.saving,submitAnnotations:this.props.submitAnnotations})),r.a.createElement("div",{className:"page-button-container next-page",title:a&&!this.props.inSearchMode?"Finish annotating this page to move on to the next page.":""},r.a.createElement("button",{className:a?" disabled":this.props.querying?"loading":"",onClick:this.props.loadNextPage},"Next",r.a.createElement("i",{className:"fa fa-chevron-right"}))))}}]),a}(n.Component),Z=function(){function e(t,a){Object(p.a)(this,e),this.token=t,this.tokenIndex=a,this.bioTag="O",this.highlighting=null}return Object(d.a)(e,[{key:"addLabel",value:function(e,t,a,n,r){void 0===this.entityClasses&&(this.entityClasses=new Array);var s=-1!==this.entityClasses.indexOf(t);return(this.bioTag!==e||this.spanText!==a||this.spanStartIdx!==n||this.spanEndIdx!==r||!s)&&(this.bioTag=e,this.spanText=a,this.spanStartIdx=n,this.spanEndIdx=r,s||this.entityClasses.push(t),!0)}},{key:"removeAllLabels",value:function(){delete this.entityClasses,delete this.spanText,delete this.spanStartIdx,delete this.spanEndIdx,this.bioTag="O"}},{key:"sameMention",value:function(e){return e.spanStartIdx===this.spanStartIdx&&e.spanEndIdx===this.spanEndIdx}},{key:"sameEntityClasses",value:function(e){return S.a.isEqual(this.entityClasses,e.entityClasses)}},{key:"removeLabel",value:function(e){var t=this.entityClasses.indexOf(e);-1!==t?(this.entityClasses.splice(t,1),0===this.entityClasses.length&&(this.bioTag="O",delete this.entityClasses,delete this.spanText,delete this.spanStartIdx,delete this.spanEndIdx)):console.log("Warning: tried to remove an entity class from an annotation that did not exist.")}},{key:"changeBioTag",value:function(e){this.bioTag=e}},{key:"hasLabel",value:function(){return"O"!==this.bioTag}},{key:"isLastInSpan",value:function(){return this.spanEndIdx===this.tokenIndex}},{key:"setSpanStartIdx",value:function(e){this.spanStartIdx=e}},{key:"setSpanEndIdx",value:function(e){this.spanEndIdx=e}},{key:"setHighlighting",value:function(e,t){this.highlighting=[e,t]}},{key:"prettyPrint",value:function(){console.log("Token:    ",this.token),console.log("BIO Tag:  ",this.bioTag),console.log("Span:     ",this.spanText),console.log("StartIdx: ",this.spanStartIdx),console.log("EndIdx: ",this.spanEndIdx),console.log("Classes:  \n",this.entityClasses),console.log("\n")}}]),e}();var X=function(e,t,a,n){console.log(e),console.log(t),console.log("---");var r=new Array;if(n){for(var s in t)r.push(e[0]);e=r}if(a)var o=a.split(" ");var i=new Array(e.length);for(var l in e){i[l]=new Array(e[l].length);var c=0;for(var u in e[l])if(i[l][u]=new Z(e[l][u],parseInt(u)),a){var m=e[l][u].indexOf(o[c]);m>=0?(i[l][u].setHighlighting(m,m+o[c].length-1),c++):c=0}}if(!t)return i;for(var l in t)if(t[l])for(var p in t[l].mentions){var d=t[l].mentions[p],h=d.start,g=d.end;for(var f in d.labels)for(var v=d.labels[f],b=h;b<g;b++){var E=b===h?"B":"I";i[l][b].addLabel(E,v,e[l].slice(h,g).join(" "),h,g-1)}}return i},z=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("main",{class:"error-page"},r.a.createElement("h1",null,"403: Access denied."),r.a.createElement("p",null,"You do not have permission to access the requested page."))}}]),a}(n.Component),$={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}};var ee=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this,t=this.props.docIdx,a=this.props.value;return r.a.createElement("span",{className:"confidence-button conf-"+a+(this.props.checked?" checked":""),onClick:function(){return e.props.updateConfidence(t,a)},title:"Assign a "+a+" confidence to this document."})}}]),a}(n.Component),te=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"confidence-buttons"},r.a.createElement(ee,Object.assign({value:"low",checked:"low"===this.props.confidence},this.props)),r.a.createElement(ee,Object.assign({value:"medium",checked:"medium"===this.props.confidence},this.props)),r.a.createElement(ee,Object.assign({value:"high",checked:"high"===this.props.confidence},this.props)))}}]),a}(n.Component),ae=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"document-container header"},r.a.createElement("div",{className:"document header"},r.a.createElement("div",{className:"sentence-index"}),r.a.createElement("div",{className:"sentence"},"Document"),r.a.createElement("div",{className:"confidence-buttons"},"Confidence")))}}]),a}(n.Component),ne=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={commentsOpen:!1},n.sentenceRef=r.a.createRef(),n.documentUnderneathRef=r.a.createRef(),n.commentBoxRef=r.a.createRef(),n}return Object(d.a)(a,[{key:"componentDidUpdate",value:function(e,t){!S.a.isEqual(e.words,this.props.words)&&this.state.commentsOpen&&this.setState({commentsOpen:!1})}},{key:"toggleOpenComments",value:function(){this.setState({commentsOpen:!this.state.commentsOpen},(function(){}))}},{key:"saveToPng",value:function(){var e=this,t=this.sentenceRef.current;I.a.toBlob(t,{bgcolor:"#fefefe"}).then((function(t){Object(x.saveAs)(t,"document-"+e.props.index+".png")}))}},{key:"submitComment",value:function(e,t){var a=this;this.props.submitComment(e,this.props.index,(function(){t(),a.commentBoxRef.current.scrollTop=a.commentBoxRef.current.scrollHeight}))}},{key:"render",value:function(){return r.a.createElement("div",{className:"document-container"+(this.props.confidence?" conf conf-"+this.props.confidence:"")},r.a.createElement("div",{className:"document-wrapper"},r.a.createElement("div",{className:"document"},r.a.createElement("div",{className:"sentence-index"},r.a.createElement("span",{className:"inner"},this.props.displayIndex)),r.a.createElement("div",{className:"sentence",ref:this.sentenceRef},r.a.createElement(L,{index:this.props.index,words:this.props.words,annotations:this.props.annotations,selections:this.props.selections,updateSelections:this.props.updateSelections,entityColourMap:this.props.entityColourMap,deleteTag:this.props.deleteTag})),r.a.createElement(te,{docIdx:this.props.index,confidence:this.props.confidence,updateConfidence:this.props.updateConfidence})),r.a.createElement("div",{className:"document document-underneath"+(this.state.commentsOpen?" open":""),ref:this.documentUnderneathRef},r.a.createElement("div",{className:"sentence-index"}),r.a.createElement("div",{className:"sentence"},r.a.createElement("div",{className:"bottom-buttons"},r.a.createElement("div",{className:"open-comments-button"+(this.props.comments.length>0?" has-comment":"")},r.a.createElement("span",{className:"inner",onClick:this.toggleOpenComments.bind(this)},r.a.createElement("i",{className:"fa fa-comment"}),r.a.createElement("span",{className:"num-comments"},this.props.comments.length))),r.a.createElement("div",{className:"save-to-png",onClick:this.saveToPng.bind(this),title:"Click to download a .png file of this document"},r.a.createElement("span",{className:"inner"},r.a.createElement("i",{className:"fa fa-download"})))),this.props.user&&r.a.createElement("div",{className:"comments-wrapper"},r.a.createElement("div",{className:"comments-inner"},r.a.createElement("div",{className:"comments-even-more-inner",ref:this.commentBoxRef},this.props.comments.map((function(e,t){return r.a.createElement(G,Object.assign({index:t},e,{hideDocumentString:!0}))}))),r.a.createElement(J,{user_profile_icon:this.props.user.profile_icon,submitComment:this.submitComment.bind(this)})))),r.a.createElement("div",{className:"confidence-buttons"}))))}}]),a}(n.Component);function re(e){if(e.hasChildNodes())return e.firstChild;for(;e&&!e.nextSibling;)e=e.parentNode;return e?e.nextSibling:null}var se=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this.props.entityClass;return void 0===e&&(e="(not a valid class)"),r.a.createElement("div",{className:"hotkey-info"+(0===this.props.chain.length?" hidden":"")},r.a.createElement("span",{className:"chain"},this.props.chain),": ",r.a.createElement("span",null,e))}}]),a}(n.Component);var oe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e))._isMounted=!1,n.state={visible:!0,querying:!1,wikipediaSummary:null,wikipediaReadMoreUrl:null},n}return Object(d.a)(a,[{key:"queryWikipedia",value:function(){var e=this;if(!this.state.querying){var t=this.props.tokens;this.setState({querying:!0},(function(){var a,n,r,s=e;r=function(e,r,o){if(s._isMounted){var i=t;r?(e.toLowerCase()!==t.toLowerCase()&&(i=e),a=r+"...",n=o):(n=null,a=null),s.setState({wikipediaTitle:i,wikipediaSummary:a,wikipediaReadMoreUrl:n,querying:!1})}},O.a.ajax({url:"https://en.wikipedia.org/w/api.php",data:{action:"query",list:"search",srsearch:t,format:"json"},dataType:"jsonp",success:function(e){!function(e,t){try{t(e.query.search[0].title,e.query.search[0].snippet.replace(/<\/?[^>]+(>|$)/g,""),"https://en.wikipedia.org/wiki/"+e.query.search[0].title.replace(/ /g,"_"))}catch(a){t()}}(e,r)}})}))}}},{key:"componentDidMount",value:function(){this._isMounted=!0}},{key:"componentWillUnmount",value:function(){this._isMounted=!1}},{key:"toggleVisibility",value:function(){this.setState({visible:!this.state.visible})}},{key:"componentDidUpdate",value:function(e,t){e.tokens!==this.props.tokens&&this.queryWikipedia()}},{key:"render",value:function(){if(!this.state.querying&&this.state.wikipediaTitle&&this.state.wikipediaTitle!==this.props.tokens)var e=r.a.createElement("span",{className:"different"},"[",this.state.wikipediaTitle,"] ");else e="";var t=this.state.wikipediaSummary?this.state.wikipediaSummary:"(no Wikipedia entry)";return this.props.tokens||(t="Select one or more words to automatically look them up on Wikipedia."),this.state.querying&&(t=r.a.createElement("span",null,r.a.createElement("i",{className:"fa fa-spin fa-cog"}),"\xa0\xa0Loading...")),r.a.createElement("div",{className:"tokens-info"},r.a.createElement("div",{id:"wikipedia-summary-container",className:this.state.visible?"show":"hidden"},r.a.createElement("p",{className:"tokens"},this.props.tokens||"Wikipedia lookup"),r.a.createElement("p",{className:"summary"},e,t),r.a.createElement("span",{className:"more show"},(this.state.querying||!this.props.tokens)&&r.a.createElement("span",{className:"left",style:{color:"rgba(0, 0, 0, 0)"}},"."),!this.state.querying&&this.props.tokens&&r.a.createElement("span",{className:"left"},"Results from Wikipedia"),r.a.createElement("span",{className:"right"},!this.state.querying&&this.props.tokens&&r.a.createElement("a",{id:"ec-read-more",href:this.state.wikipediaReadMoreUrl,target:"_blank"},"Read more ",r.a.createElement("i",{className:"fa fa-sm fa-external-link"}))))),r.a.createElement("button",{id:"wikipedia-hide-show",className:this.state.visible?"up":"down",onClick:this.toggleVisibility.bind(this)},"Show"))}}]),a}(n.Component),ie=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={documentGroupAnnotationId:null,documents:[],documentIds:[],documentAnnotationIds:[],categoryHierarchy:{children:[]},annotations:[],confidences:[],comments:[],selections:n.getEmptySelectionsArray(10),currentSelection:n.getEmptyCurrentSelection(),mostRecentSelectionText:null,hotkeyMap:{},reverseHotkeyMap:{},terminalHotkeys:new Set,hotkeyChain:[],hotkeyBindingFn:null,hotkeyTimeoutFn:null,holdingCtrl:!1,holdingShift:!1,entityColourMap:{},docGroupLastModified:null,pageNumber:-1,totalPagesAvailable:-1,changesMade:!1,recentlySaved:!1,selectionChangeFn:null,windowMouseUpFn:null,loading:{querying:!0,saving:!1,firstLoad:!0},showingProgressBar:!1,searchTerm:null,docsPerPage:10,taggingCompletePage:!1},n}return Object(d.a)(a,[{key:"selectionChange",value:function(e,t){if(!(this.state.currentSelection.wordStartIndex<0)){var a=window.getSelection&&window.getSelection();if(a&&a.rangeCount>0){var n=function(e){var t=e.startContainer,a=e.endContainer;if(t==a)return[t.parentNode];for(var n=[];t&&t!=a;)n.push(t=re(t));for(t=e.startContainer;t&&t!=e.commonAncestorContainer;)n.unshift(t),t=t.parentNode;return n}(a.getRangeAt(0));t.removeClass("highlighted"),O()(n).find(".word-inner").addClass("highlighted")}}}},{key:"windowMouseUp",value:function(e,t){if(!(e.target.classList.contains("page-input")||e.target.classList.contains("comment-input")||e.target.classList.contains("search-bar"))&&(t.removeClass("highlighted"),!(this.state.currentSelection.wordStartIndex<0)&&!e.target.classList.contains("word-inner"))){var a=this.state.currentSelection.sentenceIndex;this.updateSelections(a,this.state.documents[a].length-1,"up")}}},{key:"initMouseEvents",value:function(){var e=this,t=O()(".word-inner");document.removeEventListener("selectionchange",this.state.selectionChangeFn),window.removeEventListener("mouseup",this.state.windowMouseUpFn),this.setState({selectionChangeFn:function(a){return e.selectionChange(a,t)},windowMouseUpFn:function(a){return e.windowMouseUp(a,t)}},(function(){document.addEventListener("selectionchange",e.state.selectionChangeFn),window.addEventListener("mouseup",e.state.windowMouseUpFn)}))}},{key:"initKeybinds",value:function(){var e=this;document.addEventListener("keydown",(function(t){switch(t.key){case"Shift":e.state.holdingShift||e.setState({holdingShift:!0});break;case"Control":e.state.holdingCtrl||e.setState({holdingCtrl:!0});break;case"ArrowLeft":t.preventDefault(),e.moveSelectionHorizontally("left");break;case"ArrowUp":t.preventDefault(),e.moveSelectionVertically("up");break;case"ArrowRight":t.preventDefault(),e.moveSelectionHorizontally("right");break;case"ArrowDown":t.preventDefault(),e.moveSelectionVertically("down")}})),document.addEventListener("keyup",(function(t){switch(t.key){case"Shift":e.state.holdingShift&&e.setState({holdingShift:!1});break;case"Control":e.state.holdingCtrl&&e.setState({holdingCtrl:!1})}}))}},{key:"hotkeyTimeout",value:function(){var e=this.state.hotkeyChain.join(""),t=this.state.reverseHotkeyMap[e];void 0!==t&&this.applyTag(t),window.clearTimeout(this.state.hotkeyTimeoutFn),this.setState({hotkeyTimeoutFn:null,hotkeyChain:[]})}},{key:"bindHotkeys",value:function(e,t){var a=this;if(!(e.keyCode<49||e.keyCode>57)){var n=e.keyCode-48;if(!O()("#page-input").is(":focus")&&!O()("textarea").is(":focus")){var r=Array.prototype.concat(this.state.hotkeyChain,n);this.setState({hotkeyChain:r},(function(){if(window.clearTimeout(a.state.hotkeyTimeoutFn),a.state.terminalHotkeys.has(r.join("")))a.hotkeyTimeout();else{var e=window.setTimeout((function(){return a.hotkeyTimeout()}),333);a.setState({hotkeyTimeoutFn:e})}}))}}}},{key:"setupHotkeyKeybinds",value:function(){var e=this;console.log("Setting up hotkey keybinds..."),console.log(this.state.reverseHotkeyMap),document.removeEventListener("keydown",this.state.hotkeyBindingFn);var t=function(t){return e.bindHotkeys(t,e.state.hotkeyMap)};document.addEventListener("keydown",t),this.setState({hotkeyBindingFn:t})}},{key:"initHotkeyMap",value:function(e,t){var a=this;console.log("Setting up hotkey map...");var n=function e(t,a,n,r,s,o){if(o||(n[t.full_name]=r),t.children)for(var i=0;i<Math.min(9,t.children.length);i++)e(t.children[i],i+1,n,Array.prototype.concat(r,i+1),s);else s.add(r.join(""));return{hotkeyMap:n,terminalHotkeys:s}}({children:e},0,[],[],new Set,!0),r=n.hotkeyMap,s=n.terminalHotkeys,o=function(e){var t={};for(var a in e){t[e[a].join("")]=a}return t}(r);this.setState({hotkeyMap:r,reverseHotkeyMap:o,terminalHotkeys:s},(function(){a.setupHotkeyKeybinds(),t&&t()}))}},{key:"initConfidencesArray",value:function(e){return new Array(e.length)}},{key:"initEntityColourMap",value:function(e){var t={};for(var a in e){var n=e[a];t[n.name]=n.colorId+1}return t}},{key:"justifyWords",value:function(){O()(".word-inner").each((function(e,t){var a=t.offsetWidth,n=25*Math.ceil(a/25);O()(t).css("min-width",n+"px")}))}},{key:"clearWordJustification",value:function(){O()(".word:not(.tag) .word-inner").each((function(e,t){O()(t).css("min-width","auto")}))}},{key:"loadNextPage",value:function(){if(!this.state.loading.querying){var e=this.state.pageNumber+1;e!==this.state.totalPagesAvailable||this.state.searchTerm?this.queryAPI(!1,e):this.queryAPI(!1)}}},{key:"goToPage",value:function(e){this.state.loading.querying||(console.log(e),this.state.searchTerm?this.queryAPI(!1,e):e===this.state.totalPagesAvailable?this.queryAPI(!1):this.queryAPI(!1,e))}},{key:"loadPreviousPage",value:function(){this.queryAPI(!1,this.state.pageNumber-1)}},{key:"searchDocuments",value:function(e){var t=this;this.setState({searchTerm:e},(function(){e?t.queryAPI(!1,1):t.queryAPI(!1)}))}},{key:"setDocsPerPage",value:function(e){var t=this,a=e.target.value,n=this.state.pageNumber,r=this.state.docsPerPage,s=Math.min(this.state.totalPagesAvailable+1,Math.floor(n/a*r));s===this.state.totalPagesAvailable+1&&(s=null),this.setState({docsPerPage:a},(function(){t.queryAPI(!1,s)}))}},{key:"queryAPI",value:function(e,t){var a,n=this.state.searchTerm;a=t?"getDocumentGroup?pageNumber="+t+"&perPage="+this.state.docsPerPage:"getDocumentGroup?pageNumber=latest&perPage="+this.state.docsPerPage,n&&(a+="&searchTerm="+n),this.setState({loading:{querying:!0,saving:!1,firstLoad:e}},function(){var t=this;fetch("http://localhost:3000/api/projects/"+this.props.project_id+"/tagging/"+a,$).then((function(e){if(200!==e.status){var t=e.text();throw console.log(t),new Error(e.status)}return e.text()})).then((function(a){try{var n=JSON.parse(a)}catch(r){return void alert(r)}if(n.tagging_complete)return t.setState({taggingCompletePage:!0,pageNumber:n.pageNumber,totalPages:n.totalPages,totalPagesAvailable:n.totalPagesAvailable+1,changesMade:!1,recentlySaved:!1,loading:{querying:!1,saving:!1}}),void console.log(n);t.setState({data:n,documents:n.documents,documentIds:n.documentIds,documentAnnotationIds:n.documentAnnotationIds?n.documentAnnotationIds:null,confidences:t.initConfidencesArray(n.documents),annotations:X(n.documents,n.automaticAnnotations),comments:n.comments,categoryHierarchy:n.categoryHierarchy,entityColourMap:t.initEntityColourMap(n.categoryHierarchy.children),selections:t.getEmptySelectionsArray(n.documents.length),mostRecentSelectionText:null,pageNumber:n.pageNumber,totalPages:n.totalPages,totalPagesAvailable:n.totalPagesAvailable,docGroupLastModified:n.lastModified,documentGroupAnnotationId:n.documentGroupAnnotationId,changesMade:!1,recentlySaved:!1,loading:{querying:!1,saving:!1},taggingCompletePage:!1},(function(){n.projectTitle&&n.projectAuthor&&t.props.setProject(n.projectTitle,n.projectAuthor),e&&(t.initKeybinds(),t.initHotkeyMap(t.state.categoryHierarchy.children)),t.initMouseEvents(),t.clearWordJustification(),t.justifyWords(),t.selectFirstWord(),window.scrollTo(0,0)}))})).catch((function(e){console.log(e.message),t.props.setErrorCode(parseInt(e.message))}))}.bind(this))}},{key:"annotationsToJSON",value:function(){var e=this.state.annotations,t=[];for(var a in e){var n=[];for(var r in e[a]){var s=e[a][r];s.entityClasses?n.push([s.bioTag+"-",s.entityClasses]):n.push([""])}t.push(n)}return t}},{key:"submitAnnotations",value:function(){var e=this;if(!this.state.recentlySaved){var t=b("csrf-token"),a=this.annotationsToJSON(),n={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","csrf-token":t},dataType:"json",body:JSON.stringify({documentIds:this.state.documentIds,documentAnnotationIds:this.state.documentAnnotationIds,labels:a})};this.setState({loading:{querying:!1,saving:!0}},(function(){fetch("http://localhost:3000/api/projects/"+e.props.project_id+"/tagging/submitAnnotations",n).then((function(e){if(200!==e.status)throw new Error(e.status);return e.text()})).then((function(t){try{var a=JSON.parse(t).documentAnnotationIds;if(console.log("Submitted annotations OK"),e.state.pageNumber!==e.state.totalPagesAvailable||e.state.searchTerm)n=e.state.totalPagesAvailable;else{var n=e.state.totalPagesAvailable+1;e.setState({showingProgressBar:!0},(function(){window.setTimeout((function(){return e.setState({showingProgressBar:!1})}),3e3)}))}e.setState({docGroupLastModified:Date.now(),totalPagesAvailable:n,documentAnnotationIds:a,changesMade:!1,recentlySaved:!0,loading:{querying:!1,saving:!1}})}catch(r){console.log("ERROR:",r),alert(t)}})).catch((function(t){console.log(t.message),e.props.setErrorCode(parseInt(t.message))}))}))}}},{key:"componentWillMount",value:function(){this.queryAPI(!0)}},{key:"getEmptyCurrentSelection",value:function(){return{wordStartIndex:-1,wordEndIndex:-1,sentenceIndex:-1}}},{key:"moveSelectionVertically",value:function(e){console.log("Moving",e)}},{key:"moveSelectionHorizontally",value:function(e){console.log("Moving",e);for(var t,a=this.state.selections,n=0;n<a.length;n++)for(var r=0;r<a[n].length;r++){var s=a[n][r];"left"===e?this.state.holdingShift?s.wordEndIndex>s.wordStartIndex?s.wordEndIndex--:s.wordStartIndex=Math.max(s.wordStartIndex-1,0):(s.wordStartIndex=Math.max(s.wordStartIndex-1,0),s.wordEndIndex=s.wordStartIndex):"right"===e&&(this.state.holdingShift||(s.wordStartIndex=Math.min(this.state.documents[n].length-1,s.wordEndIndex+1)),s.wordEndIndex=Math.min(this.state.documents[n].length-1,s.wordEndIndex+1)),t=this.state.documents[n].slice(s.wordStartIndex,s.wordEndIndex+1).join(" ")}this.setState({selections:a,mostRecentSelectionText:t})}},{key:"getEmptySelectionsArray",value:function(e){if(!e)e=this.state.documents.length;for(var t=new Array(e),a=0;a<t.length;a++)t[a]=new Array;return t}},{key:"selectFirstWord",value:function(){var e=this.state.selections;0!==e.length&&(e[0].push({wordStartIndex:0,wordEndIndex:0}),this.setState({selections:e,mostRecentSelectionText:this.state.documents.length>0?this.state.documents[0][0]:""}))}},{key:"clearSelections",value:function(){this.setState({currentSelection:this.getEmptyCurrentSelection(),selections:this.getEmptySelectionsArray()})}},{key:"updateSelections",value:function(e,t,a){var n,r,s=this.state.selections,o=this.state.currentSelection;if("down"===a)this.state.holdingCtrl||(s=this.getEmptySelectionsArray()),r=-1,o={sentenceIndex:e,wordStartIndex:n=t};else if("up"===a){if(-1===o.wordStartIndex)return void this.clearSelections();if(n=o.wordStartIndex,o.sentenceIndex!==e&&(n=0),r=t,t<n){var i=n;n=t,r=i}o=this.getEmptyCurrentSelection(),s[e].push({wordStartIndex:n,wordEndIndex:r});var l=this.state.documents[e].slice(n,r+1).join(" ");window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}this.setState({currentSelection:o,selections:s,mostRecentSelectionText:l||this.state.mostRecentSelectionText})}},{key:"applyTag",value:function(e){var t=this,a=this.state.selections,n=this.state.documents,r=this.state.annotations;for(var s in a)for(var o in a[s]){for(var i=a[s][o],l=i.wordStartIndex,c=i.wordEndIndex,u=r[s][l].spanStartIdx,m=r[s][l].spanEndIdx,p=!1,d=l+1;d<=c;d++){var h=r[s][d];if(u!==h.spanStartIdx||m!==h.spanEndIdx){p=!0;break}}if(p){for(d=l;d<=c;d++){(v=r[s][d]).removeAllLabels()}for(var g in r[s]){(v=r[s][g]).spanEndIdx>=l&&v.spanStartIdx<=l&&v.setSpanEndIdx(l-1),v.spanStartIdx<=c&&(v.setSpanStartIdx(c+1),v.tokenIndex===c+1&&v.changeBioTag("B"))}}for(var f in r[s].slice(0,l)){(v=r[s][f]).spanStartIdx<l&&v.spanEndIdx>=c&&v.setSpanEndIdx(l-1)}for(var f in r[s].slice(c+1,r[s].length)){var v;(v=r[s][parseInt(f)+c+1]).spanStartIdx<=l&&v.spanEndIdx>=c&&(v.setSpanStartIdx(c+1),"0"===f&&v.changeBioTag("B"))}var b=!1;for(d=l;d<=c;d++){var E=d===l?"B":"I",y=n[s].slice(l,c+1).join(" ");b=r[s][d].addLabel(E,e,y,l,c)}b&&this.captureEvent("Applied label",parseInt(s),l,c,e)}this.setState({annotations:r},(function(){t.justifyWords()}))}},{key:"deleteTag",value:function(e,t,a){var n=this.state.annotations,r=n[e][t],s=r.spanStartIdx,o=r.spanEndIdx;for(var i in this.captureEvent("Deleted label",e,s,o,a),n[e]){var l=n[e][i];l.spanStartIdx===s&&l.spanEndIdx===o&&l.removeLabel(a)}this.setState({annotations:n})}},{key:"updateConfidence",value:function(e,t){var a=this.state.confidences;a[e]===t?a[e]=void 0:a[e]=t,this.setState({confidences:a})}},{key:"submitComment",value:function(e,t,a){var n=this;console.log("Message:",e,"Document index",t);var r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","csrf-token":b("csrf-token")},dataType:"json",body:JSON.stringify({text:e,documentId:this.state.documentIds[t]})};fetch("http://localhost:3000/api/projects/"+this.props.project_id+"/comments/submit",r).then((function(e){if(200!==e.status)throw new Error(e.status);return e.text()})).then((function(e){console.log(e);try{var r=JSON.parse(e);console.log("Submitted comment OK");var s=n.state.comments;s[t].push(r.comment),n.setState({comments:s},a)}catch(o){console.log("ERROR:",o)}})).catch((function(e){console.log(e.message),n.props.setErrorCode(parseInt(e.message))}))}},{key:"captureEvent",value:function(e,t,a,n,r){this.state.documents[t].slice(a,n+1).join(" ");"Applied label"!==e&&"Deleted label"!==e||this.setState({changesMade:!0,recentlySaved:!1})}},{key:"render",value:function(){var e=this,t=this.state.taggingCompletePage;return r.a.createElement("div",null,!this.state.error&&r.a.createElement("div",{id:"tagging-interface",className:(this.state.loading.querying?"loading":"")+(t?" tagging-complete-page":"")},r.a.createElement("div",{id:"tagging-container"},t&&r.a.createElement(le,null),r.a.createElement("div",{id:"sentence-tagging"},this.state.loading.firstLoad&&r.a.createElement("div",{className:"loading-message"},r.a.createElement("i",{className:"fa fa-cog fa-spin"}),"Loading..."),r.a.createElement(K,{showingProgressBar:this.state.showingProgressBar,pageNumber:this.state.pageNumber,totalPages:this.state.totalPages,totalPagesAvailable:this.state.totalPagesAvailable,lastModified:this.state.docGroupLastModified,recentlySaved:this.state.recentlySaved,changesMade:this.state.changesMade,querying:this.state.loading.querying,saving:this.state.loading.saving,inSearchMode:this.state.searchTerm,showDocsPerPage:!0,docsPerPage:this.state.docsPerPage,docsPerPageOptions:[1,3,5,10,15,20],showSaveButton:!0,searchDocuments:this.searchDocuments.bind(this),submitAnnotations:this.submitAnnotations.bind(this),loadPreviousPage:this.loadPreviousPage.bind(this),loadNextPage:this.loadNextPage.bind(this),goToPage:this.goToPage.bind(this),setDocsPerPage:this.setDocsPerPage.bind(this)}),r.a.createElement(ae,null),this.state.documents.map((function(t,a){return r.a.createElement(ne,{key:a,index:a,displayIndex:10*(e.state.pageNumber-1)+a+1,words:t,annotations:e.state.annotations[a],comments:e.state.comments[a],confidence:e.state.confidences[a],selections:e.state.selections[a],updateSelections:e.updateSelections.bind(e),updateConfidence:e.updateConfidence.bind(e),entityColourMap:e.state.entityColourMap,deleteTag:e.deleteTag.bind(e),submitComment:e.submitComment.bind(e),user:e.props.user})})),!this.state.loading.querying&&0===this.state.documents.length&&!this.state.taggingCompletePage&&r.a.createElement("div",{className:"loading-message no-results-found"},"No results found."))),r.a.createElement("div",{id:"tagging-menu"},r.a.createElement("div",{className:"project-card"},r.a.createElement("div",null,r.a.createElement("div",{className:"project-name"+(this.props.projectTitle?"":" st"),style:{display:"block"}},r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/dashboard"},this.props.projectTitle?this.props.projectTitle:"xxxxxxxx")),r.a.createElement("div",{className:"project-creator"+(this.props.projectAuthor?"":" st"),style:{display:"block"}},"Created by ",r.a.createElement("span",{className:"creator-name"},this.props.projectAuthor?this.props.projectAuthor:"xxxxxxxx")))),r.a.createElement(oe,{tokens:this.state.mostRecentSelectionText}),r.a.createElement(se,{chain:this.state.hotkeyChain,entityClass:this.state.reverseHotkeyMap[this.state.hotkeyChain.join("")]}),r.a.createElement(q,{items:this.state.categoryHierarchy.children,hotkeyMap:this.state.hotkeyMap,hotkeyChain:this.state.hotkeyChain.join(""),initHotkeyMap:this.initHotkeyMap.bind(this),applyTag:this.applyTag.bind(this),visible:!t,draggable:!0}))))}}]),a}(n.Component),le=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{id:"tagging-complete-message"},r.a.createElement("span",{class:"tagging-complete-text"},r.a.createElement("h2",null,"Annotation complete!"),r.a.createElement("p",null,"Thank you for your participation in this project.")))}}]),a}(n.Component),ce=ie,ue=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("article",{className:"features-list"},r.a.createElement("h2",null,"Version 2.0 - List of features (19 September 2020)"),r.a.createElement("p",null,"Redcoat underwent a significant revision for Version 2.0, bringing a wide array of new features including:"),r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("b",null,"Overall"),r.a.createElement("ul",null,r.a.createElement("li",null,"The front-end has been completely rebuilt in React. Redcoat now feels significantly more responsive as a result."))),r.a.createElement("li",null,r.a.createElement("b",null,"Project dashboard"),r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("b",null,"Key information"),": The dashboard now shows key information at the top such as number of annotations, average agreement score, and average time per doc (which is still a work in progress)."),r.a.createElement("li",null,r.a.createElement("b",null,"Entity frequencies"),": A chart showing the number of mentions of each entity, which dynamically updates as annotators annotate the project."),r.a.createElement("li",null,r.a.createElement("b",null,"Activity"),": A chart showing the activity of each annotator."),r.a.createElement("li",null,r.a.createElement("b",null,"Annotations/document"),": A waffle chart showing the number of times each document has been annotated."),r.a.createElement("li",null,r.a.createElement("b",null,"Comments"),": A list of all comments made about the project, with links to the corresponding documents in the new Curation Interface."))),r.a.createElement("li",null,r.a.createElement("b",null,"Curation interface"),r.a.createElement("ul",null,r.a.createElement("li",null,"The curation interface visualises all of the annotations made by each annotator and allows each annotator to comment on each doc using the comments window on the right."),r.a.createElement("li",null,"The compiled labels are displayed at the bottom of the annotators' annotations when more than one user has annotated the document."),r.a.createElement("li",null,"Documents can be searched and sorted in a similar manner to the annotation interface."))),r.a.createElement("li",null,r.a.createElement("b",null,"Annotation interface"),r.a.createElement("ul",null,r.a.createElement("li",null,"Annotators may navigate back to previous documents and update them as necessary."),r.a.createElement("li",null,"Annotators can search for specific documents via the search field at the top."),r.a.createElement("li",null,"Annotators can choose the number of documents per page - it is no longer fixed at 10."),r.a.createElement("li",null,"The categories in the category hierarchy can be dragged and dropped so that annotators can essentially rebind the hotkeys for each category when desired."),r.a.createElement("li",null,"Multiple tokens can be selected at once by holding Ctrl."),r.a.createElement("li",null,"Users can write comments on any document (visible by anyone also annotating the project) via the comments button at the bottom of each document."),r.a.createElement("li",null,"Users may specify their confidence via the Confidence buttons on the right (still a work in progress)."),r.a.createElement("li",null,"There is a screenshot button at the bottom of each document which automatically saves a screenshot of the doc to a .png file."),r.a.createElement("li",null,"The save button has been moved to the top."),r.a.createElement("li",null,"The overall design of the interface has changed significantly to make it feel more polished."))),r.a.createElement("li",null,r.a.createElement("b",null,"Projects page"),r.a.createElement("ul",null,r.a.createElement("li",null,"The projects page has also changed in appearance, and now has a more streamlined look."),r.a.createElement("li",null,"There are fewer controls over searching/filtering etc - those may be implemented again later."))),r.a.createElement("li",null,r.a.createElement("b",null,"User profile"),r.a.createElement("ul",null,r.a.createElement("li",null,"There is now a User profile page."),r.a.createElement("li",null,"Users may customise their profile icon - the background, foreground and icon can be changed. These icons will appear on any comments the user makes on any projects."))),r.a.createElement("li",null,r.a.createElement("b",null,"Other changes"),r.a.createElement("ul",null,r.a.createElement("li",null,"Annotator agreement is now calculated whenever a document annotation is saved. The agreement metric is a jaccard-based similarity metric that incorporates both token similarity and span similarity (will be discussed in a future paper).")))),r.a.createElement("h2",null,"Version 1.0 - List of features (5 April 2019)"),r.a.createElement("p",null,"Below is a list of features that are currently present in Redcoat."),r.a.createElement("ul",null,r.a.createElement("li",null," Project Setup page",r.a.createElement("ul",null,r.a.createElement("li",null,"Create annotation projects for Entity Recognition on the Setup Project page"),r.a.createElement("li",null,"Automatic tokenisation of data, with summary of number of tokens/documents"),r.a.createElement("li",null,"Create a concept hierarchy via an interactive tree, or alternatively via text input"),r.a.createElement("li",null,"Multiple built-in hierarchies: NER, FIGER, Mining"),r.a.createElement("li",null,"New project and associated data is persistent across refreshes"))),r.a.createElement("li",null,"Projects page",r.a.createElement("ul",null,r.a.createElement("li",null,"Sort, search, and filter projects"),r.a.createElement("li",null,"Detailed project summary"))),r.a.createElement("li",null,"Annotation interface",r.a.createElement("ul",null,r.a.createElement("li",null,"Annotate projects via an intuitive user interface"),r.a.createElement("li",null,"Keyboard support on the annotation interface (hotkeys, selection with arrow keys)"),r.a.createElement("li",null,"Wikipedia summary of words in the annotation interface"),r.a.createElement("li",null,"Search/filter category hierarchy to quickly find the relevant entity category ")))),r.a.createElement("h3",null,"Attributions"),r.a.createElement("p",null,"The pencil icon on the tagging interface was made by ",r.a.createElement("a",{href:"https://www.flaticon.com/authors/icongeek26",title:"Icongeek26"},"Icongeek26")," from ",r.a.createElement("a",{href:"https://www.flaticon.com/",title:"Flaticon"},"www.flaticon.com"),"."),r.a.createElement("p",null,"The Krippendorff Alpha agreement metric calculation was found on GitHub: ",r.a.createElement("a",{href:"https://github.com/tanbt/krippendorff-alpha"},"https://github.com/tanbt/krippendorff-alpha"),"."))}}]),a}(n.Component),me=a(34),pe={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},de=(n.Component,function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={data:{projects:n.getDummyProjects(),numUserInvolvedIn:null,numCreatedByUser:null,numDocGroupsAnnotated:0,totalDocGroups:1},view:"All projects",loading:!0},n}return Object(d.a)(a,[{key:"getDummyProjects",value:function(){function e(e,t){for(var a="",n=e+Math.floor(Math.random()*(t-e)),r=0;r<n;r++)a+="x";return a}for(var t=[],a=0;a<10;a++)t.push({name:e(5,20),description:Math.random()<.5?null:e(20,50),total_users:0,created_at:null,icon_name:""});return t}},{key:"componentWillMount",value:function(){var e=this;this.props.setProject(null,null),fetch("http://localhost:3000/api/projects",pe).then((function(e){if(200!==e.status){var t=e.text();throw console.log("Response:",t),new Error(e.status)}return e.text()})).then((function(t){var a=JSON.parse(t);e.setState({data:a,loading:!1})})).catch((function(t){console.log(t.message),e.props.setErrorCode(parseInt(t.message))}))}},{key:"setView",value:function(e){var t=this;this.setState({view:e,loading:!0},(function(){window.setTimeout((function(){t.setState({loading:!1})}),100)}))}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"projects-table-wrapper"},r.a.createElement("div",{id:"projects-table-header"},r.a.createElement("div",{className:"row-button"+("All projects"===this.state.view?" active":""),onClick:function(){return e.setView("All projects")}},"All projects ",r.a.createElement("span",{className:"counter"},this.state.data.numUserInvolvedIn)),r.a.createElement("div",{className:"row-button"+("Your projects"===this.state.view?" active":""),onClick:function(){return e.setView("Your projects")}},"Your projects ",r.a.createElement("span",{className:"counter"},this.state.data.numCreatedByUser))),r.a.createElement("div",{id:"projects-table",className:this.state.loading?"loading":""},this.state.data.projects.filter((function(t){return"Your projects"!==e.state.view||t.userIsCreator})).map((function(t,a){return r.a.createElement("div",{className:"row",index:a},r.a.createElement("div",{className:"col-name-desc"},r.a.createElement("div",{className:"projects-table-pie"},e.state.loading&&r.a.createElement(me.PieChart,{data:[{value:0,color:"rgb(109, 201, 34)"},{value:1,color:"rgba(0, 0, 0, 0)"}],background:"#d5d5d5",lineWidth:18,startAngle:270}),!e.state.loading&&r.a.createElement(me.PieChart,{data:[{value:t.numDocGroupsAnnotated,color:"rgb(109, 201, 34)"},{value:t.totalDocGroups-t.numDocGroupsAnnotated,color:"rgba(0, 0, 0, 0)"}],background:"#d5d5d5",animate:!0,animationDuration:500,lineWidth:18,startAngle:270})),r.a.createElement("div",{className:"name-desc-row"},r.a.createElement("div",{className:"project-name"},r.a.createElement(v.b,{to:"/projects/"+t._id+"/dashboard"},t.name)),t.description&&r.a.createElement("div",{className:"project-description"},t.description),r.a.createElement("div",{className:"project-creator"},"Created by ",r.a.createElement("span",{className:"creator-name"},t.creator)))),r.a.createElement("div",{className:"col-date"},r.a.createElement("span",{className:"project-created-at"},"Created on ",H(t.created_at))),r.a.createElement("div",{className:"col-stats"},r.a.createElement("span",{className:"project-total-comments"},r.a.createElement("i",{class:"fa fa-comment"})," ",r.a.createElement("span",{className:"comment-count"},t.total_comments)),r.a.createElement("span",{className:"project-total-users"},r.a.createElement("i",{class:"fa fa-user"})," ",r.a.createElement("span",{className:"user-count"},t.total_users))))}))))}}]),a}(n.Component)),he=a(138),ge=a(375),fe=a(374),ve=a(35),be={GET:{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"}};function Ee(e){return ye.apply(this,arguments)}function ye(){return(ye=Object(u.a)(c.a.mark((function e(t){return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){setTimeout(e,t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(){return(je=Object(u.a)(c.a.mark((function e(t,a,n){var r,s,o,i,l,u=arguments;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=u.length>3&&void 0!==u[3]?u[3]:0,console.log(t),e.next=4,fetch(t,be[a]);case 4:if(200===(s=e.sent).status){e.next=9;break}return o=parseInt(s.status),n(o),e.abrupt("return",Promise.resolve(new Error(o)));case 9:return e.next=11,s.text();case 11:return i=e.sent,e.prev=12,l=JSON.parse(i),e.next=16,Ee(r);case 16:return e.abrupt("return",Promise.resolve(l));case 19:return e.prev=19,e.t0=e.catch(12),console.log(e.t0),n(500),e.abrupt("return",Promise.reject(new Error(500)));case 24:case"end":return e.stop()}}),e,null,[[12,19]])})))).apply(this,arguments)}var ke=function(e,t,a){return je.apply(this,arguments)};var Ce=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return console.log(this.props.data,this.props.loading,"xxx"),r.a.createElement("main",{className:"project-page"},r.a.createElement("h2",null,"Entity Hierarchy"),r.a.createElement("div",{className:"wrapper"},this.props.loading&&function(){var e=new Array(15).fill(0);function t(e,t){for(var a="",n=0;n<e+Math.floor(Math.random()*t);n++)a+="x";return a}return r.a.createElement("table",{className:"project-page-table"},r.a.createElement("tbody",null,e.map((function(e,a){return r.a.createElement("tr",null,r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement("span",{className:"st"},t(30,70)))),r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement("span",{className:"st"},t(30,70)))))}))))}(),!this.props.loading&&r.a.createElement(q,{items:this.props.data.children,visible:!0,draggable:!1,displayOnly:!0})))}}]),a}(n.Component);var we=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("table",{className:"project-page-table"},r.a.createElement("tbody",null,this.props.data.active_users.length>0&&r.a.createElement("tr",null,r.a.createElement("td",{colspan:"2"},r.a.createElement("span",{className:"inner row-divider"},"Active"))),this.props.data.active_users.map((function(e,t){return r.a.createElement("tr",null,r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement(C,{user:e}),r.a.createElement("span",null,e.email," (",e.username,")"))))})),this.props.data.pending_invitations.length>0&&r.a.createElement("tr",null,r.a.createElement("td",{colspan:"2"},r.a.createElement("span",{className:"inner row-divider"},"Pending invitations"))),this.props.data.pending_invitations.map((function(e,t){return r.a.createElement("tr",null,r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement(C,{user:e.profile_icon?e:null}),r.a.createElement("span",null,e.email," ",e.username?"("+e.username+")":"",")"))))}))))}}]),a}(n.Component),Ne=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("main",{className:"project-page"},r.a.createElement("h2",null,"Annotators"),r.a.createElement("div",{className:"wrapper"},this.props.loading&&function(){var e=new Array(15).fill(0);function t(e,t){for(var a="",n=0;n<e+Math.floor(Math.random()*t);n++)a+="x";return a}return r.a.createElement("table",{className:"project-page-table"},r.a.createElement("tbody",null,e.map((function(e,a){return r.a.createElement("tr",null,r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement("span",{className:"st"},t(30,70)))),r.a.createElement("td",null,r.a.createElement("span",{className:"inner"},r.a.createElement("span",{className:"st"},t(30,70)))))}))))}(),!this.props.loading&&r.a.createElement(we,{data:this.props.data})))}}]),a}(n.Component),Oe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"componentDidMount",value:function(){this.props.clearErrorCode()}},{key:"render",value:function(){return r.a.createElement(f.a,{to:"/login"})}}]),a}(n.Component),Se={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"}},xe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={documentId:null,documents:[],annotations:[],compiledAnnotation:null,comments:[],annotatorAgreement:null,pageNumber:1,totalPages:1,recentlySaved:!1,changesMade:!1,searchTerm:null,sortBy:"Annotations",documentIdQuery:null,entityColourMap:{},loading:{querying:!0,saving:!1}},n.commentBoxRef=r.a.createRef(),n._isMounted=!1,n.refreshDataFn=null,n}return Object(d.a)(a,[{key:"componentWillMount",value:function(){this._isMounted=!0,this.props.documentIdQuery?this.setState({documentIdQuery:this.props.documentIdQuery},this.queryAPI):(console.log("Loading state:",this.props.prevState),this.props.prevState?this.setState(this.props.prevState):this.queryAPI())}},{key:"componentDidMount",value:function(){}},{key:"componentWillUnmount",value:function(){this._isMounted=!1}},{key:"componentDidUpdate",value:function(e,t){S.a.isEqual(t,this.state)||(console.log("state updated"),this.props.saveState(this.state))}},{key:"queryAPI",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t,a=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isMounted){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.setState({loading:{querying:!0,saving:!1}});case 4:t="http://localhost:3000/api/projects/"+this.props.project_id+"/curation?pageNumber="+this.state.pageNumber+"&sortBy="+this.state.sortBy,this.state.searchTerm&&(t+="&searchTerm="+this.state.searchTerm),this.state.documentIdQuery&&(t+="&documentId="+this.state.documentIdQuery),fetch(t,Se).then((function(e){if(403===e.status)throw new Error(403);if(401===e.status)throw new Error(401);return e.text()})).then((function(e){var t=JSON.parse(e);a.setState({documentId:t.documentId,tokens:t.tokens,annotations:X([t.tokens],t.annotations,a.state.searchTerm,!0),compiledAnnotation:t.compiledAnnotation?X([t.tokens],[t.compiledAnnotation],a.state.searchTerm,!0)[0]:null,comments:t.comments,users:t.users,saveTimes:t.saveTimes,documentIdQuery:null,annotatorAgreement:t.annotatorAgreement,entityColourMap:a.initEntityColourMap(t.categoryHierarchy.children),pageNumber:t.pageNumber,totalPages:t.totalPages,loading:{querying:!1,saving:!1}},(function(){a.refreshDataFn&&window.clearTimeout(a.refreshDataFn),a.refreshDataFn=window.setTimeout(a.queryAPI.bind(a),3e3)}))})).catch((function(e){console.log(e.message),a.props.setErrorCode(parseInt(e.message))}));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"searchDocuments",value:function(e){this.setState({pageNumber:1,searchTerm:e},this.queryAPI)}},{key:"submitAnnotations",value:function(){return null}},{key:"loadPreviousPage",value:function(){this.state.loading.querying||1!==this.state.pageNumber&&this.setState({pageNumber:this.state.pageNumber-1},this.queryAPI)}},{key:"loadNextPage",value:function(){this.state.loading.querying||this.state.pageNumber>=this.state.totalPages||this.setState({pageNumber:this.state.pageNumber+1},this.queryAPI)}},{key:"goToPage",value:function(e){this.state.loading.querying||e<1||e>this.state.totalPages||this.setState({pageNumber:e},this.queryAPI)}},{key:"setSortBy",value:function(e){var t=e.target.value;this.setState({sortBy:t},this.queryAPI)}},{key:"initEntityColourMap",value:function(e){var t={};for(var a in e){var n=e[a];t[n.name]=n.colorId+1}return t}},{key:"submitComment",value:function(e,t){var a=this,n=this;console.log("Message:",e);var r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","csrf-token":b("csrf-token")},dataType:"json",body:JSON.stringify({text:e,documentId:this.state.documentId})};fetch("http://localhost:3000/api/projects/"+this.props.project_id+"/comments/submit",r).then((function(e){if(403===e.status)throw new Error(403);if(401===e.status)throw new Error(401);return e.text()})).then((function(e){console.log(e);try{var r=JSON.parse(e),s=a.state.comments;s.push(r.comment),a.setState({comments:s},(function(){t(),n.commentBoxRef.current.scrollTop=n.commentBoxRef.current.scrollHeight}))}catch(o){console.log("ERROR:",o),t()}})).catch((function(e){console.log(e.message),a.props.setErrorCode(parseInt(e.message))}))}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"tagging-interface"},r.a.createElement("div",{id:"sentence-tagging",className:"curation-page"},r.a.createElement(K,{pageNumber:this.state.pageNumber,totalPages:this.state.totalPages,totalPagesAvailable:this.state.totalPages,recentlySaved:this.state.recentlySaved,changesMade:this.state.changesMade,querying:this.state.loading.querying,saving:this.state.loading.saving,inSearchMode:this.state.searchTerm,showSortBy:!0,sortBy:this.state.sortBy,sortByOptions:["Annotations","Agreement","Document Index"],setSortBy:this.setSortBy.bind(this),searchDocuments:this.searchDocuments.bind(this),submitAnnotations:this.submitAnnotations.bind(this),loadPreviousPage:this.loadPreviousPage.bind(this),loadNextPage:this.loadNextPage.bind(this),goToPage:this.goToPage.bind(this),curationPage:!0}),!this.state.loading.querying&&!this.state.tokens&&r.a.createElement("div",{className:"loading-message no-results-found"},"No results found."),r.a.createElement("div",{className:"curation-interface-inner"},r.a.createElement("div",{className:"document-window",id:"sentence-tagging"},r.a.createElement("div",{className:"agreement-score"},r.a.createElement("span",{className:"name"},"Agreement:"),null!==this.state.annotatorAgreement&&r.a.createElement("span",{className:"value"},(100*this.state.annotatorAgreement).toFixed(2),"%"),null===this.state.annotatorAgreement&&r.a.createElement("span",{className:"value na"},"N/A")),this.state.annotations.map((function(t,a){return r.a.createElement(Ae,{user:e.state.users[a]||null,index:a,tokens:e.state.tokens,annotations:e.state.annotations[a],entityColourMap:e.state.entityColourMap,displayOnly:!0,saveTime:e.state.saveTimes[a]||null})})),this.state.compiledAnnotation&&r.a.createElement("div",{className:"divider"},r.a.createElement("span",null)),this.state.compiledAnnotation&&r.a.createElement(Ae,{specialName:"Compiled labels",specialDescription:"These labels are automatically compiled from the annotations above.",tokens:this.state.tokens,annotations:this.state.compiledAnnotation,entityColourMap:this.state.entityColourMap,displayOnly:!0})),r.a.createElement("div",{className:"comments-pane"},r.a.createElement("div",{className:"comments-wrapper"},this.props.user&&r.a.createElement("div",{className:"comments-inner"},r.a.createElement("h3",{className:0===this.state.comments.length?"hidden":""},"Comments ",this.state.comments.length>0&&"("+this.state.comments.length+")"),0===this.state.comments.length&&r.a.createElement("div",{className:"no-comments-yet"},"No comments yet."),r.a.createElement("div",{className:"comments-even-more-inner",ref:this.commentBoxRef},this.state.comments.map((function(e,t){return r.a.createElement(G,Object.assign({index:t},e,{hideDocumentString:!0}))}))),r.a.createElement(J,{user_profile_icon:this.props.user.profile_icon,submitComment:this.submitComment.bind(this)})))))))}}]),a}(n.Component),Ae=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"document-container"},r.a.createElement("div",{className:"document-wrapper"},r.a.createElement("div",{className:"curation-document"+(this.props.specialName||this.props.user?"":" not-yet-annotated")},!this.props.specialName&&r.a.createElement("div",{className:"user-row"},r.a.createElement(C,{user:this.props.user}),r.a.createElement("span",{className:"username"},this.props.user&&this.props.user.username),r.a.createElement("div",{className:"save-time"},"Saved on ",H(this.props.saveTime))),this.props.specialName&&r.a.createElement("div",{className:"user-row"},r.a.createElement("span",{className:"username"},r.a.createElement("em",null,this.props.specialName),r.a.createElement("i",{class:"fa fa-info-circle",title:this.props.specialDescription}))),r.a.createElement("div",{className:"sentence display-only"},r.a.createElement(L,{index:this.props.index,words:this.props.tokens,annotations:this.props.annotations,entityColourMap:this.props.entityColourMap,displayOnly:!0})))))}}]),a}(n.Component),Ie=xe,Pe=a(275);ve.defaults.global.defaultFontFamily="Open Sans",ve.defaults.global.animation.duration=500;var Te=["#36A2EB","#FF6384","#6dc922","#B4436C","#FFCE56","#F78154","#5FAD56","#4D9078","#586BA4","#324376","#F5DD90","#6665DD","#7B4B94"],Me=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this.props.data.length-1,t=this.props.data.reduce((function(e,t){return e+t}),0),a=Math.min(100,t)/t,n=[],s=-1,o=0;for(var i in this.props.data){var l=this.props.data[i],c=Math.floor(l*a);n.push(r.a.createElement("span",{style:{top:19*Math.ceil(o/10)+"px"},className:"waffle-chart-tooltip tooltip-"+(1===s?"right":"left")},r.a.createElement("b",{style:{background:"rgba(54, 162, 235,"+Math.max(.1,(e-i)/e)+")"}},e-i===0?"Not yet annotated":e-i+" annotation"+(e-i===1?"":"s")),r.a.createElement("span",{className:"num-docs"},this.props.data[i]," docs"))),s*=-1,Math.floor(c/10)+1,o+=c}return r.a.createElement("div",{className:"waffle-chart-container"},r.a.createElement("div",{className:"waffle-chart-legend"},r.a.createElement("span",null,e),r.a.createElement("div",{className:"waffle-chart-legend-inner"}),r.a.createElement("span",null,"0")),r.a.createElement("div",{className:"waffle-chart",id:"annotations-per-doc-chart"},r.a.createElement("div",{className:"waffle-chart-squares"},this.props.data.map((function(t,n){var s=e-n;return new Array(Math.floor(t*a)).fill(0).map((function(t,a){return r.a.createElement("div",{className:"waffle-square",style:{background:"rgba(54, 162, 235,"+Math.max(.1,s/e)+")"}},s)}))}))),r.a.createElement("div",{className:"waffle-chart-info"},"1 square = ~",Math.ceil(1/a)," documents"),r.a.createElement("div",{className:"waffle-chart-tooltips"},n)))}}]),a}(n.Component);function De(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function qe(e){for(var t in e.datasets){var a=parseInt(t)%Te.length;e.datasets[t]=Object.assign({},e.datasets[t],Object(he.a)({fill:!1,lineTension:.1,backgroundColor:Te[a],borderColor:Te[a],borderCapStyle:"square",borderDash:[],borderDashOffset:0,borderJoinStyle:"bevel",pointBorderColor:Te[a],pointBackgroundColor:Te[a],pointBorderWidth:3,pointHoverRadius:6,pointHoverBackgroundColor:Te[a],pointHoverBorderColor:"rgba(220,220,220,1)",pointHoverBorderWidth:2,pointRadius:1,pointHitRadius:10},"lineTension",0))}return e}function Fe(e,t){return[Math.max(e[0]-t,0),Math.max(e[1]-t,0),Math.max(e[2]-t,0)]}String.prototype.convertToRGB=function(){if(6!=this.length)throw"Only six-digit hex colors are allowed.";var e=this.match(/.{1,2}/g);return[parseInt(e[0],16),parseInt(e[1],16),parseInt(e[2],16)]};var Re=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={data:[],multicolour:!1},n}return Object(d.a)(a,[{key:"getColouredData",value:function(e,t){var a=["#99FFCC","#FFCCCC","#CCCCFF","#CCFF99","#CCFFCC","#CCFFFF","#FFCC99","#FFCCFF","#FFFF99","#FFFFCC","#CCCC99","#fbafff"];console.log(e.entityClasses,"<<");var n=e;if(n.entityClasses.datasets[0].borderWidth=1,t)for(var r in n.entityClasses.datasets[0].backgroundColor=[],n.entityClasses.datasets[0].borderColor=[],e.entityClasses.labels){var s=e.entityClasses.labels[r],o=e.colourIndexes[s];console.log(o,s);var i=a[o%a.length];console.log(i);var l=i.slice(1,7).convertToRGB();n.entityClasses.datasets[0].backgroundColor.push("rgba("+l[0]+", "+l[1]+", "+l[2]+", 1)");var c=Fe(l,50);n.entityClasses.datasets[0].borderColor.push("rgba("+c[0]+", "+c[1]+", "+c[2]+", 1)")}else n.entityClasses.datasets[0].backgroundColor="rgba(54, 162, 235, 0.6)",n.entityClasses.datasets[0].borderColor="rgba(54, 162, 235, 0.6)";return n}},{key:"componentWillMount",value:function(){this.setState({data:this.getColouredData(this.props.data,this.props.multicolour),multicolour:this.props.multicolour})}},{key:"shouldComponentUpdate",value:function(e,t){return this.state.multicolour!==t.multicolour||e.multicolour!==this.props.multicolour}},{key:"componentDidUpdate",value:function(e,t){var a=this.props.multicolour;this.setState({multicolour:a,data:this.getColouredData(this.state.data,a)})}},{key:"render",value:function(){return r.a.createElement(ve.Bar,{data:this.state.data.entityClasses,height:230,options:{responsive:!0,maintainAspectRatio:!1,legend:{display:!1},scales:{yAxes:[{ticks:{beginAtZero:!0,precision:0},scaleLabel:{display:!0,labelString:"Frequency"}}]}}})}}]),a}(n.Component),_e=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={data:[]},n}return Object(d.a)(a,[{key:"componentWillMount",value:function(){this.setState({data:this.props.data,cumulative:this.props.cumulative})}},{key:"processActivityChartData",value:function(e){Object.assign({},this.props.data.datasets);if(console.log("cumu",e),e){console.log(this.props.data.activityChartData,"<<");var t=function(e){for(var t=[],a=0;a<e.length;a++){for(var n={label:e[a].label,data:new Array(e[a].data.length).fill(0)},r=0,s=e[a].data.length-1;s>=0;s--)r+=e[a].data[s],n.data[s]=r;console.log(n,">>"),t.push(n)}return t}(this.props.data.datasets),a=qe({labels:Object.assign([],this.props.data.labels),datasets:t});return console.log(a,"<<<"),a}return this.props.data}},{key:"shouldComponentUpdate",value:function(e,t){return this.state.cumulative!==t.cumulative||e.cumulative!==this.props.cumulative}},{key:"componentDidUpdate",value:function(e,t){var a=this.props.cumulative;this.setState({cumulative:a,data:this.processActivityChartData(a)})}},{key:"render",value:function(){return console.log("rerendering",this.props.cumulative),r.a.createElement(ve.Line,{data:this.state.data,height:230,redraw:!0,options:{responsive:!0,maintainAspectRatio:!1,scales:{xAxes:[{type:"time",time:{unit:"day"},ticks:{max:new Date}}],yAxes:[{ticks:{beginAtZero:!0,precision:0},scaleLabel:{display:!0,labelString:"Annotations"}}]}}})}}]),a}(n.Component),Be=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={entityChartMulticolour:!1,activityChartCumulative:!1},n}return Object(d.a)(a,[{key:"toggleEntityChartColours",value:function(){this.setState({entityChartMulticolour:!this.state.entityChartMulticolour})}},{key:"toggleActivityChartCumulative",value:function(){this.setState({activityChartCumulative:!this.state.activityChartCumulative})}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"project-dashboard",className:"padded "+(this.props.loading?"loading":"")},r.a.createElement("div",{className:"dashboard-top-row"},r.a.createElement("div",{className:"dashboard-key-items"},r.a.createElement("div",{className:"dashboard-item"},r.a.createElement("div",{className:"flex-wrapper"},r.a.createElement("div",null,r.a.createElement("div",{className:"name"},"# Annotated"),r.a.createElement("div",{className:"value"},r.a.createElement("span",{class:"st st-darker"},De(this.props.data.numDocGroupsAnnotated)," / ",De(this.props.data.totalDocGroups)))),r.a.createElement("div",{class:"pieChart"},this.props.loading&&r.a.createElement(me.PieChart,{data:[{value:0,color:"rgb(109, 201, 34)"},{value:1,color:"rgba(0, 0, 0, 0)"}],background:"#d5d5d5",lineWidth:18,startAngle:270}),!this.props.loading&&r.a.createElement(me.PieChart,{data:[{value:this.props.data.numDocGroupsAnnotated,color:"rgb(109, 201, 34)"},{value:this.props.data.totalDocGroups-this.props.data.numDocGroupsAnnotated,color:"rgba(0, 0, 0, 0)"}],background:"#d5d5d5",animate:!0,animationDuration:500,lineWidth:18,startAngle:270})))),r.a.createElement("div",{className:"dashboard-item"},r.a.createElement("div",{className:"name"},"Avg. agreement",r.a.createElement("span",{className:"information",title:"Average agreement is only calculated for documents with more than one annotation."},r.a.createElement("i",{class:"fa fa-info-circle"}))),r.a.createElement("div",{className:"value"},r.a.createElement("span",{class:"st st-darker"}," ",this.props.data.avgAgreement?Math.round(100*this.props.data.avgAgreement)+"%":"--"," "))),r.a.createElement("div",{className:"dashboard-item"},r.a.createElement("div",{className:"name"},"Avg. time per document"),r.a.createElement("div",{className:"value"},r.a.createElement("span",{class:"st st-darker"},this.props.data.avgTimePerDocument," seconds")))),r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/tagging",className:"annotate-button"},r.a.createElement("i",{class:"fa fa-pencil"}),"Annotate",r.a.createElement("div",{className:"subtitle"},this.props.data.userDocsAnnotated,"/",this.props.data.userAnnotationsRequired," complete"))),r.a.createElement("div",{className:"dashboard-white-boxes"},r.a.createElement("div",{className:"dashboard-wrapper-item col-60"},r.a.createElement("div",{className:"dashboard-item col-100"},r.a.createElement("div",{className:"inner"},r.a.createElement("div",{className:"dashboard-flex-header"},r.a.createElement("h3",null,"Entity frequencies"),this.props.data.entityChartData&&r.a.createElement("div",{onClick:this.toggleEntityChartColours.bind(this),className:"chart-option"+(this.state.entityChartMulticolour?" active":"")},r.a.createElement("span",{className:"checkbox"}),r.a.createElement("span",null,"Colour by class"))),r.a.createElement("div",null,this.props.loading&&r.a.createElement("div",{className:"chart-placeholder"},r.a.createElement("i",{class:"fa fa-cog fa-spin"}),"Loading..."),!this.props.loading&&!this.props.data.entityChartData&&r.a.createElement("div",{className:"chart-placeholder chart-not-available"},"This project does not have any annotations yet."),!this.props.loading&&this.props.data.entityChartData&&r.a.createElement(Re,{data:this.props.data.entityChartData,multicolour:this.state.entityChartMulticolour})))),r.a.createElement("div",{className:"dashboard-item col-60"},r.a.createElement("div",{className:"inner"},r.a.createElement("div",{className:"dashboard-flex-header"},r.a.createElement("h3",null,"Activity"),this.props.data.activityChartData&&r.a.createElement("div",{onClick:this.toggleActivityChartCumulative.bind(this),className:"chart-option"+(this.state.activityChartCumulative?" active":"")},r.a.createElement("span",{className:"checkbox"}),r.a.createElement("span",null,"Cumulative"))),r.a.createElement("div",null,this.props.loading&&r.a.createElement("div",{className:"chart-placeholder"},r.a.createElement("i",{class:"fa fa-cog fa-spin"}),"Loading..."),!this.props.loading&&!this.props.data.activityChartData&&r.a.createElement("div",{className:"chart-placeholder chart-not-available"},"This project does not have any activity yet."),!this.props.loading&&this.props.data.activityChartData&&r.a.createElement(_e,{data:this.props.data.activityChartData,cumulative:this.state.activityChartCumulative})))),r.a.createElement("div",{className:"dashboard-item col-40"},r.a.createElement("div",{className:"inner"},r.a.createElement("h3",null,"Annotations/document"),this.props.loading&&r.a.createElement("div",{className:"chart-placeholder"},r.a.createElement("i",{class:"fa fa-cog fa-spin"}),"Loading..."),!this.props.loading&&r.a.createElement(Me,{data:this.props.data.annotationsChartData})))),r.a.createElement("div",{className:"dashboard-item col-40 double-height"},r.a.createElement("div",{className:"inner"},r.a.createElement("h3",null,"Comments"),r.a.createElement("div",{className:"comments-wrapper"+(0===this.props.data.comments.length?" no-comments":"")},0===this.props.data.comments.length&&r.a.createElement("div",{className:"no-comments"},"This project does not have any comments yet."),this.props.data.comments.map((function(t,a){return r.a.createElement(G,Object.assign({index:a},t,{project_id:e.props.project_id}))})))))))}}]),a}(n.Component),Ue=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=window.location.pathname,t=e.split("/").slice(3,e.split("/").length);return console.log(t),r.a.createElement("nav",{id:"project-view-sidenav"},r.a.createElement("div",{className:"project-card"},r.a.createElement("div",null,r.a.createElement("div",{className:"project-name"+(this.props.projectTitle?"":" st"),style:{display:"block"}},r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/dashboard"},this.props.projectTitle?this.props.projectTitle:"xxxxxxxx")),r.a.createElement("div",{className:"project-creator"+(this.props.projectAuthor?"":" st"),style:{display:"block"}},"Created by ",r.a.createElement("span",{className:"creator-name"},this.props.projectAuthor?this.props.projectAuthor:"xxxxxxxx")))),r.a.createElement("ul",{className:"sidenav-items"},r.a.createElement(We,{project_id:this.props.project_id,view:t,name:"Dashboard",icon:"bar-chart"}),r.a.createElement(We,{project_id:this.props.project_id,view:t,name:"Entity Hierarchy",icon:"sitemap"}),r.a.createElement(Le,{project_id:this.props.project_id,view:t,name:"Annotations",menuItems:[{name:"Curation",icon:"gavel"},{name:"Download",icon:"download"}],icon:"list-alt"}),r.a.createElement(We,{project_id:this.props.project_id,view:t,name:"Annotators",icon:"user"}),r.a.createElement(We,{project_id:this.props.project_id,view:t,name:"Settings",icon:"wrench"})))}}]),a}(n.Component),Le=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this,t=this.props.name.replace(" ","-").toLowerCase();console.log(this.props.view,t);var a=this.props.menuItems[0].name.replace(" ","-").toLowerCase(),n=this.props.view[0]===t;return r.a.createElement("li",{className:"submenu-header"+(this.props.view[0]===t?" active":"")},r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/"+t+"/"+a},r.a.createElement("i",{className:"fa fa-"+this.props.icon}),this.props.name),r.a.createElement("ul",{className:"submenu"+(n?" open":"")},this.props.menuItems.map((function(a,n){return r.a.createElement(We,{project_id:e.props.project_id,view:e.props.view,name:a.name,parentPath:t,icon:a.icon})}))))}}]),a}(n.Component),We=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this.props.name.replace(" ","-").toLowerCase();return this.props.parentPath&&(e=this.props.parentPath+"/"+e),r.a.createElement("li",{className:this.props.view.join("/")===e?"active":""},r.a.createElement(v.b,{to:"/projects/"+this.props.project_id+"/"+e},r.a.createElement("i",{className:"fa fa-"+this.props.icon}),this.props.name))}}]),a}(n.Component),He=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("main",null,"This page is still a work in progress!")}}]),a}(n.Component),Ge=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={loading:!0,error:null,data:{dashboard:{userDocsAnnotated:0,userAnnotationsRequired:0,numDocGroupsAnnotated:999,totalDocGroups:9999,avgAgreement:.5,avgTimePerDocument:15,comments:[{author:"Mr Pingu",date:"4 Sept",text:"Noot noot! I don't know what this is",document_string:"one two three four five six seven ",user_profile_icon:{foreground:"#eee",background:"#eee",icon:"fa-user"}},{author:"Mrs Pingu",date:"3 Sept",text:"This doesn't make sense",document_string:"one two three four five six seven one two three four five six seven one two three four five six seven ",user_profile_icon:{foreground:"#eee",background:"#eee",icon:"fa-user"}},{author:"Michael",date:"1 Sept",text:"Not sure what a flange is",document_string:"one two three four five six seven one two three four five six seven ",user_profile_icon:{foreground:"#eee",background:"#eee",icon:"fa-user"}},{author:"Michael",date:"1 Sept",text:"I sure hope these never get rendered",document_string:"one two three four five six seven ",user_profile_icon:{foreground:"#eee",background:"#eee",icon:"fa-user"}},{author:"Borat",date:"1 Sept",text:"very nice",document_string:"one two three four five six seven one two three four five six seven ",user_profile_icon:{foreground:"#eee",background:"#eee",icon:"fa-user"}}]},categoryHierarchy:{children:[]}}},n.curationInterfaceState=null,n}return Object(d.a)(a,[{key:"componentWillMount",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t,a,n=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this,e.prev=1,e.next=4,ke("http://localhost:3000/api/projects/"+this.props.project_id,"GET",this.props.setErrorCode,555);case 4:(a=e.sent).dashboard.activityChartData&&(a.dashboard.activityChartData=qe(a.dashboard.activityChartData)),t.setState({loading:!1,data:a},(function(){n.props.setProject(a.project_name,a.project_author)})),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),console.log(e.t0);case 12:case"end":return e.stop()}}),e,this,[[1,9]])})));return function(){return e.apply(this,arguments)}}()},{key:"setCurationInterfaceData",value:function(e){console.log("saving state",e),this.curationInterfaceState=e}},{key:"render",value:function(){var e=this,t=this.props.location;console.log("Rendering project view",this.curationInterfaceState);var a=Pe.parse(t.search).docId;return r.a.createElement("div",{id:"project-view",className:this.state.loading?"loading":""},r.a.createElement(Ue,{project_id:this.props.project_id,projectTitle:this.props.projectTitle,projectAuthor:this.props.projectAuthor}),r.a.createElement("div",{className:"project-view-wrapper"},r.a.createElement(ge.a,{className:"transition-group"},r.a.createElement(fe.a,{key:t.key,timeout:{enter:400,exit:400},classNames:"fade"},r.a.createElement("section",{className:"route-section"+(this.state.loading?"":" loaded")},r.a.createElement(f.d,{location:t},r.a.createElement(f.b,{path:"/projects/:id/dashboard",render:function(){return r.a.createElement(Be,{loading:e.state.loading,data:e.state.data.dashboard,project_id:e.props.project_id})}}),r.a.createElement(f.b,{path:"/projects/:id/annotations/curation",render:function(){return r.a.createElement(Ie,{user:e.props.user,project_id:e.props.project_id,prevState:e.curationInterfaceState,saveState:e.setCurationInterfaceData.bind(e),loading:e.state.loading,documentIdQuery:a,setErrorCode:e.props.setErrorCode})}}),r.a.createElement(f.b,{path:"/projects/:id/annotations/download",render:function(){return r.a.createElement(He,e.state)}}),r.a.createElement(f.b,{path:"/projects/:id/entity-hierarchy",render:function(){return r.a.createElement(Ce,{loading:e.state.loading,data:e.state.data.categoryHierarchy,colourIndexes:e.state.data.dashboard.entityChartData?e.state.data.dashboard.entityChartData.colourIndexes:null})}}),r.a.createElement(f.b,{path:"/projects/:id/annotators",render:function(){return r.a.createElement(Ne,{data:e.state.data.invitationsTable?e.state.data.invitationsTable:{},loading:e.state.loading})}}),r.a.createElement(f.b,{path:"/projects/:id/settings",render:function(){return r.a.createElement(He,e.state)}}),r.a.createElement(f.b,{render:function(){return r.a.createElement(y,null)}})))))))}}]),a}(n.Component),Je=Object(f.h)(Ge),Ye="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,".split(". ");function Ve(){for(var e=[],t=0;t<200;t++)e.push(Ye[Math.floor(Math.random()*Ye.length)]+". ");return e.join("")}var Qe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={characters:Ve()},n.characterChangeFn=null,n}return Object(d.a)(a,[{key:"changeCharacters",value:function(){this.setState({characters:Ve()})}},{key:"componentWillUnmount",value:function(){window.clearInterval(this.characterChangeFn)}},{key:"componentWillMount",value:function(){this.characterChangeFn=window.setInterval(this.changeCharacters.bind(this),1e3)}},{key:"render",value:function(){return r.a.createElement("div",{className:"letters-background"},this.state.characters)}}]),a}(n.Component),Ke=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{class:"user-form form-box"},r.a.createElement("div",{class:"header"},r.a.createElement("h1",null,"Register")),r.a.createElement("div",{class:"body"},r.a.createElement("div",{className:"loading-message"},r.a.createElement("i",{className:"fa fa-spinner fa-spin"}),"Loading..."),r.a.createElement("form",{action:"/redcoat/register",method:"post"},r.a.createElement("div",null,r.a.createElement("label",null,"Username"),r.a.createElement("input",{type:"text",name:"username",autoFocus:"autofocus",placeholder:"Username"})),r.a.createElement("div",null,r.a.createElement("label",null,"Email"),r.a.createElement("input",{type:"email",name:"email",placeholder:"Email",required:"required"})),r.a.createElement("div",null,r.a.createElement("label",null,"Password"),r.a.createElement("input",{id:"password",type:"password",name:"password",placeholder:"Password",required:"required"}),r.a.createElement("label",null,"Password confirmation"),r.a.createElement("input",{id:"password_confirmation",type:"password",name:"password_confirmation",required:"required",placeholder:"Password confirmation"})),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(v.b,{class:"back-button",to:"/"},r.a.createElement("i",{class:"fa fa-chevron-left"}),"\xa0\xa0 Back")),r.a.createElement("div",null,r.a.createElement("input",{type:"submit",value:"Register"}))))))}}]),a}(n.Component),Ze=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={email:"",password:"",error:null,errorMessage:null},n}return Object(d.a)(a,[{key:"handleUsernameChange",value:function(e){this.setState({email:e.target.value})}},{key:"handlePasswordChange",value:function(e){this.setState({password:e.target.value})}},{key:"submitForm",value:function(e){var t=this;e.preventDefault(),console.log(e);var a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","csrf-token":b("csrf-token")},dataType:"json",body:JSON.stringify({email:this.state.email,password:this.state.password}),credentials:"include"};this.setState({errorMessage:null,loading:!0},(function(){return window.setTimeout((function(){fetch("http://localhost:3000/api/users/login",a).then(function(){var e=Object(u.a)(c.a.mark((function e(t){var a;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(200===t.status){e.next=5;break}return e.next=3,t.json();case 3:throw a=e.sent,new Error(a.message);case 5:return e.abrupt("return",t.text());case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).then((function(e){try{var a=JSON.parse(e)}catch(n){throw console.log(n,a),new Error("An unexpected error has occured")}t.props.setUserData(a)})).catch((function(e){t.setState({errorMessage:e.message,password:"",loading:!1})}))}),1)}))}},{key:"render",value:function(){return r.a.createElement("div",{class:"user-form form-box"+(this.state.loading?" loading":"")},r.a.createElement("div",{class:"header"},r.a.createElement("h1",null,"Login")),r.a.createElement("div",{class:"body"},r.a.createElement("div",{className:"loading-message"},r.a.createElement("i",{className:"fa fa-spinner fa-spin"}),"Loading..."),this.state.errorMessage&&r.a.createElement("div",{className:"error-message"},r.a.createElement("span",{className:"error"},"Error: "),this.state.errorMessage,"."),r.a.createElement("form",{onSubmit:this.submitForm.bind(this),method:"post"},r.a.createElement("div",null,r.a.createElement("label",null,"Username or email"),r.a.createElement("input",{type:"text",name:"email",autoFocus:"autofocus",required:"required",placeholder:"Username or email",value:this.state.email,onChange:this.handleUsernameChange.bind(this)})),r.a.createElement("div",null,r.a.createElement("label",null,"Password"),r.a.createElement("input",{type:"password",name:"password",required:"required",placeholder:"Password",value:this.state.password,onChange:this.handlePasswordChange.bind(this)})),r.a.createElement(v.b,{class:"forgot-password-link",to:"/forgot_password"},"Forgot password?"),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(v.b,{class:"back-button",to:"/"},r.a.createElement("i",{class:"fa fa-chevron-left"}),"\xa0\xa0 Back")),r.a.createElement("div",null,r.a.createElement("input",{type:"submit",value:"Login"}))))))}}]),a}(n.Component),Xe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{class:"user-form form-box"},r.a.createElement("div",{class:"header"},r.a.createElement("h1",null,"Forgot Password")),r.a.createElement("div",{class:"body"},r.a.createElement("form",{action:"/redcoat/forgot_password",method:"post"},r.a.createElement("input",{type:"hidden",name:"_csrf",value:"oOFHs5QK-_YPdUWgNII3vfrQ_erXv2dwFmz8"}),r.a.createElement("div",null,r.a.createElement("label",null,"Email"),r.a.createElement("input",{type:"email",name:"email",placeholder:"Email",required:"required",autoFocus:"autofocus"})),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(v.b,{class:"back-button",to:"/login"},r.a.createElement("i",{class:"fa fa-chevron-left"}),"\xa0\xa0 Back")),r.a.createElement("div",null,r.a.createElement("input",{type:"submit",value:"Reset password"}))))))}}]),a}(n.Component),ze=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"homepage-main"},r.a.createElement("h1",{id:"h1-welcome","data-content":"Redcoat"},"Redcoat"),r.a.createElement("h2",{id:"h2-byline","data-content":"Collaborative Annotation Tool"},"Collaborative Annotation Tool"),r.a.createElement("div",{class:"buttons"},r.a.createElement(v.b,{to:"/register"},r.a.createElement("div",{class:"button",id:"register-button"},r.a.createElement("h2",null,"Register"))),r.a.createElement(v.b,{to:"/login"},r.a.createElement("div",{class:"button",id:"login-button"},r.a.createElement("h2",null,"Login")))))}}]),a}(n.Component),$e=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){var e=this,t=this.props.location;return r.a.createElement("section",{id:"welcome"},r.a.createElement(Qe,null),r.a.createElement(ge.a,{className:"transition-group"},r.a.createElement(fe.a,{key:t.key,timeout:{enter:400,exit:400},classNames:"fade"},r.a.createElement("section",{className:"route-section homepage-route-section"},r.a.createElement(f.d,{location:t},r.a.createElement(f.b,{path:"/login",render:function(){return r.a.createElement(Ze,{setUserData:e.props.setUserData})}}),r.a.createElement(f.b,{path:"/register",component:Ke}),r.a.createElement(f.b,{path:"/forgot_password",component:Xe}),r.a.createElement(f.b,{path:"/",component:ze}))))))}}]),a}(n.Component),et=Object(f.h)($e),tt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"componentDidUpdate",value:function(e){this.props.location.pathname!==e.location.pathname&&(console.log("clearing"),this.props.clearErrorCode())}},{key:"render",value:function(){return r.a.createElement("div",null)}}]),a}(n.Component),at=Object(f.h)(tt),nt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement("p",null,"Hello I am the setup project page"))}}]),a}(n.Component),rt=a(83),st=["user","anchor","automobile","asterisk","bath","battery","binoculars","bicycle","bomb","bullhorn","child","cubes","female","diamond","cogs","coffee","fax","flag","fire-extinguisher","flash","fire","male","heart","gift","globe","legal","leaf","microphone","paw","rocket","magnet","star","space-shuttle","trophy","umbrella"],ot=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffeb3b","#ffc107","#ff9800","#ff5722","#795548","#eee","#ccc","#aaa","#888","#444","#222"],it=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={user:{profile_icon:{foreground:"#aaa",background:"#eee",icon:"user"}}},n}return Object(d.a)(a,[{key:"componentDidUpdate",value:function(e,t){S.a.isEqual(e.user,this.props.user)||S.a.isEqual(this.props.user,this.state.user)||(console.log("sidsp"),this.setState({user:this.props.user}))}},{key:"componentWillMount",value:function(){this.props.user&&this.setState({user:this.props.user})}},{key:"saveChanges",value:function(){var e=this,t=this;console.log("saving");var a={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","csrf-token":b("csrf-token")},dataType:"json",body:JSON.stringify(this.state.user.profile_icon)};this.setState({saving:!0},(function(){fetch("http://localhost:3000/api/users/set_profile_icon",a).then((function(e){if(200!==e.status)throw new Error(e.status);return e.text()})).then((function(a){var n=JSON.parse(a);t.props.setUserProfileIcon(n.profile_icon),e.setState({saving:!1})})).catch((function(t){e.props.setErrorCode(parseInt(t.message))}))}))}},{key:"handleForegroundColourChange",value:function(e){var t=this.state.user;t.profile_icon.foreground=e.hex,this.setState({user:t})}},{key:"handleBackgroundColourChange",value:function(e){console.log("hello");var t=this.state.user;t.profile_icon.background=e.hex,this.setState({user:t})}},{key:"setIcon",value:function(e){var t=this;if(-1!==st.indexOf(e)){var a=this.state.user;a.profile_icon.icon=e,this.setState({user:a},(function(){console.log(t.state.user.profile_icon.icon)}))}}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"user-profile-page"},r.a.createElement("section",{className:"form-section"},r.a.createElement("h3",null,"Profile icon"),r.a.createElement("div",{className:"flex-columns align-center"},r.a.createElement("div",{className:"flex-column"},r.a.createElement("div",{className:"profile-icon-preview"},r.a.createElement("div",{className:"circle-icon profile-icon extra-large box-shadow",style:{background:this.state.user.profile_icon.background}},r.a.createElement("i",{className:"profile-icon-i fa fa-"+this.state.user.profile_icon.icon,style:{color:this.state.user.profile_icon.foreground}})))),r.a.createElement("div",{className:"flex-column vertical-align-top"},r.a.createElement("h4",null,"Foreground colour"),r.a.createElement(rt.TwitterPicker,{colors:ot,color:this.state.user.profile_icon.foreground,onChangeComplete:this.handleForegroundColourChange.bind(this)}),r.a.createElement("h4",null,"Background colour"),r.a.createElement(rt.TwitterPicker,{colors:ot,color:this.state.user.profile_icon.background,onChangeComplete:this.handleBackgroundColourChange.bind(this)})),r.a.createElement("div",{className:"flex-column vertical-align-top"},r.a.createElement("h4",null,"Icon"),r.a.createElement("div",{className:"icon-options"},st.map((function(t,a){return r.a.createElement("div",{onClick:function(){return e.setIcon(t)},className:"icon-option"+(t===e.state.user.profile_icon.icon?" active":"")},r.a.createElement("i",{class:"fa fa-"+t}))}))))),r.a.createElement("div",{className:"form-save-row"},r.a.createElement("a",{className:"annotate-button submit-button",onClick:this.saveChanges.bind(this)},r.a.createElement("i",{class:"fa fa-save"}),"Save"))))}}]),a}(n.Component),lt=(a(372),{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"}),ct=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement("header",{className:"bg-header"},r.a.createElement("div",{id:"header-project-details",className:"title"},r.a.createElement("h1",null,this.props.pageTitle))),r.a.createElement("main",{className:"container"},this.props.pageComponent))}}]),a}(n.Component),ut=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,this.props.pageComponent)}}]),a}(n.Component),mt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"loading-screen"+(this.props.fadingOut?" fading-out":"")},r.a.createElement("div",{className:"background background-under"}),r.a.createElement("div",{className:"background background-over"}),r.a.createElement("span",null,r.a.createElement("i",{className:"fa fa-cog fa-spin"}),"Loading..."))}}]),a}(n.Component),pt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,this.props.pageComponent)}}]),a}(n.Component),dt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"render",value:function(){return r.a.createElement("footer",null,r.a.createElement("div",{className:"footer-logo"}),r.a.createElement("h2",null,"Redcoat"),r.a.createElement("p",null,"Built by the NLP-TLP team at UWA."))}}]),a}(n.Component),ht=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(p.a)(this,a),t.call(this,e)}return Object(d.a)(a,[{key:"componentWillMount",value:function(){this.props.logout()}},{key:"render",value:function(){return r.a.createElement(f.a,{to:"/"})}}]),a}(n.Component),gt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(p.a)(this,a),(n=t.call(this,e)).state={pageTitle:"Redcoat",username:null,projectTitle:null,projectAuthor:null,setProject:n.setProject.bind(Object(m.a)(n)),loading:!0,loadingFadeOut:!1,loggingOut:!1,user:null,errorCode:null},n}return Object(d.a)(a,[{key:"clearErrorCode",value:function(){this.setState({errorCode:null})}},{key:"setErrorCode",value:function(e){var t=this;this.setState({errorCode:e,user:401===e?null:this.state.user},(function(){console.log(t.state.user,t.state.errorCode)}))}},{key:"setProject",value:function(e,t){this.setState({projectTitle:e,projectAuthor:t})}},{key:"getUserData",value:function(){var e=this;window.setTimeout((function(){fetch("http://localhost:3000/api/users/userData",lt).then((function(e){return e.text()})).then((function(t){console.log(t);var a=JSON.parse(t);e.setState({user:a.user,loading:!1,loadingFadeOut:!0},(function(){window.setTimeout((function(){return e.setState({loadingFadeOut:!1})}),500)}))}))}),200)}},{key:"setUserData",value:function(e){this.setState({user:e})}},{key:"logout",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state.user){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.setState({user:null});case 4:window.setTimeout((function(){return fetch("http://localhost:3000/api/users/logout",lt).then((function(e){return e.text()})).then((function(e){console.log("Logged out"),t.setState({user:null})}))}),2);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"setUserProfileIcon",value:function(e){var t=this.state.user;t.profile_icon=e,console.log(e),this.setState({user:t})}},{key:"componentWillMount",value:function(){this.getUserData()}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{id:"app",className:(this.state.loading?"loading":"")+(this.state.loggingOut?" logging-out":"")},r.a.createElement(v.a,null,r.a.createElement(E,null),r.a.createElement(at,{clearErrorCode:this.clearErrorCode.bind(this)}),(this.state.loading||this.state.loadingFadeOut)&&r.a.createElement(mt,{fadingOut:this.state.loadingFadeOut}),!this.state.loading&&r.a.createElement("div",{className:"fade-in"},r.a.createElement(w,{user:this.state.user,loading:this.state.loading}),!this.state.errorCode&&r.a.createElement(f.d,null,r.a.createElement(ft,{user:this.state.user,path:"/projects/:id/tagging",render:function(t){return r.a.createElement(ut,Object.assign({},e.state,{pageComponent:r.a.createElement(ce,{projectTitle:e.state.projectTitle,projectAuthor:e.state.projectAuthor,setProject:e.setProject.bind(e),project_id:t.match.params.id,user:e.state.user,setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(ft,{user:this.state.user,path:"/projects/:id",render:function(t){return r.a.createElement(pt,Object.assign({},e.state,{pageTitle:"Project View",pageComponent:r.a.createElement(Je,{project_id:t.match.params.id,setProject:e.setProject.bind(e),projectTitle:e.state.projectTitle,projectAuthor:e.state.projectAuthor,user:e.state.user,setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(ft,{user:this.state.user,path:"/projects",render:function(){return r.a.createElement(ct,Object.assign({},e.state,{pageTitle:"Projects",pageComponent:r.a.createElement(de,{setProject:e.setProject.bind(e),setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(ft,{user:this.state.user,path:"/setup-project",render:function(){return r.a.createElement(ct,Object.assign({},e.state,{pageTitle:"Setup project",pageComponent:r.a.createElement(nt,null)}))}}),r.a.createElement(ft,{user:this.state.user,path:"/profile",render:function(){return r.a.createElement(ct,Object.assign({},e.state,{pageTitle:"User Profile",pageComponent:r.a.createElement(it,{user:e.state.user,setUserProfileIcon:e.setUserProfileIcon.bind(e),setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(f.b,{path:"/features",component:function(){return r.a.createElement(ct,Object.assign({},e.state,{pageTitle:"Features",pageComponent:r.a.createElement(ue,null)}))}}),r.a.createElement(f.b,{path:"/logout",render:function(){return r.a.createElement(ht,{logout:e.logout.bind(e)})}}),r.a.createElement(f.b,{path:"/",render:function(){return e.state.user&&!e.state.loggingOut?r.a.createElement(f.a,{to:"/projects"}):r.a.createElement(et,{setUserData:e.setUserData.bind(e)})}}),r.a.createElement(f.b,{render:function(){return r.a.createElement(ct,Object.assign({},e.state,{pageTitle:"",pageComponent:r.a.createElement(y,null)}))}})," />"),401===this.state.errorCode&&r.a.createElement(Oe,{clearErrorCode:this.clearErrorCode.bind(this)}),403===this.state.errorCode&&r.a.createElement(z,null))),!this.state.loading&&r.a.createElement(dt,null))}}]),a}(n.Component),ft=function(e){e.component;var t=Object(i.a)(e,["component"]);return r.a.createElement(f.b,Object.assign({},t,{render:function(e){t.user,Object(i.a)(t,["user"]);return t.user?t.render(e):r.a.createElement(f.a,{to:"/login"})}}))},vt=gt;Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(vt,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[142,1,2]]]);
  //# sourceMappingURL=main.47bcd91b.chunk.js.map