text: (this.webpackJsonptagging_interface=this.webpackJsonptagging_interface||[]).push([[0],{146: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=="},153:function(e,t,a){e.exports=a(394)},158:function(e,t,a){},160:function(e,t,a){},191:function(e,t){},393:function(e,t,a){e.exports=a.p+"static/media/redcoat-1-grey.fd5c7c00.png"},394:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),s=a(22),i=a.n(s),o=(a(158),a(93)),l=a(5),c=a.n(l),u=a(7),m=a(29),d=a(1),p=a(2),h=a(4),g=a(3),f=(a(160),a(8)),v=a(15),b="/redcoat/";var E=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 y(){var e=Object(v.g)().pathname;return Object(n.useEffect)((function(){window.scrollTo(0,0)}),[e]),null}var k=a(25),j=a(146),w=a.n(j),N=a(17),C=a.n(N),x=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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?e.profile_icon.background:"#ddd"}},r.a.createElement("i",{className:"profile-icon-i fa fa-"+(e.profile_icon?e.profile_icon.icon:"user"),style:{color:e.profile_icon?e.profile_icon.foreground:"#666"}})):r.a.createElement("div",{className:"circle-icon profile-icon "+(this.props.size||"small"),style:{background:"#ddd"}})}}]),a}(n.Component),S=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"componentDidUpdate",value:function(){C()("#invitations-menu > *").prop("onclick",null).off("click"),C()("#invitations-menu > *").click((function(e){C()("#invitations-button").focus()}))}},{key:"render",value:function(){var e=this;if(this.props.user&&this.props.user.project_invitations){var t,a=this.props.user.project_invitations,n=0,s=Object(k.a)(a);try{for(s.s();!(t=s.n()).done;){var i=t.value;i.accepted||i.declined||n++}}catch(o){s.e(o)}finally{s.f()}}return r.a.createElement("nav",{id:"navbar"},r.a.createElement("div",{className:"navbar-left"},r.a.createElement("div",{id:"logo"},r.a.createElement(f.b,{to:b},r.a.createElement("img",{src:w.a})," ",r.a.createElement("span",{className:"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(f.b,{to:b+"projects"},"Projects list")),r.a.createElement("li",null,r.a.createElement(f.b,{to:b+"projects/new"},"New 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 invitations"+(0===n?" inactive":""),id:"invitations-menu"},r.a.createElement("button",{id:"invitations-button"},r.a.createElement("i",{className:"fa fa-envelope"}),n>0&&r.a.createElement("span",{className:"invites-count",id:"invites-count"},n)),this.props.user.project_invitations&&a.length>0?r.a.createElement("ul",{className:"dropdown-menu-items"},a.map((function(t,a){return r.a.createElement("li",{key:a},r.a.createElement("span",{className:"invite"},r.a.createElement("span",{className:"link"},t.inviting_user_username)," has invited you to annotate ",r.a.createElement("span",{className:"link"},t.project_name),".",!t.accepted&&!t.declined&&!t.pending&&r.a.createElement("div",{className:"invite-form"},r.a.createElement("button",{className:"accept",onClick:function(){return e.props.acceptInvitation(a)}},"Accept"),r.a.createElement("button",{className:"decline",onClick:function(){return e.props.declineInvitation(a)}},"Decline")),t.pending&&r.a.createElement("div",{className:"invite-form-loading"},r.a.createElement("span",null,r.a.createElement("i",{className:"fa fa-cog fa-spin"}),"\xa0Loading...")),t.accepted&&r.a.createElement("div",{className:"invite-form-accepted"},r.a.createElement("span",null,r.a.createElement("i",{className:"fa fa-check"}),"\xa0Invitation accepted! ",r.a.createElement(f.b,{to:b+"projects/"+t.project_id+"/dashboard"},"(Go to project)"))),t.declined&&r.a.createElement("div",{className:"invite-form-declined"},r.a.createElement("span",null,r.a.createElement("i",{className:"fa fa-close"}),"\xa0Invitation declined."))))}))):r.a.createElement("ul",{className:"dropdown-menu-items"},r.a.createElement("li",null,r.a.createElement("span",{className:"invite"},"You have no active invitations.")))),this.props.user&&r.a.createElement("div",{className:"dropdown-menu"},r.a.createElement("button",{className:"flex"},r.a.createElement(x,{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(f.b,{to:b+"profile"},"Profile")),r.a.createElement("li",null,r.a.createElement(f.b,{to:b+"logout"},"Logout")))),!this.props.user&&r.a.createElement("div",{className:"dropdown-menu log-in"},r.a.createElement("button",null,"Not logged in\xa0\xa0",r.a.createElement("i",{className:"fa fa-xs fa-chevron-down"})),r.a.createElement("ul",{className:"dropdown-menu-items"},r.a.createElement("li",null,r.a.createElement(f.b,{to:b+"login"},"Login")),r.a.createElement("li",null,r.a.createElement(f.b,{to:b+"register"},"Register")))),!this.props.loading&&r.a.createElement("div",{className:"dropdown-menu short"},r.a.createElement(f.b,{to:b+"features"},"v2.0a"))),!this.props.loading&&r.a.createElement("header",{className:"decorative-bar"}))}}]),a}(n.Component),O=a(11),_=(a(165),a(147)),P=a(148),I=a.n(P),A=a(151),T=a(40),M=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("li",{className:"new-category"},r.a.createElement("span",{className:"inner-container"},r.a.createElement("span",{className:"category-name"+(this.props.disabled?" disabled":""),onClick:this.props.newItem},r.a.createElement("i",{className:"fa fa-plus"}),"New Category")))}}]),a}(n.Component),D=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={isHovered:!1,name:""},n.nameInputRef=r.a.createRef(),n.changeNameTimeoutFn=null,n.nameCanUpdateTimeoutFn=null,n.nameCanUpdate=!0,n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){0===this.props.item.name.length&&this.nameInputRef.current.focus(),this.setState({name:this.props.item.name.slice()})}},{key:"componentDidUpdate",value:function(e,t){e.item.name!==this.state.name&&t.name===this.state.name&&this.nameCanUpdate&&this.setState({name:this.props.item.name.slice()})}},{key:"componentWillUnmount",value:function(){this.changeNameTimeoutFn&&window.clearTimeout(this.changeNameTimeoutFn),this.nameCanUpdateTimeoutFn&&window.clearTimeout(this.nameCanUpdateTimeoutFn)}},{key:"setHovered",value:function(e){this.setState({isHovered:e})}},{key:"itemNameChange",value:function(e,t){var a=this,n=e.target.value;function r(){this.nameCanUpdate=!0}this.setState({name:n},(function(){a.changeNameTimeoutFn&&window.clearTimeout(a.changeNameTimeoutFn),a.changeNameTimeoutFn=window.setTimeout(a.props.itemNameChange,1e3,n,t),a.nameCanUpdate=!1,a.nameCanUpdateTimeoutFn&&window.clearTimeout(a.nameCanUpdateTimeoutFn),a.nameCanUpdateTimeoutFn=window.setTimeout(r.bind(a),1e3),a.props.userIsModifying()}))}},{key:"render",value:function(){var e=this,t=this.props.item,n=this.props.index,s=this.props.item.children,i=t.colorId,o=this.props.modifiable,l=this.props.path;if(this.props.colorByIndex&&(i=n),s)var c=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),isTopLevelCategory:!1,path:e.props.path.concat([n]),openedItems:e.props.openedItems,onClick:e.props.onClick,hotkeyMap:e.props.hotkeyMap,hotkeyChain:e.props.hotkeyChain,applyTag:e.props.applyTag,colorByIndex:e.props.colorByIndex,modifiable:e.props.modifiable,itemNameChange:e.props.itemNameChange,itemDescChange:e.props.itemDescChange,deleteItem:e.props.deleteItem,newItem:e.props.newItem,userIsModifying:e.props.userIsModifying})})));else c="";if(this.props.hotkeyMap)var u=this.props.hotkeyMap.hasOwnProperty(this.props.item.full_name),m=u?this.props.hotkeyMap[this.props.item.full_name].join(""):"";else u=!1,m="";var d=r.a.createElement("span",{className:"inner-container"},r.a.createElement("span",{className:"left"},(s||o)&&r.a.createElement("span",{className:"open-button"+(s?"":" no-children-yet")+(t.name.length>0?"":" hidden"),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"+(u?" has-hotkey":"")+(o?" modifiable":"")+(this.props.hotkeyChain===m?" hotkey-active":""),"data-hotkey-id":m,onClick:this.props.applyTag?function(){return e.props.applyTag(e.props.item.full_name)}:null},o?r.a.createElement("input",{required:!0,onKeyDown:function(e){return 13==e.keyCode?e.preventDefault():""},className:0===this.state.name.length?"empty":this.props.errorEntityNames&&this.props.errorEntityNames.has(t.full_name)?" error":"",placeholder:"(no name)",ref:this.nameInputRef,maxLength:50,value:this.state.name,onChange:function(t){return e.itemNameChange(t,l)}}):t.name)),r.a.createElement("span",{className:"right"},r.a.createElement("span",{className:"description"+(o?" modifiable":"")},o?r.a.createElement("input",{maxLength:100,onKeyDown:function(e){return 13==e.keyCode?e.preventDefault():""},value:t.description||"",onChange:function(t){return e.props.itemDescChange(t,l)},placeholder:"(no description)"}):t.description||"")),o&&r.a.createElement("span",{className:"delete-button-container"},r.a.createElement("span",{className:"delete-button",onClick:function(){e.setHovered(!1),e.props.deleteItem(l)},onMouseEnter:function(){return e.setHovered(!0)},onMouseLeave:function(){return e.setHovered(!1)}},r.a.createElement("i",{className:"fa fa-trash"}))));return this.props.isTopLevelCategory?this.props.draggable?r.a.createElement(T.b,{key:t.id.toString(),draggableId:t.id.toString(),index:n},(function(t,a){return r.a.createElement("li",Object.assign({ref:t.innerRef},t.draggableProps,{className:"draggable "+(a.isDragging?"dragging":"not-dragging")+" color-"+(parseInt(i)%12+1)+(e.state.isHovered?" delete-hover":"")}),r.a.createElement("div",Object.assign({},t.dragHandleProps,{className:"drag-handle-container"}),r.a.createElement("span",{className:"drag-handle"})),d,c,e.props.open&&e.props.modifiable&&r.a.createElement("ul",null,r.a.createElement(M,{newItem:function(){return e.props.newItem(l)}})))})):r.a.createElement("li",{className:" color-"+(parseInt(i)%12+1)+(this.state.isHovered?" delete-hover":"")},d,c,this.props.open&&this.props.modifiable&&r.a.createElement("ul",null,r.a.createElement(M,{newItem:function(){return e.props.newItem(l)}}))):r.a.createElement("li",{className:this.state.isHovered?" delete-hover":""},d,c,this.props.open&&this.props.modifiable&&r.a.createElement("ul",null,r.a.createElement(M,{newItem:function(){return e.props.newItem(l)}})))}}]),a}(n.Component),F=function(e,t,a){var n=Array.from(e),r=n.splice(t,1),s=Object(A.a)(r,1)[0];return n.splice(a,0,s),n};function q(e){for(var t=new Array(e.length),a=0;a<t.length;a++)t[a]=a;return t}var R=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.a)(a,[{key:"componentDidUpdate",value:function(e,t){var a=q(this.props.items);O.a.isEqual(e.items,this.props.items)||this.setState({openedItems:new Set,orderedItems:this.props.items,itemOrder:a})}},{key:"componentWillMount",value:function(){var e=q(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=F(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":"")+(this.props.tableForm?" table-form":"")},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(D,{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,itemNameChange:e.props.itemNameChange,path:[n]})})),n.placeholder)}))))}}]),a}(n.Component),U=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={items:[],openedItems:new Set,errorEntityNames:new Set,userIsModifying:!1},n.userIsModifyingFn=null,n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.setState({items:this.props.items})}},{key:"componentDidUpdate",value:function(e,t){!O.a.isEqual(this.props.items,this.state.items)&&O.a.isEqual(t.items,this.state.items)&&this.setState({items:this.props.items,openedItems:new Set,errorEntityNames:this.props.errorEntityNames}),this.props.errorEntityNames!==this.state.errorEntityNames&&this.setState({errorEntityNames:this.props.errorEntityNames})}},{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(){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(t.destination){e.next=2;break}return e.abrupt("return");case 2:return this.state.items,a=F(this.state.items,t.source.index,t.destination.index),e.next=6,this.setState({items:a});case 6:this.props.updateHierarchy(this.state.items);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"newItem",value:function(e){var t=this,a=this.state.items;if(e.length>0){for(var n=a,r=0;r<e.length-1;r++){n=n[e[r]].children}var s=n[e[e.length-1]];s.children||(s.children=new Array);i={name:"",description:"",colorId:s.colorId,full_name:s.full_name+"/"};s.children.push(i)}else{var i={name:"",description:"",colorId:this.state.items.length+1,full_name:"",id:this.state.items.length+1};a.push(i)}this.setState({items:a},(function(){t.props.markModified(),console.log("created new item",t.state.items)}))}},{key:"userIsModifying",value:function(){var e=this;this.userIsModifyingFn&&window.clearTimeout(this.userIsModifyingFn),this.userIsModifyingFn=window.setTimeout(function(){var e=this;this.setState({userIsModifying:!1},(function(){e.props.userIsModifying(!1)}))}.bind(this),1e3),this.setState({userIsModifying:!0},(function(){e.props.userIsModifying(!0)}))}},{key:"itemNameChange",value:function(e,t){for(var a=this,n=performance.now(),r=e,s=this.state.items,i=s,o=0;o<t.length-1;o++){i=i[t[o]].children}var l=i[t[t.length-1]];l.name=r;var c=!1,u=this.state.openedItems;this.state.openedItems.has(l.full_name)&&(c=!0,u.delete(l.full_name));var m=l.full_name.split("/");m[m.length-1]=r,l.full_name=m.join("/"),c&&u.add(l.full_name),this.setState({items:s,openedItems:u},(function(){var e=performance.now();console.log(e-n),a.props.markModified()}))}},{key:"itemDescChange",value:function(e,t){for(var a=this,n=e.target.value,r=this.state.items,s=r,i=0;i<t.length-1;i++){s=s[t[i]].children}s[t[t.length-1]].description=n,this.setState({items:r},(function(){a.props.markModified()}))}},{key:"deleteItem",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n,r,s,i,o,l;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this.state.items,n=a,t.length>1)for(r=0;r<t.length-1;r++)s=t[r],i=n[s],n=n[s].children;return o=this.state.openedItems,l=n[t[t.length-1]],o.delete(l.full_name),n.splice(t[t.length-1],1),0===n.length&&t.length>1&&delete i.children,e.next=10,this.setState({items:a,openedItems:o});case 10:this.props.markModified();case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"render",value:function(){var e=this,t=this.state.items,a=this.state.openedItems;return r.a.createElement("div",{id:"category-hierarchy-tree",className:"table-form display-only"},r.a.createElement("ul",null,r.a.createElement("li",{className:"header-row"},r.a.createElement("span",{className:"inner-container"},r.a.createElement("span",{className:"left"},r.a.createElement("span",{className:"category-name"},"Entity Class")),r.a.createElement("span",{className:"right"},r.a.createElement("span",{className:"description"},"Description")),r.a.createElement("span",{className:"delete-button-container"},r.a.createElement("span",{className:"delete-button"}))))),r.a.createElement(T.a,{onDragEnd:this.onDragEnd.bind(this)},r.a.createElement(T.c,{droppableId:"droppable"},(function(n,s){return r.a.createElement("ul",Object.assign({className:"draggable-list reversed-stripes "+(e.props.limitHeight?"limit-height":"")+(s.isDraggingOver?" dragging":"")+(e.state.userIsModifying?" drag-disabled":"")},n.droppableProps,{ref:n.innerRef}),t.map((function(t,n){return r.a.createElement(D,{key:n,item:t,index:n,onClick:e.toggleCategory.bind(e),open:a.has(t.name),openedItems:e.state.openedItems,isTopLevelCategory:!0,draggable:!0,colorByIndex:!0,modifiable:!0,itemNameChange:e.itemNameChange.bind(e),itemDescChange:e.itemDescChange.bind(e),deleteItem:e.deleteItem.bind(e),newItem:e.newItem.bind(e),errorEntityNames:e.state.errorEntityNames,userIsModifying:e.userIsModifying.bind(e),path:[n]})})),n.placeholder,r.a.createElement(M,{newItem:function(){return e.newItem([])}}))}))))}}]),a}(n.Component),B=R,H=a(150),L=a.n(H);function W(e,t){return t[e.split("/").slice(0,1)[0]]}var G=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),Y=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={selected:!1},n.wordInnerRef=r.a.createRef(),n}return Object(p.a)(a,[{key:"deleteTag",value:function(e){this.props.deleteTag(this.props.index,e)}},{key:"componentDidUpdate",value:function(e,t){}},{key:"getHighlightedWord",value:function(){var e=this.props.text,t=this.props.highlighting;console.log(this.props.highlighting,"<X");for(var a="",n=0;n<e.length;n++)n===t[0]&&(a+='<span class="search-highlight">'),a+=e[n],n===t[1]&&(a+="</span>");return L()(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(G,{deleteTag:e.deleteTag.bind(e),key:a,bioTag:e.props.bioTag,entityClass:t,colourIdx:W(t,e.props.entityColourMap)})}));else n="";var s=this.props.text;this.props.highlighting&&(s=this.getHighlightedWord());var i=t?" tag-"+W(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"+i+(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),V=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).sentenceRef=r.a.createRef(),n}return Object(p.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:"componentDidUpdate",value:function(e,t){if(this.props.selections&&0===e.selections.length&&this.props.selections.length>0){var a=this.sentenceRef.current,n=document.body.getBoundingClientRect(),r=a.getBoundingClientRect().top-n.top;window.scrollTo({top:r-200,left:0,behavior:"smooth"})}}},{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":""),ref:this.sentenceRef},this.props.words.map((function(t,a){return r.a.createElement(Y,{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",ref:this.sentenceRef},this.props.words.map((function(t,n){return r.a.createElement(Y,{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),K=a(209);var Q=function(e,t){return t&&t.no_hours?K(e,"dd mmm"):K(e,"dd mmm")+" at "+K(e,"h:MM tt")},z=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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"},Q(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(f.b,{to:b+"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(d.a)(this,a),(n=t.call(this,e)).state={comment:""},n.inputRef=r.a.createRef(),n}return Object(p.a)(a,[{key:"componentDidUpdate",value:function(e,t){e.open!=this.props.open&&this.props.open&&this.inputRef.current.focus()}},{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",{ref:this.inputRef,name:"comment-input",className:"comment-input",placeholder:"Write a comment...",onChange:this.setComment.bind(this),value:this.state.comment,maxlength:"10000"})))),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),Z=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),X=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),$=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={value:""},n.inputRef=r.a.createRef(),n}return Object(p.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),C()(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),ee=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={pageNumber:null,pageNumberError:!1},n.pageInputRef=r.a.createRef(),n}return Object(p.a)(a,[{key:"clearPageNumberInput",value:function(){var e=C()(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 "+Q(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($,{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),C()(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),C()(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(X,{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(Z,{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),te=function(){function e(t,a){Object(d.a)(this,e),this.token=t,this.tokenIndex=a,this.bioTag="O",this.highlighting=null}return Object(p.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 O.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 ae=function(e,t,a,n){console.log(a,"<SEARCHTERM"),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 i=a.split(" ");var o=new Array(e.length);for(var l in e){o[l]=new Array(e[l].length);var c=0;for(var u in e[l])if(o[l][u]=new te(e[l][u],parseInt(u)),a){var m=e[l][u].indexOf(i[c]);m>=0?(o[l][u].setHighlighting(m,m+i[c].length-1),c++):c=0}}if(!t)return o;for(var l in t)if(t[l])for(var d in t[l].mentions){var p=t[l].mentions[d],h=p.start,g=p.end;for(var f in p.labels)for(var v=p.labels[f],b=h;b<g;b++){var E=b===h?"B":"I";o[l][b].addLabel(E,v,e[l].slice(h,g).join(" "),h,g-1)}}return o},ne=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),re=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),se=a(10),ie="http://localhost:3000/api/",oe=E("csrf-token"),le=a(210),ce={GET:{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json"},credentials:"include"},POST:{method:"POST",headers:{"csrf-token":oe,Accept:"application/json"},dataType:"json",body:null}};function ue(){return(ue=Object(u.a)(c.a.mark((function e(t,a,n){var r,s,i,o,l,u,m,d,p,h=arguments;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=h.length>3&&void 0!==h[3]?h[3]:null,s=h.length>4&&void 0!==h[4]&&h[4],h.length>5&&void 0!==h[5]?h[5]:0,i=h.length>6&&void 0!==h[6]&&h[6],o=h.length>7&&void 0!==h[7]?h[7]:null,l=Object(se.a)({},ce[a]),"POST"!==a){e.next=10;break}if(r){e.next=9;break}throw new Error("Cannot POST without post body");case 9:s?(l.body=r,delete l.headers,l.headers={"csrf-token":oe}):(l.body=JSON.stringify(r),l.headers["Content-Type"]="application/json");case 10:return e.next=12,fetch(ie+t,l);case 12:if(u=e.sent,console.log(u,"<resp"),200===u.status){e.next=18;break}return m=parseInt(u.status),n(m),e.abrupt("return",Promise.resolve(new Error(m)));case 18:return e.next=20,u.text();case 20:if(d=e.sent,!i){e.next=24;break}return le(d,o),e.abrupt("return",Promise.resolve());case 24:return console.log(d),e.prev=25,p=JSON.parse(d),e.abrupt("return",Promise.resolve(p));case 30:return e.prev=30,e.t0=e.catch(25),console.log(e.t0),n(500),e.abrupt("return",Promise.reject(new Error(500)));case 35:case"end":return e.stop()}}),e,null,[[25,30]])})))).apply(this,arguments)}var me=function(e,t,a){return ue.apply(this,arguments)};a(211);var de=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),pe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{className:"confidence-buttons"},r.a.createElement(de,Object.assign({value:"low",checked:"low"===this.props.confidence},this.props)),r.a.createElement(de,Object.assign({value:"medium",checked:"medium"===this.props.confidence},this.props)),r.a.createElement(de,Object.assign({value:"high",checked:"high"===this.props.confidence},this.props)))}}]),a}(n.Component),he=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),ge=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.a)(a,[{key:"componentDidUpdate",value:function(e,t){!O.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(_.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(V,{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(pe,{docIdx:this.props.index,confidence:this.props.confidence,updateConfidence:this.props.updateConfidence})),r.a.createElement("div",{className:"document document-underneath"+(this.state.commentsOpen?" open":"")+(this.props.comments.length>0?" has-comment":""),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,this.props.comments.length>0?" comment"+(this.props.comments.length>1?"s":""):""))),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(z,Object.assign({key:t,index:t},e,{hideDocumentString:!0}))}))),r.a.createElement(J,{open:this.state.commentsOpen,user_profile_icon:this.props.user.profile_icon,submitComment:this.submitComment.bind(this)})))),r.a.createElement("div",{className:"confidence-buttons"}))))}}]),a}(n.Component);function fe(e){if(e.hasChildNodes())return e.firstChild;for(;e&&!e.nextSibling;)e=e.parentNode;return e?e.nextSibling:null}var ve=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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 be=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e))._isMounted=!1,n.state={visible:!0,querying:!1,wikipediaSummary:null,wikipediaReadMoreUrl:null},n}return Object(p.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,i){if(s._isMounted){var o=t;r?(e.toLowerCase()!==t.toLowerCase()&&(o=e),a=r+"...",n=i):(n=null,a=null),s.setState({wikipediaTitle:o,wikipediaSummary:a,wikipediaReadMoreUrl:n,querying:!1})}},C.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),Ee=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.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=fe(t));for(t=e.startContainer;t&&t!=e.commonAncestorContainer;)n.unshift(t),t=t.parentNode;return n}(a.getRangeAt(0));t.removeClass("highlighted"),C()(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=C()(".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})}}));var t=this;window.onblur=function(){t.setState({holdingShift:!1,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(!C()("#page-input").is(":focus")&&!C()("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,i){if(i||(n[t.full_name]=r),t.children)for(var o=0;o<Math.min(9,t.children.length);o++)e(t.children[o],o+1,n,Array.prototype.concat(r,o+1),s);else s.add(r.join(""));return{hotkeyMap:n,terminalHotkeys:s}}({children:e},0,[],[],new Set,!0),r=n.hotkeyMap,s=n.terminalHotkeys,i=function(e){var t={};for(var a in e){t[e[a].join("")]=a}return t}(r);this.setState({hotkeyMap:r,reverseHotkeyMap:i,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%12+1}return t}},{key:"justifyWords",value:function(){C()(".word-inner").each((function(e,t){var a=t.offsetWidth,n=25*Math.ceil(a/25);C()(t).css("min-width",n+"px")}))}},{key:"clearWordJustification",value:function(){C()(".word:not(.tag) .word-inner").each((function(e,t){C()(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(){var e=Object(u.a)(c.a.mark((function e(t,a){var n,r,s;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.state.searchTerm,n=a?"getDocumentGroup?pageNumber="+a+"&perPage="+this.state.docsPerPage:"getDocumentGroup?pageNumber=latest&perPage="+this.state.docsPerPage,r&&(n+="&searchTerm="+r),e.next=5,this.setState({loading:{querying:!0,saving:!1,firstLoad:t}});case 5:return e.next=7,me("projects/"+this.props.project_id+"/tagging/"+n,"GET",this.props.setErrorCode);case 7:if(!(s=e.sent).tagging_complete){e.next=12;break}return this.setState({taggingCompletePage:!0,pageNumber:s.pageNumber,totalPages:s.totalPages,totalPagesAvailable:s.totalPagesAvailable+1,changesMade:!1,recentlySaved:!1,loading:{querying:!1,saving:!1}}),console.log(s),e.abrupt("return");case 12:return e.next=14,this.setState({data:s,documents:s.documents,documentIds:s.documentIds,documentAnnotationIds:s.documentAnnotationIds?s.documentAnnotationIds:null,confidences:this.initConfidencesArray(s.documents),annotations:ae(s.documents,s.automaticAnnotations,this.state.searchTerm),comments:s.comments,categoryHierarchy:s.categoryHierarchy,entityColourMap:this.initEntityColourMap(s.categoryHierarchy.children),selections:this.getEmptySelectionsArray(s.documents.length),mostRecentSelectionText:null,pageNumber:s.pageNumber,totalPages:s.totalPages,totalPagesAvailable:s.totalPagesAvailable,docGroupLastModified:s.lastModified,documentGroupAnnotationId:s.documentGroupAnnotationId,changesMade:!1,recentlySaved:!1,loading:{querying:!1,saving:!1},taggingCompletePage:!1});case 14:s.projectTitle&&s.projectAuthor&&this.props.setProject(s.projectTitle,s.projectAuthor),t&&(this.initKeybinds(),this.initHotkeyMap(this.state.categoryHierarchy.children)),this.initMouseEvents(),this.clearWordJustification(),this.justifyWords(),this.selectFirstWord(),window.scrollTo(0,0);case 21:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{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=Object(u.a)(c.a.mark((function e(){var t,a,n,r,s,i=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.state.recentlySaved){e.next=2;break}return e.abrupt("return");case 2:return t=this.annotationsToJSON(),a={documentIds:this.state.documentIds,documentAnnotationIds:this.state.documentAnnotationIds,labels:t},this.setState({loading:{querying:!1,saving:!0}}),e.next=7,me("projects/"+this.props.project_id+"/tagging/submitAnnotations","POST",this.props.setErrorCode,a);case 7:n=e.sent,r=n.documentAnnotationIds,console.log("Submitted annotations OK"),this.state.pageNumber!==this.state.totalPagesAvailable||this.state.searchTerm?s=this.state.totalPagesAvailable:(s=this.state.totalPagesAvailable+1,this.setState({showingProgressBar:!0},(function(){window.setTimeout((function(){return i.setState({showingProgressBar:!1})}),3e3)}))),this.setState({docGroupLastModified:Date.now(),totalPagesAvailable:s,documentAnnotationIds:r,changesMade:!1,recentlySaved:!0,loading:{querying:!1,saving:!1}});case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{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);for(var t,a=this.state.selections,n=this.getEmptySelectionsArray(),r=0;r<a.length;r++)for(var s=0;s<a[r].length;s++){a[r][s];if("up"===e){var i=-1;0===r&&(i=0)}else if("down"===e){i=1;r===a.length-1&&(i=0)}n[r+i]=[{wordStartIndex:0,wordEndIndex:0}],t=this.state.documents[r+i].slice(0,1).join(" ")}this.setState({selections:n,mostRecentSelectionText:t})}},{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,i=this.state.currentSelection;if("down"===a)this.state.holdingCtrl||(s=this.getEmptySelectionsArray()),r=-1,i={sentenceIndex:e,wordStartIndex:n=t};else if("up"===a){if(-1===i.wordStartIndex)return void this.clearSelections();if(n=i.wordStartIndex,i.sentenceIndex!==e&&(n=0),r=t,t<n){var o=n;n=t,r=o}i=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:i,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 i in a[s]){for(var o=a[s][i],l=o.wordStartIndex,c=o.wordEndIndex,u=r[s][l].spanStartIdx,m=r[s][l].spanEndIdx,d=!1,p=l+1;p<=c;p++){var h=r[s][p];if(u!==h.spanStartIdx||m!==h.spanEndIdx){d=!0;break}}if(d){for(p=l;p<=c;p++){(v=r[s][p]).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(p=l;p<=c;p++){var E=p===l?"B":"I",y=n[s].slice(l,c+1).join(" ");b=r[s][p].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,i=r.spanEndIdx;for(var o in this.captureEvent("Deleted label",e,s,i,a),n[e]){var l=n[e][o];l.spanStartIdx===s&&l.spanEndIdx===i&&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(){var e=Object(u.a)(c.a.mark((function e(t,a,n){var r,s,i;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("Message:",t,"Document index",a),r={text:t,documentId:this.state.documentIds[a]},console.log(this.state.documentIds[a],"xzzz"),e.next=5,me("projects/"+this.props.project_id+"/comments/submit","POST",this.props.setErrorCode,r);case 5:s=e.sent,console.log("Submitted comment OK"),(i=this.state.comments)[a].push(s.comment),this.setState({comments:i},n);case 10:case"end":return e.stop()}}),e,this)})));return function(t,a,n){return e.apply(this,arguments)}}()},{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(ye,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(ee,{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(he,null),this.state.documents.map((function(t,a){return r.a.createElement(ge,{key:a,index:a,displayIndex:(e.state.pageNumber-1)*e.state.docsPerPage+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(f.b,{to:b+"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(be,{tokens:this.state.mostRecentSelectionText}),r.a.createElement(ve,{chain:this.state.hotkeyChain,entityClass:this.state.reverseHotkeyMap[this.state.hotkeyChain.join("")]}),r.a.createElement(B,{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),ye=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),ke=Ee,je=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("article",{className:"features-list"},r.a.createElement("h2",null,"Version 2.0 alpha - List of features (3 October 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,"New project form"),r.a.createElement("ul",null,r.a.createElement("li",null,"The new project form is also remade in React - it is now based on form pages rather than one continuous form so the process of creating a new project is much better."))),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),we=a(37),Ne=(n.Component,function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.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=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.props.setProject(null,null),e.next=3,me("projects/","GET",this.props.setErrorCode,1);case 3:t=e.sent,this.setState({data:t,loading:!1});case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{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(we.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(we.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(f.b,{to:b+"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 ",Q(t.created_at))),r.a.createElement("div",{className:"col-stats"},r.a.createElement("span",{className:"project-total-comments",title:"This project has "+t.total_comments+" 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",title:"This project has "+t.total_users+" users."},r.a.createElement("i",{class:"fa fa-user"})," ",r.a.createElement("span",{className:"user-count"},t.total_users))))}))))}}]),a}(n.Component)),Ce=a(64),xe=a(397),Se=a(396),Oe=a(38);a(286);var _e=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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:"category-hierarchy-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(B,{items:this.props.data.children,visible:!0,draggable:!1,displayOnly:!0,tableForm:!0})))}}]),a}(n.Component);var Pe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return console.log(this.props.data.pending_invitations),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(x,{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(x,{user:e.profile_icon?e:null}),r.a.createElement("span",null,e.email," ",e.username?"("+e.username+")":""))))}))))}}]),a}(n.Component),Ie=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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(Pe,{data:this.props.data})))}}]),a}(n.Component),Ae=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.props.clearErrorCode()}},{key:"render",value:function(){return r.a.createElement(v.a,{to:b+"login"})}}]),a}(n.Component),Te=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.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){O.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,n=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:return t="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),e.next=9,me(t,"GET",this.props.setErrorCode);case 9:a=e.sent,this.setState({documentId:a.documentId,tokens:a.tokens,annotations:ae([a.tokens],a.annotations,this.state.searchTerm,!0),compiledAnnotation:a.compiledAnnotation?ae([a.tokens],[a.compiledAnnotation],this.state.searchTerm,!0)[0]:null,comments:a.comments,users:a.users,saveTimes:a.saveTimes,documentIdQuery:null,annotatorAgreement:a.annotatorAgreement,entityColourMap:this.initEntityColourMap(a.categoryHierarchy.children),pageNumber:a.pageNumber,totalPages:a.totalPages,loading:{querying:!1,saving:!1}},(function(){n.refreshDataFn&&window.clearTimeout(n.refreshDataFn),n.refreshDataFn=window.setTimeout(n.queryAPI.bind(n),3e3)}));case 11: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(){var e=Object(u.a)(c.a.mark((function e(t,a){var n,r,s,i;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this,console.log("Message:",t),E("csrf-token"),r={text:t,documentId:this.state.documentId},e.next=6,me("projects/"+this.props.project_id+"/comments/submit","POST",this.props.setErrorCode,r);case 6:s=e.sent,(i=this.state.comments).push(s.comment),this.setState({comments:i},(function(){a(),n.commentBoxRef.current.scrollTop=n.commentBoxRef.current.scrollHeight}));case 10:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{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(ee,{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(Me,{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(Me,{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&&this.state.comments&&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(z,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),Me=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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.user&&!this.props.specialName&&r.a.createElement("div",{className:"user-col"}),!this.props.specialName&&this.props.user&&r.a.createElement("div",{className:"user-col"},r.a.createElement(x,{user:this.props.user}),r.a.createElement("div",null,r.a.createElement("div",{className:"username"},this.props.user&&this.props.user.username),r.a.createElement("div",{className:"save-time",style:{display:"none"}},Q(this.props.saveTime,{no_hours:!0})))),this.props.specialName&&r.a.createElement("div",{className:"user-col"},r.a.createElement("div",null,r.a.createElement("div",{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(V,{index:this.props.index,words:this.props.tokens,annotations:this.props.annotations,entityColourMap:this.props.entityColourMap,displayOnly:!0})))))}}]),a}(n.Component),De=Te,Fe=a(287);Oe.defaults.global.defaultFontFamily="Open Sans",Oe.defaults.global.animation.duration=500;var qe=["#36A2EB","#FF6384","#6dc922","#B4436C","#FFCE56","#F78154","#5FAD56","#4D9078","#586BA4","#324376","#F5DD90","#6665DD","#7B4B94"],Re=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"downloadAnnotationsOfUser",value: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:return a="projects/"+this.props.project_id+"/download_annotations/"+t._id,e.next=3,me(a,"GET",this.props.setErrorCode,null,!1,0,!0,"annotations-"+t.username+".json");case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"downloadCombinedAnnotations",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t="projects/"+this.props.project_id+"/download_combined_annotations",e.next=3,me(t,"GET",this.props.setErrorCode,null,!1,0,!0,"annotations-combined.json");case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"render",value:function(){var e=this;return r.a.createElement("main",{className:"project-page"},r.a.createElement("h2",null,"Annotations"),r.a.createElement("div",{className:"combined-annotations-download-box"},0===this.props.data.combined_annotations_available?r.a.createElement("div",null,"There are not yet any annotations available for download."):r.a.createElement("div",null,r.a.createElement("strong",null,this.props.data.combined_annotations_available," "),"\xa0annotations are ready for download. ",r.a.createElement("button",{className:"annotate-button",onClick:function(){return e.downloadCombinedAnnotations()}},r.a.createElement("i",{className:"fa fa-download"}),"Download all"))),r.a.createElement("div",{className:"annotations-table-container"},r.a.createElement("table",{id:"annotations-table",className:"project-page-table annotations-table"},r.a.createElement("thead",null,r.a.createElement("tr",null,r.a.createElement("th",null,"Annotator"),r.a.createElement("th",null,"# Annotations"),r.a.createElement("th",null))),r.a.createElement("tbody",null,this.props.data.users.map((function(t,a){return r.a.createElement("tr",null,r.a.createElement("td",null,r.a.createElement("div",{className:"user-row"},r.a.createElement(x,{user:t}),t.username)),r.a.createElement("td",null,t.num_annotations),r.a.createElement("td",null,r.a.createElement("button",{className:"annotate-button"+(0===t.num_annotations?" disabled":""),onClick:function(){return e.downloadAnnotationsOfUser(t)}},r.a.createElement("i",{className:"fa fa-download"}),"Download")))}))))))}}]),a}(n.Component),Ue=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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,i=0;for(var o in this.props.data){var l=this.props.data[o],c=Math.floor(l*a);n.push(r.a.createElement("span",{style:{top:19*Math.ceil(i/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-o)/e)+")"}},e-o===0?"Not yet annotated":e-o+" annotation"+(e-o===1?"":"s")),r.a.createElement("span",{className:"num-docs"},this.props.data[o]," docs"))),s*=-1,Math.floor(c/10)+1,i+=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 Be(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function He(e){for(var t in e.datasets){var a=parseInt(t)%qe.length;e.datasets[t]=Object.assign({},e.datasets[t],Object(Ce.a)({fill:!1,lineTension:.1,backgroundColor:qe[a],borderColor:qe[a],borderCapStyle:"square",borderDash:[],borderDashOffset:0,borderJoinStyle:"bevel",pointBorderColor:qe[a],pointBackgroundColor:qe[a],pointBorderWidth:3,pointHoverRadius:6,pointHoverBackgroundColor:qe[a],pointHoverBorderColor:"rgba(220,220,220,1)",pointHoverBorderWidth:2,pointRadius:1,pointHitRadius:10},"lineTension",0))}return e}function Le(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 We=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:[],multicolour:!1},n}return Object(p.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],i=e.colourIndexes[s];console.log(i,s);var o=a[i%a.length];console.log(o);var l=o.slice(1,7).convertToRGB();n.entityClasses.datasets[0].backgroundColor.push("rgba("+l[0]+", "+l[1]+", "+l[2]+", 1)");var c=Le(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(Oe.Bar,{data:this.state.data.entityClasses,height:230,options:{plugins:{datalabels:{display:!0,color:"rgba(0, 0, 0, 0.8)",anchor:"end",align:"start",offset:-20}},layout:{padding:{top:15}},responsive:!0,maintainAspectRatio:!1,legend:{display:!1},scales:{yAxes:[{ticks:{beginAtZero:!0,precision:0},scaleLabel:{display:!0,labelString:"Frequency"}}]}}})}}]),a}(n.Component),Ge=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:[]},n}return Object(p.a)(a,[{key:"componentWillMount",value:function(){console.log(this.props.data),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=He({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(Oe.Line,{data:this.state.data,height:230,redraw:!0,options:{plugins:{datalabels:{display:!1}},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),Ye=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={entityChartMulticolour:!1,activityChartCumulative:!1},n}return Object(p.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"},Be(this.props.data.numDocGroupsAnnotated)," / ",Be(this.props.data.totalDocGroups)))),r.a.createElement("div",{class:"pieChart"},r.a.createElement("span",{className:"pie-chart-value"},r.a.createElement("span",{className:"inner st st-darker"},(100*this.props.data.numDocGroupsAnnotated/this.props.data.totalDocGroups).toFixed(0),"%")),this.props.loading&&r.a.createElement(we.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(we.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(f.b,{to:b+"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(We,{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(Ge,{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(Ue,{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(z,Object.assign({index:a},t,{project_id:e.props.project_id}))})))))))}}]),a}(n.Component),Ve=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){var e=window.location.pathname,t=e.slice(b.length-1,e.length),a=t.split("/").slice(3,t.split("/").length);return console.log(a),r.a.createElement("nav",{id:"project-view-sidenav"},r.a.createElement("div",{className:"project-card"},r.a.createElement("div",{className:"project-title-creator"},r.a.createElement("div",{className:"project-name"+(this.props.projectTitle?"":" st"),style:{display:"block"}},r.a.createElement(f.b,{to:b+"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(Qe,{project_id:this.props.project_id,view:a,name:"Dashboard",icon:"bar-chart"}),r.a.createElement(Qe,{project_id:this.props.project_id,view:a,name:"Entity Hierarchy",icon:"sitemap"}),r.a.createElement(Ke,{project_id:this.props.project_id,view:a,name:"Annotations",menuItems:[{name:"Curation",icon:"gavel"},{name:"Download",icon:"download"}],icon:"list-alt"}),r.a.createElement(Qe,{project_id:this.props.project_id,view:a,name:"Annotators",icon:"user"}),r.a.createElement(Qe,{project_id:this.props.project_id,view:a,name:"Settings",icon:"wrench"})))}}]),a}(n.Component),Ke=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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(f.b,{to:b+"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(Qe,{project_id:e.props.project_id,view:e.props.view,name:a.name,parentPath:t,icon:a.icon})}))))}}]),a}(n.Component),Qe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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(f.b,{to:b+"projects/"+this.props.project_id+"/"+e},r.a.createElement("i",{className:"fa fa-"+this.props.icon}),this.props.name))}}]),a}(n.Component),ze=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("main",null,"This page is still a work in progress!")}}]),a}(n.Component),Je=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.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,me("projects/"+this.props.project_id,"GET",this.props.setErrorCode,555);case 4:(a=e.sent).dashboard.activityChartData&&(a.dashboard.activityChartData=He(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=Fe.parse(t.search).docId;return r.a.createElement("div",{id:"project-view",className:this.state.loading?"loading":""},r.a.createElement(Ve,{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(xe.a,{className:"transition-group"},r.a.createElement(Se.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(v.d,{location:t},r.a.createElement(v.b,{path:b+"projects/:id/dashboard",render:function(){return r.a.createElement(Ye,{loading:e.state.loading,data:e.state.data.dashboard,project_id:e.props.project_id})}}),r.a.createElement(v.b,{path:b+"projects/:id/annotations/curation",render:function(){return r.a.createElement(De,{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(v.b,{path:b+"projects/:id/annotations/download",render:function(){return r.a.createElement(Re,{user:e.props.user,project_id:e.props.project_id,data:e.state.data.annotationsTable?e.state.data.annotationsTable:{users:[],num_combined_available:0},setErrorCode:e.props.setErrorCode})}}),r.a.createElement(v.b,{path:b+"projects/:id/entity-hierarchy",render:function(){return r.a.createElement(_e,{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(v.b,{path:b+"projects/:id/annotators",render:function(){return r.a.createElement(Ie,{data:e.state.data.invitationsTable?e.state.data.invitationsTable:{},loading:e.state.loading})}}),r.a.createElement(v.b,{path:b+"projects/:id/settings",render:function(){return r.a.createElement(ze,e.state)}}),r.a.createElement(v.b,{render:function(){return r.a.createElement(re,null)}})))))))}}]),a}(n.Component),Ze=Object(v.h)(Je),Xe=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={email:"",password:"",error:null,errorMessage:null},n}return Object(p.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(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),a={email:this.state.email,password:this.state.password},e.next=4,this.setState({errorMessage:null,loading:!0});case 4:return e.next=6,me("users/login","POST",this.props.setErrorCode,a);case 6:n=e.sent,console.log("D:",n),n.error?this.setState({errorMessage:n.error,password:"",loading:!1}):this.props.setUserData(n);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{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(f.b,{class:"forgot-password-link",to:b+"forgot_password"},"Forgot password?"),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(f.b,{class:"back-button",to:b},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),$e=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={username:"",password:"",passwordConfirmation:"",email:"",success:!1,errorMessage:null,loading:!1},n}return Object(p.a)(a,[{key:"handleUsernameChange",value:function(e){this.setState({username:e.target.value})}},{key:"handleEmailChange",value:function(e){this.setState({email:e.target.value})}},{key:"handlePasswordChange",value:function(e){this.setState({password:e.target.value})}},{key:"handlePasswordConfirmationChange",value:function(e){this.setState({passwordConfirmation:e.target.value})}},{key:"submitForm",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),this.state.password===this.state.passwordConfirmation){e.next=4;break}return this.setState({errorMessage:"Password and password confirmation do not match."}),e.abrupt("return");case 4:return a={username:this.state.username,email:this.state.email,password:this.state.password},e.next=7,this.setState({errorMessage:null,loading:!0});case 7:return e.next=9,me("users/register","POST",this.props.setErrorCode,a);case 9:n=e.sent,console.log("D:",n),n.error?this.setState({errorMessage:n.error,password:"",passwordConfirmation:"",loading:!1}):this.setState({success:!0,loading:!1});case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"render",value:function(){return this.state.success?r.a.createElement(v.a,{to:b+"projects"}):r.a.createElement("div",{class:"user-form form-box"+(this.state.loading?" loading":"")},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..."),this.state.errorMessage&&r.a.createElement("div",{className:"error-message"},r.a.createElement("span",{className:"error"},"Error: "),this.state.errorMessage,"."),r.a.createElement("div",{className:"loading-message"},r.a.createElement("i",{className:"fa fa-spinner fa-spin"}),"Loading..."),r.a.createElement("form",{onSubmit:this.submitForm.bind(this)},r.a.createElement("div",null,r.a.createElement("label",null,"Username"),r.a.createElement("input",{onChange:this.handleUsernameChange.bind(this),value:this.state.username,type:"text",name:"username",autoFocus:"autofocus",placeholder:"Username",required:"required"})),r.a.createElement("div",null,r.a.createElement("label",null,"Email"),r.a.createElement("input",{onChange:this.handleEmailChange.bind(this),type:"email",name:"email",placeholder:"Email",required:"required"})),r.a.createElement("div",null,r.a.createElement("label",null,"Password"),r.a.createElement("input",{id:"input-password",type:"password",name:"password",required:"required",value:this.state.password,onChange:this.handlePasswordChange.bind(this)}),r.a.createElement("label",null,"Password confirmation"),r.a.createElement("input",{id:"input-password-confirmation",type:"password",name:"password",required:"required",value:this.state.passwordConfirmation,onChange:this.handlePasswordConfirmationChange.bind(this)})),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(f.b,{class:"back-button",to:b},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),et=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={loading:!1,errorMessage:null,email:"",success:!1},n}return Object(p.a)(a,[{key:"handleEmailChange",value:function(e){this.setState({email:e.target.value})}},{key:"submitForm",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),a={email:this.state.email},e.next=4,this.setState({errorMessage:null,loading:!0});case 4:return e.next=6,me("users/forgot_password","POST",this.props.setErrorCode,a);case 6:n=e.sent,console.log("D:",n),n.error?this.setState({errorMessage:n.error,password:"",loading:!1}):this.setState({success:!0,loading:!1});case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{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,"Forgot Password")),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,"."),this.state.success?r.a.createElement("div",null,r.a.createElement("div",{className:"form-notice form-success"},"An email has been sent to your email address with instructions on how to reset your password."),r.a.createElement("div",{class:"buttons"},r.a.createElement(f.b,{class:"back-button",to:b+"login"},r.a.createElement("i",{class:"fa fa-chevron-left"}),"\xa0\xa0 Back"))):r.a.createElement("form",{onSubmit:this.submitForm.bind(this)},r.a.createElement("div",null,r.a.createElement("label",null,"Email address"),r.a.createElement("input",{type:"email",name:"email",autoFocus:"autofocus",required:"required",placeholder:"Username or email",value:this.state.email,onChange:this.handleEmailChange.bind(this)})),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(f.b,{class:"back-button",to:b+"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),tt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={loading:!1,errorMessage:null,password:"",passwordConfirmation:"",success:!1},n}return Object(p.a)(a,[{key:"handlePasswordChange",value:function(e){this.setState({password:e.target.value})}},{key:"handlePasswordConfirmationChange",value:function(e){this.setState({passwordConfirmation:e.target.value})}},{key:"submitForm",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),this.state.password===this.state.passwordConfirmation){e.next=4;break}return this.setState({errorMessage:"Password and password confirmation do not match."}),e.abrupt("return");case 4:return a={password:this.state.password},e.next=7,this.setState({errorMessage:null,loading:!0});case 7:return e.next=9,me("users/reset_password/"+this.props.token,"POST",this.props.setErrorCode,a);case 9:n=e.sent,console.log("D:",n),n.error?this.setState({errorMessage:n.error,password:"",loading:!1}):this.setState({success:!0,loading:!1});case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{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,"Reset Password")),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,"."),this.state.success?r.a.createElement("div",null,r.a.createElement("div",{className:"form-notice form-success"},"Your password has been reset."),r.a.createElement("div",{class:"buttons"},r.a.createElement(f.b,{class:"back-button",to:b+"login"},r.a.createElement("i",{class:"fa fa-chevron-left"}),"\xa0\xa0 Login"))):r.a.createElement("form",{onSubmit:this.submitForm.bind(this)},r.a.createElement("div",null,r.a.createElement("label",null,"Password"),r.a.createElement("input",{id:"input-password",type:"password",name:"password",autoFocus:"autofocus",required:"required",value:this.state.password,onChange:this.handlePasswordChange.bind(this)})),r.a.createElement("div",null,r.a.createElement("label",null,"Password confirmation"),r.a.createElement("input",{id:"input-password-confirmation",type:"password",name:"password",required:"required",value:this.state.passwordConfirmation,onChange:this.handlePasswordConfirmationChange.bind(this)})),r.a.createElement("div",{class:"buttons"},r.a.createElement("div",null,r.a.createElement(f.b,{class:"back-button",to:b+"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),at="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 nt(){for(var e=[],t=0;t<200;t++)e.push(at[Math.floor(Math.random()*at.length)]+". ");return e.join("")}var rt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={characters:nt()},n.characterChangeFn=null,n}return Object(p.a)(a,[{key:"changeCharacters",value:function(){this.setState({characters:nt()})}},{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),st=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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(f.b,{to:b+"register"},r.a.createElement("div",{class:"button",id:"register-button"},r.a.createElement("h2",null,"Register"))),r.a.createElement(f.b,{to:b+"login"},r.a.createElement("div",{class:"button",id:"login-button"},r.a.createElement("h2",null,"Login")))))}}]),a}(n.Component),it=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){var e=this,t=this.props.location;return r.a.createElement("section",{id:"welcome"},r.a.createElement(rt,null),r.a.createElement(xe.a,{className:"transition-group"},r.a.createElement(Se.a,{key:t.key,timeout:{enter:400,exit:400},classNames:"fade"},r.a.createElement("section",{className:"route-section homepage-route-section"},r.a.createElement(v.d,{location:t},r.a.createElement(v.b,{path:b+"login",render:function(){return r.a.createElement(Xe,{setErrorCode:e.props.setErrorCode,setUserData:e.props.setUserData})}}),r.a.createElement(v.b,{path:b+"register",render:function(){return r.a.createElement($e,{setErrorCode:e.props.setErrorCode})}}),r.a.createElement(v.b,{path:b+"forgot_password",render:function(){return r.a.createElement(et,{setErrorCode:e.props.setErrorCode})}}),r.a.createElement(v.b,{path:b+"reset_password/:id",render:function(t){return r.a.createElement(tt,{token:t.match.params.id,setErrorCode:e.props.setErrorCode})}}),r.a.createElement(v.b,{exact:!0,path:b+"reset_password",render:function(){return r.a.createElement(v.a,{to:b})}}),r.a.createElement(v.b,{path:b,component:st}))))))}}]),a}(n.Component),ot=Object(v.h)(it),lt=a(90),ct=a.n(lt),ut=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("span",{className:"form-help",onClick:this.props.onClick},r.a.createElement("i",{className:"fa fa-info-circle fa-xxs"}),r.a.createElement("span",{className:"info"},"Info"))}}]),a}(n.Component),mt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={file:null,filename:null,errorCleared:!1},n}return Object(p.a)(a,[{key:"componentDidUpdate",value:function(e,t){O.a.isEqual(t.filename,this.state.filename)||this.props.updateFile(this.state.file),e.hasError!==this.props.hasError&&this.props.hasError&&this.setState({errorCleared:!1})}},{key:"updateFile",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(console.log(t.target.files[0]),t.target.files[0]){e.next=3;break}return e.abrupt("return");case 3:this.setState({file:t.target.files[0],filename:t.target.files[0].name,errorCleared:!0},(function(){a.props.updateFile(a.state.file)}));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"render",value:function(){var e=this;return r.a.createElement("div",{className:"upload-form-container"},r.a.createElement("div",{className:"upload-form "+(this.props.file_metadata?"saved":"")+(this.props.hasError&&!this.state.errorCleared?"error":"")},r.a.createElement("input",{required:!this.props.file_metadata,type:"file",id:"upload-dataset",name:"upload-dataset",onChange:function(t){return e.updateFile(t)}}),r.a.createElement("label",{htmlFor:"upload-dataset"},this.props.saving?r.a.createElement("span",{className:"center"},r.a.createElement("i",{className:"form-icon fa fa-cog fa-spin"}),"Uploading..."):this.props.hasError&&!this.state.errorCleared?r.a.createElement("span",{className:"center"},r.a.createElement("i",{className:"form-icon fa fa-times"}),"An error occurred while uploading",r.a.createElement("br",null),r.a.createElement("em",null,this.state.filename),"."):this.props.file_metadata?r.a.createElement("span",null,r.a.createElement("span",{className:"center"},r.a.createElement("em",null,this.props.file_metadata[0][1])," uploaded successfully."),r.a.createElement("table",{className:"file-metadata"},r.a.createElement("tbody",null,this.props.file_metadata.slice(1,this.props.file_metadata.length).map((function(e,t){return r.a.createElement("tr",{key:t},r.a.createElement("td",null,e[0],":"),r.a.createElement("td",null,e[1]))}))))):this.state.filename?r.a.createElement("span",null,r.a.createElement("i",{className:"form-icon fa fa-check"}),"Ready to upload ",r.a.createElement("em",null,this.state.filename),"."):r.a.createElement("span",null,r.a.createElement("i",{className:"form-icon fa fa-upload"}),"Click here to upload a ",this.props.name?this.props.name:"dataset","."))))}}]),a}(n.Component),dt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:{project_name:"",project_description:"",dataset:null}},n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.setState({data:this.props.data})}},{key:"componentDidUpdate",value:function(e,t){O.a.isEqual(this.props.data,this.state.data)||O.a.isEqual(t.data,this.state.data)||this.props.updateFormPageData(this.state.data,{reset_form:!1})}},{key:"updateProjectName",value:function(e){var t=e.target.value;0===t.trim().length&&(t=""),this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{project_name:t})})}},{key:"updateProjectDescription",value:function(e){var t=e.target.value;0===t.trim().length&&(t=""),this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{project_description:t})})}},{key:"updateDataset",value:function(e){var t=this;this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{dataset:e})},(function(){console.log("changed"),t.props.updateFormPageData(t.state.data,{reset_form:!0})}))}},{key:"render",value:function(){var e=this,t=r.a.createElement("div",null,r.a.createElement("h2",null,"Data"),r.a.createElement("p",null,"Please upload your data using the form. The data may be in one of two formats: "),r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("b",null,"Raw data"),": The dataset must be saved as a .txt file. Each token within your data must be separated by a space, and each document must be on a new line."),r.a.createElement("li",null,"(Coming soon): ",r.a.createElement("b",null,"Already labelled data"),": The dataset must be saved as a .json file, in the same format as Redcoat annotation files.")));return r.a.createElement("div",null,r.a.createElement("div",{className:"flex-columns flex-columns-2"},r.a.createElement("div",{className:"flex-column"},r.a.createElement("h2",null,"Project details"),r.a.createElement("div",{className:"form-group"+(this.props.errorPaths.has("project_name")?" error":"")},r.a.createElement("label",null,"Project name"),r.a.createElement("input",{required:!0,onKeyDown:function(e){return 13==e.keyCode?e.preventDefault():""},maxLength:100,placeholder:"Project name",value:this.state.data.project_name||"",onChange:function(t){return e.updateProjectName(t)}})),r.a.createElement("div",{className:"form-group"+(this.props.errorPaths.has("project_description")?" error":"")},r.a.createElement("label",null,"Project description (optional)"),r.a.createElement("textarea",{maxLength:1e3,placeholder:"Project description",value:this.state.data.project_description||"",onChange:function(t){return e.updateProjectDescription(t)}}))),r.a.createElement("div",{className:"flex-column"},r.a.createElement("h2",null,"Data ",r.a.createElement(ut,{onClick:function(){return e.props.toggleFormHelp(t)}})),r.a.createElement(mt,{saving:this.props.saving&&!this.props.data.file_metadata,hasError:this.props.errorPaths&&this.props.errorPaths.has("dataset"),updateFile:this.updateDataset.bind(this),file_metadata:this.props.data.file_metadata}))))}}]),a}(n.Component),pt=[{name:"Named Entity Recognition (NER)",entities:["Person","Organisation","Location","Miscellaneous"]},{name:"Fine-grained Entity Recognition (FIGER)",entities:["person","person/actor","person/architect","person/artist","person/athlete","person/author","person/coach","person/director","person/doctor","person/engineer","person/monarch","person/musician","person/politician","person/religious_leader","person/soldier","person/terrorist","organization","organization/airline","organization/company","organization/educational_institution","organization/fraternity_sorority","organization/sports_league","organization/sports_team","organization/terrorist_organisation","organization/government_agency","organization/government","organization/political_party","organization/educational_department","organization/military","organization/news_agency","location","location/city","location/country","location/county","location/province","location/railway","location/road","location/bridge","location/body_of_water","location/island","location/mountain","location/glacier","location/astral_body","location/cemetary","location/park","product","product/engine","product/airplane","product/car","product/ship","product/spacecraft","product/train","product/camera","product/mobile_phone","product/computer","product/software","product/game","product/instrument","product/weapon","art","art/film","art/play","art/written_work","art/newspaper","art/music","event","event/attack","event/election","event/protest","event/military_conflict","event/natural_disaster","event/sports_event","event/terrorist_attack","event/building","event/airport","event/dam","event/hospital","event/hotel","event/library","event/power_station","event/restaurant","event/sports_facility","event/theater","time","color","award","educational_degree","title","law","ethnicity","language","religion","god","chemical_thing","biological_thing","medical_treatment","disease","symptom","drug","body_part","living_thing","animal","food","website","broadcast_network","broadcast_program","tv_channel","currency","stock_exchange","algorithm","programming_language","transit_system","transit_line"]},{name:"Maintenance work orders",entities:["Item","Activity","Location","Time","Attribute","Cardinality","Agent","Consumable","Observation","Observation/Observed_state","Observation/Quantitative","Observation/Qualitative","Specifier","Event","Unsure","Typo","Abbreviation"],descriptions:{Item:"A maintainable item",Consumable:"Entities that are replaced and not repaired. & oil, grease, bolts, water, filters, gasket",Activity:"An action done by an agent","Observation/Observed_state":"The state of an item - must be discrete (in that state or not) and unambiguous","Observation/Qualitative":"An imprecise measure","Observation/Quantitative":"A precise measure (include units if available)",Location:"Where an item is, either absolutely or relative to another item",Specifier:"An adjective that specifies an item, i.e. could differentiate it from other items",Attribute:"An attribute of an item. It is specific to an item. The attribute is not a value",Agent:"A person, organisation, or individual",Cardinality:"Numerical values or terms describing members of a set",Time:"When an activity occurs, either absolutely or relative in time to another activity",Event:"A point in time that describes a state transition. No agent is specifically identified",Typo:"A spelling error or typo",Unsure:"Use this tag when not sure what something is",Abbreviation:"An abbreviated term"}},{name:"Mining accidents",entities:["accident_cause","accident_cause/bodily_contact","accident_cause/caught_between","accident_cause/fall","accident_cause/fall/fall_from_heights","accident_cause/fall/fall_from_vehicle","accident_cause/over_exertion","accident_cause/recurrence","accident_cause/stepping","accident_cause/struck_by_object","accident_cause/trip_and_fall","accident_cause/vehicle_related","activity","activity/driving","activity/running","activity/walking","age_group","age_group/age_15_24","age_group/age_25_34","age_group/age_35_44","age_group/age_45_54","age_group/age_55_64","age_group/age_65_100","body_part","body_part/arm","body_part/arm/elbow","body_part/arm/elbow/left_elbow","body_part/arm/elbow/right_elbow","body_part/arm/hand","body_part/arm/hand/fingers","body_part/arm/hand/left_hand","body_part/arm/hand/right_hand","body_part/arm/hand/thumb","body_part/arm/hand/thumb/left_thumb","body_part/arm/hand/thumb/right_thumb","body_part/arm/left_arm","body_part/arm/right_arm","body_part/arm/shoulder","body_part/arm/shoulder/left_shoulder","body_part/arm/shoulder/right_shoulder","body_part/arm/wrist","body_part/arm/wrist/left_wrist","body_part/arm/wrist/right_wrist","body_part/back","body_part/back/lower_back","body_part/back/upper_back","body_part/body","body_part/body/chest","body_part/body/stomach","body_part/body/torso","body_part/groin","body_part/head","body_part/head/ear","body_part/head/ear/left_ear","body_part/head/ear/right_ear","body_part/head/eye","body_part/head/eye/left_eye","body_part/head/eye/right_eye","body_part/head/mouth","body_part/head/nose","body_part/leg","body_part/leg/ankle","body_part/leg/ankle/left_ankle","body_part/leg/ankle/right_ankle","body_part/leg/calf","body_part/leg/calf/left_calf","body_part/leg/calf/right_calf","body_part/leg/foot","body_part/leg/foot/left_foot","body_part/leg/foot/right_foot","body_part/leg/foot/toes","body_part/leg/knee","body_part/leg/knee/left_knee","body_part/leg/knee/right_knee","body_part/leg/left_leg","body_part/leg/right_leg","body_part/leg/thigh","body_part/leg/thigh/left_thigh","body_part/leg/thigh/right_thigh","body_part/neck","equipment","equipment/bund_wall","equipment/cage","equipment/cables","equipment/catenery_cable","equipment/chock","equipment/chute","equipment/filter","equipment/headframe","equipment/jumbo","equipment/mechanical_equipment","equipment/mechanical_equipment/auger","equipment/mechanical_equipment/cavity_monitoring_system","equipment/mechanical_equipment/conveyor","equipment/mechanical_equipment/crusher","equipment/mechanical_equipment/pump","equipment/mechanical_equipment/pump/sump_pump","equipment/mechanical_equipment/skip","equipment/personal_protective_equipment","equipment/pipe","gender","gender/female","gender/male","injury","injury/amputation","injury/bite","injury/bruises","injury/bruises/contusion","injury/burn","injury/burn/electric_burn","injury/burn/thermal_burn","injury/chemical_effect","injury/crush_injury","injury/dislocation","injury/dislocation/displacement","injury/fracture","injury/fracture/break","injury/laceration","injury/loss_of_conciousness","injury/multiple_injuries","injury/muscle","injury/muscle/sprain","injury/muscle/strain","injury/puncture","injury/splinter","injury/unspecified_injuries","location","location/camp_medical_centre","location/kitchen","location/office","person","person/blast_guard","person/blaster","person/boilermaker","person/chef","person/contractor","person/driller","person/driver","person/electrical_worker","person/employee","person/fitter","person/individual","person/injured_person","person/maintainer","person/offsider","person/operator","person/personnel","person/process_worker","person/service_crew","person/spotter","person/supervisor","person/telehandler","person/underground_operator","person/worker","severity","severity/minor","severity/serious","severity/fatal","severity/ndi","vehicle","vehicle/light_vehicle","vehicle/light_vehicle/car","vehicle/light_vehicle/forklift","vehicle/light_vehicle/man_car","vehicle/light_vehicle/mine_car","vehicle/light_vehicle/ute","vehicle/light_vehicle/golf_buggy","vehicle/heavy_vehicle","vehicle/heavy_vehicle/bogger","vehicle/heavy_vehicle/continuous_miner","vehicle/heavy_vehicle/dozer","vehicle/heavy_vehicle/dump_truck","vehicle/heavy_vehicle/excavator","vehicle/heavy_vehicle/haul_truck","vehicle/heavy_vehicle/scraper","vehicle/heavy_vehicle/grader","unspecified_category"]}],ht=a(49),gt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:{entity_hierarchy:[],hierarchy_preset:"None"},loading:!1,preset_is_modified:!1},n.selectLabelRef=r.a.createRef(),n.selectRef=r.a.createRef(),n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.setState({data:this.props.data})}},{key:"componentDidMount",value:function(){this.setState({data:this.props.data,preset_is_modified:this.props.data.hierarchy_preset.indexOf("(modified)")>0})}},{key:"componentDidUpdate",value:function(e,t){O.a.isEqual(this.props.data,this.state.data)||O.a.isEqual(t.data,this.state.data)||this.props.updateFormPageData(this.state.data,{reset_form:!1})}},{key:"markModified",value:function(){var e=Object(u.a)(c.a.mark((function e(){return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.state.preset_is_modified){e.next=3;break}return this.props.markModified(),e.abrupt("return");case 3:return e.next=5,this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{hierarchy_preset:"None"===this.state.data.hierarchy_preset?"Custom":this.state.data.hierarchy_preset+(this.state.data.hierarchy_preset.endsWith(" (modified)")?"":" (modified)")}),preset_is_modified:!0});case 5:return e.abrupt("return",Promise.resolve());case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"updateHierarchy",value:function(){var e=Object(u.a)(c.a.mark((function e(t){return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log(t[0],"X"),e.next=3,this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{entity_hierarchy:t})});case 3:return e.next=5,this.markModified();case 5:console.log(this.state.data.hierarchy_preset),this.props.updateFormPageData(this.state.data);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"changePreset",value:function(e){var t=this;var a=e.target.value;this.setState({loading:!0},(function(e){var n=function(e){if("None"===e)return{name:"None",entities:new Array,hierarchy:[],descriptions:{}};console.log(e,"X");var t,a=Object(k.a)(pt);try{for(a.s();!(t=a.n()).done;){var n=t.value;if(n.name===e)return{name:n.name,entities:n.entities,hierarchy:Object(ht.txt2json)(Object(ht.slash2txt)(n.entities),n.entities,n.descriptions).children,descriptions:n.descriptions||{}}}}catch(r){a.e(r)}finally{a.f()}}(a);console.log(n.entities),console.log(n.hierarchy),t.selectRef.current.blur(),t.setState({data:{entity_hierarchy:n.hierarchy,hierarchy_preset:n.name},loading:!1,preset_is_modified:!1},(function(){t.props.updateFormPageData(t.state.data),window.scrollTo({top:t.selectLabelRef.current.offsetTop+140,left:0,behavior:"smooth"})}))}))}},{key:"render",value:function(){var e=this,t=r.a.createElement("div",null,r.a.createElement("h2",null,"Entity Hierarchy"),r.a.createElement("p",null,"Please define your entity hierarchy."),r.a.createElement("p",null,"You may create new categories by entering them in the form below. You may also select from a list of presets, such as the standard 4-class Named Entity Recognition model."));function a(e){return e.name}var n=function(e){var t=new Set;if(!e)return t;var a,n=Object(k.a)(e);try{for(n.s();!(a=n.n()).done;){var r,s=a.value.message.match(/\((".*)"\)/g)[0]||"";t.add(s.slice(2,s.length-2))}}catch(r){n.e(r)}finally{n.f()}return t}(this.props.errors);return r.a.createElement("div",null,r.a.createElement("h2",null,"Entity Hierarchy ",r.a.createElement(ut,{onClick:function(){return e.props.toggleFormHelp(t)}})),!this.props.loading&&r.a.createElement("div",{className:"form-group no-padding"},r.a.createElement("label",{ref:this.selectLabelRef},"Preset"),r.a.createElement("select",{onChange:function(t){return e.changePreset(t)},ref:this.selectRef,value:this.state.data.hierarchy_preset},r.a.createElement("option",{value:"None"},"None"),pt.map((function(e,t){return r.a.createElement("option",{value:a(e),key:t},a(e)," ")})),this.state.preset_is_modified&&r.a.createElement("option",{value:this.state.data.hierarchy_preset},this.state.data.hierarchy_preset))),r.a.createElement("div",{className:"category-hierarchy-wrapper min-height"},!this.props.loading&&!this.state.loading&&r.a.createElement(U,{items:this.state.data.entity_hierarchy||[],preset:this.state.selectedPreset,visible:!0,limitHeight:!0,updateHierarchy:this.updateHierarchy.bind(this),markModified:this.markModified.bind(this),errorEntityNames:n,userIsModifying:this.props.userIsModifying})))}}]),a}(n.Component),ft=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:{use_automatic_tagging:"not-defined",dataset:null}},n.selectRef=r.a.createRef(),n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.setState({data:this.props.data})}},{key:"componentDidUpdate",value:function(e,t){O.a.isEqual(this.props.data,this.state.data)||O.a.isEqual(t.data,this.state.data)&&(!this.state.data.dataset||O.a.isEqual(t.data.dataset.name,this.state.data.dataset.name))||(console.log("changed"),this.props.updateFormPageData(this.state.data,{reset_form:!0}))}},{key:"updateUseAutomaticTagging",value:function(e){var t=e.target.value;this.selectRef.current.blur(),this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{use_automatic_tagging:t})})}},{key:"updateDataset",value:function(e){var t=this;this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{dataset:e})},(function(){console.log("changed"),t.props.updateFormPageData(t.state.data,{reset_form:!0})}))}},{key:"render",value:function(){var e=this,t=r.a.createElement("div",null,r.a.createElement("h2",null,"Automatic Tagging"),r.a.createElement("p",null,"Redcoat can automatically annotate terms according to a dictionary, helping to save annotation time. These annotations can be adjusted by your annotators when necessary."),r.a.createElement("p",null,"To use automatic tagging, you can upload a CSV file where each row is a (term, entity type), e.g."),r.a.createElement("code",null,"car,Vehicle",r.a.createElement("br",null),"running around,Activity",r.a.createElement("br",null),"left leg,Body_part/Leg",r.a.createElement("br",null)),r.a.createElement("p",null,'In the example above, "car" will be automatically labelled as a Vehicle, "running around" as an Activity, and "left leg" as a Body_part/Leg.'),r.a.createElement("p",null,"Note that the entity types must appear in your entity hierarchy, which is defined on the previous page."));return r.a.createElement("div",null,r.a.createElement("h2",null,"Automatic Tagging ",r.a.createElement(ut,{onClick:function(){return e.props.toggleFormHelp(t)}})),r.a.createElement("div",{className:"form-group"},r.a.createElement("label",{htmlFor:"use-automatic-tagging"},"Use automatic tagging?"),r.a.createElement("select",{name:"use-automatic-tagging",onChange:this.updateUseAutomaticTagging.bind(this),id:"use-automatic-tagging",value:this.state.data.use_automatic_tagging,ref:this.selectRef},r.a.createElement("option",{disabled:!0,hidden:!0,value:"not-defined"},"Click to select"),r.a.createElement("option",{value:"yes"},"Yes"),r.a.createElement("option",{value:"no"},"No"))),r.a.createElement("div",{className:"form-group"},"yes"===this.state.data.use_automatic_tagging&&r.a.createElement(mt,{saving:this.props.saving&&!this.props.data.file_metadata,hasError:this.props.errorPaths&&this.props.errorPaths.has("automatic_tagging"),updateFile:this.updateDataset.bind(this),file_metadata:this.props.data.file_metadata,name:"dictionary"})))}}]),a}(n.Component),vt=a(92);var bt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){var e=this.props.user;return r.a.createElement("span",{className:"user-details"},r.a.createElement(x,{user:e.is_registered?e:null}),r.a.createElement("span",null,r.a.createElement("div",{className:"annotator-username"},e.is_registered?e.username:e.email),r.a.createElement("div",{className:"annotator-registration-date"},e.is_registered?"Joined on "+Q(e.created_at,{no_hours:!0}):"Not yet registered")))}}]),a}(n.Component),Et=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:{users:[]},loading:!0,showingSuggestions:!1,userSearchResults:null,userSuggestions:[],searchTerm:""},n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("x",this.props.data),e.next=3,this.setState({data:this.props.data});case 3:t=this.props.data.suggested_users,this.setState({loading:!1,data:this.props.data,userSuggestions:t,userSearchResults:t.length>0?t:null,showingSuggestions:t.length>0});case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"queryAPI",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t,a,n,r;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({loading:!0});case 2:if(0!==this.state.searchTerm.length){e.next=5;break}return this.setState({loading:!1,userSearchResults:this.state.userSuggestions.length>0?this.state.userSuggestions:null,showingSuggestions:this.state.userSuggestions.length>0}),e.abrupt("return");case 5:return t=this.state.searchTerm,a=(s=t).indexOf("@")>0&&2===s.split("@").length,e.next=9,me("http://localhost:3000/api/projects/new/searchUsers?searchTerm="+t+"&isEmail="+a,"GET",this.props.setErrorCode,!1,!1,200);case 9:n=e.sent,r=n.users,a&&0===n.users.length&&(r=[{is_registered:!1,email:t}]),this.setState({loading:!1,userSearchResults:r,showingSuggestions:!1});case 13:case"end":return e.stop()}var s}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"changeSearchTerm",value:function(e){var t=e.target.value;this.setState({searchTerm:t})}},{key:"submitViaEnter",value:function(e){console.log(e,"EEE"),e.preventDefault(),this.queryAPI()}},{key:"onKeyDown",value:function(e){13===e.keyCode&&(e.preventDefault(),this.queryAPI())}},{key:"alreadyAddedUser",value:function(e){var t,a=Object(k.a)(this.state.data.users);try{for(a.s();!(t=a.n()).done;){var n=t.value;if(e.username&&n.username===e.username)return!0;if(e.email&&n.email===e.email)return!0}}catch(r){a.e(r)}finally{a.f()}return!1}},{key:"removeUser",value:function(e){var t=this,a=Object(vt.a)(this.state.data.users);a.splice(e,1),this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{users:a})},(function(){return t.props.updateFormPageData(t.state.data)}))}},{key:"addUser",value:function(e){var t=this,a=Object(vt.a)(this.state.data.users);return a.push(e),this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{users:a})},(function(){return t.props.updateFormPageData(t.state.data)})),null}},{key:"deleteHighlightRow",value:function(e){document.getElementById("annotator-num-"+e).classList.add("delete-hover")}},{key:"removeHighlightRow",value:function(){var e,t=document.getElementsByClassName("annotator"),a=Object(k.a)(t);try{for(a.s();!(e=a.n()).done;){e.value.classList.remove("delete-hover")}}catch(n){a.e(n)}finally{a.f()}}},{key:"render",value:function(){var e=this,t=r.a.createElement("div",null,r.a.createElement("h2",null,"Annotators"),r.a.createElement("p",null,"Please specify the annotators of this project."),r.a.createElement("p",null,'You can search for annotators by username via the left-side window. Click "add" to add them to this project. An invitation to join your project will be sent to them once the project is created.'),r.a.createElement("p",null,"You can also enter an email address into the search bar. If no account with the email address exists, you can still them as an annotator - Redcoat will send them an invitation to register and join your project once your project has been created."),r.a.createElement("p",null,"If no search term has been entered, Redcoat will suggest annotators for you based on your recent projects."),r.a.createElement("p",null,"You can remove annotators using the trash icon in the right-side window. At present you cannot remove yourself from the annotation task."));return r.a.createElement("div",null,r.a.createElement("h2",null,"Annotators ",r.a.createElement(ut,{onClick:function(){return e.props.toggleFormHelp(t)}})),r.a.createElement("div",{className:"flex-columns flex-columns-2"},r.a.createElement("div",{className:"flex-column flex-column-33"+(this.state.loading?" loading-prevent-action":"")},r.a.createElement("div",{className:"annotators-box"},r.a.createElement("div",{className:"annotators-box-header"},"Annotator lookup"),r.a.createElement("div",{className:"annotators-box-body"},r.a.createElement("div",{className:"input-row"},r.a.createElement("input",{id:"annotator-name",placeholder:"Username or email address",value:this.state.searchTerm,onKeyDown:function(t){return e.onKeyDown(t)},onChange:this.changeSearchTerm.bind(this)}),r.a.createElement("button",{onClick:this.queryAPI.bind(this),className:"annotate-button",type:"button"},r.a.createElement("i",{className:"fa fa-search"}),"Search")),r.a.createElement("div",{className:"annotators-box-list search-results"},null===this.state.userSearchResults&&r.a.createElement("div",{className:"not-searched-yet"},"Enter a username or email address above to search for annotators."),this.state.userSearchResults&&0===this.state.userSearchResults.length&&r.a.createElement("div",{className:"no-search-results"},"No results found."),this.state.userSearchResults&&this.state.userSearchResults.length>0&&r.a.createElement("div",{className:"search-results-found"},this.state.showingSuggestions?r.a.createElement("h4",null,"Suggestions (",this.state.userSearchResults.length,")"):r.a.createElement("h4",null,"Search results (",this.state.userSearchResults.length,")"),this.state.userSearchResults.map((function(t,a){return r.a.createElement("div",{className:"annotator search-result"},r.a.createElement(bt,{user:t}),e.alreadyAddedUser(t)?r.a.createElement("div",{className:"annotate-button user-added"},"Added",r.a.createElement("i",{className:"right fa fa-check"})):r.a.createElement("div",{className:"annotate-button",onClick:e.addUser.bind(e,t)},"Add ",r.a.createElement("i",{className:"right fa fa-chevron-right"})))}))))))),r.a.createElement("div",{className:"flex-column flex-column-66"},r.a.createElement("div",{className:"annotators-box"},r.a.createElement("div",{className:"annotators-box-header"},"Annotators to invite"),r.a.createElement("div",{className:"annotators-box-body"},r.a.createElement("div",{className:"annotators-box-list "},this.state.data.users.map((function(t,a){return r.a.createElement("div",{className:"annotator",id:"annotator-num-"+a},r.a.createElement(bt,{user:t}),a>0&&r.a.createElement("span",{className:"delete-button-container"},r.a.createElement("span",{className:"delete-button",onClick:e.removeUser.bind(e,a),onMouseEnter:function(){return e.deleteHighlightRow(a)},onMouseLeave:e.removeHighlightRow},r.a.createElement("i",{className:"fa fa-trash"}))))}))))))))}}]),a}(n.Component),yt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={data:{hierarchy_permissions:""}},n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.setState({data:this.props.data})}},{key:"changeOverlap",value: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:return a=t.target.value,e.next=3,this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{overlap:a})});case 3:this.props.updateFormPageData(this.state.data);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"setPermissions",value: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:return a=t.target.value,e.next=3,this.setState({data:Object(se.a)(Object(se.a)({},this.state.data),{},{hierarchy_permissions:a})});case 3:this.props.updateFormPageData(this.state.data);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"render",value:function(){var e=this,t=r.a.createElement("div",null,r.a.createElement("h2",null,"Project Options"),r.a.createElement("p",null,"Please specify the options of this project."),r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("b",null,"Hierarchy permissions"),": If allowed, your annotators will be able to add categories as they appear, or delete ones that aren not relevant. This option is useful if you aren't sure whether your category hierarchy covers every possible category in your dataset. "),r.a.createElement("li",null,r.a.createElement("b",null,"Overlap"),': The number of times each document will be annotated. More overlap can result in a more robust set of results, but requires longer annotation time. You can mark your project as "complete" at any time.'))),a=this.state.data.overlap,n=this.state.data.num_users;return r.a.createElement("div",null,r.a.createElement("h2",null,"Project Options ",r.a.createElement(ut,{onClick:function(){return e.props.toggleFormHelp(t)}})),r.a.createElement("div",{className:"form-group"},r.a.createElement("label",null,"To what extent should annotators be able to modify the category hierarchy?"),r.a.createElement("select",{value:this.state.data.hierarchy_permissions,required:!0,onChange:function(t){return e.setPermissions(t)}},r.a.createElement("option",{disabled:!0,hidden:!0,value:""},"Click to select"),r.a.createElement("option",{value:"no_modification"},"No modifications allowed."),r.a.createElement("option",{value:"create_edit_only"},"Annotators can create new categories."),r.a.createElement("option",{value:"full_permission"},"Annotators can create, delete and rename categories."))),r.a.createElement("div",{className:"form-group",style:{"margin-top":"40px"}},r.a.createElement("label",null,"How many times should a document be annotated before annotation is considered complete?"),r.a.createElement("div",{className:"input-range-group"+(1===n?" disabled":"")},1===n&&r.a.createElement("div",{className:"disabled-message"},r.a.createElement("span",{className:"inapplicable"},"This option is inapplicable because you are the only annotator.")),r.a.createElement("div",{className:"inner"},r.a.createElement("div",{className:"input-range-summary"},r.a.createElement("p",null,r.a.createElement("span",{className:"num"},a)," annotation",a>1?"s":"","/document",r.a.createElement("br",null)),r.a.createElement("p",{className:"small"},"Each annotator labels approximately ",r.a.createElement("span",{className:"avg"},(1/n*a*100).toFixed(2)),"% of the corpus.")),r.a.createElement("div",{class:"input-range-container"},r.a.createElement("div",{class:"left"},"1"),r.a.createElement("input",{id:"input-overlap",name:"input-overlap",type:"range",min:"1",max:n,onChange:function(t){return e.changeOverlap(t)},value:a,onKeyDown:function(e){return 13==e.keyCode?e.preventDefault():""}}),r.a.createElement("div",{class:"right"},n))))))}}]),a}(n.Component);ct.a.setAppElement("body");var kt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement("h2",null,r.a.createElement("span",{className:"st st-darker"},"Empty form hello")),"entity_hierarchy"===this.props.page&&r.a.createElement("div",null,r.a.createElement("div",{className:"form-group no-padding"},r.a.createElement("label",null,r.a.createElement("span",{className:"st st-darker"},"Preset")),r.a.createElement("select",{className:"st"},r.a.createElement("option",null,"Hello"))),r.a.createElement("div",{className:"category-hierarchy-wrapper"},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)))))}))))}())))}}]),a}(n.Component),jt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("div",{onClick:this.props.gotoFormPage,className:"item "+(this.props.active?"active":"")+(this.props.ready?"":" disabled")},r.a.createElement("div",{className:"inner"},this.props.name,"saved"===this.props.pageProgress&&r.a.createElement("i",{className:"fa fa-check"}),"error"===this.props.pageProgress&&r.a.createElement("i",{className:"fa fa-times"}),"requires_attention"===this.props.pageProgress&&r.a.createElement("i",{className:"fa fa-warning"})))}}]),a}(n.Component);function wt(e){if(!e)return new Set;var t,a=new Set,n=Object(k.a)(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;a.add(r.path)}}catch(s){n.e(s)}finally{n.f()}return a}var Nt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;Object(d.a)(this,a),(n=t.call(this,e)).ref=r.a.createRef();var s=function(){return{loading:this.state.loading,saving:this.state.saving,toggleFormHelp:this.toggleFormHelp.bind(this),errors:this.state.formErrors,errorPaths:wt(this.state.formErrors),data:this.state.data,markModified:this.markModified.bind(this),updateFormPageData:this.updateFormPageData.bind(this),userIsModifying:this.userIsModifying.bind(this)}}.bind(Object(m.a)(n));return n.formPages=[{name:"Project details & data",pathname:"project_details",component:function(){return r.a.createElement(dt,s())}},{name:"Entity hierarchy",pathname:"entity_hierarchy",component:function(){return r.a.createElement(gt,Object.assign({hierarchyPresets:["Named Entity Recognition (NER)","Fine-grained Entity Recognition (FIGER)","Maintenance"]},s()))}},{name:"Automatic tagging",pathname:"automatic_tagging",component:function(){return r.a.createElement(ft,s())}},{name:"Annotators",pathname:"annotators",component:function(){return r.a.createElement(Et,s())}},{name:"Project options",pathname:"project_options",component:function(){return r.a.createElement(yt,s())}}],n.formPageDependencies={entity_hierarchy:["automatic_tagging",2],project_details:["project_options",4],annotators:["project_options",4]},n.state={data:{},currentFormPageIndex:null,formErrors:null,formErrorShake:!1,loading:!0,saving:!1,wasModified:!1,isSaved:!1,formHelpContent:null,verifyFormPageChange:!1,nextPageAfterVerification:0,verifySubmitNewProjectForm:!1,creatingNewProject:!1,creatingNewProjectErrors:null,creatingNewProjectSuccess:!1,newlyCreatedProjectId:null,userIsModifying:!1,formPageProgress:["not_started","not_started","not_started","not_started","not_started"]},n}return Object(p.a)(a,[{key:"componentDidMount",value:function(){this.queryAPI(!0)}},{key:"markModified",value:function(){this.setState({wasModified:!0,isSaved:!1})}},{key:"userIsModifying",value:function(e){this.setState({userIsModifying:e})}},{key:"updateFormPageData",value:function(){var e=Object(u.a)(c.a.mark((function e(t,a){var n=this;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!a||!a.reset_form){e.next=4;break}return e.next=3,this.setState({data:Object(se.a)(Object(se.a)({},t),{},{file_metadata:null}),wasModified:!0,isSaved:!1},(function(){console.log(n.state.data,"<data")}));case 3:return e.abrupt("return");case 4:this.setState({data:t,wasModified:!0,isSaved:!1},(function(){console.log(n.state.data)}));case 5:case"end":return e.stop()}}),e,this)})));return function(t,a){return e.apply(this,arguments)}}()},{key:"queryAPI",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n,r,s,i,o;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({loading:!0,data:{}});case 2:return a=t?"":"?formPage="+this.getFormPagePathname(),e.next=5,me("projects/new/get"+a,"GET",this.props.setErrorCode,!1,!1,t?0:555);case 5:if(n=e.sent,r=this.state.formPageProgress,!t){e.next=19;break}s=n.latest_form_page,i=0;case 10:if(!(i<this.formPages.length)){e.next=17;break}if(this.formPages[i].pathname!==s){e.next=14;break}return o=i,e.abrupt("break",17);case 14:i++,e.next=10;break;case 17:e.next=20;break;case 19:o=this.state.currentFormPageIndex;case 20:r=n.form_page_progress,console.log(n,"RES"),this.setState({data:n.data,isSaved:n.is_saved,currentFormPageIndex:o,wasModified:!1,loading:!1,formPageProgress:r});case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"componentDidUpdate",value:function(e){this.props.location!==e.location&&this.updateCurrentFormPageIndex()}},{key:"toggleFormHelp",value:function(e){this.setState({formHelpContent:e})}},{key:"getFormPagePathname",value:function(){return this.formPages[this.state.currentFormPageIndex].pathname}},{key:"submitFormPage",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n,r,s,i;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),console.log("Submitting"),e.next=4,this.setState({saving:!0});case 4:if(this.getFormPagePathname(),a=this.state.data,n="projects/new/submit?formPage=",console.log("THIS STATE DATA IS ",a),0!==this.state.currentFormPageIndex){e.next=21;break}return e.next=11,me(n+"project_details","POST",this.props.setErrorCode,a);case 11:if((r=e.sent).errors||this.state.data.file_metadata){e.next=19;break}return console.log(a.dataset,"xxxx"),(s=new FormData).append("file",a.dataset),e.next=18,me(n+"dataset","POST",this.props.setErrorCode,s,!0);case 18:r=e.sent;case 19:e.next=52;break;case 21:if(1!==this.state.currentFormPageIndex){e.next=28;break}return a={entity_hierarchy:Object(ht.json2slash)({children:a.entity_hierarchy}),hierarchy_preset:a.hierarchy_preset},e.next=25,me(n+"entity_hierarchy","POST",this.props.setErrorCode,a);case 25:r=e.sent,e.next=52;break;case 28:if(2!==this.state.currentFormPageIndex){e.next=42;break}if("yes"!==a.use_automatic_tagging){e.next=37;break}return(s=new FormData).append("file",a.dataset),e.next=34,me(n+"automatic_tagging","POST",this.props.setErrorCode,s,!0);case 34:r=e.sent,e.next=40;break;case 37:return e.next=39,me(n+"automatic_tagging","POST",this.props.setErrorCode,{clear_automatic_tagging:!0});case 39:r=e.sent;case 40:e.next=52;break;case 42:if(3!==this.state.currentFormPageIndex){e.next=48;break}return e.next=45,me(n+"annotators","POST",this.props.setErrorCode,a);case 45:r=e.sent,e.next=52;break;case 48:if(4!==this.state.currentFormPageIndex){e.next=52;break}return e.next=51,me(n+"project_options","POST",this.props.setErrorCode,a);case 51:r=e.sent;case 52:if(console.log("Response: ",r),!r.errors){e.next=57;break}this.renderWithErrors(r),e.next=60;break;case 57:return i=this.state.data,r.file_metadata&&(i.file_metadata=r.file_metadata),e.abrupt("return",this.setState({data:i,formErrors:null,isSaved:!0,saving:!1,formPageProgress:r.form_page_progress}));case 60:return e.abrupt("return",null);case 61:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"renderWithErrors",value:function(e){console.log("Response",e);var t=e.errors,a=e.form_page_progress;console.log(a,"XX"),this.setState({formErrors:t,isModified:!1,isSaved:!1,saving:!1,formPageProgress:a},(function(){window.scrollTo({top:0,left:0,behavior:"smooth"})}))}},{key:"gotoPrevFormPage",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.state.currentFormPageIndex){e.next=2;break}return e.abrupt("return");case 2:t=this.state.currentFormPageIndex-1,this.gotoFormPage(t);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"gotoNextFormPage",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state.currentFormPageIndex!==this.formPages.length-1){e.next=2;break}return e.abrupt("return");case 2:t=this.state.currentFormPageIndex+1,this.gotoFormPage(t);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"handleCloseModal",value:function(){this.state.creatingNewProject||this.setState({formHelpContent:null})}},{key:"gotoFormPage",value:function(){var e=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.next=2,this.setState({currentFormPageIndex:t,loading:!0,isSaved:!1,formErrors:null,verifyFormPageChange:!1});case 2:this.queryAPI(),window.scrollTo({top:0,left:0});case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"verifyFormPageChange",value:function(e){var t=this.state.wasModified,a=this.state.isSaved;t&&!a?this.setState({verifyFormPageChange:!0,nextPageAfterVerification:e}):this.gotoFormPage(e)}},{key:"verifySubmitNewProjectForm",value:function(){this.setState({creatingNewProjectErrors:null,verifySubmitNewProjectForm:!0})}},{key:"submitNewProjectForm",value:function(){var e=Object(u.a)(c.a.mark((function e(){var t;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("SUBMITTING"),e.next=3,this.setState({creatingNewProject:!0});case 3:return e.next=5,me("projects/new/submitFinal","POST",this.props.setErrorCode,{},!1,1e3);case 5:if(!(t=e.sent).errors){e.next=10;break}return console.log(t),this.setState({creatingNewProjectErrors:t.errors}),e.abrupt("return");case 10:this.setState({newlyCreatedProjectId:t.project_id,creatingNewProjectSuccess:!0,creatingNewProjectErrors:null,creatingNewProject:!1,verifySubmitNewProjectForm:!1});case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"shakeForm",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.isSaved){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.setState({formErrorShake:!0});case 4:window.setTimeout((function(){return t.setState({formErrorShake:!1})}),500);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"renderFormPage",value:function(e){return void 0===this.formPages[e]?r.a.createElement(kt,null):this.formPages[e].component()}},{key:"checkFormIsComplete",value:function(){console.log(this.state.formPageProgress);var e,t=Object(k.a)(this.state.formPageProgress);try{for(t.s();!(e=t.n()).done;){if("saved"!==e.value)return!1}}catch(a){t.e(a)}finally{t.f()}return!0}},{key:"render",value:function(){var e=this,t=this.checkFormIsComplete(),a=this.state.currentFormPageIndex===this.formPages.length-1;if(this.state.currentFormPageIndex)var n=this.getFormPagePathname();return this.state.creatingNewProjectSuccess?r.a.createElement(v.a,{to:b+"projects/"+this.state.newlyCreatedProjectId+"/dashboard"}):r.a.createElement("form",{id:"new-project-form",className:(this.state.formErrors?"errors":"")+(this.state.formErrorShake?"shake":"")+(this.state.saving?" saving":"")+(this.state.loading?" loading":""),ref:this.ref,onSubmit:this.state.isSaved?null:function(t){return e.submitFormPage(t)}},r.a.createElement(ct.a,{isOpen:!!(this.state.formHelpContent||this.state.verifyFormPageChange||this.state.verifySubmitNewProjectForm),contentLabel:"Hello there",onRequestClose:this.handleCloseModal.bind(this),className:"modal"+(this.state.verifyFormPageChange||this.state.verifySubmitNewProjectForm?" verify-back":""),overlayClassName:"modal-overlay",app:this.ref},this.state.verifyFormPageChange?r.a.createElement("div",null,r.a.createElement("p",null,"You have unsaved changes. ",this.state.nextPageAfterVerification===this.state.currentFormPage-1?"Are you sure you want to go back to the previous page?":"Are you sure you want to jump to this page?"),r.a.createElement("div",{className:"verify-back-row"},r.a.createElement("button",{className:"annotate-button grey-button",onClick:function(){return e.setState({verifyFormPageChange:!1})}},"No"),r.a.createElement("button",{className:"annotate-button",onClick:function(){return e.gotoFormPage(e.state.nextPageAfterVerification)}},"Yes"))):this.state.verifySubmitNewProjectForm?this.state.creatingNewProject?r.a.createElement("div",null,!this.state.creatingNewProjectErrors&&r.a.createElement("div",{className:"creating-new-project"},r.a.createElement("i",{className:"fa fa-cog fa-spin"}),"Creating new project..."),this.state.creatingNewProjectErrors&&r.a.createElement("div",null,r.a.createElement("div",{className:"form-notice form-errors"},r.a.createElement("i",{className:"fa fa-times"}),"An unexpected error occured:",r.a.createElement("ul",null,this.state.creatingNewProjectErrors.map((function(e,t){return r.a.createElement("li",null,e.message||JSON.stringify(e))})))),r.a.createElement("button",{className:"annotate-button grey-button",onClick:function(){return e.setState({creatingNewProjectErrors:null,creatingNewProject:!1,verifySubmitNewProjectForm:!1})}},r.a.createElement("i",{className:"fa fa-chevron-left"}),"Back"))):r.a.createElement("div",null,r.a.createElement("p",null,"Are you ready to create the project?"),r.a.createElement("div",{className:"verify-back-row"},r.a.createElement("button",{className:"annotate-button grey-button",onClick:function(){return e.setState({verifySubmitNewProjectForm:!1})}},"No"),r.a.createElement("button",{className:"annotate-button gold-stripey-button",onClick:function(){return e.submitNewProjectForm()}},"Create Project"))):this.state.formHelpContent),r.a.createElement("header",{className:"bg-header"},r.a.createElement("div",{id:"header-project-details",className:"title"},r.a.createElement("h1",null,"New project"))),r.a.createElement("header",{className:"new-project-header"},r.a.createElement("div",{className:"container flex-container"},this.formPages.map((function(t,a){return r.a.createElement(jt,{name:t.name,gotoFormPage:e.verifyFormPageChange.bind(e,a),pathname:t.pathname,key:a,pageProgress:e.state.formPageProgress[a],active:a===e.state.currentFormPageIndex,ready:"not_started"!==e.state.formPageProgress[a]})})))),r.a.createElement("main",{className:"container new-project"},r.a.createElement("div",{className:"new-project-form-body"},r.a.createElement(xe.a,{className:"transition-group"},r.a.createElement(Se.a,{key:this.state.currentFormPageIndex,timeout:{enter:400,exit:400},classNames:"fade"},r.a.createElement("section",{className:"route-section"},r.a.createElement("div",{className:"form-notice form-loading "+(this.state.loading?"":"hidden")},r.a.createElement("i",{className:"fa fa-cog fa-spin"}),"Loading..."),r.a.createElement("div",{className:"form-notice form-success "+(this.state.isSaved?"":"hidden")},r.a.createElement("i",{className:"fa fa-check"}),"This page is saved."),r.a.createElement("div",{className:"form-notice form-warning "+(this.state.loading||"requires_attention"!==this.state.formPageProgress[this.state.currentFormPageIndex]?"hidden":"")},r.a.createElement("i",{className:"fa fa-warning"}),"This form was reset by a previous form. Please fill it in again to continue."),r.a.createElement("div",{className:"form-notice small-margin-top form-warning "+(this.state.isSaved&&this.formPageDependencies[n]&&"saved"===this.state.formPageProgress[this.formPageDependencies[n][1]]?"":"hidden")},r.a.createElement("i",{className:"fa fa-warning"}),"Modifying the form below will reset the ",n&&this.formPageDependencies[n]&&this.formPageDependencies[n][0]&&this.formPageDependencies[n][0].replace("_"," ")," form."),r.a.createElement("div",{className:"form-notice form-errors "+(this.state.formErrors?"":"hidden")},r.a.createElement("i",{className:"fa fa-times"}),"Please fix the following errors before saving:",r.a.createElement("ul",null,this.state.formErrors&&this.state.formErrors.map((function(e,t){return r.a.createElement("li",{key:t},e.message)})),!this.state.formErrors&&r.a.createElement("li",null))),!this.state.loading&&this.renderFormPage(this.state.currentFormPageIndex),this.state.loading&&r.a.createElement(kt,{page:n})))))),r.a.createElement("div",{className:"new-project-submit-row"+(this.state.userIsModifying?" disabled":"")},r.a.createElement("div",{className:"container"},r.a.createElement("button",{type:"button",onClick:function(){return e.verifyFormPageChange(e.state.currentFormPageIndex-1)},className:"annotate-button new-project-button grey-button"+(0===this.state.currentFormPageIndex?" disabled":"")},r.a.createElement("i",{className:"fa fa-chevron-left"}),"Back"),r.a.createElement("div",{className:"buttons-right"},r.a.createElement("button",{type:this.state.isSaved?"button":"submit",className:"annotate-button new-project-button "+(this.state.wasModified||this.state.isSaved?"":"disabled")+(this.state.isSaved?" saved":"")+(this.state.saving?" saving":""),onClick:function(){return e.shakeForm()}},r.a.createElement("i",{className:"fa fa-"+(this.state.isSaved?"check":this.state.saving?"cog fa-spin":"save")}),this.state.saving?"Saving":"Save"+(this.state.isSaved?"d":"")),a?r.a.createElement("button",{type:"button",onClick:function(){return e.verifySubmitNewProjectForm()},className:"annotate-button new-project-button gold-stripey-button "+(this.state.isSaved&&t?"":"disabled")},"Create Project"):r.a.createElement("button",{type:"button",onClick:function(){return e.verifyFormPageChange(e.state.currentFormPageIndex+1)},className:"annotate-button new-project-button "+(this.state.isSaved?"":"disabled")},"Next",r.a.createElement("i",{className:"fa fa-chevron-right after"}))))))}}]),a}(n.Component),Ct=a(91),xt=["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"],St=["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4caf50","#8bc34a","#cddc39","#ffeb3b","#ffc107","#ff9800","#ff5722","#795548","#eee","#ccc","#aaa","#888","#444","#222"],Ot=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.a)(this,a),(n=t.call(this,e)).state={user:{profile_icon:{foreground:"#aaa",background:"#eee",icon:"user"}}},n}return Object(p.a)(a,[{key:"componentDidUpdate",value:function(e,t){O.a.isEqual(e.user,this.props.user)||O.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=Object(u.a)(c.a.mark((function e(){var t,a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this,console.log("saving"),a=this.state.user.profile_icon,e.next=5,this.setState({saving:!0});case 5:return e.next=7,me("users/set_profile_icon","POST",this.props.setErrorCode,a);case 7:n=e.sent,t.props.setUserProfileIcon(n.profile_icon),this.setState({saving:!1});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{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!==xt.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(Ct.TwitterPicker,{colors:St,color:this.state.user.profile_icon.foreground,onChangeComplete:this.handleForegroundColourChange.bind(this)}),r.a.createElement("h4",null,"Background colour"),r.a.createElement(Ct.TwitterPicker,{colors:St,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"},xt.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),_t=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("main",{class:"error-page"},r.a.createElement("h1",null,"500: Internal server error."),r.a.createElement("p",null,"An unexpected error has occurred."))}}]),a}(n.Component),Pt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),It=Object(v.h)(Pt),At=(a(393),function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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)),Tt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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("div",{class:"right"},r.a.createElement(f.b,{className:"button",to:b+"projects/new"},r.a.createElement("i",{class:"fa fa-plus-circle"}),"New project")))),r.a.createElement("main",{className:"container"},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(d.a)(this,a),t.call(this,e)}return Object(p.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(d.a)(this,a),t.call(this,e)}return Object(p.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),Ft=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"render",value:function(){return r.a.createElement("div",null,this.props.pageComponent)}}]),a}(n.Component),qt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.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),Rt=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){return Object(d.a)(this,a),t.call(this,e)}return Object(p.a)(a,[{key:"componentWillMount",value:function(){this.props.logout()}},{key:"render",value:function(){return r.a.createElement(v.a,{to:b})}}]),a}(n.Component),Ut=function(e){Object(h.a)(a,e);var t=Object(g.a)(a);function a(e){var n;return Object(d.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(p.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=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:return e.next=2,me("users/userData","GET",this.setErrorCode.bind(this),555);case 2:return t=e.sent,e.next=5,this.setState({user:t.user,loading:!1,loadingFadeOut:!0});case 5:window.setTimeout((function(){return a.setState({loadingFadeOut:!1})}),500);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"setUserData",value:function(e){this.setState({user:e})}},{key:"logout",value:function(){var e=Object(u.a)(c.a.mark((function e(){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:return e.next=6,me("users/logout","GET",this.setErrorCode.bind(this));case 6:e.sent,this.setState({user:null});case 8: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:"acceptInvitation",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("accept"),(a=this.state.user.project_invitations)[t].pending=!0,e.next=5,this.setState({invitations:a});case 5:return n=a[t]._id,e.next=8,me("projects/invitations/"+n+"/accept","POST",this.setErrorCode,{},null,555);case 8:e.sent,a[t].accepted=!0,a[t].pending=!1,this.setState({invitations:a});case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"declineInvitation",value:function(){var e=Object(u.a)(c.a.mark((function e(t){var a,n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("decline"),(a=this.state.user.project_invitations)[t].pending=!0,e.next=5,this.setState({invitations:a});case 5:return n=a[t]._id,e.next=8,me("http://localhost:3000/api/projects/invitations/"+n+"/decline","POST",this.setErrorCode,{},null,555);case 8:e.sent,a[t].declined=!0,a[t].pending=!1,this.setState({invitations:a});case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{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(f.a,null,r.a.createElement(y,null),r.a.createElement(It,{clearErrorCode:this.clearErrorCode.bind(this)}),(this.state.loading||this.state.loadingFadeOut)&&r.a.createElement(Dt,{fadingOut:this.state.loadingFadeOut}),!this.state.loading&&r.a.createElement("div",{className:"fade-in"},r.a.createElement(S,{user:this.state.user,loading:this.state.loading,acceptInvitation:this.acceptInvitation.bind(this),declineInvitation:this.declineInvitation.bind(this)}),!this.state.errorCode&&r.a.createElement(v.d,null,r.a.createElement(Bt,{user:this.state.user,path:b+"projects/:id/tagging",render:function(t){return r.a.createElement(Mt,Object.assign({},e.state,{pageComponent:r.a.createElement(ke,{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(Bt,{user:this.state.user,path:b+"projects/new",render:function(){return r.a.createElement(Nt,{setErrorCode:e.setErrorCode.bind(e)})}}),r.a.createElement(Bt,{user:this.state.user,path:b+"projects/:id",render:function(t){return r.a.createElement(Ft,Object.assign({},e.state,{pageTitle:"Project View",pageComponent:r.a.createElement(Ze,{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(Bt,{user:this.state.user,path:b+"projects",render:function(){return r.a.createElement(Tt,Object.assign({},e.state,{pageTitle:"Projects",pageComponent:r.a.createElement(Ne,{setProject:e.setProject.bind(e),setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(Bt,{user:this.state.user,path:b+"profile",render:function(){return r.a.createElement(At,Object.assign({},e.state,{pageTitle:"User Profile",pageComponent:r.a.createElement(Ot,{user:e.state.user,setUserProfileIcon:e.setUserProfileIcon.bind(e),setErrorCode:e.setErrorCode.bind(e)})}))}}),r.a.createElement(v.b,{path:b+"features",component:function(){return r.a.createElement(At,Object.assign({},e.state,{pageTitle:"Features",pageComponent:r.a.createElement(je,null)}))}}),r.a.createElement(v.b,{path:b+"logout",render:function(){return r.a.createElement(Rt,{logout:e.logout.bind(e)})}}),r.a.createElement(v.b,{path:b,render:function(){return e.state.user&&!e.state.loggingOut?r.a.createElement(v.a,{to:b+"projects"}):r.a.createElement(ot,{setUserData:e.setUserData.bind(e),setErrorCode:e.setErrorCode.bind(e)})}}),r.a.createElement(v.b,{render:function(){return r.a.createElement(At,Object.assign({},e.state,{pageTitle:"",pageComponent:r.a.createElement(re,null)}))}})," />"),401===this.state.errorCode&&r.a.createElement(Ae,{clearErrorCode:this.clearErrorCode.bind(this)}),403===this.state.errorCode&&r.a.createElement(ne,null),404===this.state.errorCode&&r.a.createElement(re,null),500===this.state.errorCode&&r.a.createElement(_t,null))),!this.state.loading&&r.a.createElement(qt,null))}}]),a}(n.Component),Bt=function(e){e.component;var t=Object(o.a)(e,["component"]);return r.a.createElement(v.b,Object.assign({},t,{render:function(e){t.user,Object(o.a)(t,["user"]);return t.user?t.render(e):r.a.createElement(v.a,{to:b+"login"})}}))},Ht=Ut;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}$/));i.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(Ht,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))},49:function(e,t){var a=function e(t){if(0==t.children.length)delete t.children;else for(var a in t.children)e(t.children[a])};e.exports.slash2txt=function(e){for(var t=[],a=0;a<e.length;a++)t.push(e[a].replace(/[^\/]*\//g," "));return t.join("\n")},e.exports.txt2json=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="name",s=e.split("\n"),i=0,o={children:[]};o[""+r]="entity";for(var l=[],c=o,u=-1,m=0;m<s.length;m++){var d=s[m].trim(),p=s[m].search(/\S/)+1;if(1==p&&u++,p<i)l=l.slice(0,p);else if(p==i+1)l.push(c);else if(p>i+1)return new Error("Unparsable tree.");i=p,(c={id:m,children:[],colorId:u})[r]=d,c.full_name=t[m],n[t[m]]&&(c.description=n[t[m]]),l.length>0&&l[l.length-1].children.push(c)}return a(o),o},e.exports.json2slash=function(e){return function(e){for(var t=e.split("\n"),a=[],n=1,r=[],s="",i=0;i<t.length;i++){var o=t[i].replace(/\s/g,"").replace(/\//g,"|"),l=t[i].search(/\S/)+1;l<n?r=r.slice(0,l-1):l==n+1&&r.push(s),n=l,s=o,a.push(r.join("/")+(r.length>0?"/":"")+o)}return a}(function(e){var t=[],a=1;function n(e){t.push(new Array(a).join(" ")+e.name.replace(/\|/,"/")),e.children?(a++,e.children.forEach(n),a--):e._children&&(a++,e._children.forEach(n),a--)}return e.children?e.children.forEach(n):e._children&&e._children.forEach(n),t.join("\n")}(e))}}},[[153,1,2]]]);
  //# sourceMappingURL=main.0d1b4d48.chunk.js.map