-
Notifications
You must be signed in to change notification settings - Fork 0
/
549.43176d7a9c289f50bf38.js
1 lines (1 loc) · 34.7 KB
/
549.43176d7a9c289f50bf38.js
1
"use strict";(self.webpackChunksparkworks_console=self.webpackChunksparkworks_console||[]).push([[549],{19549:function(Z,S,g){g.r(S),g.d(S,{amplify_confirm_sign_in:function(){return R},amplify_confirm_sign_up:function(){return M},amplify_forgot_password:function(){return L},amplify_require_new_password:function(){return W},amplify_sign_in:function(){return P},amplify_sign_up:function(){return U},amplify_verify_contact:function(){return V}});var N=g(43085),F=g(8239),y=g(75134),_=g(47289),O=g(88774),c=g.n(O),s=g(65513),h=g(53799),T=g(45013),D=g(77),f=g(82073),p=g(33542),l=g(30031),C=g(84665),d=g(36755),A=g(99056),R=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.handleSubmit=function(t){return e.confirm(t)},this.headerText=l.T.CONFIRM_SMS_CODE,this.submitButtonText=l.T.CONFIRM,this.handleAuthStateChange=d.d,this.defaultFormFields=[{type:"code",required:!0,handleInputChange:function(r){return e.handleCodeChange(r)}}],this.formFields=this.defaultFormFields,this.mfaOption=f.M.SMS,this.loading=!1}return(0,_.Z)(m,[{key:"componentWillLoad",value:function(){this.setup()}},{key:"userHandler",value:function(){this.setup()}},{key:"setup",value:function(){this.user&&this.user.challengeName===f.C.SoftwareTokenMFA&&(this.mfaOption=f.M.TOTP,this.headerText===l.T.CONFIRM_SMS_CODE&&(this.headerText=l.T.CONFIRM_TOTP_CODE)),this.constructedFormFieldOptions=this.constructFormFieldOptions(this.formFields)}},{key:"handleCodeChange",value:function(e){this.code=e.target.value}},{key:"confirm",value:(a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r&&r.preventDefault(),i=this.user.challengeName===f.C.SoftwareTokenMFA?f.C.SoftwareTokenMFA:null,p.g&&"function"==typeof p.g.confirmSignIn){n.next=4;break}throw new Error(C.N);case 4:return this.loading=!0,n.prev=5,n.next=8,p.g.confirmSignIn(this.user,this.code,i);case 8:return n.next=10,(0,A.c)(this.user,this.handleAuthStateChange);case 10:n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),(0,d.a)(n.t0);case 15:return n.prev=15,this.loading=!1,n.finish(15);case 18:case"end":return n.stop()}},t,this,[[5,12,15,18]])})),function(t){return a.apply(this,arguments)})},{key:"constructFormFieldOptions",value:function(e){var t=this,r=[];if(void 0!==e)return e.length<=0?this.defaultFormFields:(e.forEach(function(i){r.push("string"==typeof i||"code"!==i.type?i:Object.assign({handleInputChange:function(n){return t.handleCodeChange(n)}},i))}),r)}},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),handleSubmit:this.handleSubmit,submitButtonText:h.o.get(this.submitButtonText),loading:this.loading,secondaryFooterContent:(0,s.h)("span",null,(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignIn)}},h.o.get(l.T.BACK_TO_SIGN_IN)))},(0,s.h)("amplify-auth-fields",{formFields:this.constructedFormFieldOptions})))}}],[{key:"watchers",get:function(){return{user:["userHandler"]}}}]),m;var a}(),M=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.handleSubmit=function(t){return e.confirmSignUp(t)},this.headerText=l.T.CONFIRM_SIGN_UP_HEADER_TEXT,this.submitButtonText=l.T.CONFIRM_SIGN_UP_SUBMIT_BUTTON_TEXT,this.formFields=[],this.handleAuthStateChange=d.d,this.usernameAlias="username",this.loading=!1,this.newFormFields=[],this.phoneNumber={countryDialCodeValue:C.g,phoneNumberValue:null}}return(0,_.Z)(m,[{key:"componentWillLoad",value:function(){this.setup()}},{key:"formFieldsHandler",value:function(){this.buildFormFields()}},{key:"userHandler",value:function(){this.setup()}},{key:"setup",value:function(){this.userInput=this.user&&this.user.username,this._signUpAttrs=this.user&&this.user.signUpAttrs,(0,d.c)(this.usernameAlias),this.buildFormFields()}},{key:"buildDefaultFormFields",value:function(){var e=this;this.newFormFields=[{type:"".concat(this.usernameAlias),required:!0,handleInputChange:this.handleFormFieldInputChange("".concat(this.usernameAlias)),value:this.userInput,disabled:!!this.userInput,inputProps:{autocomplete:"username"}},{type:"code",label:h.o.get(l.T.CONFIRM_SIGN_UP_CODE_LABEL),placeholder:h.o.get(l.T.CONFIRM_SIGN_UP_CODE_PLACEHOLDER),required:!0,hint:(0,s.h)("div",null,h.o.get(l.T.CONFIRM_SIGN_UP_LOST_CODE)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.resendConfirmCode()}},h.o.get(l.T.CONFIRM_SIGN_UP_RESEND_CODE))),handleInputChange:this.handleFormFieldInputChange("code")}]}},{key:"buildFormFields",value:function(){var e=this;if(0===this.formFields.length)this.buildDefaultFormFields();else{var t=[];this.formFields.forEach(function(r){var i=Object.assign({},r);"code"===i.type&&(i.hint=(0,d.i)(i)?(0,s.h)("div",null,h.o.get(l.T.CONFIRM_SIGN_UP_LOST_CODE)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.resendConfirmCode()}},h.o.get(l.T.CONFIRM_SIGN_UP_RESEND_CODE))):i.hint),i.handleInputChange=function(o){return e.handleFormFieldInputWithCallback(o,r)},t.push(i)}),this.newFormFields=t}}},{key:"handleFormFieldInputChange",value:function(e){var t=this;switch(e){case"username":case"email":return function(r){return t.userInput=r.target.value};case"phone_number":return function(r){return(0,d.h)(r,t.phoneNumber)};case"code":return function(r){return t.code=r.target.value};default:return}}},{key:"setFieldValue",value:function(e){switch(e.type){case"username":case"email":this.userInput=void 0===e.value?"":e.value;break;case"phone_number":e.dialCode&&(this.phoneNumber.countryDialCodeValue=e.dialCode),this.phoneNumber.phoneNumberValue=e.value}}},{key:"handleFormFieldInputWithCallback",value:function(e,t){(t.handleInputChange?t.handleInputChange:function(o,n){n(o)})(e,this.handleFormFieldInputChange(t.type).bind(this))}},{key:"getUsername",value:function(){if(this.user&&this.user.username)return this.user.username;switch(this.usernameAlias){case"username":case"email":return this.userInput;case"phone_number":return(0,d.b)(this.phoneNumber)}}},{key:"resendConfirmCode",value:(a=(0,F.Z)(c().mark(function t(){var r;return c().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(event&&event.preventDefault(),p.g&&"function"==typeof p.g.resendSignUp){o.next=3;break}throw new Error(C.N);case 3:if(o.prev=3,r=this.getUsername()){o.next=7;break}throw new Error(l.T.EMPTY_USERNAME);case 7:return o.next=9,p.g.resendSignUp(r.trim());case 9:o.next=14;break;case 11:o.prev=11,o.t0=o.catch(3),(0,d.a)(o.t0);case 14:case"end":return o.stop()}},t,this,[[3,11]])})),function(){return a.apply(this,arguments)})},{key:"confirmSignUp",value:function(){var a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r&&r.preventDefault(),p.g&&"function"==typeof p.g.confirmSignUp){u.next=3;break}throw new Error(C.N);case 3:if(this.loading=!0,u.prev=4,i=this.getUsername()){u.next=8;break}throw new Error(l.T.EMPTY_USERNAME);case 8:return i=i.trim(),u.next=11,p.g.confirmSignUp(i,this.code);case 11:if(u.sent){u.next=14;break}throw new Error(h.o.get(l.T.CONFIRM_SIGN_UP_FAILED));case 14:if(!this._signUpAttrs||!this._signUpAttrs.password||""===this._signUpAttrs.password){u.next=19;break}return u.next=17,(0,A.h)(i,this._signUpAttrs.password,this.handleAuthStateChange);case 17:u.next=20;break;case 19:this.handleAuthStateChange(f.A.SignIn);case 20:u.next=25;break;case 22:u.prev=22,u.t0=u.catch(4),(0,d.a)(u.t0);case 25:return u.prev=25,this.loading=!1,u.finish(25);case 28:case"end":return u.stop()}},t,this,[[4,22,25,28]])}));return function(t){return a.apply(this,arguments)}}()},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),submitButtonText:h.o.get(this.submitButtonText),handleSubmit:this.handleSubmit,loading:this.loading,secondaryFooterContent:(0,s.h)("div",null,(0,s.h)("span",null,(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignIn)}},h.o.get(l.T.BACK_TO_SIGN_IN))))},(0,s.h)("amplify-auth-fields",{formFields:this.newFormFields})))}}],[{key:"watchers",get:function(){return{formFields:["formFieldsHandler"],user:["userHandler"]}}}]),m;var a}(),E=new T.k("ForgotPassword"),L=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.headerText=l.T.RESET_YOUR_PASSWORD,this.sendButtonText=l.T.SEND_CODE,this.submitButtonText=l.T.SUBMIT,this.formFields=[],this.handleSend=function(t){return e.send(t)},this.handleSubmit=function(t){return e.submit(t)},this.handleAuthStateChange=d.d,this.usernameAlias="username",this.delivery=null,this.loading=!1,this.phoneNumber={countryDialCodeValue:C.g,phoneNumberValue:null},this.newFormFields=[],this.forgotPasswordAttrs={userInput:"",password:"",code:""}}return(0,_.Z)(m,[{key:"componentWillLoad",value:function(){(0,d.c)(this.usernameAlias),this.buildFormFields()}},{key:"formFieldsHandler",value:function(){this.buildFormFields()}},{key:"buildFormFields",value:function(){var e=this;if(0===this.formFields.length)this.buildDefaultFormFields();else{var t=[];this.formFields.forEach(function(r){var i=Object.assign({},r);i.handleInputChange=function(o){return e.handleFormFieldInputWithCallback(o,r)},t.push(i)}),this.newFormFields=t}}},{key:"buildDefaultFormFields",value:function(){switch(this.usernameAlias){case"email":this.newFormFields=[{type:"email",required:!0,handleInputChange:this.handleFormFieldInputChange("email"),inputProps:{"data-test":"forgot-password-email-input"}}];break;case"phone_number":this.newFormFields=[{type:"phone_number",required:!0,handleInputChange:this.handleFormFieldInputChange("phone_number"),inputProps:{"data-test":"forgot-password-phone-number-input"}}];break;case"username":default:this.newFormFields=[{type:"username",required:!0,handleInputChange:this.handleFormFieldInputChange("username"),inputProps:{"data-test":"forgot-password-username-input"}}]}}},{key:"handleFormFieldInputChange",value:function(e){var t=this;switch(e){case"username":case"email":return function(r){return t.forgotPasswordAttrs.userInput=r.target.value};case"phone_number":return function(r){return(0,d.h)(r,t.phoneNumber)};case"password":case"code":return function(r){return t.forgotPasswordAttrs[e]=r.target.value};default:return}}},{key:"setFieldValue",value:function(e,t){switch(e.type){case"username":case"email":t.userInput=void 0===e.value?"":e.value;break;case"phone_number":e.dialCode&&(this.phoneNumber.countryDialCodeValue=e.dialCode),this.phoneNumber.phoneNumberValue=e.value;break;case"password":case"code":t[e.type]=void 0===e.value?"":e.value}}},{key:"handleFormFieldInputWithCallback",value:function(e,t){(t.handleInputChange?t.handleInputChange:function(o,n){n(o)})(e,this.handleFormFieldInputChange(t.type).bind(this))}},{key:"send",value:(a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r&&r.preventDefault(),p.g&&"function"==typeof p.g.forgotPassword){n.next=3;break}throw new Error(C.N);case 3:this.loading=!0,n.t0=this.usernameAlias,n.next="phone_number"===n.t0?7:9;break;case 7:try{this.forgotPasswordAttrs.userInput=(0,d.b)(this.phoneNumber)}catch(u){(0,d.a)(u)}return n.abrupt("break",9);case 9:return n.prev=9,n.next=12,p.g.forgotPassword(this.forgotPasswordAttrs.userInput.trim());case 12:E.debug(i=n.sent),this.newFormFields=[{type:"code",required:!0,handleInputChange:this.handleFormFieldInputChange("code"),inputProps:{"data-test":"forgot-password-code-input"}},{type:"password",required:!0,handleInputChange:this.handleFormFieldInputChange("password"),label:h.o.get(l.T.NEW_PASSWORD_LABEL),placeholder:h.o.get(l.T.NEW_PASSWORD_PLACEHOLDER)}],this.delivery=i.CodeDeliveryDetails,n.next=21;break;case 18:n.prev=18,n.t1=n.catch(9),(0,d.a)(n.t1);case 21:return n.prev=21,this.loading=!1,n.finish(21);case 24:case"end":return n.stop()}},t,this,[[9,18,21,24]])})),function(t){return a.apply(this,arguments)})},{key:"submit",value:function(){var a=(0,F.Z)(c().mark(function t(r){var i,o,n,u;return c().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(r&&r.preventDefault(),p.g&&"function"==typeof p.g.forgotPasswordSubmit){v.next=3;break}throw new Error(C.N);case 3:return this.loading=!0,v.prev=4,o=(i=this.forgotPasswordAttrs).userInput,n=i.code,u=i.password,v.next=8,p.g.forgotPasswordSubmit(o.trim(),n,u);case 8:E.debug(v.sent),this.handleAuthStateChange(f.A.SignIn),this.delivery=null,v.next=17;break;case 14:v.prev=14,v.t0=v.catch(4),(0,d.a)(v.t0);case 17:return v.prev=17,this.loading=!1,v.finish(17);case 20:case"end":return v.stop()}},t,this,[[4,14,17,20]])}));return function(t){return a.apply(this,arguments)}}()},{key:"render",value:function(){var e=this,t=this.delivery?function(i){return e.handleSubmit(i)}:function(i){return e.handleSend(i)},r=this.delivery?this.submitButtonText:this.sendButtonText;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),handleSubmit:t,loading:this.loading,secondaryFooterContent:(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignIn)},"data-test":"forgot-password-back-to-sign-in-link"},h.o.get(l.T.BACK_TO_SIGN_IN)),testDataPrefix:"forgot-password",submitButtonText:h.o.get(r)},(0,s.h)("amplify-auth-fields",{formFields:this.newFormFields})))}}],[{key:"watchers",get:function(){return{formFields:["formFieldsHandler"]}}}]),m;var a}(),k=new T.k("amplify-require-new-password"),W=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.headerText=l.T.CHANGE_PASSWORD,this.submitButtonText=l.T.CHANGE_PASSWORD_ACTION,this.handleSubmit=function(t){return e.completeNewPassword(t)},this.handleAuthStateChange=d.d,this.formFields=[{type:f.a.Password,required:!0,handleInputChange:function(r){return e.handlePasswordChange(r)},label:h.o.get(l.T.NEW_PASSWORD_LABEL),placeholder:h.o.get(l.T.NEW_PASSWORD_PLACEHOLDER),inputProps:{"data-test":"require-new-password-password-input"}}],this.loading=!1,this.requiredAttributes={},this.newFormFields=this.formFields,this.phoneNumber={countryDialCodeValue:C.g,phoneNumberValue:" "}}return(0,_.Z)(m,[{key:"userHandler",value:function(){this.setCurrentUser()}},{key:"handleRequiredAttributeInputChange",value:function(e,t){"phone_number"===e?this.formatPhoneNumber(t):this.requiredAttributes[e]=t.target.value}},{key:"setCurrentUser",value:(a=(0,F.Z)(c().mark(function t(){var i,o,n,r=this;return c().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.user){b.next=13;break}return b.prev=1,b.next=4,p.g.currentAuthenticatedUser();case 4:(i=b.sent)&&(this.currentUser=i),b.next=11;break;case 8:b.prev=8,b.t0=b.catch(1),(0,d.a)(b.t0);case 11:b.next=14;break;case 13:this.currentUser=this.user;case 14:this.currentUser&&this.currentUser.challengeParam&&this.currentUser.challengeParam.requiredAttributes&&(o=this.currentUser.challengeParam.requiredAttributes,n=(0,d.g)(),o.forEach(function(I){var v={type:I,required:!0,label:n[I].label,placeholder:n[I].placeholder,handleInputChange:function(G){return r.handleRequiredAttributeInputChange(I,G)},inputProps:{"data-test":"require-new-password-".concat(I,"-input")}};r.newFormFields=[].concat((0,N.Z)(r.newFormFields),[v])}));case 15:case"end":return b.stop()}},t,this,[[1,8]])})),function(){return a.apply(this,arguments)})},{key:"componentWillLoad",value:function(){return this.setCurrentUser()}},{key:"handlePasswordChange",value:function(e){this.password=e.target.value}},{key:"formatPhoneNumber",value:function(e){(0,d.h)(e,this.phoneNumber);try{if(e.target.name===C.b&&this.phoneNumber.phoneNumberValue){var t=(0,d.b)(this.phoneNumber);this.requiredAttributes.phone_number=t}}catch(r){k.error("error in phone number field - ".concat(r))}}},{key:"completeNewPassword",value:function(){var a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r&&r.preventDefault(),p.g&&"function"==typeof p.g.completeNewPassword){n.next=3;break}throw new Error(C.N);case 3:return this.loading=!0,n.prev=4,n.next=7,p.g.completeNewPassword(this.currentUser,this.password,this.requiredAttributes);case 7:k.debug("complete new password",i=n.sent),n.t0=i.challengeName,n.next=n.t0===f.C.SMSMFA?12:n.t0===f.C.MFASetup?14:17;break;case 12:return this.handleAuthStateChange(f.A.ConfirmSignIn,i),n.abrupt("break",19);case 14:return k.debug("TOTP setup",i.challengeParam),this.handleAuthStateChange(f.A.TOTPSetup,i),n.abrupt("break",19);case 17:return n.next=19,(0,A.c)(i,this.handleAuthStateChange);case 19:n.next=24;break;case 21:n.prev=21,n.t1=n.catch(4),(0,d.a)(n.t1);case 24:return n.prev=24,this.loading=!1,n.finish(24);case 27:case"end":return n.stop()}},t,this,[[4,21,24,27]])}));return function(t){return a.apply(this,arguments)}}()},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),handleSubmit:this.handleSubmit,loading:this.loading,secondaryFooterContent:(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignIn)}},h.o.get(l.T.BACK_TO_SIGN_IN)),submitButtonText:h.o.get(this.submitButtonText)},(0,s.h)("amplify-auth-fields",{formFields:this.newFormFields})))}}],[{key:"watchers",get:function(){return{user:["userHandler"]}}}]),m;var a}(),P=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.handleSubmit=function(t){return e.signIn(t)},this.headerText=l.T.SIGN_IN_HEADER_TEXT,this.submitButtonText=l.T.SIGN_IN_ACTION,this.handleAuthStateChange=d.d,this.usernameAlias="username",this.formFields=[],this.hideSignUp=!1,this.newFormFields=[],this.loading=!1,this.phoneNumber={countryDialCodeValue:C.g,phoneNumberValue:null},this.signInAttributes={userInput:"",password:""}}return(0,_.Z)(m,[{key:"componentWillLoad",value:function(){(0,d.c)(this.usernameAlias),this.buildFormFields()}},{key:"formFieldsHandler",value:function(){this.buildFormFields()}},{key:"handleFormFieldInputChange",value:function(e){var t=this;switch(e){case"username":case"email":return function(r){return t.signInAttributes.userInput=r.target.value};case"phone_number":return function(r){return(0,d.h)(r,t.phoneNumber)};case"password":return function(r){return t.signInAttributes.password=r.target.value};default:return function(){}}}},{key:"handleFormFieldInputWithCallback",value:function(e,t){(t.handleInputChange?t.handleInputChange:function(o,n){n(o)})(e,this.handleFormFieldInputChange(t.type).bind(this))}},{key:"signIn",value:(a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:switch(r&&r.preventDefault(),this.loading=!0,this.usernameAlias){case"phone_number":try{this.signInAttributes.userInput=(0,d.b)(this.phoneNumber)}catch(u){(0,d.a)(u)}}return i=this.signInAttributes.userInput.trim(),n.next=6,(0,A.h)(i,this.signInAttributes.password,this.handleAuthStateChange,this.usernameAlias);case 6:this.loading=!1;case 7:case"end":return n.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"buildDefaultFormFields",value:function(){var e=this,t=[];switch(this.usernameAlias){case"email":t.push({type:"email",required:!0,handleInputChange:this.handleFormFieldInputChange("email"),inputProps:{"data-test":"sign-in-email-input",autocomplete:"username"}});break;case"phone_number":t.push({type:"phone_number",required:!0,handleInputChange:this.handleFormFieldInputChange("phone_number"),inputProps:{"data-test":"sign-in-phone-number-input",autocomplete:"username"}});break;case"username":default:t.push({type:"username",required:!0,handleInputChange:this.handleFormFieldInputChange("username"),inputProps:{"data-test":"sign-in-username-input",autocomplete:"username"}})}t.push({type:"password",hint:(0,s.h)("div",null,h.o.get(l.T.FORGOT_PASSWORD_TEXT)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.ForgotPassword)},"data-test":"sign-in-forgot-password-link"},h.o.get(l.T.RESET_PASSWORD_TEXT))),required:!0,handleInputChange:this.handleFormFieldInputChange("password"),inputProps:{"data-test":"sign-in-password-input"}}),this.newFormFields=[].concat(t)}},{key:"buildFormFields",value:function(){var e=this;if(0===this.formFields.length)this.buildDefaultFormFields();else{var t=[];this.formFields.forEach(function(r){var i=Object.assign({},r);"password"===i.type&&(i.hint=(0,d.i)(i)?(0,s.h)("div",null,h.o.get(l.T.FORGOT_PASSWORD_TEXT)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.ForgotPassword)},"data-test":"sign-in-forgot-password-link"},h.o.get(l.T.RESET_PASSWORD_TEXT))):i.hint),i.handleInputChange=function(o){return e.handleFormFieldInputWithCallback(o,r)},e.setFieldValue(i,e.signInAttributes),t.push(i)}),this.newFormFields=t}}},{key:"setFieldValue",value:function(e,t){switch(e.type){case"username":case"email":t.userInput=void 0===e.value?"":e.value;break;case"phone_number":e.dialCode&&(this.phoneNumber.countryDialCodeValue=e.dialCode),this.phoneNumber.phoneNumberValue=e.value;break;case"password":t.password=void 0===e.value?"":e.value}}},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),handleSubmit:this.handleSubmit,testDataPrefix:"sign-in"},(0,s.h)("div",{slot:"subtitle"},(0,s.h)("slot",{name:"header-subtitle"})),(0,s.h)("slot",{name:"federated-buttons"},(0,s.h)("amplify-federated-buttons",{handleAuthStateChange:this.handleAuthStateChange,federated:this.federated})),!(0,D.xb)(this.federated)&&(0,s.h)("amplify-strike",null,"or"),(0,s.h)("amplify-auth-fields",{formFields:this.newFormFields}),(0,s.h)("div",{slot:"amplify-form-section-footer",class:"sign-in-form-footer"},(0,s.h)("slot",{name:"footer"},!this.hideSignUp&&(0,s.h)("slot",{name:"secondary-footer-content"},(0,s.h)("span",null,h.o.get(l.T.NO_ACCOUNT_TEXT)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignUp)},"data-test":"sign-in-create-account-link"},h.o.get(l.T.CREATE_ACCOUNT_TEXT)))),(0,s.h)("div",{class:this.hideSignUp?"full-width-footer-content":""},(0,s.h)("slot",{name:"primary-footer-content"},(0,s.h)("amplify-button",{type:"submit",disabled:this.loading,"data-test":"sign-in-sign-in-button"},this.loading?(0,s.h)("amplify-loading-spinner",null):(0,s.h)("span",null,h.o.get(this.submitButtonText)))))))))}}],[{key:"watchers",get:function(){return{formFields:["formFieldsHandler"]}}}]),m;var a}();P.style=":host{--footer-size:var(--amplify-text-sm);--footer-color:var(--amplify-grey);--footer-font-family:var(--amplify-font-family);--font-weight:var(--amplify-font-weight)}.sign-in-form-footer{font-family:var(--footer-font-family);font-size:var(--footer-size);color:var(--footer-color);font-weight:--font-weight;display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around}.sign-in-form-footer amplify-button{margin-bottom:0.625rem}@media (min-width: 672px){.sign-in-form-footer{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:baseline;align-items:baseline}.sign-in-form-footer amplify-button{margin-bottom:0}}.sign-in-form-footer *+*{margin-bottom:15px}.full-width-footer-content{width:100%}";var U=function(){function m(a){var e=this;(0,y.Z)(this,m),(0,s.r)(this,a),this.handleSubmit=function(t){return e.signUp(t)},this.handleSignUp=function(t){return e.authSignUp(t)},this.headerText=l.T.SIGN_UP_HEADER_TEXT,this.submitButtonText=l.T.SIGN_UP_SUBMIT_BUTTON_TEXT,this.haveAccountText=l.T.SIGN_UP_HAVE_ACCOUNT_TEXT,this.signInText=l.T.SIGN_IN_TEXT,this.formFields=[],this.handleAuthStateChange=d.d,this.usernameAlias="username",this.newFormFields=[],this.phoneNumber={countryDialCodeValue:C.g,phoneNumberValue:null},this.loading=!1,this.signUpAttributes={username:"",password:"",attributes:{}}}return(0,_.Z)(m,[{key:"handleFormFieldInputChange",value:function(e){var t=this;switch(e){case"username":return function(r){return t.signUpAttributes.username=r.target.value};case"password":return function(r){return t.signUpAttributes.password=r.target.value};case"email":return function(r){return t.signUpAttributes.attributes.email=r.target.value};case"phone_number":return function(r){return(0,d.h)(r,t.phoneNumber)};default:return function(r){return t.signUpAttributes.attributes[e]=r.target.value}}}},{key:"handleFormFieldInputWithCallback",value:function(e,t){(t.handleInputChange?t.handleInputChange:function(o,n){n(o)})(e,this.handleFormFieldInputChange(t.type).bind(this))}},{key:"authSignUp",value:(a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,p.g.signUp(r);case 2:if(i=n.sent){n.next=5;break}throw new Error(l.T.SIGN_UP_FAILED);case 5:return n.abrupt("return",i);case 6:case"end":return n.stop()}},t)})),function(t){return a.apply(this,arguments)})},{key:"assignPhoneNumberToSignUpAttributes",value:function(){if(this.phoneNumber.phoneNumberValue)try{this.signUpAttributes.attributes.phone_number=(0,d.b)(this.phoneNumber)}catch(e){(0,d.a)(e)}}},{key:"assignUserNameAliasToSignUpAttributes",value:function(){switch(this.usernameAlias){case"email":case"phone_number":this.signUpAttributes.username=this.signUpAttributes.attributes[this.usernameAlias]}}},{key:"assignFormInputToSignUpAttributes",value:function(){this.assignPhoneNumberToSignUpAttributes(),this.assignUserNameAliasToSignUpAttributes()}},{key:"validateSignUpAttributes",value:function(){if(!this.signUpAttributes.username)throw this.usernameAlias===f.U.email?new Error(l.T.EMPTY_EMAIL):this.usernameAlias===f.U.phone_number?new Error(l.T.EMPTY_PHONE):new Error(l.T.EMPTY_USERNAME);if(this.signUpAttributes.username.indexOf(" ")>=0)throw new Error(l.T.USERNAME_REMOVE_WHITESPACE);if(this.signUpAttributes.password!==this.signUpAttributes.password.trim())throw new Error(l.T.PASSWORD_REMOVE_WHITESPACE)}},{key:"signUp",value:function(){var a=(0,F.Z)(c().mark(function t(r){var i,o;return c().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r&&r.preventDefault(),p.g&&"function"==typeof p.g.signUp){u.next=3;break}throw new Error(C.N);case 3:return this.loading=!0,this.assignFormInputToSignUpAttributes(),u.prev=5,this.validateSignUpAttributes(),u.next=9,this.handleSignUp(this.signUpAttributes);case 9:if(!(i=u.sent).userConfirmed){u.next=15;break}return u.next=13,(0,A.h)(this.signUpAttributes.username,this.signUpAttributes.password,this.handleAuthStateChange);case 13:u.next=17;break;case 15:o=Object.assign({},this.signUpAttributes),this.handleAuthStateChange(f.A.ConfirmSignUp,Object.assign(Object.assign({},i.user),{signUpAttrs:o}));case 17:u.next=22;break;case 19:u.prev=19,u.t0=u.catch(5),(0,d.a)(u.t0);case 22:return u.prev=22,this.loading=!1,u.finish(22);case 25:case"end":return u.stop()}},t,this,[[5,19,22,25]])}));return function(t){return a.apply(this,arguments)}}()},{key:"buildDefaultFormFields",value:function(){switch(this.usernameAlias){case"email":this.newFormFields=[{type:"email",placeholder:h.o.get(l.T.SIGN_UP_EMAIL_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("email"),inputProps:{"data-test":"sign-up-email-input",autocomplete:"username"}},{type:"password",placeholder:h.o.get(l.T.SIGN_UP_PASSWORD_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("password"),inputProps:{"data-test":"sign-up-password-input",autocomplete:"new-password"}},{type:"phone_number",required:!0,handleInputChange:this.handleFormFieldInputChange("phone_number"),inputProps:{"data-test":"sign-up-phone-number-input",autocomplete:"tel-national"}}];break;case"phone_number":this.newFormFields=[{type:"phone_number",required:!0,handleInputChange:this.handleFormFieldInputChange("phone_number"),inputProps:{"data-test":"sign-up-phone-number-input",autocomplete:"username"}},{type:"password",placeholder:h.o.get(l.T.SIGN_UP_PASSWORD_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("password"),inputProps:{"data-test":"sign-up-password-input",autocomplete:"new-password"}},{type:"email",placeholder:h.o.get(l.T.SIGN_UP_EMAIL_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("email"),inputProps:{"data-test":"sign-up-email-input",autocomplete:"email"}}];break;case"username":default:this.newFormFields=[{type:"username",placeholder:h.o.get(l.T.SIGN_UP_USERNAME_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("username"),inputProps:{"data-test":"sign-up-username-input",autocomplete:"username"}},{type:"password",placeholder:h.o.get(l.T.SIGN_UP_PASSWORD_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("password"),inputProps:{"data-test":"sign-up-password-input",autocomplete:"new-password"}},{type:"email",placeholder:h.o.get(l.T.SIGN_UP_EMAIL_PLACEHOLDER),required:!0,handleInputChange:this.handleFormFieldInputChange("email"),inputProps:{"data-test":"sign-up-email-input"}},{type:"phone_number",required:!0,handleInputChange:this.handleFormFieldInputChange("phone_number"),inputProps:{"data-test":"sign-up-phone-number-input"}}]}}},{key:"buildFormFields",value:function(){var e=this;if(0===this.formFields.length)this.buildDefaultFormFields();else{var t=[];this.formFields.forEach(function(r){var i=Object.assign({},r);i.handleInputChange=function(o){return e.handleFormFieldInputWithCallback(o,r)},e.setFieldValue(r,e.signUpAttributes),t.push(i)}),this.newFormFields=t}}},{key:"setFieldValue",value:function(e,t){switch(e.type){case"username":t.username=void 0===e.value?"":e.value;break;case"password":t.password=void 0===e.value?"":e.value;break;case"email":t.attributes.email=e.value;break;case"phone_number":e.dialCode&&(this.phoneNumber.countryDialCodeValue=e.dialCode),this.phoneNumber.phoneNumberValue=e.value;break;default:t.attributes[e.type]=e.value}}},{key:"componentWillLoad",value:function(){(0,d.c)(this.usernameAlias),this.buildFormFields()}},{key:"formFieldsHandler",value:function(){this.buildFormFields()}},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{headerText:h.o.get(this.headerText),handleSubmit:this.handleSubmit,testDataPrefix:"sign-up"},(0,s.h)("div",{slot:"subtitle"},(0,s.h)("slot",{name:"header-subtitle"})),(0,s.h)("amplify-auth-fields",{formFields:this.newFormFields}),(0,s.h)("div",{class:"sign-up-form-footer",slot:"amplify-form-section-footer"},(0,s.h)("slot",{name:"footer"},(0,s.h)("slot",{name:"secondary-footer-content"},(0,s.h)("span",null,h.o.get(this.haveAccountText)," ",(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignIn)},"data-test":"sign-up-sign-in-link"},h.o.get(this.signInText)))),(0,s.h)("slot",{name:"primary-footer-content"},(0,s.h)("amplify-button",{type:"submit","data-test":"sign-up-create-account-button",disabled:this.loading},this.loading?(0,s.h)("amplify-loading-spinner",null):(0,s.h)("span",null,h.o.get(this.submitButtonText))))))))}}],[{key:"watchers",get:function(){return{formFields:["formFieldsHandler"]}}}]),m;var a}();U.style="amplify-sign-up{--footer-font-family:var(--amplify-font-family);--footer-font-size:var(--amplify-text-sm);--footer-color:var(--amplify-grey);--font-weight:var(--amplify-font-weight)}.sign-up-form-footer{font-family:var(--footer-font-family);font-size:var(--footer-font-size);color:var(--footer-color);font-weight:--font-weight;display:-ms-flexbox;display:flex;-ms-flex-direction:column-reverse;flex-direction:column-reverse;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around}.sign-up-form-footer amplify-button{margin-bottom:0.625rem}@media (min-width: 672px){.sign-up-form-footer{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:baseline;align-items:baseline}.sign-up-form-footer amplify-button{margin-bottom:0}}.sign-up-form-footer *+*{margin-bottom:15px}";var w=new T.k("AmplifyVerifyContact"),V=function(){function m(a){(0,y.Z)(this,m),(0,s.r)(this,a),this.handleAuthStateChange=d.d,this.loading=!1}return(0,_.Z)(m,[{key:"handleSubmit",value:function(e){e.preventDefault(),this.verifyAttr?this.submit(this.code):this.verify(this.contact)}},{key:"submit",value:(a=(0,F.Z)(c().mark(function t(r){var i;return c().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(i=this.verifyAttr,p.g&&"function"==typeof p.g.verifyCurrentUserAttributeSubmit){u.next=3;break}throw new Error(C.N);case 3:return this.loading=!0,u.prev=4,u.next=7,p.g.verifyCurrentUserAttributeSubmit(i,r);case 7:w.debug(u.sent),this.handleAuthStateChange(f.A.SignedIn,this.user),this.verifyAttr=null,u.next=17;break;case 13:u.prev=13,u.t0=u.catch(4),(0,d.a)(u.t0),w.error(u.t0);case 17:return u.prev=17,this.loading=!1,u.finish(17);case 20:case"end":return u.stop()}},t,this,[[4,13,17,20]])})),function(t){return a.apply(this,arguments)})},{key:"verify",value:function(){var a=(0,F.Z)(c().mark(function t(r){return c().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(r){n.next=3;break}return w.error("Neither Email nor Phone Number selected"),n.abrupt("return");case 3:if(p.g&&"function"==typeof p.g.verifyCurrentUserAttribute){n.next=5;break}throw new Error(C.N);case 5:return this.loading=!0,n.prev=6,n.next=9,p.g.verifyCurrentUserAttribute(r);case 9:w.debug(n.sent),this.verifyAttr=r,n.next=18;break;case 14:n.prev=14,n.t0=n.catch(6),(0,d.a)(n.t0),w.error(n.t0);case 18:return n.prev=18,this.loading=!1,n.finish(18);case 21:case"end":return n.stop()}},t,this,[[6,14,18,21]])}));return function(t){return a.apply(this,arguments)}}()},{key:"handleInputChange",value:function(e){var t=e.target.name;"code"===t?this.code=e.target.value:"contact"===t&&(this.contact=e.target.value)}},{key:"renderSubmit",value:function(){var e=this;return(0,s.h)("div",null,(0,s.h)("amplify-input",{inputProps:{autocomplete:"off","data-test":"verify-contact-code-input"},name:"code",placeholder:h.o.get(l.T.CODE_PLACEHOLDER),handleInputChange:function(r){return e.handleInputChange(r)}}))}},{key:"renderVerify",value:function(){var e=this,t=this.user;if(!t)return w.debug("No user to verify"),null;var r=t.unverified;if(!r)return w.debug("Unverified variable does not exist on user"),null;var o=r.phone_number;return(0,s.h)("div",null,r.email&&(0,s.h)("amplify-radio-button",{label:h.o.get(l.T.VERIFY_CONTACT_EMAIL_LABEL),key:"email",name:"contact",value:"email",handleInputChange:function(u){return e.handleInputChange(u)},inputProps:{"data-test":"verify-contact-email-radio"}}),o&&(0,s.h)("amplify-radio-button",{label:h.o.get(l.T.VERIFY_CONTACT_PHONE_LABEL),key:"phone_number",name:"contact",value:"phone_number",handleInputChange:function(u){return e.handleInputChange(u)},inputProps:{"data-test":"verify-contact-phone-number-radio"}}))}},{key:"render",value:function(){var e=this;return(0,s.h)(s.H,null,(0,s.h)("amplify-form-section",{handleSubmit:function(r){return e.handleSubmit(r)},headerText:h.o.get(l.T.VERIFY_CONTACT_HEADER_TEXT),loading:this.loading,secondaryFooterContent:(0,s.h)("span",null,(0,s.h)("amplify-button",{variant:"anchor",onClick:function(){return e.handleAuthStateChange(f.A.SignedIn,e.user)},"data-test":"verify-contact-skip-link"},"Skip")),submitButtonText:h.o.get(this.verifyAttr?l.T.VERIFY_CONTACT_SUBMIT_LABEL:l.T.VERIFY_CONTACT_VERIFY_LABEL)},this.verifyAttr?this.renderSubmit():this.renderVerify()))}}]),m;var a}()}}]);