"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[2207],{72207:(e,t,r)=>{r.r(t),r.d(t,{User:()=>m,recreate_users_table:()=>l});var s=r(89675),a=r(94174),n=r(18611),o=r(2543);class i extends n.Table{query(){const e=n.redux.getStore("page").get("kiosk_project_id");if(e){const t=r(74448).parse_query("collaborators_one_project");return t.collaborators_one_project[0].project_id=e,t}return"collaborators"}no_changefeed(){return null!=n.redux.getStore("page").get("kiosk_project_id")}_change(e,t){const r=e.get();let n=a.h.get("user_map");if(null==n)return s.N.setState({user_map:r});e.get().map(((e,t)=>(e!==n.get(t)&&(n=n.set(t,e)),!1))),s.N.setState({user_map:n})}}function l(){n.redux.removeTable("users"),n.redux.createTable("users",i)}o.s&&null==n.redux.getStore("page").get("kiosk_project_id")||n.redux.createTable("users",i);var p=r(95841),c=r(80643),u=r(24873),_=r(3844);class m extends n.Component{shouldComponentUpdate(e){if(this.props.account_id!==e.account_id)return!0;const t=null!=e.user_map?e.user_map.get(this.props.account_id):void 0;return null==t||!t.equals(null!=this.props.user_map?this.props.user_map.get(this.props.account_id):void 0)||this.props.last_active!==e.last_active||this.props.show_original!==e.show_original||this.props.name!==e.name}render_last_active(){if(this.props.last_active)return _.createElement("span",null," ","(",_.createElement(p.TimeAgo,{date:this.props.last_active}),")")}render_original(e){let t;if(t=e.first_name&&e.last_name?e.first_name+" "+e.last_name:e.first_name?e.first_name:e.last_name?e.last_name:"No Name",this.props.show_original&&t!==this.props.name)return _.createElement(p.Tip,{placement:"top",title:"User Name",tip:"The name this user has given their account."},_.createElement("span",{style:{color:"#666"}}," (",t,")"))}name(e){return(0,c.trunc_middle)(null!=this.props.name?this.props.name:`${e.first_name} ${e.last_name}`,50).trim()||"No Name"}render(){if(null==this.props.user_map||0===this.props.user_map.size)return _.createElement("span",null,"Loading...");let e=null!=this.props.user_map?this.props.user_map.get(this.props.account_id):void 0;if(null==e)return(0,c.is_valid_uuid_string)(this.props.account_id)?(s.N.fetch_non_collaborator(this.props.account_id),_.createElement("span",null,"Loading...")):_.createElement("span",null,"Unknown User ",this.props.account_id);{e=e.toJS();const t=this.name(e);return _.createElement("span",null,this.props.show_avatar&&_.createElement(_.Fragment,null,_.createElement(u.q,{account_id:this.props.account_id,first_name:t}),_.createElement(p.Space,null)),t,this.render_original(e),this.render_last_active())}}}}}]);