@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 181 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[1565],{51565:(e,t,n)=>{n.r(t),n.d(t,{AccountPage:()=>Wr});var r=n(431),a=n(32295),i=n(33667),o=n(63663),l=n(62840),s=n(38628),c=n(70919),u=n(41780),d=n(9037),p=n(24620),y=n(13435),f=n(56393),h=n(19990),m=n(42306),v=n(1362),_=n(14409),g=n(81938),b=n(85460),E=n(48587);function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){w(e,t,n[t])}))}return e}var S={display:"inline-block",padding:"10px",borderRadius:"50%",width:"50px",height:"50px",marginRight:"10px",textAlign:"center",verticalAlign:"middle"},R={width:"25px",height:"25px",top:"0",padding:"4px",fontSize:"15px"},x=k({},S,{display:"inline-block",position:"relative",backgroundSize:"contain",padding:"0"}),C={backgroundColor:y.COLORS.GRAY_D,color:"white",fontSize:"24px",display:"inline-block",padding:"6px",height:"50px",marginRight:"10px",textAlign:"center",verticalAlign:"middle",borderRadius:"10px"},O={facebook:{backgroundColor:"#395996",color:"white"},google:{backgroundColor:"#DC4839",color:"white"},twitter:{backgroundColor:"#55ACEE",color:"white"},github:{backgroundColor:"white",color:"black"},sso:{backgroundColor:"black",color:"white"}};function j(e){return(0,E.V)({name:e.name,display:e.display})}var T=function(e){var t=e.strategy,n=e.small,r=void 0!==n&&n,i=k({},O.github,e.defaultIconStyle),o=t.name,l=t.display,s=t.icon,c=r?R:{},u=k({},S,c);if(g.l.indexOf(o)>=0&&(0,h.isIconName)(o))return a.React.createElement(h.Icon,{name:o,style:k({},u,O[o])});if((0,h.isIconName)(s))return a.React.createElement(h.Icon,{name:s,style:k({},u,i)});if(null!=s){var d=k({},x,{backgroundImage:'url("'.concat(s,'")')},c);return a.React.createElement("div",{style:d})}return null==s?a.React.createElement(h.Icon,{name:"link",style:k({},u,i)}):a.React.createElement("div",{style:C},l)},A=function(e){var t=e.strategy,n=e.disabled,r=void 0!==n&&n,i=e.get_api_key,o=t.name;if("email"===o)return null;var l=function(e){var t="";return r||("sso"===e?t=(0,f.join)(u.appBasePath,"sso"):(t=(0,f.join)(u.appBasePath,"auth",e),i&&(t+="?get_api_key=".concat(i)))),t}(o),s=j(t),d=function(e,t){return a.React.createElement("span",null,(0,h.isIconName)(e)?a.React.createElement(h.Icon,{name:e}):void 0," ",t)}(o,s),p=function(){var e={fontSize:"28px"};return r&&(e.opacity=.5),e}();return r?a.React.createElement("span",{key:o,style:p},a.React.createElement(h.Tip,{placement:"bottom",title:d,tip:"Please agree to the terms of service first."},a.React.createElement(T,{strategy:t}))):a.React.createElement("a",{href:l,key:o,style:p},a.React.createElement(h.Tip,{placement:"bottom",title:d,tip:function(e){return a.React.createElement(a.React.Fragment,null,"Use ",e," to sign into your ",a.React.createElement(c.w3,null)," account instead of an email address and password.")}(s)},a.React.createElement(T,{strategy:t})))},P=function(e){var t=e.strategies,n=void 0===t?(0,b.List)([]):t,r=e.get_api_key,i=e.no_heading,o=e.style,l=e.disabled,s=n.some((function(e){return!1===e.get("public",!0)}));return a.React.createElement("div",{style:o},function(){if(!i){var e={marginTop:0};return l&&(e.opacity=.5),a.React.createElement("h3",{style:e},"Connect with")}}(),a.React.createElement("div",{style:{display:"flex"}},n.filter((function(e){return e.get("public",!0)||e.get("do_not_hide",!1)})).map((function(e){return a.React.createElement(A,{key:e.get("name"),disabled:l,get_api_key:r,strategy:e.toJS()})})),function(){if(s)return a.React.createElement(A,{disabled:l,strategy:{name:"sso",display:"Single-Sign-On",icon:"api",public:!0}})}()))},I=n(4668),z=n(63505);function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i=[],o=!0,l=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);o=!0);}catch(e){l=!0,a=e}finally{try{o||null==n.return||n.return()}finally{if(l)throw a}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?L(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var D=function(e){var t=function(){r.sign_in(l,d)},n=(0,a.useActions)("page");(0,a.useEffect)((function(){return n.set_sign_in_func(t),function(){return n.remove_sign_in_func()}}),[]);var r=(0,a.useActions)("account"),o=B((0,a.useState)(""),2),l=o[0],s=o[1],c=B((0,a.useState)(""),2),d=c[0],p=c[1];return z.createElement("div",null,z.createElement(i.X2,null,z.createElement(i.JX,{md:5,xs:12},z.createElement(I.Z,{style:{width:"100%",marginBottom:"5px"},value:l,type:"email",name:"email",placeholder:"Email address","cocalc-test":"sign-in-email",autoFocus:!0,onChange:function(e){var t=e.target.value;s(t),r.setState({sign_in_email_address:t,sign_in_error:void 0})}})),z.createElement(i.JX,{md:5,xs:12},z.createElement(I.Z.Password,{placeholder:"Password",style:{width:"100%",marginBottom:"5px"},value:d,type:"password",name:"password","cocalc-test":"sign-in-password",onChange:function(t){p(t.target.value),e.sign_in_error&&r.setState({sign_in_error:void 0})},onKeyDown:function(e){13==e.keyCode&&(e.preventDefault(),t())}})),z.createElement(i.JX,{md:2,xs:12},z.createElement(i.zx,{"cocalc-test":"sign-in-submit",style:{height:34},className:"pull-right",onClick:t},"Sign in"))),z.createElement(i.X2,null,z.createElement(i.JX,{xs:7,xsOffset:5,style:{paddingLeft:15}},z.createElement("div",{style:{marginTop:"1ex"}},z.createElement("a",{style:{fontSize:null!=e.sign_in_error?"16pt":"12pt",color:"white"},href:(0,f.join)(u.appBasePath,"/auth/password-reset")},"Forgot Password?")))),z.createElement(i.X2,null,z.createElement(i.JX,{xs:12},z.createElement("div",null,z.createElement(P,{strategies:e.strategies,get_api_key:e.get_api_key,no_heading:!0})))),z.createElement(i.X2,{className:"form-inline pull-right",style:{clear:"right",width:"100%"}},z.createElement(i.JX,{xs:12},function(){if(e.sign_in_error)return z.createElement(_.X,{error_component:z.createElement(h.Markdown,{value:e.sign_in_error}),body_style:{fontSize:"100%"},onClose:function(){return r.setState({sign_in_error:void 0})}})}())))},U=n(63505);function M(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N(e){return N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},N(e)}function W(e,t){return!t||"object"!==G(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function F(e,t){return F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},F(e,t)}var G=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var X=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&F(e,t)}(_,e);var t,n,r=(t=_,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=N(t);if(n){var a=N(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return W(this,e)});function _(e){var t,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,_),t=r.call(this,e);var i=(null===(n=e.terms_of_service)||void 0===n?void 0:n.length)>0||(null===(a=e.terms_of_service_url)||void 0===a?void 0:a.length)>0;return t.state={show_terms:i},t}var g=_.prototype;return g.render_forgot_password=function(){return U.createElement("a",{href:(0,f.join)(u.appBasePath,"/auth/password-reset")},"Forgot Password?")},g.render_launch_action=function(){if(null!=this.props.type&&null!=this.props.launch&&null!=this.props.images){var e=(0,d.WS)(this.props.type);if(null!=e){var t,n="info";if("csi"==this.props.type){var r=(0,l.Mn)(this.props.images,this.props.launch);null==r?(n="danger",t=U.createElement(U.Fragment,null,"Custom Software Image ",U.createElement("code",null,this.props.launch)," does not exist!")):t=U.createElement(U.Fragment,null,e,' "',r,'"')}else t=U.createElement(U.Fragment,null,e,": ",U.createElement("code",null,this.props.launch));return U.createElement(i.X2,{style:{marginBottom:"20px",textAlign:"center"}},U.createElement(i.bZ,{bsStyle:n,banner:!0,style:{width:"100%"}},U.createElement("b",null,"Launch action:")," ",t))}}},g.render_main_page=function(){var e;if((this.props.remember_me||m.a.get("auth_token"))&&!this.props.get_api_key)return U.createElement(v.g,null);var t=this.props.logo_square?this.props.logo_square:o.Vl,n=this.props.logo_rectangular?this.props.logo_rectangular:o.vL,r=!!this.props.logo_square&&!!this.props.logo_rectangular,a={img_icon:t,img_name:n,customized:r,img_opacity:1,color:r?y.COLORS.GRAY_D:"white",bg_color:r?y.COLORS.BLUE_LLL:y.COLORS.LANDING.LOGIN_BAR_BG,border:"5px solid ".concat(y.COLORS.LANDING.LOGIN_BAR_BG)};return e={fontSize:h.UNIT,backgroundColor:y.COLORS.LANDING.LOGIN_BAR_BG,padding:5,margin:0,borderRadius:4},U.createElement("div",{style:{margin:h.UNIT}},this.render_launch_action(),this.render_forgot_password(),U.createElement(i.X2,{style:e,className:"visible-xs"},U.createElement(D,{get_api_key:this.props.get_api_key,signing_in:this.props.signing_in,sign_in_error:this.props.sign_in_error,has_account:this.props.has_account,xs:!0,strategies:this.props.strategies,color:a.color}),U.createElement("div",{style:{clear:"both"}})),U.createElement(i.X2,{style:{backgroundColor:a.bg_color,border:a.border,padding:5,margin:0,marginBottom:20,borderRadius:5,position:"relative",whiteSpace:"nowrap",minHeight:160},className:"hidden-xs"},U.createElement("div",{style:{width:490,zIndex:10,position:"absolute",top:h.UNIT,right:h.UNIT,fontSize:"11pt",float:"right"}},U.createElement(D,{get_api_key:this.props.get_api_key,signing_in:this.props.signing_in,sign_in_error:this.props.sign_in_error,has_account:this.props.has_account,xs:!1,strategies:this.props.strategies,color:a.color})),this.props._is_configured?U.createElement("div",{style:{display:"inline-block",backgroundImage:"url('".concat(a.img_icon,"')"),backgroundSize:"contain",height:75,width:75,margin:5,verticalAlign:"center",backgroundRepeat:"no-repeat"}}):void 0,a.customized?void 0:U.createElement("div",{className:"hidden-sm",style:{display:"inline-block",fontFamily:"sans-serif",fontSize:"28px",top:h.UNIT,left:7*h.UNIT,width:300,height:75,position:"absolute",color:a.color,opacity:a.img_opacity,backgroundImage:"url('".concat(a.img_name,"')"),backgroundSize:"contain",backgroundRepeat:"no-repeat"}}),a.customized?U.createElement("img",{className:"hidden-sm",src:a.img_name,style:{display:"inline-block",top:h.UNIT,left:7*h.UNIT,width:"auto",height:50,position:"absolute",color:a.color,opacity:a.img_opacity}}):void 0,U.createElement("div",{className:"hidden-sm"},U.createElement(c.bO,{style:{fontWeight:700,fontSize:"15px",fontFamily:"sans-serif",bottom:10,left:7*h.UNIT,display:"inline-block",position:"absolute",color:a.color}}))),!this.props.get_api_key&&U.createElement(i.X2,{style:{color:y.COLORS.GRAY,fontSize:"16pt",margin:"150px 0",textAlign:"center"}},U.createElement(i.JX,{sm:12},U.createElement("a",{href:(0,f.join)(u.appBasePath,"/auth/sign-up")},"Create a new account")," ","or"," ",U.createElement("a",{href:(0,f.join)(u.appBasePath,"/auth/sign-in")},"sign in with an existing account"),".")),U.createElement(c.$_,null))},g.render=function(){var e=this.render_main_page();if(!this.props.get_api_key)return e;var t=(0,p.capitalize)(this.props.get_api_key);return U.createElement("div",null,U.createElement("div",{style:{padding:"15px"}},U.createElement("h1",null,"CoCalc API Key Access for ",t),U.createElement("div",{style:{fontSize:"12pt",color:"#444"}},t," would like your CoCalc API key.",U.createElement("br",null),U.createElement("br",null),"Sign in below to grant ",U.createElement("b",null,"full access")," to all of your CoCalc projects to ",t,", until you explicitly revoke your API key in Account preferences.",U.createElement("br",null),U.createElement("br",null),"If necessary, please"," ",U.createElement(h.A,{href:(0,f.join)(u.appBasePath,"/auth/sign-up")},"create a new account")," ","then revisit this page and sign in here.")),U.createElement("hr",null),e)},_.reduxProps=function(){var e;return M(e={page:{get_api_key:a.rtypes.string},customize:{site_name:a.rtypes.bool,is_commercial:a.rtypes.bool,_is_configured:a.rtypes.bool,logo_square:a.rtypes.string,logo_rectangular:a.rtypes.string,help_email:a.rtypes.string,terms_of_service:a.rtypes.string,terms_of_service_url:a.rtypes.string,email_signup:a.rtypes.bool},account:{sign_in_email_address:a.rtypes.string}},d.A1,{type:a.rtypes.string,launch:a.rtypes.string}),M(e,s.A1,{images:a.rtypes.immutable}),e},_}(a.Component),q=(0,a.rclass)(X),Z=n(50455),K=n(84018),J=n.n(K),Y=n(10845),Q=n.n(Y),H=n(4148),$=n.n(H),V=(n(58200),n(63505));function ee(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function te(e,t,n,r,a,i,o){try{var l=e[i](o),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,a)}function ne(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function o(e){te(i,r,a,o,l,"next",e)}function l(e){te(i,r,a,o,l,"throw",e)}o(void 0)}))}}function re(e){return re=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},re(e)}function ae(e,t){return!t||"object"!==oe(t)&&"function"!=typeof t?ee(e):t}function ie(e,t){return ie=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ie(e,t)}var oe=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var le=function(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},se=160,ce=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ie(e,t)}(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=re(t);if(n){var a=re(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return ae(this,e)});function o(e,t){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=r.call(this,e,t)).is_mounted=!0;var i,l=ee(n);return n.set_image=(i=ne((function(e){var t,n;return le(this,(function(r){switch(r.label){case 0:l.setState({is_loading:!0}),t=a.redux.getTable("account"),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,t.set({profile:{image:e}},"none")];case 2:return r.sent(),[3,5];case 3:return n=r.sent(),l.is_mounted&&l.setState({error:"".concat(n)}),[3,5];case 4:return l.is_mounted&&l.setState({is_loading:!1}),[7];case 5:return[2]}}))})),function(e){return i.apply(this,arguments)}),n.handle_gravatar_click=function(){var e;n.props.email_address&&n.set_image((e=n.props.email_address,"https://www.gravatar.com/avatar/".concat(Q()(e.toLowerCase()),"?d=identicon&s=30")))},n.handle_default_click=function(){return n.set_image("")},n.handle_image_file=function(e){if(n.setState({is_dragging_image_over_dropzone:!1}),"string"!=typeof e){var t=new FileReader;t.onload=function(e){n.is_mounted&&n.setState({custom_image_src:e.target.result})},t.readAsDataURL(e)}else n.setState({custom_image_src:e})},n.handle_image_file_upload=function(e){var t,r=e.target.files;r.length>0&&r[0].type.startsWith("image/")&&(t=r[0]),null!=t&&n.handle_image_file(t)},n.handle_image_file_drop=function(e){e.preventDefault(),e.stopPropagation();var t=e.dataTransfer.files,r=!0,a=!1,i=void 0;try{for(var o,l=t[Symbol.iterator]();!(r=(o=l.next()).done);r=!0){var s=o.value;if(s.type.startsWith("image/"))return void n.handle_image_file(s)}}catch(e){a=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw i}}var c=e.dataTransfer.getData("text")||"";(c.startsWith("http")||c.startsWith("data:image"))&&n.handle_image_file(c)},n.handle_image_file_paste=function(e){e.preventDefault();var t=e.clipboardData.items,r=!0,a=!1,i=void 0;try{for(var o,l=t[Symbol.iterator]();!(r=(o=l.next()).done);r=!0){var s=o.value;if(s.type.startsWith("image/"))return void n.handle_image_file(s.getAsFile())}}catch(e){a=!0,i=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw i}}var c=e.clipboardData.getData("text")||"";(c.startsWith("http")||c.startsWith("data:image"))&&n.handle_image_file(c)},n.handle_image_file_input=function(e){e.preventDefault();var t=e.target.files;t.length>0&&t[0].type.startsWith("image/")&&n.handle_image_file(t[0])},n.state={is_dragging_image_over_dropzone:!1,crop:{unit:"%",width:100,aspect:1}},n}var l=o.prototype;return l.componentWillUnmount=function(){this.is_mounted=!1},l.render_options_gravatar=function(){var e=this;if(this.props.email_address)return V.createElement(V.Fragment,null,V.createElement(i.zx,{style:{marginTop:"5px"},onClick:this.handle_gravatar_click},"Gravatar")," ",V.createElement("a",{href:"#",onClick:function(t){t.preventDefault(),e.setState({show_gravatar_explanation:!0})}},"What is this?"),this.state.show_gravatar_explanation?V.createElement(i.tW,{style:{marginTop:"10px",marginBottom:"10px"}},"Gravatar is a service for using a common avatar across websites. Go to the"," ",V.createElement("a",{href:"https://en.gravatar.com",target:"_blank",rel:"noopener"},"Wordpress Gravatar site")," ","and sign in (or create an account) using ",this.props.email_address,".",V.createElement("br",null),V.createElement("br",null),V.createElement(i.zx,{onClick:function(){return e.setState({show_gravatar_explanation:!1})}},"Close")):V.createElement("br",null))},l.render_options=function(){var e=this;return V.createElement(V.Fragment,null,V.createElement(i.zx,{style:{marginTop:"5px"},onClick:this.handle_default_click},"Default")," ",V.createElement("a",{href:"#",onClick:function(t){t.preventDefault(),e.setState({show_default_explanation:!0})}},"What is this?"),this.state.show_default_explanation?V.createElement(i.tW,{style:{marginTop:"10px",marginBottom:"10px"}},"The default avatar is a circle with the first letter of your name.",V.createElement("br",null),V.createElement("br",null),V.createElement(i.zx,{onClick:function(){return e.setState({show_default_explanation:!1})}},"Close")):V.createElement("br",null),this.render_options_gravatar(),V.createElement(i.NI,{type:"file",onChange:this.handle_image_file_input,className:"btn btn-default",style:{marginTop:"5px"}}),V.createElement("br",null),V.createElement("div",{className:"webapp-image-drop"+(this.state.is_dragging_image_over_dropzone?" webapp-image-drop-dragging":""),onDrop:this.handle_image_file_drop,onPaste:this.handle_image_file_paste,onDragEnter:function(){return e.setState({is_dragging_image_over_dropzone:!0})},onDragLeave:function(){return e.setState({is_dragging_image_over_dropzone:!1})}},this.state.is_dragging_image_over_dropzone?"Drop an image here.":"Drag a custom image here."))},l.handle_save_cropping=function(){var e=this;return ne((function(){return le(this,(function(t){e.setState({custom_image_src:void 0});try{e.set_image(e.state.croppedImageUrl||"")}catch(t){console.warn("ERROR cropping -- ",t),e.setState({error:"".concat(t)})}return[2]}))}))()},l.makeClientCrop=function(e){var t=this;return ne((function(){var n;return le(this,(function(r){switch(r.label){case 0:return t.imageRef&&e.width&&e.height?[4,ue(t.imageRef,e)]:[3,2];case 1:n=r.sent(),t.setState({croppedImageUrl:n}),r.label=2;case 2:return[2]}}))}))()},l.render_crop_selection=function(){var e=this;return V.createElement(V.Fragment,null,this.state.custom_image_src&&V.createElement($(),{src:this.state.custom_image_src,crop:this.state.crop,circularCrop:!0,minWidth:20,minHeight:20,onChange:function(t){e.setState({crop:t})},onImageLoaded:function(t){e.imageRef=t},onComplete:function(t){return e.makeClientCrop(t)}}),this.state.croppedImageUrl&&V.createElement(V.Fragment,null,"Preview: ",V.createElement(h.ProfileIcon,{url:this.state.croppedImageUrl,size:42})),V.createElement("br",null),V.createElement(i.Si,null,V.createElement(i.zx,{style:{marginTop:"5px"},onClick:function(){return e.handle_save_cropping()},bsStyle:"success"},"Save"),V.createElement(i.zx,{style:{marginTop:"5px"},onClick:function(){return e.setState({custom_image_src:void 0})}},"Cancel")))},l.render_loading=function(){return V.createElement("div",null,"Saving... ",V.createElement(h.Loading,null))},l.render_error=function(){var e=this;if(null!=this.state.error)return V.createElement(h.ErrorDisplay,{error:this.state.error,onClose:function(){return e.setState({error:void 0})}})},l.render=function(){return this.state.is_loading?this.render_loading():null!=this.state.custom_image_src?this.render_crop_selection():V.createElement(V.Fragment,null,this.render_error(),V.createElement("br",null),this.render_options())},o}(a.Component);function ue(e,t){return de.apply(this,arguments)}function de(){return(de=ne((function(e,t){var n,r,a,i,o;return le(this,(function(l){switch(l.label){case 0:if(null==t.width||null==t.height)throw Error("Error cropping image -- width and height not set");if(n=document.createElement("canvas"),r=e.naturalWidth/e.width,a=e.naturalHeight/e.height,n.width=t.width,n.height=t.height,null==(i=n.getContext("2d")))throw Error("Error cropping image; please retry later");return i.drawImage(e,t.x*r,t.y*a,t.width*r,t.height*a,0,0,t.width,t.height),t.width>se||t.height>se?((o=document.createElement("canvas")).width=se,o.height=se,[4,J()().resize(n,o)]):[3,2];case 1:return l.sent(),[2,o.toDataURL("image/jpeg")];case 2:return[2,n.toDataURL("image/jpeg")];case 3:return[2]}}))}))).apply(this,arguments)}var pe=n(31727),ye=n(85733),fe=n(63505);function he(e){return he=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},he(e)}function me(e,t){return!t||"object"!==_e(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ve(e,t){return ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ve(e,t)}var _e=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var ge,be=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ve(e,t)}(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=he(t);if(n){var a=he(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return me(this,e)});function o(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=r.call(this,e,t)).state={show_instructions:!1},n}var l=o.prototype;return l.onColorChange=function(e){(0,pe.e)({profile:{color:e}})},l.render_header=function(){return fe.createElement(fe.Fragment,null,fe.createElement(ye.q,{account_id:this.props.account_id,size:48}),fe.createElement(h.Space,null),fe.createElement(h.Space,null),"Avatar")},l.render=function(){return null==this.props.account_id||null==this.props.profile?fe.createElement(h.Loading,null):fe.createElement(i.s_,{header:this.render_header()},fe.createElement(h.LabeledRow,{label:"Color"},fe.createElement(Z.Z,{color:this.props.profile.get("color"),justifyContent:"flex-start",onChange:this.onColorChange})),fe.createElement(h.LabeledRow,{label:"Style"},fe.createElement(ce,{account_id:this.props.account_id,email_address:this.props.email_address,profile:this.props.profile})))},o.reduxProps=function(){return{account:{account_id:a.rtypes.string,profile:a.rtypes.immutable.Map}}},o}(a.Component),Ee=(0,a.rclass)(be),we=n(61655),ke=n(63505),Se=function(){var e=(0,a.useTypedRedux)("account","terminal");return null==e?ke.createElement(h.Loading,null):ke.createElement(i.s_,{header:ke.createElement(ke.Fragment,null," ",ke.createElement(h.Icon,{name:"terminal"})," Terminal")},ke.createElement(h.LabeledRow,{label:"Terminal color scheme"},ke.createElement(h.SelectorInput,{selected:null==e?void 0:e.get("color_scheme"),options:we.iw,on_change:function(e){return(0,pe.e)({terminal:{color_scheme:e}})}})))},Re=n(67941),xe=n(63505),Ce={"Build project / run code":(ge=Re.IS_MACOS)?"shift+enter; option+T":"shift+enter; alt+T","Force build project":ge?"shift+option+enter; shift+option+T":"shift+alt+enter; shift+alt+T","LaTeX and markdown forward and inverse search":ge?"⌘+enter":"alt+enter","Make text smaller":"control+<","Make text larger":"control+>","Toggle commenting selection":"control+/","Go to line":ge?"⌘+L":"control+L",Find:ge?"⌘+F":"control+F","Find next":ge?"⌘+G":"control+G",Replace:ge?"⌘+H":"control+H","Fold/unfold selected code":"control+Q","Fill paragraph (like in Emacs)":ge?"option+Q":"alt+Q","Shift selected text right":"tab","Shift selected text left":"shift+tab","Split view in Sage worksheet":"shift+control+I","Autoindent selection":"control+'","Format code (use Prettier, etc)":ge?"⌘+shift+F":"control+shift+F","Create multiple cursors":ge?"⌘+click":"control+click","LaTeX (etc) simple autocomplete":ge?"option+space":"control+space","Sage autocomplete":"tab","Split cell in Sage worksheet":"control+;"},Oe={"Shift-Enter":"shift+enter",Enter:"enter (shift+enter for newline)"},je=function(){var e=(0,a.useTypedRedux)("account","evaluate_key");return xe.createElement(i.s_,{header:xe.createElement(xe.Fragment,null,xe.createElement(h.Icon,{name:"keyboard"})," Keyboard shortcuts")},function(){var e=[];for(var t in Ce){var n=Ce[t];e.push(xe.createElement(h.LabeledRow,{key:t,label:t,label_cols:8},n))}return e}(),null==e?xe.createElement(h.Loading,null):xe.createElement(h.LabeledRow,{label:"Sage Worksheet evaluate key",label_cols:8},xe.createElement(h.SelectorInput,{options:Oe,selected:e,on_change:function(e){(0,pe.e)({evaluate_key:e})}})))},Te=n(53534),Ae=n(97636),Pe=n(85215),Ie=n(18760),ze=n(11018);function Le(e){return Le=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Le(e)}function Be(e,t){return!t||"object"!==Ue(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function De(e,t){return De=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},De(e,t)}var Ue=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function Me(e){return a.React.createElement("div",null,a.React.createElement("div",{style:{height:"26px"}},a.React.createElement(i.zx,{disabled:e.show_confirmation,className:"pull-right",style:e.style,onClick:e.initial_click},a.React.createElement(h.Icon,{name:"trash"})," Delete Account...")),e.show_confirmation?a.React.createElement(Ne,{confirm_click:e.confirm_click,cancel_click:e.cancel_click,required_text:e.user_name}):void 0)}var Ne=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&De(e,t)}(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=Le(t);if(n){var a=Le(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return Be(this,e)});function o(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=r.call(this,e,t)).state={confirmation_text:""},n}var l=o.prototype;return l.render_error=function(){if(null!=this.props.account_deletion_error)return a.React.createElement(h.ErrorDisplay,{error:this.props.account_deletion_error})},l.render=function(){var e=this;return a.React.createElement(i.tW,{style:{marginTop:"26px",textAlign:"center",fontSize:"15pt",backgroundColor:"darkred",color:"white"}},"Are you sure you want to DELETE YOUR ACCOUNT?",a.React.createElement("br",null),"You will ",a.React.createElement("span",{style:{fontWeight:"bold"}},"immediately")," lose access to ",a.React.createElement("span",{style:{fontWeight:"bold"}},"all")," of your projects, and any subscriptions will be canceled.",a.React.createElement("br",null),a.React.createElement("hr",{style:{marginTop:"10px",marginBottom:"10px"}}),"Do NOT delete your account if you are a current student in a course on CoCalc!"," ",a.React.createElement(h.A,{href:"https://github.com/sagemathinc/cocalc/issues/3243"},"Why?"),a.React.createElement("hr",{style:{marginTop:"10px",marginBottom:"10px"}}),'To DELETE YOUR ACCOUNT, enter "',this.props.required_text,'" below:',a.React.createElement("br",null),a.React.createElement("input",{autoFocus:!0,value:this.state.confirmation_text,placeholder:"Full name",type:"text",onChange:function(t){e.setState({confirmation_text:t.target.value})},style:{marginTop:"1ex",padding:"5px",color:"black",width:"90%"}}),a.React.createElement(i.Si,{style:{textAlign:"center",marginTop:"15px"}},a.React.createElement(i.zx,{disabled:this.state.confirmation_text!==this.props.required_text,bsStyle:"danger",onClick:function(){return e.props.confirm_click()}},a.React.createElement(h.Icon,{name:"trash"})," Yes, DELETE MY ACCOUNT"),a.React.createElement(i.zx,{bsStyle:"primary",onClick:this.props.cancel_click},"Cancel")),this.render_error())},o.reduxProps=function(){return{account:{account_deletion_error:a.rtypes.string}}},o}(a.Component),We=n(81671),Fe=n(24809),Ge=n(61741),Xe=function(e){var t,n=e.everywhere,r=e.sign_in,i=e.highlight,o=e.style,l=a.redux.getStore("account"),s=null!==(t=l.get("email_address"))&&void 0!==t?t:"your account",c="Are you sure you want to sign ".concat(s," out ");return c+=n?"on all web browsers? Every web browser will have to reauthenticate before using this account again.":"on this web browser?",l.get("is_anonymous")&&(c+="\n Everything you have done using this TEMPORARY ACCOUNT will be immediately deleted! If you would like to save your work to a new account, click cancel and sign up below."),a.React.createElement(We.Z,{title:a.React.createElement("div",{style:{maxWidth:"60ex"}},c),onConfirm:function(){var e=a.redux.getActions("account");null!=e&&e.sign_out(!!n,!!r)},okText:"Yes, sign out".concat(n?" everywhere":""),cancelText:"Cancel"},a.React.createElement(Fe.Z,{icon:a.React.createElement(Ge.Z,null),type:i?"primary":void 0,style:o},r?a.React.createElement("span",null,"Sign in to your account..."):a.React.createElement("span",null,"Sign out",n?" everywhere":"","...")))},qe=n(63505);function Ze(e,t,n,r,a,i,o){try{var l=e[i](o),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,a)}function Ke(e){return Ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Ke(e)}function Je(e,t){return!t||"object"!==Qe(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Ye(e,t){return Ye=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ye(e,t)}var Qe=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var He=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ye(e,t)}(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=Ke(t);if(n){var a=Ke(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return Je(this,e)});function o(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=r.call(this,e,t)).mounted=!0,n.state={password:"",state:"init"},n}var l=o.prototype;return l.componentWillUnmount=function(){this.mounted=!1},l.render_confirm=function(){var e,t,n=this;switch(this.state.state){case"confirm-delete":e="delete",t="Are you sure you want to delete your API key? ";break;case"confirm-regenerate":e="regenerate",t="Are you sure you want to regenerate your API key? ";break;default:throw Error("bug -- invalid state for render_confirm")}return qe.createElement("div",null,t," ",qe.createElement("b",null,qe.createElement("i",null,"Anything using the current API key will stop working.")),qe.createElement("br",null),qe.createElement("br",null),qe.createElement(i.zx,{onClick:function(){return n.setState({state:"showkey"})}},"Cancel"),qe.createElement(i.zx,{onClick:function(){return n.do_action(e)},style:{marginLeft:"5px"},bsStyle:"danger"},"Yes"))},l.do_action=function(e){var t,n=this;return(t=function(){var t,r;return function(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(a){switch(a.label){case 0:n.setState({state:"loading"}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Ae.webapp_client.account_client.api_key(e,n.state.password)];case 2:return t=a.sent(),n.mounted&&n.setState({api_key:t,state:"showkey"}),[3,4];case 3:return r=a.sent(),n.mounted&&n.setState({error:r,password:"",api_key:void 0,state:"error"}),[3,4];case 4:return[2]}}))},function(){var e=this,n=arguments;return new Promise((function(r,a){var i=t.apply(e,n);function o(e){Ze(i,r,a,o,l,"next",e)}function l(e){Ze(i,r,a,o,l,"throw",e)}o(void 0)}))})()},l.render_api_key=function(){return this.state.api_key?qe.createElement("div",null,qe.createElement(h.CopyToClipBoard,{value:this.state.api_key,style:{display:"inline-block",width:"100%"}}),this.render_button("delete","Delete key"),qe.createElement("span",{style:{marginRight:"5px"}}),this.render_button("regenerate","Regenerate key")):qe.createElement("div",null,"You do not have an API key.",qe.createElement("br",null),qe.createElement("br",null),this.render_button("regenerate","Create API Key"))},l.click_action_button=function(e){switch(this.state.state){case"init":return void this.setState({state:"password"});case"password":return void this.do_action(e);case"showkey":return void(this.state.api_key?this.setState({state:"confirm-".concat(e)}):this.do_action(e))}},l.render_button=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this;if(null==t)switch(e){case"get":t="Reveal Key";break;case"delete":t="Delete Key";break;case"regenerate":t="Regenerate Key"}return(0,p.startswith)(this.state.state,"confirm-")&&(n=!0),qe.createElement(i.zx,{onClick:function(){return r.click_action_button(e)},disabled:n},t,this.state.api_key||"init"===this.state.state?"...":"")},l.render_get_password=function(){var e=this;return qe.createElement("div",{style:{display:"flex"}},qe.createElement(i.NI,{autoFocus:!0,style:{flex:1,marginRight:"5px"},type:"password",ref:"password",placeholder:"Current password",value:this.state.password,onChange:function(){var t,n=null===(t=a.ReactDOM.findDOMNode(e.refs.password))||void 0===t?void 0:t.value;null!=n&&e.setState({password:n})}}),this.render_button("get",void 0,!this.state.password&&this.state.password.length>6))},l.render_content=function(){var e=this;if(this.state.error)return qe.createElement(h.ErrorDisplay,{error:this.state.error,onClose:function(){return e.setState({error:"",state:"init",password:""})}});switch(this.state.state){case"loading":return qe.createElement(h.Loading,null);case"password":return this.render_get_password();case"showkey":return this.render_api_key();case"confirm-delete":case"confirm-regenerate":return qe.createElement("span",null,this.render_api_key(),qe.createElement("br",null),this.render_confirm())}},l.render_close=function(){var e=this;return qe.createElement(h.CloseX,{on_close:function(){return e.setState({password:"",state:"init"})},style:{marginRight:"5px",marginLeft:"20px"}})},l.render_workaround=function(){if("password"==this.state.state)return qe.createElement(qe.Fragment,null,qe.createElement("hr",null),"NOTE: If you do not have a password set, there is"," ",qe.createElement("a",{href:"https://github.com/sagemathinc/cocalc/wiki/password",target:"_blank",rel:"noopener"},"a workaround to generate your API key."))},l.render_docs=function(){return qe.createElement("div",null,qe.createElement("hr",null),qe.createElement("span",{style:{color:"#666"}},qe.createElement("a",{href:"https://doc.cocalc.com/api/",target:"_blank",rel:"noopener"},"Learn about the API..."),this.render_workaround()))},l.render_well=function(){return qe.createElement(i.tW,null,this.render_close(),this.render_content(),this.render_docs())},l.render_init=function(){return qe.createElement("div",{className:"pull-right"},this.render_button("get"))},l.render=function(){return qe.createElement(h.LabeledRow,{label:"API key"},qe.createElement("div",{style:{minHeight:"30px"}},"init"===this.state.state?this.render_init():this.render_well()))},o}(a.Component),$e=n(34440),Ve=n(63505);function et(e,t,n,r,a,i,o){try{var l=e[i](o),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,a)}function tt(e){return tt=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},tt(e)}function nt(e,t){return!t||"object"!==at(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function rt(e,t){return rt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},rt(e,t)}var at=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var it=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&rt(e,t)}(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=tt(t);if(n){var a=tt(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return nt(this,e)});function o(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o),(n=r.call(this,e,t)).state={state:"view",password:"",email_address:"",error:""},n}var l=o.prototype;return l.start_editing=function(){this.setState({state:"edit",email_address:null!=this.props.email_address?this.props.email_address:"",error:"",password:""})},l.cancel_editing=function(){this.setState({state:"view",password:""})},l.save_editing=function(){var e,t=this;return(e=function(){var e,n,r;return function(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(a){switch(a.label){case 0:if(t.state.password.length<6)return t.setState({state:"edit",error:"Password must be at least 6 characters long."}),[2];t.setState({state:"saving"}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Ae.webapp_client.account_client.change_email(t.state.email_address,t.state.password)];case 2:return a.sent(),[3,4];case 3:return e=a.sent(),t.setState({state:"edit",error:"Error -- ".concat(e)}),[2];case 4:if(t.props.is_anonymous&&(0,Te.c)("email_sign_up",{source:"anonymous_account"}),t.setState({state:"view",error:"",password:""}),!t.props.verify_emails&&!t.props.is_anonymous)return[2];a.label=5;case 5:return a.trys.push([5,7,,8]),[4,Ae.webapp_client.account_client.send_verification_email(!t.props.is_anonymous)];case 6:return a.sent(),[3,8];case 7:return n=a.sent(),r="Problem sending welcome email: ".concat(n),console.log(r),(0,$e.alert_message)({type:"error",message:r}),[3,8];case 8:return[2]}}))},function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function o(e){et(i,r,a,o,l,"next",e)}function l(e){et(i,r,a,o,l,"throw",e)}o(void 0)}))})()},l.is_submittable=function(){return!(""===this.state.password||this.state.email_address===this.props.email_address)},l.render_change_button=function(){return Ve.createElement(i.zx,{disabled:!this.is_submittable(),onClick:this.save_editing.bind(this),bsStyle:"success"},this.button_label())},l.render_error=function(){var e=this;if(this.state.error)return Ve.createElement(h.ErrorDisplay,{error:this.state.error,onClose:function(){return e.setState({error:""})},style:{marginTop:"15px"}})},l.render_edit=function(){var e=this,t=this.props.email_address?"Current password":"Choose a password";return Ve.createElement(i.tW,{style:{marginTop:"3ex"}},Ve.createElement(i.cw,null,"New email address",Ve.createElement(i.NI,{autoFocus:!0,type:"email_address",ref:"email_address",value:this.state.email_address,placeholder:"user@example.com",onChange:function(){return e.setState({email_address:a.ReactDOM.findDOMNode(e.refs.email_address).value})},maxLength:254})),t,Ve.createElement("form",{onSubmit:function(t){if(t.preventDefault(),e.is_submittable())return e.save_editing()}},Ve.createElement(i.cw,null,Ve.createElement(i.NI,{type:"password",ref:"password",value:this.state.password,placeholder:t,onChange:function(){var t,n=null===(t=a.ReactDOM.findDOMNode(e.refs.password))||void 0===t?void 0:t.value;null!=n&&e.setState({password:n})}}))),Ve.createElement(i.Si,null,this.render_change_button(),Ve.createElement(i.zx,{onClick:this.cancel_editing.bind(this)},"Cancel")),this.render_error(),this.render_saving())},l.render_saving=function(){if("saving"===this.state.state)return Ve.createElement(h.Saving,null)},l.button_label=function(){return this.props.is_anonymous?"Sign up using an email address and password":this.props.email_address?"Change email address":"Set email address and password"},l.render=function(){var e=this.props.is_anonymous?Ve.createElement("h5",{style:{color:"#666"}},"Sign up using an email address and password"):"Email address";return Ve.createElement(h.LabeledRow,{label:e,style:this.props.disabled?{color:"#666"}:void 0},Ve.createElement("div",null,this.props.email_address,"view"===this.state.state?Ve.createElement(i.zx,{disabled:this.props.disabled,className:"pull-right",onClick:this.start_editing.bind(this)},this.button_label(),"..."):void 0),"view"!==this.state.state?this.render_edit():void 0)},o}(a.Component),ot=n(63505);function lt(e,t,n,r,a,i,o){try{var l=e[i](o),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,a)}function st(e){return st=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},st(e)}function ct(e,t){return!t||"object"!==dt(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function ut(e,t){return ut=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},ut(e,t)}var dt=function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};var pt=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ut(e,t)}(a,e);var t,n,r=(t=a,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=st(t);if(n){var a=st(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return ct(this,e)});function a(e,t){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(n=r.call(this,e,t)).is_mounted=!0,n.state={disabled_button:!1},n}var o=a.prototype;return o.componentWillUnmount=function(){this.is_mounted=!1},o.componentWillReceiveProps=function(e){e.email_address!==this.props.email_address&&this.setState({disabled_button:!1})},o.verify=function(){var e,t=this;return(e=function(){var e,n;return function(e,t){var n,r,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)