1const bo="Logging",Ja="x-amz-user-agent",Mo="NoHubcallbackProvidedException";var D;(function(e){e.DEBUG="DEBUG",e.ERROR="ERROR",e.INFO="INFO",e.WARN="WARN",e.VERBOSE="VERBOSE",e.NONE="NONE"})(D||(D={}));const Ft={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};class V{constructor(t,n=D.WARN){this.name=t,this.level=n,this._pluggables=[]}_padding(t){return t<10?"0"+t:""+t}_ts(){const t=new Date;return[this._padding(t.getMinutes()),this._padding(t.getSeconds())].join(":")+"."+t.getMilliseconds()}configure(t){return t?(this._config=t,this._config):this._config}_log(t,...n){let o=this.level;V.LOG_LEVEL&&(o=V.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(o=window.LOG_LEVEL);const s=Ft[o];if(!(Ft[t]>=s))return;let r=console.log.bind(console);t===D.ERROR&&console.error&&(r=console.error.bind(console)),t===D.WARN&&console.warn&&(r=console.warn.bind(console)),V.BIND_ALL_LOG_LEVELS&&(t===D.INFO&&console.info&&(r=console.info.bind(console)),t===D.DEBUG&&console.debug&&(r=console.debug.bind(console)));const d=`[${t}] ${this._ts()} ${this.name}`;let c="";if(n.length===1&&typeof n[0]=="string")c=`${d} - ${n[0]}`,r(c);else if(n.length===1)c=`${d} ${n[0]}`,r(d,n[0]);else if(typeof n[0]=="string"){let a=n.slice(1);a.length===1&&(a=a[0]),c=`${d} - ${n[0]} ${a}`,r(`${d} - ${n[0]}`,a)}else c=`${d} ${n}`,r(d,n);for(const a of this._pluggables){const u={message:c,timestamp:Date.now()};a.pushLogs([u])}}log(...t){this._log(D.INFO,...t)}info(...t){this._log(D.INFO,...t)}warn(...t){this._log(D.WARN,...t)}error(...t){this._log(D.ERROR,...t)}debug(...t){this._log(D.DEBUG,...t)}verbose(...t){this._log(D.VERBOSE,...t)}addPluggable(t){t&&t.getCategoryName()===bo&&(this._pluggables.push(t),t.configure(this._config))}listPluggables(){return this._pluggables}}V.LOG_LEVEL=null;V.BIND_ALL_LOG_LEVELS=!1;class U extends Error{constructor({message:t,name:n,recoverySuggestion:o,underlyingError:s,metadata:i}){if(super(t),this.name=n,this.underlyingError=s,this.recoverySuggestion=o,i){const{extendedRequestId:r,httpStatusCode:d,requestId:c}=i;this.metadata={extendedRequestId:r,httpStatusCode:d,requestId:c}}this.constructor=U,Object.setPrototypeOf(this,U.prototype)}}var re;(function(e){e.NoEndpointId="NoEndpointId",e.PlatformNotSupported="PlatformNotSupported",e.Unknown="Unknown",e.NetworkError="NetworkError"})(re||(re={}));const ct=(e,t=U)=>(n,o,s)=>{const{message:i,recoverySuggestion:r}=e[o];if(!n)throw new t({name:o,message:s?`${i} ${s}`:i,recoverySuggestion:r})},be=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",Ce=new V("Hub");class Vn{constructor(t){this.listeners=new Map,this.protectedChannels=["core","auth","api","analytics","interactions","pubsub","storage","ui","xr"],this.name=t}_remove(t,n){const o=this.listeners.get(t);if(!o){Ce.warn(`No listeners for ${t}`);return}this.listeners.set(t,[...o.filter(({callback:s})=>s!==n)])}dispatch(t,n,o,s){typeof t=="string"&&this.protectedChannels.indexOf(t)>-1&&(s===be||Ce.warn(`WARNING: ${t} is protected and dispatching on it can have unintended consequences`));const i={channel:t,payload:{...n},source:o,patternInfo:[]};try{this._toListeners(i)}catch(r){Ce.error(r)}}listen(t,n,o="noname"){let s;if(typeof n!="function")throw new U({name:Mo,message:"No callback supplied to Hub"});s=n;let i=this.listeners.get(t);return i||(i=[],this.listeners.set(t,i)),i.push({name:o,callback:s}),()=>{this._remove(t,s)}}_toListeners(t){const{channel:n,payload:o}=t,s=this.listeners.get(n);s&&s.forEach(i=>{Ce.debug(`Dispatching to ${n} with `,o);try{i.callback(t)}catch(r){Ce.error(r)}})}}const He=new Vn("__default__"),Xa=new Vn("internal-hub"),Uo=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new U({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},Do=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new U({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},Oo=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new U({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})},dt={convert(e,t){let n=e;return t!=null&&t.urlSafe&&(n=n.replace(/-/g,"+").replace(/_/g,"/")),Oo()(n)}};var H;(function(e){e.AuthTokenConfigException="AuthTokenConfigException",e.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",e.AuthUserPoolException="AuthUserPoolException",e.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",e.OAuthNotConfigureException="OAuthNotConfigureException"})(H||(H={}));const Fo={[H.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[H.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[H.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[H.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[H.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},ut=ct(Fo);function w(e){let t=!0;e?t=!!e.userPoolId&&!!e.userPoolClientId:t=!1,ut(t,H.AuthUserPoolException)}function Qa(e){var n,o,s,i,r,d,c,a;const t=!!((o=(n=e==null?void 0:e.loginWith)==null?void 0:n.oauth)!=null&&o.domain)&&!!((i=(s=e==null?void 0:e.loginWith)==null?void 0:s.oauth)!=null&&i.redirectSignOut)&&!!((d=(r=e==null?void 0:e.loginWith)==null?void 0:r.oauth)!=null&&d.redirectSignIn)&&!!((a=(c=e==null?void 0:e.loginWith)==null?void 0:c.oauth)!=null&&a.responseType);ut(t,H.OAuthNotConfigureException)}function Za(e){const t=!!(e!=null&&e.identityPoolId);ut(t,H.InvalidIdentityPoolIdException)}function Ee(e){const t=e.split(".");if(t.length!==3)throw new Error("Invalid token");try{const o=t[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(dt.convert(o).split("").map(r=>`%${`00${r.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")),i=JSON.parse(s);return{toString:()=>e,payload:i}}catch{throw new Error("Invalid token payload")}}const $n=e=>{const t=Reflect.ownKeys(e);for(const n of t){const o=e[n];(o&&typeof o=="object"||typeof o=="function")&&$n(o)}return Object.freeze(e)},Lo=new V("parseAWSExports"),ko={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},Bo=(e={})=>{var Pt,_t,Nt,bt,Mt,Ut;if(!Object.prototype.hasOwnProperty.call(e,"aws_project_region"))throw new U({name:"InvalidParameterException",message:"Invalid config parameter.",recoverySuggestion:"Ensure passing the config object imported from `amplifyconfiguration.json`."});const{aws_appsync_apiKey:t,aws_appsync_authenticationType:n,aws_appsync_graphqlEndpoint:o,aws_appsync_regi
1on:s,aws_bots_config:i,aws_cognito_identity_pool_id:r,aws_cognito_sign_up_verification_method:d,aws_cognito_mfa_configuration:c,aws_cognito_mfa_types:a,aws_cognito_password_protection_settings:u,aws_cognito_verification_mechanisms:h,aws_cognito_signup_attributes:l,aws_cognito_social_providers:p,aws_cognito_username_attributes:f,aws_mandatory_sign_in:g,aws_mobile_analytics_app_id:y,aws_mobile_analytics_app_region:I,aws_user_files_s3_bucket:L,aws_user_files_s3_bucket_region:ne,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:Rt,aws_user_pools_id:fe,aws_user_pools_web_client_id:Ro,geo:vt,oauth:Xe,predictions:Z,aws_cloud_logic_custom:Tt,Notifications:vo,modelIntrospection:At}=e,P={};y&&(P.Analytics={Pinpoint:{appId:y,region:I}});const{InAppMessaging:oe,Push:se}=vo??{};if(oe!=null&&oe.AWSPinpoint||se!=null&&se.AWSPinpoint){if(oe!=null&&oe.AWSPinpoint){const{appId:T,region:ie}=oe.AWSPinpoint;P.Notifications={InAppMessaging:{Pinpoint:{appId:T,region:ie}}}}if(se!=null&&se.AWSPinpoint){const{appId:T,region:ie}=se.AWSPinpoint;P.Notifications={...P.Notifications,PushNotification:{Pinpoint:{appId:T,region:ie}}}}}if(Array.isArray(i)&&(P.Interactions={LexV1:Object.fromEntries(i.map(T=>[T.name,T]))}),o){const T=ko[n];T||Lo.debug(`Invalid authentication type ${n}. Falling back to IAM.`),P.API={GraphQL:{endpoint:o,apiKey:t,region:s,defaultAuthMode:T??"iam"}},At&&(P.API.GraphQL.modelIntrospection=At)}const To=c?{status:c&&c.toLowerCase(),totpEnabled:(a==null?void 0:a.includes("TOTP"))??!1,smsEnabled:(a==null?void 0:a.includes("SMS"))??!1}:void 0,Ao=u?{minLength:u.passwordPolicyMinLength,requireLowercase:((Pt=u.passwordPolicyCharacters)==null?void 0:Pt.includes("REQUIRES_LOWERCASE"))??!1,requireUppercase:((_t=u.passwordPolicyCharacters)==null?void 0:_t.includes("REQUIRES_UPPERCASE"))??!1,requireNumbers:((Nt=u.passwordPolicyCharacters)==null?void 0:Nt.includes("REQUIRES_NUMBERS"))??!1,requireSpecialCharacters:((bt=u.passwordPolicyCharacters)==null?void 0:bt.includes("REQUIRES_SYMBOLS"))??!1}:void 0,xo=Array.from(new Set([...h??[],...l??[]])).reduce((T,ie)=>({...T,[ie.toLowerCase()]:{required:!0}}),{}),xt=(f==null?void 0:f.includes("EMAIL"))??!1,Ct=(f==null?void 0:f.includes("PHONE_NUMBER"))??!1;(r||fe)&&(P.Auth={Cognito:{identityPoolId:r,allowGuestAccess:g!=="enable",signUpVerificationMethod:d,userAttributes:xo,userPoolClientId:Ro,userPoolId:fe,mfa:To,passwordFormat:Ao,loginWith:{username:!(xt||Ct),email:xt,phone:Ct}}});const Co=Xe?Object.keys(Xe).length>0:!1,Po=p?p.length>0:!1;if(P.Auth&&Co&&(P.Auth.Cognito.loginWith={...P.Auth.Cognito.loginWith,oauth:{...Ko(Xe),...Po&&{providers:Wo(p)}}}),L&&(P.Storage={S3:{bucket:L,region:ne,dangerouslyConnectToHttpEndpointForTesting:Rt}}),vt){const{amazon_location_service:T}=vt;P.Geo={LocationService:{maps:T.maps,geofenceCollections:T.geofenceCollections,searchIndices:T.search_indices,region:T.region}}}if(Tt&&(P.API={...P.API,REST:Tt.reduce((T,ie)=>{const{name:_o,endpoint:No,region:Dt,service:Ot}=ie;return{...T,[_o]:{endpoint:No,...Ot?{service:Ot}:void 0,...Dt?{region:Dt}:void 0}}},{})}),Z){const{VoiceId:T}=((Ut=(Mt=Z==null?void 0:Z.convert)==null?void 0:Mt.speechGenerator)==null?void 0:Ut.defaults)??{};P.Predictions=T?{...Z,convert:{...Z.convert,speechGenerator:{...Z.convert.speechGenerator,defaults:{voiceId:T}}}}:Z}return P},Lt=e=>(e==null?void 0:e.split(","))??[],Ko=({domain:e,scope:t,redirectSignIn:n,redirectSignOut:o,responseType:s})=>({domain:e,scopes:t,redirectSignIn:Lt(n),redirectSignOut:Lt(o),responseType:s}),Wo=e=>e.map(t=>{const n=t.toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)}),qo=Symbol("oauth-listener"),_=[];for(let e=0;e<256;++e)_.push((e+256).toString(16).slice(1));function Ho(e,t=0){return(_[e[t+0]]+_[e[t+1]]+_[e[t+2]]+_[e[t+3]]+"-"+_[e[t+4]]+_[e[t+5]]+"-"+_[e[t+6]]+_[e[t+7]]+"-"+_[e[t+8]]+_[e[t+9]]+"-"+_[e[t+10]]+_[e[t+11]]+_[e[t+12]]+_[e[t+13]]+_[e[t+14]]+_[e[t+15]]).toLowerCase()}let Qe;const Vo=new Uint8Array(16);function $o(){if(!Qe){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Qe=crypto.getRandomValues.bind(crypto)}return Qe(Vo)}const zo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kt={randomUUID:zo};function Go(e,t,n){var s;if(kt.randomUUID&&!t&&!e)return kt.randomUUID();e=e||{};const o=e.random??((s=e.rng)==null?void 0:s.call(e))??$o();if(o.length<16)throw new Error("Random bytes length must be >= 16");if(o[6]=o[6]&15|64,o[8]=o[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[n+i]=o[i];return t}return Ho(o)}function jo(e){const{version:t}=e;return t?t.startsWith("1"):!1}function Yo(e){if(!e)return;const{bucket_name:t,aws_region:n,buckets:o}=e;return{S3:{bucket:t,region:n,buckets:o&&rs(o)}}}function Jo(e){if(!e)return;const{user_pool_id:t,user_pool_client_id:n,identity_pool_id:o,password_policy:s,mfa_configuration:i,mfa_methods:r,unauthenticated_identities_enabled:d,oauth:c,username_attributes:a,standard_required_attributes:u,groups:h,passwordless:l}=e,p={Cognito:{userPoolId:t,userPoolClientId:n,groups:h}};
1return o&&(p.Cognito={...p.Cognito,identityPoolId:o}),s&&(p.Cognito.passwordFormat={requireLowercase:s.require_lowercase,requireNumbers:s.require_numbers,requireUppercase:s.require_uppercase,requireSpecialCharacters:s.require_symbols,minLength:s.min_length??6}),i&&(p.Cognito.mfa={status:is(i),smsEnabled:r==null?void 0:r.includes("SMS"),totpEnabled:r==null?void 0:r.includes("TOTP")}),d&&(p.Cognito.allowGuestAccess=d),c&&(p.Cognito.loginWith={oauth:{domain:c.domain,redirectSignIn:c.redirect_sign_in_uri,redirectSignOut:c.redirect_sign_out_uri,responseType:c.response_type==="token"?"token":"code",scopes:c.scopes,providers:ss(c.identity_providers)}}),a&&(p.Cognito.loginWith={...p.Cognito.loginWith,email:a.includes("email"),phone:a.includes("phone_number"),username:a.includes("username")}),u&&(p.Cognito.userAttributes=u.reduce((f,g)=>({...f,[g]:{required:!0}}),{})),l&&(p.Cognito.passwordless={emailOtpEnabled:l.email_otp_enabled,smsOtpEnabled:l.sms_otp_enabled,webAuthn:l.web_authn?{relyingPartyId:l.web_authn.relying_party_id,userVerification:l.web_authn.user_verification}:void 0,preferredChallenge:l.preferred_challenge}),p}function Xo(e){if(!(e!=null&&e.amazon_pinpoint))return;const{amazon_pinpoint:t}=e;return{Pinpoint:{appId:t.app_id,region:t.aws_region}}}function Qo(e){if(!e)return;const{aws_region:t,geofence_collections:n,maps:o,search_indices:s}=e;return{LocationService:{region:t,searchIndices:s,geofenceCollections:n,maps:o}}}function Zo(e){if(!e)return;const{aws_region:t,default_authorization_type:n,url:o,api_key:s,model_introspection:i}=e;return{GraphQL:{endpoint:o,defaultAuthMode:zn(n),region:t,apiKey:s,modelIntrospection:i}}}function es(e){if(!(e!=null&&e.events))return;const{url:t,aws_region:n,api_key:o,default_authorization_type:s}=e.events;return{Events:{endpoint:t,defaultAuthMode:zn(s),region:n,apiKey:o}}}function ts(e){if(!e)return;const{aws_region:t,channels:n,amazon_pinpoint_app_id:o}=e,s=n.includes("IN_APP_MESSAGING"),i=n.includes("APNS")||n.includes("FCM");if(!(s||i))return;const r={};return s&&(r.InAppMessaging={Pinpoint:{appId:o,region:t}}),i&&(r.PushNotification={Pinpoint:{appId:o,region:t}}),r}function ns(e){const t={};if(e.storage&&(t.Storage=Yo(e.storage)),e.auth&&(t.Auth=Jo(e.auth)),e.analytics&&(t.Analytics=Xo(e.analytics)),e.geo&&(t.Geo=Qo(e.geo)),e.data&&(t.API=Zo(e.data)),e.custom){const n=es(e.custom);n&&"Events"in n&&(t.API={...t.API,...n})}return e.notifications&&(t.Notifications=ts(e.notifications)),t}const os={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};function zn(e){return os[e]}const Bt={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"};function ss(e=[]){return e.reduce((t,n)=>(Bt[n]!==void 0&&t.push(Bt[n]),t),[])}function is(e){return e==="OPTIONAL"?"optional":e==="REQUIRED"?"on":"off"}function rs(e){const t={};return e.forEach(({name:n,bucket_name:o,aws_region:s,paths:i})=>{if(n in t)throw new Error(`Duplicate friendly name found: ${n}. Name must be unique.`);const r=i?Object.entries(i).reduce((d,[c,a])=>(a!==void 0&&(d[c]=a),d),{}):void 0;t[n]={bucketName:o,region:s,paths:r}}),t}const as=e=>Object.keys(e).some(t=>t.startsWith("aws_"))?Bo(e):jo(e)?ns(e):e;function cs(e,t,n,o){function s(i){return i instanceof n?i:new n(function(r){r(i)})}return new(n||(n=Promise))(function(i,r){function d(u){try{a(o.next(u))}catch(h){r(h)}}function c(u){try{a(o.throw(u))}catch(h){r(h)}}function a(u){u.done?i(u.value):s(u.value).then(d,c)}a((o=o.apply(e,t||[])).next())})}function ds(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,s,i,r=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return r.next=d(0),r.throw=d(1),r.return=d(2),typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function d(a){return function(u){return c([a,u])}}function c(a){if(o)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(n=0)),n;)try{if(o=1,s&&(i=a[0]&2?s.return:a[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,a[1])).done)return i;switch(s=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,s=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(u){a=[6,u],s=0}finally{o=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}var k=64,us=32,ls=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756
1734187,3204031479,3329325298]),hs=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ps=Math.pow(2,53)-1,Ke=function(){function e(){this.state=Int32Array.from(hs),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return e.prototype.update=function(t){if(this.finished)throw new Error("Attempted to update an already finished hash.");var n=0,o=t.byteLength;if(this.bytesHashed+=o,this.bytesHashed*8>ps)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;o>0;)this.buffer[this.bufferLength++]=t[n++],o--,this.bufferLength===k&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var t=this.bytesHashed*8,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),o=this.bufferLength;if(n.setUint8(this.bufferLength++,128),o%k>=k-8){for(var s=this.bufferLength;s<k;s++)n.setUint8(s,0);this.hashBuffer(),this.bufferLength=0}for(var s=this.bufferLength;s<k-8;s++)n.setUint8(s,0);n.setUint32(k-8,Math.floor(t/4294967296),!0),n.setUint32(k-4,t),this.hashBuffer(),this.finished=!0}for(var i=new Uint8Array(us),s=0;s<8;s++)i[s*4]=this.state[s]>>>24&255,i[s*4+1]=this.state[s]>>>16&255,i[s*4+2]=this.state[s]>>>8&255,i[s*4+3]=this.state[s]>>>0&255;return i},e.prototype.hashBuffer=function(){for(var t=this,n=t.buffer,o=t.state,s=o[0],i=o[1],r=o[2],d=o[3],c=o[4],a=o[5],u=o[6],h=o[7],l=0;l<k;l++){if(l<16)this.temp[l]=(n[l*4]&255)<<24|(n[l*4+1]&255)<<16|(n[l*4+2]&255)<<8|n[l*4+3]&255;else{var p=this.temp[l-2],f=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10;p=this.temp[l-15];var g=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3;this.temp[l]=(f+this.temp[l-7]|0)+(g+this.temp[l-16]|0)}var y=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&a^~c&u)|0)+(h+(ls[l]+this.temp[l]|0)|0)|0,I=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&i^s&r^i&r)|0;
1h=u,u=a,a=c,c=d+y|0,d=r,r=i,i=s,s=y+I|0}o[0]+=s,o[1]+=i,o[2]+=r,o[3]+=d,o[4]+=c,o[5]+=a,o[6]+=u,o[7]+=h},e}();const fs=e=>new TextEncoder().encode(e);var Es=typeof Buffer<"u"&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:fs;function Gn(e){return e instanceof Uint8Array?e:typeof e=="string"?Es(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}function gs(e){return typeof e=="string"?e.length===0:e.byteLength===0}var Ve=function(){function e(t){this.secret=t,this.hash=new Ke,this.reset()}return e.prototype.update=function(t){if(!(gs(t)||this.error))try{this.hash.update(Gn(t))}catch(n){this.error=n}},e.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},e.prototype.digest=function(){return cs(this,void 0,void 0,function(){return ds(this,function(t){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new Ke,this.secret){this.outer=new Ke;var t=ms(this.secret),n=new Uint8Array(k);n.set(t);for(var o=0;o<k;o++)t[o]^=54,n[o]^=92;this.hash.update(t),this.outer.update(n);for(var o=0;o<t.byteLength;o++)t[o]=0}},e}();function ms(e){var t=Gn(e);if(t.byteLength>k){var n=new Ke;n.update(t),t=n.digest()}var o=new Uint8Array(k);return o.set(t),o}for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`)}var x;(function(e){e.WebUnknown="0",e.React="1",e.NextJs="2",e.Angular="3",e.VueJs="4",e.Nuxt="5",e.Svelte="6",e.ServerSideUnknown="100",e.ReactSSR="101",e.NextJsSSR="102",e.AngularSSR="103",e.VueJsSSR="104",e.NuxtSSR="105",e.SvelteSSR="106",e.ReactNative="201",e.Expo="202"})(x||(x={}));var nt;(function(e){e.AI="ai",e.API="api",e.Auth="auth",e.Analytics="analytics",e.DataStore="datastore",e.Geo="geo",e.InAppMessaging="inappmessaging",e.Interactions="interactions",e.Predictions="predictions",e.PubSub="pubsub",e.PushNotification="pushnotification",e.Storage="storage"})(nt||(nt={}));var Kt;(function(e){e.CreateConversation="1",e.GetConversation="2",e.ListConversations="3",e.DeleteConversation="4",e.SendMessage="5",e.ListMessages="6",e.OnMessage="7",e.Generation="8",e.UpdateConversation="9"})(Kt||(Kt={}));var Wt;(function(e){e.Record="1",e.IdentifyUser="2"})(Wt||(Wt={}));var qt;(function(e){e.GraphQl="1",e.Get="2",e.Post="3",e.Put="4",e.Patch="5",e.Del="6",e.Head="7"})(qt||(qt={}));var C;(function(e){e.SignUp="1",e.ConfirmSignUp="2",e.ResendSignUpCode="3",e.SignIn="4",e.FetchMFAPreference="6",e.UpdateMFAPreference="7",e.SetUpTOTP="10",e.VerifyTOTPSetup="11",e.ConfirmSignIn="12",e.DeleteUserAttributes="15",e.DeleteUser="16",e.UpdateUserAttributes="17",e.FetchUserAttributes="18",e.ConfirmUserAttribute="22",e.SignOut="26",e.UpdatePassword="27",e.ResetPassword="28",e.ConfirmResetPassword="29",e.FederatedSignIn="30",e.RememberDevice="32",e.ForgetDevice="33",e.FetchDevices="34",e.SendUserAttributeVerificationCode="35",e.SignInWithRedirect="36",e.StartWebAuthnRegistration="37",e.CompleteWebAuthnRegistration="38",e.ListWebAuthnCredentials="39",e.DeleteWebAuthnCredential="40"})(C||(C={}));var Ht;(function(e){e.Subscribe="1",e.GraphQl="2"})(Ht||(Ht={}));var Vt;(function(e){e.SearchByText="0",e.SearchByCoordinates="1",e.SearchForSuggestions="2",e.SearchByPlaceId="3",e.SaveGeofences="4",e.GetGeofence="5",e.ListGeofences="6",e.DeleteGeofences="7"})(Vt||(Vt={}));var $t;(function(e){e.SyncMessages="1",e.IdentifyUser="2",e.NotifyMessageInteraction="3"})($t||($t={}));var zt;(function(e){e.None="0"})(zt||(zt={}));var Gt;(function(e){e.Convert="1",e.Identify="2",e.Interpret="3"})(Gt||(Gt={}));var jt;(function(e){e.Subscribe="1"})(jt||(jt={}));var Yt;(function(e){e.InitializePushNotifications="1",e.IdentifyUser="2"})(Yt||(Yt={}));var Jt;(function(e){e.UploadData="1",e.DownloadData="2",e.List="3",e.Copy="4",e.Remove="5",e.GetProperties="6",e.GetUrl="7",e.GetDataAccess="8",e.ListCallerAccessGrants="9"})(Jt||(Jt={}));const Ss="6.17.0",je=()=>typeof global<"u",me=()=>typeof window<"u",jn=()=>typeof document<"u",lt=()=>typeof process<"u",Me=(e,t)=>!!Object.keys(e).find(n=>n.startsWith(t));var Xt={};function ys(){const e=o=>o.startsWith("_react")||o.startsWith("__react"),t=o=>Object.keys(o).find(e),n=()=>Array.from(document.querySelectorAll("[id]"));return jn()&&n().some(t)}function Is(){return lt()&&typeof Xt<"u"&&!!Object.keys(Xt).find(e=>e.includes("react"))}function ws(){return me()&&Me(window,"__VUE")}function Rs(){return je()&&Me(global,"__VUE")}var Qt={};function vs(){return me()&&Me(window,"__SVELTE")}function Ts(){return lt()&&typeof Qt<"u"&&!!Object.keys(Qt).find(e=>e.includes("svelte"))}function As(){return me()&&window.next&&typeof window.next=="object"}function xs(){return je()&&(Me(global,"__next")||Me(global,"__NEXT"))}function Cs(){return me()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function Ps(){return je()&&typeof global.__NUXT_PATHS__<"u"}var Zt={};function _s(){const e=!!(jn()&&document.querySelector("[ng-version]")),t=!!(me()&&typeof window.ng<"u");return e||t}function Ns(){var e;return lt()&&typeof Zt=="object"&&((e=Zt.npm_lifecycle_script)==null?void 0:e.startsWith("ng "))||!1}function bs(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}function Ms(){return je()&&typeof global.expo<"u"}function Us(){return me()}const Ds=[{platform:x.Expo,detectionMethod:Ms},{platform:x.ReactNative,detectionMethod:bs},{platform:x.NextJs,detectionMethod:As},{platform:x.Nuxt,detectionMethod:Cs},{platform:x.Angular,detectionMethod:_s},{platform:x.React,detectionMethod:ys},{platform:x.VueJs,detectionMethod:ws},{platform:x.Svelte,detectionMethod:vs},{platform:x.WebUnknown,detectionMethod:Us},{platform:x.NextJsSSR,detectionMethod:xs},{platform:x.NuxtSSR,detectionMethod:Ps},{platform:x.ReactSSR,detectionMethod:Is},{platform:x.VueJsSSR,detectionMethod:Rs},{platform:x.AngularSSR,detectionMethod:Ns},{platform:x.SvelteSSR,detectionMethod:Ts}];function Os(){var e;return((e=Ds.find(t=>t.detectionMethod()))==null?void 0:e.platform)||x.ServerSideUnknown}let Ne;const Ze=[];let ot=!1;const Fs=10,Ls=10,ks=1e3,Yn=()=>{var e;if(!Ne){if(Ne=Os(),ot)for(;Ze.length;)(e=Ze.pop())==null||e();else Ze.forEach(t=>{t()});en(x.ServerSideUnknown,Fs),en(x.WebUnknown,Ls)}return Ne};function Bs(){Ne=void 0}function en(e,t){Ne===e&&!ot&&setTimeout(()=>{Bs(),ot=!0,setTimeout(Yn,ks)},t)}const Ks={},Ws=(e,t)=>{var n,o;return(o=(n=Ks[e])==null?void 0:n[t])==null?void 0:o.additionalDetails},qs="aws-amplify",Hs=e=>e.replace(/\+.*/,""),Vs=({category:e,action:t}={})=>{const n=[[qs,Hs(Ss)]];if(e&&n.push([e,t]),n.push(["framework",Yn()]),e&&t){const o=Ws(e,t);o&&o.forEach(s=>
1{n.push(s)})}return n},Jn=e=>Vs(e).map(([o,s])=>o&&s?`${o}/${s}`:o).join(" "),Xn=()=>typeof window<"u"&&typeof window.document<"u",tn=new V("Auth");class $s{configure(t,n){var o,s;this.authConfig=t,this.authOptions=n,t&&((o=t.Cognito)!=null&&o.userPoolEndpoint)&&tn.warn(nn("Amazon Cognito User Pool")),t&&((s=t.Cognito)!=null&&s.identityPoolEndpoint)&&tn.warn(nn("Amazon Cognito Identity Pool"))}async fetchAuthSession(t={}){var i,r,d,c,a,u;let n,o;const s=await this.getTokens(t);return s?(o=(r=(i=s.accessToken)==null?void 0:i.payload)==null?void 0:r.sub,n=await((c=(d=this.authOptions)==null?void 0:d.credentialsProvider)==null?void 0:c.getCredentialsAndIdentityId({authConfig:this.authConfig,tokens:s,authenticated:!0,forceRefresh:t.forceRefresh}))):n=await((u=(a=this.authOptions)==null?void 0:a.credentialsProvider)==null?void 0:u.getCredentialsAndIdentityId({authConfig:this.authConfig,authenticated:!1,forceRefresh:t.forceRefresh})),{tokens:s,credentials:n==null?void 0:n.credentials,identityId:n==null?void 0:n.identityId,userSub:o}}async clearCredentials(){var t,n;await((n=(t=this.authOptions)==null?void 0:t.credentialsProvider)==null?void 0:n.clearCredentialsAndIdentityId())}async getTokens(t){var n,o;return await((o=(n=this.authOptions)==null?void 0:n.tokenProvider)==null?void 0:o.getTokens(t))??void 0}}const nn=e=>`You are using a custom Amazon ${e} endpoint, ensure the endpoint is correct.`;class zs{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new $s}configure(t,n){var s,i,r,d,c;const o=as(t);this.resourcesConfig=o,n&&(this.libraryOptions=n),this.resourcesConfig=$n(this.resourcesConfig),this.Auth.configure(this.resourcesConfig.Auth,this.libraryOptions.Auth),((s=this.resourcesConfig.Analytics)!=null&&s.Pinpoint||(r=(i=this.resourcesConfig.Notifications)==null?void 0:i.InAppMessaging)!=null&&r.Pinpoint||(c=(d=this.resourcesConfig.Notifications)==null?void 0:d.PushNotification)!=null&&c.Pinpoint)&&console.warn("AWS will end support for Amazon Pinpoint on October 30, 2026. The guidance is to use AWS End User Messaging for push notifications and SMS, Amazon Simple Email Service for sending emails, Amazon Connect for campaigns, journeys, endpoints, and engagement analytics. Pinpoint recommends Amazon Kinesis for event collection and mobile analytics."),He.dispatch("core",{event:"configure",data:this.resourcesConfig},"Configure",be),this.notifyOAuthListener(),this.isConfigured=!0}getConfig(){return this.isConfigured||console.warn("Amplify has not been configured. Please call Amplify.configure() before using this service."),this.resourcesConfig}[qo](t){var n,o,s;(o=(n=this.resourcesConfig.Auth)==null?void 0:n.Cognito.loginWith)!=null&&o.oauth?t((s=this.resourcesConfig.Auth)==null?void 0:s.Cognito):this.oAuthListener=t}notifyOAuthListener(){var t,n,o;!((n=(t=this.resourcesConfig.Auth)==null?void 0:t.Cognito.loginWith)!=null&&n.oauth)||!this.oAuthListener||(this.oAuthListener((o=this.resourcesConfig.Auth)==null?void 0:o.Cognito),this.oAuthListener=void 0)}}const z=new zs,Qn=e=>{const{headers:t,statusCode:n}=e;return{...Gs(e)?e.$metadata:{},httpStatusCode:n,requestId:t["x-amzn-requestid"]??t["x-amzn-request-id"]??t["x-amz-request-id"],extendedRequestId:t["x-amz-id-2"],cfId:t["x-amz-cf-id"]}},Gs=e=>typeof(e==null?void 0:e.$metadata)=="object",Zn=async e=>{if(!e||e.statusCode<300)return;const t=await eo(e),o=(r=>{const[d]=r.toString().split(/[,:]+/);return d.includes("#")?d.split("#")[1]:d})(e.headers["x-amzn-errortype"]??t.code??t.__type??"UnknownError"),s=t.message??t.Message??"Unknown error",i=new Error(s);return Object.assign(i,{name:o,$metadata:Qn(e)})},eo=async e=>{if(!e.body)throw new Error("Missing response payload");const t=await e.body.json();return Object.assign(t,{$metadata:Qn(e)})},Se=(e,t,n,o)=>async(s,i)=>{const r={...o,...s},d=await r.endpointResolver(r,i),c=await t(i,d),a=await e(c,{...r});return n(a)},js=5*60*1e3;function Ys(e=js){return o=>{const s=2**o*100+100*Math.random();return s>e?!1:s}}const to=3,on="amz-sdk-invocation-id",Js="amz-sdk-request",sn=5*60*1e3,Xs=e=>{const n=Ys(sn)(e);return n===!1?sn:n},Qs=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],Zs=e=>!!e&&Qs.includes(e),ei=e=>async(t,n)=>{const o=n??await e(t)??void 0,s=(o==null?void 0:o.code)||(o==null?void 0:o.name),i=t==null?void 0:t.statusCode;return{retryable:si(n)||oi(i,s)||Zs(s)||ii(i,s)}},ti=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],ni=["TimeoutError","RequestTimeout","RequestTimeoutException"],oi=(e,t)=>e===429||!!t&&ti.includes(t),si=e=>[re.NetworkError,"ERR_NETWORK"].includes(e==null?void 0:e.name),ii=(e,t)=>!!e&&[500,502,503,504].includes(e)||!!t&&ni.includes(t),ri=({maxAttempts:e=to,retryDecider:t,computeDelay:n,abortSignal:o})=>{if(e<1)throw new Error("maxAttempts must be greater than 0");return(s,i)=>
1async function(d){let c,a=i.attemptsCount??0,u;const h=()=>{if(u)return rn(u,a),u;throw rn(c,a),c};for(;!(o!=null&&o.aborted)&&a<e;){try{u=await s(d),c=void 0}catch(f){c=f,u=void 0}a=(i.attemptsCount??0)>a?i.attemptsCount??0:a+1,i.attemptsCount=a;const{isCredentialsExpiredError:l,retryable:p}=await t(u,c,i);if(p){if(i.isCredentialsExpired=!!l,!(o!=null&&o.aborted)&&a<e){const f=n(a);await ai(f,o)}continue}else return h()}if(o!=null&&o.aborted)throw new Error("Request aborted.");return h()}},ai=(e,t)=>{if(t!=null&&t.aborted)return Promise.resolve();let n,o;const s=new Promise(i=>{o=i,n=setTimeout(i,e)});return t==null||t.addEventListener("abort",function i(r){clearTimeout(n),t==null||t.removeEventListener("abort",i),o()}),s},rn=(e,t)=>{Object.prototype.toString.call(e)==="[object Object]"&&(e.$metadata={...e.$metadata??{},attempts:t})},ci=Go,di=()=>e=>async function(n){return n.headers[on]||(n.headers[on]=ci()),e(n)},ui=({maxAttempts:e=to})=>(t,n)=>async function(s){const i=n.attemptsCount??0;return s.headers[Js]=`attempt=${i+1}; max=${e}`,t(s)},li=({userAgentHeader:e="x-amz-user-agent",userAgentValue:t=""})=>n=>async function(s){if(t.trim().length===0)return await n(s);{const i=e.toLowerCase();return s.headers[i]=s.headers[i]?`${s.headers[i]} ${t}`:t,await n(s)}},no=(e,t)=>(n,o)=>{const s={};let i=r=>e(r,o);for(let r=t.length-1;r>=0;r--){const d=t[r];i=d(o)(i,s)}return i(n)},et=e=>{let t;return()=>(t||(t=e()),t)},hi=e=>!["HEAD","GET"].includes(e.toUpperCase()),pi=async({url:e,method:t,headers:n,body:o},{abortSignal:s,cache:i,withCrossDomainCredentials:r})=>{var h;let d;try{d=await fetch(e,{method:t,headers:n,body:hi(t)?o:void 0,signal:s,cache:i,credentials:r?"include":"same-origin"})}catch(l){throw l instanceof TypeError?new U({name:re.NetworkError,message:"A network error has occurred.",underlyingError:l}):l}const c={};(h=d.headers)==null||h.forEach((l,p)=>{c[p.toLowerCase()]=l});const a={statusCode:d.status,headers:c,body:null},u=Object.assign(d.body??{},{text:et(()=>d.text()),blob:et(()=>d.blob()),json:et(()=>d.json())});return{...a,body:u}},fi=no(pi,[li,di,ri,ui]),oo={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},Ei={partitions:[oo,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]},gi=e=>{const{partitions:t}=Ei;for(const{regions:n,outputs:o,regionRegex:s}of t){const i=new RegExp(s);if(n.includes(e)||i.test(e))return o.dnsSuffix}return oo.outputs.dnsSuffix},ht=URL;class _e extends U{constructor(){super({name:re.PlatformNotSupported,message:"Function not supported on current platform"})}}class so{constructor(t){this.storage=t}async setItem(t,n){if(!this.storage)throw new _e;this.storage.setItem(t,n)}async getItem(t){if(!this.storage)throw new _e;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new _e;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new _e;this.storage.clear()}}class io{constructor(){this.storage=new Map}get length(){return this.storage.size}key(t){return t>this.length-1?null:Array.from(this.storage.keys())[t]}setItem(t,n){this.storage.set(t,n)}getItem(t){return this.storage.get(t)??null}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}}const ro=new V("CoreStorageUtils"),mi=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{ro.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new io},ao=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return ro.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new io}};class Si extends so{constructor(){super(mi())}}class yi extends so{constructor(){super(ao())}}class Ii{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new _e;return this._storage}setItem(t,n){this.storage.setItem(t,n)}getItem(t){return this.storage.getItem(t)}removeItem(t){this.storage.removeItem(t)}clear(){this.storage.clear()}}
1class wi extends Ii{constructor(){super(ao())}}const co=new Si;new yi;const j=new wi,Ri=e=>{let t;return async(...n)=>t||(t=new Promise((o,s)=>{e(...n).then(i=>{o(i)}).catch(i=>{s(i)}).finally(()=>{t=void 0})}),t)};function an({expiresAt:e,clockDrift:t,tolerance:n=5e3}){return Date.now()+t+n>e}const vi=async()=>{const{userAgentData:e}=navigator;if(!e)return navigator.userAgent;const{platform:t="",platformVersion:n="",model:o="",architecture:s="",fullVersionList:i=[]}=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),r=i.map(c=>`${c.brand}/${c.version}`).join(";");return[t,n,s,o,t,r].filter(c=>c).join(" ")||navigator.userAgent};function Ti(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}const Ue={convert(e,t={urlSafe:!1,skipPadding:!1}){const n=typeof e=="string"?e:Ti(e);let o=Do()(n);return t.urlSafe&&(o=o.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(o=o.replace(/=/g,"")),o}};function Ai(){return Uo().getRandomValues(new Uint32Array(1))[0]}function xi(e){const{words:t}=e,{sigBytes:n}=e,o=[];for(let s=0;s<n;s++){const i=t[s>>>2]>>>24-s%4*8&255;o.push((i>>>4).toString(16)),o.push((i&15).toString(16))}return o.join("")}class pt{constructor(t,n){this.words=[];let o=t;o=this.words=o||[],n!==void 0?this.sigBytes=n:this.sigBytes=o.length*4}random(t){const n=[];for(let o=0;o<t;o+=4)n.push(Ai());return new pt(n,t)}toString(){return xi(this)}}var S;(function(e){e.EmptySignInUsername="EmptySignInUsername",e.EmptySignInPassword="EmptySignInPassword",e.CustomAuthSignInPassword="CustomAuthSignInPassword",e.EmptySignUpUsername="EmptySignUpUsername",e.EmptySignUpPassword="EmptySignUpPassword",e.EmptyConfirmSignUpUsername="EmptyConfirmSignUpUsername",e.EmptyConfirmSignUpCode="EmptyConfirmSignUpCode",e.EmptyResendSignUpCodeUsername="EmptyresendSignUpCodeUsername",e.EmptyChallengeResponse="EmptyChallengeResponse",e.EmptyConfirmResetPasswordUsername="EmptyConfirmResetPasswordUsername",e.EmptyConfirmResetPasswordNewPassword="EmptyConfirmResetPasswordNewPassword",e.EmptyConfirmResetPasswordConfirmationCode="EmptyConfirmResetPasswordConfirmationCode",e.EmptyResetPasswordUsername="EmptyResetPasswordUsername",e.EmptyVerifyTOTPSetupCode="EmptyVerifyTOTPSetupCode",e.EmptyConfirmUserAttributeCode="EmptyConfirmUserAttributeCode",e.IncorrectMFAMethod="IncorrectMFAMethod",e.EmptyUpdatePassword="EmptyUpdatePassword",e.InvalidPreferredChallenge="InvalidPreferredChallenge"})(S||(S={}));const Ci={[S.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[S.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[S.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[S.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[S.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[S.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[S.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[S.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[S.EmptySignInPassword]:{message:"password is required to signIn"},[S.EmptySignInUsername]:{message:"username is required to signIn"},[S.EmptySignUpPassword]:{message:"password is required to signUp"},[S.EmptySignUpUsername]:{message:"username is required to signUp"},[S.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[S.IncorrectMFAMethod]:{message:"Incorrect MFA method was chosen. It should be either SMS, TOTP, or EMAIL",recoverySuggestion:"Try to pass SMS, TOTP, or EMAIL as the challengeResponse"},[S.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[S.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[S.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"},[S.InvalidPreferredChallenge]:{message:"The preferred challenge is not enabled in your backend configuration",recoverySuggestion:"Ensure the authentication method is enabled in your Amplify backend configuration"}};var cn;
1(function(e){e.DEFAULT_MSG="Authentication Error",e.EMPTY_EMAIL="Email cannot be empty",e.EMPTY_PHONE="Phone number cannot be empty",e.EMPTY_USERNAME="Username cannot be empty",e.INVALID_USERNAME="The username should either be a string or one of the sign in types",e.EMPTY_PASSWORD="Password cannot be empty",e.EMPTY_CODE="Confirmation code cannot be empty",e.SIGN_UP_ERROR="Error creating account",e.NO_MFA="No valid MFA method provided",e.INVALID_MFA="Invalid MFA type",e.EMPTY_CHALLENGE="Challenge response cannot be empty",e.NO_USER_SESSION="Failed to get the session because the user is empty",e.NETWORK_ERROR="Network Error",e.DEVICE_CONFIG="Device tracking has not been configured in this User Pool",e.AUTOSIGNIN_ERROR="Please use your credentials to sign in",e.OAUTH_ERROR="Couldn't finish OAuth flow, check your User Pool HostedUI settings"})(cn||(cn={}));var X;(function(e){e.SignInException="SignInException",e.OAuthSignInError="OAuthSignInException"})(X||(X={}));class m extends U{constructor(t){super(t),this.constructor=m,Object.setPrototypeOf(this,m.prototype)}}function M(e,t){const{message:n,recoverySuggestion:o}=Ci[t];if(!e)throw new m({name:t,message:n,recoverySuggestion:o})}function R(e){const t=e==null?void 0:e.split("_")[0];if(!e||e.indexOf("_")<0||!t||typeof t!="string")throw new m({name:"InvalidUserPoolId",message:"Invalid user pool id provided."});return t}function ec(e){if(!e||!e.includes(":"))throw new m({name:"InvalidIdentityPoolIdException",message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."});return e.split(":")[0]}var dn;(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(dn||(dn={}));var un;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(un||(un={}));var ln;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UsernameExistsException="UsernameExistsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(ln||(ln={}));var hn;(function(e){e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyFailedAttemptsException="TooManyFailedAttemptsException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(hn||(hn={}));var pn;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyFailedAttemptsException="TooManyFailedAttemptsException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(pn||(pn={}));var fn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(fn||(fn={}));var En;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(En||(En={}));var gn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(gn||(gn={}));var mn;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPol
1icyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(mn||(mn={}));var Sn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Sn||(Sn={}));var yn;(function(e){e.ExternalServiceException="ExternalServiceException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceConflictException="ResourceConflictException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException"})(yn||(yn={}));var In;(function(e){e.ExternalServiceException="ExternalServiceException",e.InternalErrorException="InternalErrorException",e.InvalidIdentityPoolConfigurationException="InvalidIdentityPoolConfigurationException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceConflictException="ResourceConflictException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException"})(In||(In={}));var wn;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(wn||(wn={}));var Rn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException"})(Rn||(Rn={}));var $e;(function(e){e.PasswordResetRequiredException="PasswordResetRequiredException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})($e||($e={}));var vn;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPol
1icyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(vn||(vn={}));var Tn;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.MFAMethodNotFoundException="MFAMethodNotFoundException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Tn||(Tn={}));var An;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(An||(An={}));var xn;(function(e){e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidPasswordException="InvalidPasswordException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UsernameExistsException="UsernameExistsException"})(xn||(xn={}));var Cn;(function(e){e.AliasExistsException="AliasExistsException",e.CodeDeliveryFailureException="CodeDeliveryFailureException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidEmailRoleAccessPolicyException="InvalidEmailRoleAccessPolicyException",e.InvalidLambdaResponseException="InvalidLambdaResponseException",e.InvalidParameterException="InvalidParameterException",e.InvalidSmsRoleAccessPolicyException="InvalidSmsRoleAccessPolicyException",e.InvalidSmsRoleTrustRelationshipException="InvalidSmsRoleTrustRelationshipException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Cn||(Cn={}));var Pn;(function(e){e.CodeMismatchException="CodeMismatchException",e.EnableSoftw
1areTokenMFAException="EnableSoftwareTokenMFAException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Pn||(Pn={}));var _n;(function(e){e.AliasExistsException="AliasExistsException",e.CodeMismatchException="CodeMismatchException",e.ExpiredCodeException="ExpiredCodeException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.LimitExceededException="LimitExceededException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(_n||(_n={}));var Nn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Nn||(Nn={}));var bn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.InvalidUserPoolConfigurationException="InvalidUserPoolConfigurationException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(bn||(bn={}));const Ye="UserUnAuthenticatedException",Pi="UserAlreadyAuthenticatedException",_i="DeviceMetadataNotFoundException",Ni="InvalidRedirectException",bi="InvalidAppSchemeException",Mi="InvalidPreferredRedirectUrlException",tc=new m({name:Ni,message:"signInRedirect or signOutRedirect had an invalid format or was not found.",recoverySuggestion:"Please make sure the signIn/Out redirect in your oauth config is valid."});new m({name:bi,message:"A valid non-http app scheme was not found in the config.",recoverySuggestion:"Please make sure a valid custom app scheme is present in the config."});new m({name:Mi,message:"The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.",recoverySuggestion:"Please make sure a matching preferredRedirectUrl is provided."});const Ui="InvalidOriginException",nc=new m({name:Ui,message:"redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin",recoverySuggestion:"Please call signInWithRedirect from the same origin."}),oc="OAuthSignOutException",Di="TokenRefreshException",Oi="UnexpectedSignInInterruptionException";function Fi(e){if(!e||!e.accessToken)throw new m({name:Ye,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function sc(e){if(!e||!e.idToken)throw new m({name:Ye,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}
1const Li=new m({name:Di,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow. 2 Please change your oauth configuration to use 'code grant' flow.`,recoverySuggestion:`Please logout and change your Amplify configuration to use "code grant" flow. 3 E.g { responseType: 'code' }`}),ki=new m({name:Ye,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function Bi(e){if(qi(e))throw Li;if(!Wi(e))throw ki}function uo(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new m({name:_i,message:"Either deviceKey, deviceGroupKey or secretPassword were not found during the sign-in process.",recoverySuggestion:"Make sure to not clear storage after calling the signIn API."})}const Ki={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function lo(e){return(e==null?void 0:e.accessToken)||(e==null?void 0:e.idToken)}function Wi(e){return lo(e)&&(e==null?void 0:e.refreshToken)}function qi(e){return lo(e)&&!(e!=null&&e.refreshToken)}const Hi=async e=>{var d,c;const t=(d=e.getConfig().Auth)==null?void 0:d.Cognito;w(t);const n=await e.Auth.getTokens({forceRefresh:!1});Fi(n);const{"cognito:username":o,sub:s}=((c=n.idToken)==null?void 0:c.payload)??{},i={username:o,userId:s},r=Vi(n);return r&&(i.signInDetails=r),i};function Vi(e){return e==null?void 0:e.signInDetails}const ho=async()=>Hi(z),N=(e,t)=>Jn({category:nt.Auth,action:e,...t}),ye=e=>(t,n)=>{const o=$i(e),s=JSON.stringify(t);return zi(n,o,s)},$i=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}),zi=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"});function te(e){if(!e||e.name==="Error"||e instanceof TypeError)throw new m({name:re.Unknown,message:"An unknown error has occurred.",underlyingError:e})}const Ie=()=>async e=>{if(e.statusCode>=300){const t=await Zn(e);throw te(t),new m({name:t.name,message:t.message,metadata:t.$metadata})}return eo(e)},Gi=()=>(e,t)=>async function(o){var s,i,r;return o.headers={...o.headers,"cache-control":"no-store",...await((r=(i=(s=z.libraryOptions)==null?void 0:s.Auth)==null?void 0:i.headers)==null?void 0:r.call(i))},e(o)},we=no(fi,[Gi]),po="cognito-idp",Re={service:po,retryDecider:ei(Zn),computeDelay:Xs,get userAgentValue(){return Jn()},cache:"no-store"},De=e=>Se(we,ye("InitiateAuth"),Ie(),{...Re,...e}),O=e=>Se(we,ye("RespondToAuthChallenge"),Ie(),{...Re,...e}),ji=e=>Se(we,ye("VerifySoftwareToken"),Ie(),{...Re,...e}),Yi=e=>Se(we,ye("AssociateSoftwareToken"),Ie(),{...Re,...e}),Ji=({region:e})=>({url:new ht(`https://${po}.${e}.${gi(e)}`)}),v=({endpointOverride:e})=>t=>e?{url:new ht(e)}:Ji(t),Xi=e=>Se(we,ye("GetTokensFromRefreshToken"),Ie(),{...Re,...e}),Qi=async({tokens:e,authConfig:t,username:n,clientMetadata:o})=>{var f;w(t==null?void 0:t.Cognito);const{userPoolId:s,userPoolClientId:i,userPoolEndpoint:r}=t.Cognito,d=R(s);Bi(e);const c=Xi({endpointResolver:v({endpointOverride:r})}),{AuthenticationResult:a}=await c({region:d},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:(f=e.deviceMetadata)==null?void 0:f.deviceKey,ClientMetadata:o}),u=Ee((a==null?void 0:a.AccessToken)??""),h=a!=null&&a.IdToken?Ee(a.IdToken):void 0,{iat:l}=u.payload;if(!l)throw new m({name:"iatNotFoundException",message:"iat not found in access token"});const p=l*1e3-new Date().getTime();return{accessToken:u,idToken:h,clockDrift:p,refreshToken:(a==null?void 0:a.RefreshToken)??e.refreshToken,username:n}},Zi=Ri(Qi),er={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var ze;(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(ze||(ze={}));const tr={[ze.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},nr=ct(tr),Mn="CognitoIdentityServiceProvider";class or{getKeyValueStorage(){if(!this.keyValueStorage)throw new m
3({name:"KeyValueStorageNotFoundException",message:"KeyValueStorage was not found in TokenStore"});return this.keyValueStorage}setKeyValueStorage(t){this.keyValueStorage=t}setAuthConfig(t){this.authConfig=t}async loadTokens(){try{const t=await this.getAuthKeys(),n=await this.getKeyValueStorage().getItem(t.accessToken);if(!n)throw new m({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});const o=Ee(n),s=await this.getKeyValueStorage().getItem(t.idToken),i=s?Ee(s):void 0,r=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,d=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",c=Number.parseInt(d),a=await this.getKeyValueStorage().getItem(t.signInDetails),u={accessToken:o,idToken:i,refreshToken:r,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:c,username:await this.getLastAuthUser()};return a&&(u.signInDetails=JSON.parse(a)),u}catch{return null}}async storeTokens(t){nr(t!==void 0,ze.InvalidAuthTokens);const n=t.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),n);const o=await this.getAuthKeys();await this.getKeyValueStorage().setItem(o.accessToken,t.accessToken.toString()),t.idToken?await this.getKeyValueStorage().setItem(o.idToken,t.idToken.toString()):await this.getKeyValueStorage().removeItem(o.idToken),t.refreshToken?await this.getKeyValueStorage().setItem(o.refreshToken,t.refreshToken):await this.getKeyValueStorage().removeItem(o.refreshToken),t.deviceMetadata&&(t.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(o.deviceKey,t.deviceMetadata.deviceKey),t.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(o.deviceGroupKey,t.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(o.randomPasswordKey,t.deviceMetadata.randomPassword)),t.signInDetails?await this.getKeyValueStorage().setItem(o.signInDetails,JSON.stringify(t.signInDetails)):await this.getKeyValueStorage().removeItem(o.signInDetails),await this.getKeyValueStorage().setItem(o.clockDrift,`${t.clockDrift}`)}async clearTokens(){const t=await this.getAuthKeys();await Promise.all([this.getKeyValueStorage().removeItem(t.accessToken),this.getKeyValueStorage().removeItem(t.idToken),this.getKeyValueStorage().removeItem(t.clockDrift),this.getKeyValueStorage().removeItem(t.refreshToken),this.getKeyValueStorage().removeItem(t.signInDetails),this.getKeyValueStorage().removeItem(this.getLastAuthUserKey()),this.getKeyValueStorage().removeItem(t.oauthMetadata)])}async getDeviceMetadata(t){const n=await this.getAuthKeys(t),o=await this.getKeyValueStorage().getItem(n.deviceKey),s=await this.getKeyValueStorage().getItem(n.deviceGroupKey),i=await this.getKeyValueStorage().getItem(n.randomPasswordKey);return i&&s&&o?{deviceKey:o,deviceGroupKey:s,randomPassword:i}:null}async clearDeviceMetadata(t){const n=await this.getAuthKeys(t);await Promise.all([this.getKeyValueStorage().removeItem(n.deviceKey),this.getKeyValueStorage().removeItem(n.deviceGroupKey),this.getKeyValueStorage().removeItem(n.randomPasswordKey)])}async getAuthKeys(t){var o;w((o=this.authConfig)==null?void 0:o.Cognito);const n=t??await this.getLastAuthUser();return sr(Mn,`${this.authConfig.Cognito.userPoolClientId}.${n}`)}getLastAuthUserKey(){var n;w((n=this.authConfig)==null?void 0:n.Cognito);const t=this.authConfig.Cognito.userPoolClientId;return`${Mn}.${t}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(t){const{oauthMetadata:n}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(n,JSON.stringify(t))}async getOAuthMetadata(){const{oauthMetadata:t}=await this.getAuthKeys(),n=await this.getKeyValueStorage().getItem(t);return n&&JSON.parse(n)}}const sr=(e,t)=>fo(er)(`${e}`,t);function fo(e){const t=Object.values({...e});return(n,o)=>t.reduce((s,i)=>({...s,[i]:`${n}.${o}.${i}`}),{})}const Un="amplify-signin-with-hostedUI",W="CognitoIdentityServiceProvider";class ir{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(t.inflightOAuth),this.keyValueStorage.removeItem(t.oauthPKCE),this.keyValueStorage.removeItem(t.oauthState)])}async clearOAuthData(){w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(Un),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){w(this.cognitoConfig);const n=q(W,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthState,t)}loadPKCE(){w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){w(this.cognitoConfig);const n=q(W,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){w(this.cognitoConfig);const n=q(W,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(n.inflightOAuth,`${t}`)}async loadOAuthSignIn(){var i;w(this.cognitoConfig);const t=q(W,this.cognitoConfig.userPoolClientId),n=await this.keyValueStorage.getItem(Un),[o,s]=((i=await this.keyValueStorage.getItem(t.oauthSignIn))==null?void 0:i.split(","))??[];return{isOAuthSignIn:o==="true"||n==="true",preferPrivateSession:s==="true"}}async storeOAuthSignIn(t,n=!1){w(this.cognitoConfig);const o=q(W,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.oauthSignIn,`${t},${n}`)}}const q=(e,t)=>
3fo(Ki)(e,t),Dn=new ir(co),st=[],rr=e=>{st.push(e)},ic=()=>{var e;for(;st.length;)(e=st.pop())==null||e()};class ar{constructor(){this.waitForInflightOAuth=Xn()?async()=>{if(await Dn.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,n)=>{rr(t)}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){Dn.setAuthConfig(t.Cognito),this.authConfig=t}setTokenRefresher(t){this.tokenRefresher=t}setAuthTokenStore(t){this.tokenStore=t}getTokenStore(){if(!this.tokenStore)throw new m({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new m({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}setClientMetadataProvider(t){this.clientMetadataProvider=t}async getTokens(t){var r,d,c,a,u,h;let n;try{w((r=this.authConfig)==null?void 0:r.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,n=await this.getTokenStore().loadTokens();const o=await this.getTokenStore().getLastAuthUser();if(n===null)return null;const s=!!(n!=null&&n.idToken)&&an({expiresAt:(((c=(d=n.idToken)==null?void 0:d.payload)==null?void 0:c.exp)??0)*1e3,clockDrift:n.clockDrift??0}),i=an({expiresAt:(((u=(a=n.accessToken)==null?void 0:a.payload)==null?void 0:u.exp)??0)*1e3,clockDrift:n.clockDrift??0});return(t!=null&&t.forceRefresh||s||i)&&(n=await this.refreshTokens({tokens:n,username:o,clientMetadata:(t==null?void 0:t.clientMetadata)??await((h=this.clientMetadataProvider)==null?void 0:h.call(this))}),n===null)?null:{accessToken:n==null?void 0:n.accessToken,idToken:n==null?void 0:n.idToken,signInDetails:n==null?void 0:n.signInDetails}}async refreshTokens({tokens:t,username:n,clientMetadata:o}){try{const{signInDetails:s}=t,i=await this.getTokenRefresher()({tokens:t,authConfig:this.authConfig,username:n,clientMetadata:o});return i.signInDetails=s,await this.setTokens({tokens:i}),He.dispatch("auth",{event:"tokenRefresh"},"Auth",be),i}catch(s){return this.handleErrors(s)}}handleErrors(t){if(te(t),this.isAuthenticationError(t)&&this.clearTokens(),He.dispatch("auth",{event:"tokenRefresh_failure",data:{error:t}},"Auth",be),t.name.startsWith("NotAuthorizedException"))return null;throw t}isAuthenticationError(t){return["NotAuthorizedException","TokenRevokedException","UserNotFoundException","PasswordResetRequiredException","UserNotConfirmedException","RefreshTokenReuseException"].some(o=>{var s,i;return(i=(s=t==null?void 0:t.name)==null?void 0:s.startsWith)==null?void 0:i.call(s,o)})}async setTokens({tokens:t}){return this.getTokenStore().storeTokens(t)}async clearTokens(){return this.getTokenStore().clearTokens()}getDeviceMetadata(t){return this.getTokenStore().getDeviceMetadata(t)}clearDeviceMetadata(t){return this.getTokenStore().clearDeviceMetadata(t)}setOAuthMetadata(t){return this.getTokenStore().setOAuthMetadata(t)}getOAuthMetadata(){return this.getTokenStore().getOAuthMetadata()}}class cr{constructor(){this.authTokenStore=new or,this.authTokenStore.setKeyValueStorage(co),this.tokenOrchestrator=new ar,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(Zi)}getTokens(t={}){return this.tokenOrchestrator.getTokens(t)}setKeyValueStorage(t){this.authTokenStore.setKeyValueStorage(t)}
3setClientMetadataProvider(t){this.tokenOrchestrator.setClientMetadataProvider(t)}setAuthConfig(t){this.authTokenStore.setAuthConfig(t),this.tokenOrchestrator.setAuthConfig(t)}}const dr=new cr,{tokenOrchestrator:Q}=dr;async function ce(e){if(e.AccessToken){const t=Ee(e.AccessToken),n=(t.payload.iat||0)*1e3,o=new Date().getTime(),s=n>0?n-o:0;let i,r,d;e.RefreshToken&&(r=e.RefreshToken),e.IdToken&&(i=Ee(e.IdToken)),e!=null&&e.NewDeviceMetadata&&(d=e.NewDeviceMetadata);const c={accessToken:t,idToken:i,refreshToken:r,clockDrift:s,deviceMetadata:d,username:e.username};e!=null&&e.signInDetails&&(c.signInDetails=e.signInDetails),await Q.setTokens({tokens:c})}else throw new U({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const ur="Unable to get user session following successful sign-in.",de=async()=>{try{He.dispatch("auth",{event:"signedIn",data:await ho()},"Auth",be)}catch(e){throw e.name===Ye?new m({name:Oi,message:ur,recoverySuggestion:"This most likely is due to auth tokens not being persisted. If you are using cookie store, please ensure cookies can be correctly set from your server."}):e}};function Eo(){return{active:!1}}const lr=(e,t)=>{switch(t.type){case"SET_USERNAME":return{...e,username:t.value};case"SET_SESSION":return{...e,session:t.value};case"START":return{...e,active:!0};case"RESET":return Eo();default:return e}},hr=e=>{let t=e(Eo(),{type:"RESET"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},go=hr(lr),pr=3*60*1e3,ke="CognitoSignInState",Y={username:`${ke}.username`,challengeName:`${ke}.challengeName`,signInSession:`${ke}.signInSession`,expiry:`${ke}.expiry`},fr=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return Be({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return Be(t.value),{...t.value};case"SET_CHALLENGE_NAME":return Be({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return Be({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return gr();case"RESET_STATE":return mo(),ft();default:return e}},Er=e=>{const t=Number(e),n=Date.now();return t<=n},K=()=>{$.dispatch({type:"RESET_STATE"})},mo=()=>{for(const e of Object.values(Y))j.removeItem(e)},ft=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),gr=()=>{const e=j.getItem(Y.expiry);if(!e||Er(e))return mo(),ft();const t=j.getItem(Y.username)??void 0,n=j.getItem(Y.challengeName)??void 0,o=j.getItem(Y.signInSession)??void 0;return{username:t,challengeName:n,signInSession:o}},mr=e=>{let t=e(ft(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},$=mr(fr);function ue(e){$.dispatch({type:"SET_SIGN_IN_STATE",value:e})}const Be=({challengeName:e,signInSession:t,username:n})=>{n&&j.setItem(Y.username,n),e&&j.setItem(Y.challengeName,e),t&&(j.setItem(Y.signInSession,t),j.setItem(Y.expiry,String(Date.now()+pr)))},On="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.";class J extends U{constructor(t){super(t),this.constructor=J,Object.setPrototypeOf(this,J.prototype)}}var A;(function(e){e.PasskeyNotSupported="PasskeyNotSupported",e.PasskeyAlreadyExists="PasskeyAlreadyExists",e.InvalidPasskeyRegistrationOptions="InvalidPasskeyRegistrationOptions",e.InvalidPasskeyAuthenticationOptions="InvalidPasskeyAuthenticationOptions",e.RelyingPartyMismatch="RelyingPartyMismatch",e.PasskeyRegistrationFailed="PasskeyRegistrationFailed",e.PasskeyRetrievalFailed="PasskeyRetrievalFailed",e.PasskeyRegistrationCanceled="PasskeyRegistrationCanceled",e.PasskeyAuthenticationCanceled="PasskeyAuthenticationCanceled",e.PasskeyOperationAborted="PasskeyOperationAborted"})(A||(A={}));const tt="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",Fn="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Ge={[A.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:On},[A.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:Fn},[A.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:Fn},[A.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:On},[A.PasskeyRetrievalFailed]:{message:"Device failed to retrieve passkey.",recoverySuggestion:"Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP."},[A.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[A.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:tt},[A.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:tt},[A.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:tt},[A.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},Et=ct(Ge,J),Sr=e=>{if(e instanceof Error){if(e.name==="AbortError"){const{message:t,recoverySuggestion:n}=Ge[A.PasskeyOperationAborted];
3return new J({name:A.PasskeyOperationAborted,message:t,recoverySuggestion:n,underlyingError:e})}if(e.name==="SecurityError"){const{message:t,recoverySuggestion:n}=Ge[A.RelyingPartyMismatch];return new J({name:A.RelyingPartyMismatch,message:t,recoverySuggestion:n,underlyingError:e})}}return new J({name:re.Unknown,message:"An unknown error has occurred.",underlyingError:e})},yr=e=>{if(e instanceof J)return e;if(e instanceof Error&&e.name==="NotAllowedError"){const{message:t,recoverySuggestion:n}=Ge[A.PasskeyAuthenticationCanceled];return new J({name:A.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:n,underlyingError:e})}return Sr(e)},Ir=()=>Xn()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",Pe=e=>Ue.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0}),Ln=e=>Uint8Array.from(dt.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer,wr=e=>{const t=Ln(e.challenge),n=(e.allowCredentials||[]).map(o=>({...o,id:Ln(o.id)}));return{...e,challenge:t,allowCredentials:n}},Rr=e=>{const t={clientDataJSON:Pe(e.response.clientDataJSON),authenticatorData:Pe(e.response.authenticatorData),signature:Pe(e.response.signature)};e.response.userHandle&&(t.userHandle=Pe(e.response.userHandle));const n={id:e.id,rawId:Pe(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(n.authenticatorAttachment=e.authenticatorAttachment),n};function vr(e){Et(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,A.PasskeyRetrievalFailed)}const Tr=async e=>{try{const t=Ir();Et(t,A.PasskeyNotSupported);const n=wr(e),o=await navigator.credentials.get({publicKey:n});return vr(o),Rr(o)}catch(t){throw yr(t)}},Ar=e=>Se(we,ye("ConfirmDevice"),Ie(),{...Re,...e}),We={convert(e){return new TextEncoder().encode(e)}};function E(e,t){e!=null&&this.fromString(e,t)}function b(){return new E(null,null)}let ee;const xr=0xdeadbeefcafe,kn=(xr&16777215)===15715070;function Cr(e,t,n,o,s,i){for(;--i>=0;){const r=t*this[e++]+n[o]+s;s=Math.floor(r/67108864),n[o++]=r&67108863}return s}function Pr(e,t,n,o,s,i){const r=t&32767,d=t>>15;for(;--i>=0;){let c=this[e]&32767;const a=this[e++]>>15,u=d*c+a*r;c=r*c+((u&32767)<<15)+n[o]+(s&1073741823),s=(c>>>30)+(u>>>15)+d*a+(s>>>30),n[o++]=c&1073741823}return s}function _r(e,t,n,o,s,i){const r=t&16383,d=t>>14;for(;--i>=0;){let c=this[e]&16383;const a=this[e++]>>14,u=d*c+a*r;c=r*c+((u&16383)<<14)+n[o]+s,s=(c>>28)+(u>>14)+d*a,n[o++]=c&268435455}return s}const Bn=typeof navigator<"u";Bn&&kn&&navigator.appName==="Microsoft Internet Explorer"?(E.prototype.am=Pr,ee=30):Bn&&kn&&navigator.appName!=="Netscape"?(E.prototype.am=Cr,ee=26):(E.prototype.am=_r,ee=28);E.prototype.DB=ee;E.prototype.DM=(1<<ee)-1;E.prototype.DV=1<<ee;const gt=52;E.prototype.FV=Math.pow(2,gt);E.prototype.F1=gt-ee;E.prototype.F2=2*ee-gt;const Nr="0123456789abcdefghijklmnopqrstuvwxyz",Je=[];let ve,B;ve=48;for(B=0;B<=9;++B)Je[ve++]=B;ve=97;for(B=10;B<36;++B)Je[ve++]=B;ve=65;for(B=10;B<36;++B)Je[ve++]=B;function Kn(e){return Nr.charAt(e)}function br(e,t){const n=Je[e.charCodeAt(t)];return n??-1}function Mr(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function Ur(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}function mt(e){const t=b();return t.fromInt(e),t}function Dr(e,t){let n;if(t===16)n=4;else if(t===8)n=3;else if(t===2)n=1;else if(t===32)n=5;else if(t===4)n=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let o=e.length,s=!1,i=0;for(;--o>=0;){const r=br(e,o);if(r<0){e.charAt(o)==="-"&&(s=!0);continue}s=!1,i===0?this[this.t++]=r:i+n>this.DB?(this[this.t-1]|=(r&(1<<this.DB-i)-1)<<i,this[this.t++]=r>>this.DB-i):this[this.t-1]|=r<<i,i+=n,i>=this.DB&&(i-=this.DB)}this.clamp(),s&&E.ZERO.subTo(this,this)}function Or(){const e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function Fr(e){if(this.s<0)return"-"+this.negate().toString(e);let t;if(e==16)t=4;else if(e===8)t=3;else if(e===2)t=1;else if(e===32)t=5;else if(e===4)t=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");const n=(1<<t)-1;let o,s=!1,i="",r=this.t,d=this.DB-r*this.DB%t;if(r-- >0)for(d<this.DB&&(o=this[r]>>d)>0&&(s=!0,i=Kn(o));r>=0;)d<t?(o=(this[r]&(1<<d)-1)<<t-d,o|=this[--r]>>(d+=this.DB-t)):(o=this[r]>>(d-=t)&n,d<=0&&(d+=this.DB,--r)),o>0&&(s=!0),s&&(i+=Kn(o));return s?i:"0"}function Lr(){const e=b();return E.ZERO.subTo(this,e),e}function kr(){return this.s<0?this.negate():this}function Br(e){let t=this.s-e.s;if(t!=0)return t;let n=this.t;if(t=n-e.t,t!=0)return this.s<0?-t:t;for(;--n>=0;)if((t=this[n]-e[n])!=0)return t;return 0}function St(e){let t=1,n;return(n=e>>>16)!==0&&(e=n,t+=16),(n=e>>8)!==0&&(e=n,t+=8),(n=e>>4)!==0&&(e=n,t+=4),(n=e>>2)!==0&&(e=n,t+=2),(n=e>>1)!==0&&(e=n,t+=1),t}function Kr(){return this.t<=0?0:this.DB*(this.t-1)+St(this[this.t-1]^this.s&this.DM)}function Wr(e,t){let n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s}function qr(e,t){for(let n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s}function Hr(e,t){const n=e%this.DB,o=this.DB-n,s=(1<<o)-1,i=Math.floor(e/this.DB);let r=this.s<<n&this.DM,d;for(d=this.t-1;d>=0;--d)t[d+i+1]=this[d]>>o|r,r=(this[d]&s)<<n;for(d=i-1;d>=0;--d)t[d]=0;t[i]=r,t.t=this.t+i+1,t.s=this.s,t.clamp()}function Vr(e,t){t.s=this.s;const n=Math.floor(e/this.DB);if(n>=this.t){t.t=0;return}const o=e%this.DB,s=this.DB-o,i=(1<<o)-1;t[0]=this[n]>>o;for(let r=n+1;r<this.t;++r)t[r-n-1]|=(this[r]&i)<<s,t[r-n]=this[r]>>o;o>0&&(t[this.t-n-1]|=(this.s&i)<<s),t.t=this.t-n,t.clamp()}function $r(e,t){let n=0,o=0;const s=Math.min(e.t,this.t);for(;n<s;)o+=this[n]-e[n],t[n++]=o&this.DM,o>>=this.DB;if(e.t<this.t){for(o-=e.s;n<this.t;)o+=this[n],t[n++]=o&this.DM,o>>=this.DB;o+=this.s}else{for(o+=this.s;n<e.t;)o-=e[n],t[n++]=o&this.DM,o>>=this.DB;o-=e.s}t.s=o<0?-1:0,o<-1?t[n++]=this.DV+o:o>0&&(t[n++]=o),t.t=n,t.clamp()}function zr(e,t){const n=this.abs(),o=e.abs();let s=n.t;for(t.t=s+o.t;--s>=0;)t[s]=0;for(s=0;s<o.t;++s)t[s+n.t]=n.am(0,o[s],t,s,0,n.t);t.s=0,t.clamp(),this.s!==e.s&&E.ZERO.subTo(t,t)}function Gr(e){const t=this.abs();let n=e.t=2*t.t;for(;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){const o=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,o,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()}function jr(e,t,n){const o=e.abs();if(o.t<=0)return;const s=this.abs();if(s.t<o.t){t!=null&&t.fromInt(0),n!=null&&this.copyTo(n);return}n===null&&(n=b());const i=b(),r=this.s,d=e.s,c=this.DB-St(o[o.t-1]);c>0?(o.lShiftTo(c,i),s.lShiftTo(c,n)):(o.copyTo(i),s.copyTo(n));const a=i.t,u=i[a-1];if(u===0)return;const h=u*(1<<this.F1)+(a>1?i[a-2]>>this.F2:0),l=this.FV/h,p=(1<<this.F1)/h,f=1<<this.F2;let g=n.t,y=g-a;const I=t===null?b():t;
3for(i.dlShiftTo(y,I),n.compareTo(I)>=0&&(n[n.t++]=1,n.subTo(I,n)),E.ONE.dlShiftTo(a,I),I.subTo(i,i);i.t<a;)i[i.t++]=0;for(;--y>=0;){let L=n[--g]===u?this.DM:Math.floor(n[g]*l+(n[g-1]+f)*p);if((n[g]+=i.am(0,L,n,y,0,a))<L)for(i.dlShiftTo(y,I),n.subTo(I,n);n[g]<--L;)n.subTo(I,n)}t!==null&&(n.drShiftTo(a,t),r!==d&&E.ZERO.subTo(t,t)),n.t=a,n.clamp(),c>0&&n.rShiftTo(c,n),r<0&&E.ZERO.subTo(n,n)}function Yr(e){const t=b();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(E.ZERO)>0&&e.subTo(t,t),t}function Jr(){if(this.t<1)return 0;const e=this[0];if(!(e&1))return 0;let t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Xr(e){return this.compareTo(e)===0}function Qr(e,t){let n=0,o=0;const s=Math.min(e.t,this.t);for(;n<s;)o+=this[n]+e[n],t[n++]=o&this.DM,o>>=this.DB;if(e.t<this.t){for(o+=e.s;n<this.t;)o+=this[n],t[n++]=o&this.DM,o>>=this.DB;o+=this.s}else{for(o+=this.s;n<e.t;)o+=e[n],t[n++]=o&this.DM,o>>=this.DB;o+=e.s}t.s=o<0?-1:0,o>0?t[n++]=o:o<-1&&(t[n++]=this.DV+o),t.t=n,t.clamp()}function Zr(e){const t=b();return this.addTo(e,t),t}function ea(e){const t=b();return this.subTo(e,t),t}function ta(e){const t=b();return this.multiplyTo(e,t),t}function na(e){const t=b();return this.divRemTo(e,t,null),t}function Te(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function oa(e){const t=b();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(E.ZERO)>0&&this.m.subTo(t,t),t}function sa(e){const t=b();return e.copyTo(t),this.reduce(t),t}function ia(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(let t=0;t<this.m.t;++t){let n=e[t]&32767;const o=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(n=t+this.m.t,e[n]+=this.m.am(0,o,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function ra(e,t){e.squareTo(t),this.reduce(t)}function aa(e,t,n){e.multiplyTo(t,n),this.reduce(n)}Te.prototype.convert=oa;Te.prototype.revert=sa;Te.prototype.reduce=ia;Te.prototype.mulTo=aa;Te.prototype.sqrTo=ra;function ca(e,t,n){let o=e.bitLength(),s,i=mt(1);const r=new Te(t);if(o<=0)return i;o<18?s=1:o<48?s=3:o<144?s=4:o<768?s=5:s=6;const d=[];let c=3;const a=s-1,u=(1<<s)-1;if(d[1]=r.convert(this),s>1){const I=b();for(r.sqrTo(d[1],I);c<=u;)d[c]=b(),r.mulTo(I,d[c-2],d[c]),c+=2}let h=e.t-1,l,p=!0,f=b(),g;for(o=St(e[h])-1;h>=0;){for(o>=a?l=e[h]>>o-a&u:(l=(e[h]&(1<<o+1)-1)<<a-o,h>0&&(l|=e[h-1]>>this.DB+o-a)),c=s;!(l&1);)l>>=1,--c;if((o-=c)<0&&(o+=this.DB,--h),p)d[l].copyTo(i),p=!1;else{for(;c>1;)r.sqrTo(i,f),r.sqrTo(f,i),c-=2;c>0?r.sqrTo(i,f):(g=i,i=f,f=g),r.mulTo(f,d[l],i)}for(;h>=0&&!(e[h]&1<<o);)r.sqrTo(i,f),g=i,i=f,f=g,--o<0&&(o=this.DB-1,--h)}const y=r.revert(i);return n(null,y),y}E.prototype.copyTo=Mr;E.prototype.fromInt=Ur;E.prototype.fromString=Dr;E.prototype.clamp=Or;E.prototype.dlShiftTo=Wr;E.prototype.drShiftTo=qr;E.prototype.lShiftTo=Hr;E.prototype.rShiftTo=Vr;E.prototype.subTo=$r;E.prototype.multiplyTo=zr;E.prototype.squareTo=Gr;E.prototype.divRemTo=jr;E.prototype.invDigit=Jr;E.prototype.addTo=Qr;E.prototype.toString=Fr;E.prototype.negate=Lr;E.prototype.abs=kr;E.prototype.compareTo=Br;E.prototype.bitLength=Kr;E.prototype.mod=Yr;E.prototype.equals=Xr;E.prototype.add=Zr;E.prototype.subtract=ea;E.prototype.multiply=ta;E.prototype.divide=na;E.prototype.modPow=ca;E.ZERO=mt(0);E.ONE=mt(1);const da=async({a:e,g:t,k:n,x:o,B:s,N:i,U:r})=>new Promise((d,c)=>{t.modPow(o,i,(a,u)=>{if(a){c(a);return}s.subtract(n.multiply(u)).modPow(e.add(r.multiply(o)),i,(h,l)=>{if(h){c(h);return}d(l.mod(i))})})}),ua="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",So={},it={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),So[e]=t,it[t]=e}const ge=e=>{if(e.length%2!==0)throw new Error("Hex encoded strings must have an even number length");const t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2){const o=e.slice(n,n+2).toLowerCase();if(o in it)t[n/2]=it[o];else throw new Error(`Cannot decode unrecognized sequence ${o} as hexadecimal`)}return t},yt=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=So[e[n]];return t},rt=e=>{const t=new Ve;t.update(e);const n=t.digestSync(),o=yt(n);return new Array(64-o.length).join("0")+o},qe=e=>rt(ge(e)),la=/^[89a-f]/i,G=e=>{if(!(e instanceof E))throw new Error("Not a BigInteger");const t=e.compareTo(E.ZERO)<0;let n=e.abs().toString(16);if(n=n.length%2!==0?`0${n}`:n,n=la.test(n)?`00${n}`:n,t){const o=n.split("").map(i=>{const r=~parseInt(i,16)&15;return"0123456789ABCDEF".charAt(r)}).join("");n=new E(o,16).add(E.ONE).toString(16),n.toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},ha=({A:e,B:t})=>{const n=new E(qe(G(e)+G(t)),16);if(n.equals(E.ZERO))throw new Error("U cannot be zero.");return n},pa=(e,t,n)=>{const o=new Ve(t);o.update(e);const s=o.digestSync(),i=new Ve(s);return i.update(n),i.digestSync().slice(0,16)},It=e=>{const t=new pt().random(e).toString();return ge(t)},fa=()=>
3Ue.convert(It(40));class Ea{constructor({userPoolName:t,a:n,g:o,A:s,N:i}){this.encoder=We,this.userPoolName=t,this.a=n,this.g=o,this.A=s,this.N=i,this.k=new E(qe(`${G(i)}${G(o)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new m({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new m({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new m({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(t,n){this.randomPassword=fa();const o=`${t}${n}:${this.randomPassword}`,s=rt(o),i=yt(It(16));return this.saltToHashDevices=G(new E(i,16)),new Promise((r,d)=>{this.g.modPow(new E(qe(this.saltToHashDevices+s),16),this.N,(c,a)=>{if(c){d(c);return}this.verifierDevices=G(a),r()})})}async getPasswordAuthenticationKey({username:t,password:n,serverBValue:o,salt:s}){if(o.mod(this.N).equals(E.ZERO))throw new Error("B cannot be zero.");const i=ha({A:this.A,B:o}),r=`${this.userPoolName}${t}:${n}`,d=rt(r),c=new E(qe(G(s)+d),16),a=await da({a:this.a,g:this.g,k:this.k,x:c,B:o,N:this.N,U:i}),u=this.encoder.convert("Caldera Derived Key"),h=this.encoder.convert("�"),l=new Uint8Array(u.byteLength+h.byteLength);return l.set(u,0),l.set(h,u.byteLength),pa(ge(G(a)),ge(G(i)),l)}}const ga=async({a:e,g:t,N:n})=>new Promise((o,s)=>{t.modPow(e,n,(i,r)=>{if(i){s(i);return}if(r.mod(n).equals(E.ZERO)){s(new Error("Illegal parameter. A mod N cannot be 0."));return}o(r)})}),Oe=async e=>{const t=new E(ua,16),n=new E("2",16),o=ma(),s=await ga({a:o,g:n,N:t});return new Ea({userPoolName:e,a:o,g:n,A:s,N:t})},ma=()=>{const e=yt(It(128));return new E(e,16)};async function le({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:n,accessToken:o}){if(!n)return;const s=e.split("_")[1]||"",i=await Oe(s),r=n==null?void 0:n.DeviceKey,d=n==null?void 0:n.DeviceGroupKey;try{await i.generateHashDevice(d??"",r??"")}catch{return}const c={Salt:Ue.convert(ge(i.getSaltToHashDevices())),PasswordVerifier:Ue.convert(ge(i.getVerifierDevices()))},a=i.getRandomPassword();try{return await Ar({endpointResolver:v({endpointOverride:t})})({region:R(e)},{AccessToken:o,DeviceName:await vi(),DeviceKey:n==null?void 0:n.DeviceKey,DeviceSecretVerifierConfig:c}),{deviceKey:r,deviceGroupKey:d,randomPassword:a}}catch{return}}async function Sa(e){var p;const t=(p=z.getConfig().Auth)==null?void 0:p.Cognito;w(t);const{username:n,signInSession:o,signInDetails:s,challengeName:i}=$.getState();if(i!=="WEB_AUTHN"||!n)throw new m({name:X.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:r}=e;Et(!!r,A.InvalidPasskeyAuthenticationOptions);const d=await Tr(JSON.parse(r)),c=O({endpointResolver:v({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:a,ChallengeParameters:u,AuthenticationResult:h,Session:l}=await c({region:R(t.userPoolId),userAgentValue:N(C.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:n,CREDENTIAL:JSON.stringify(d)},ClientId:t.userPoolClientId,Session:o});if(ue({signInSession:l,username:n,challengeName:a,signInDetails:s}),h)return await ce({...h,username:n,NewDeviceMetadata:await le({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:h.NewDeviceMetadata,accessToken:h.AccessToken}),signInDetails:s}),$.dispatch({type:"RESET_STATE"}),await de(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(a==="WEB_AUTHN")throw new m({name:X.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:a,challengeParameters:u}}function F({username:e,userPoolId:t,userPoolClientId:n}){if(typeof window>"u")return;const o=window.AmazonCognitoAdvancedSecurityData;if(typeof o>"u")return;const s=o.getData(e,t,n);return s?{EncodedData:s}:{}}const ya=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ia=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],yo=()=>{const e=new Date,t=Ia[e.getUTCDay()],n=ya[e.getUTCMonth()],o=e.getUTCDate();let s=e.getUTCHours();s<10&&(s=`0${s}`);let i=e.getUTCMinutes();i<10&&(i=`0${i}`);let r=e.getUTCSeconds();r<10&&(r=`0${r}`);const d=e.getUTCFullYear();return`${t} ${n} ${o} ${s}:${i}:${r} UTC ${d}`},Io=({userPoolName:e,username:t,challengeParameters:n,dateNow:o,hkdf:s})=>{const i=We.convert(e),r=We.convert(t),d=wa(n.SECRET_BLOCK),c=We.convert(o),a=new Uint8Array(i.byteLength+r.byteLength+d.byteLength+c.byteLength);a.set(i,0),a.set(r,i.byteLength),a.set(d,i.byteLength+r.byteLength),a.set(c,i.byteLength+r.byteLength+d.byteLength);const u=new Ve(s);u.update(a);const h=u.digestSync();return Ue.convert(h)},wa=e=>{const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),o=dt.convert(n),s=new Uint8Array(o.length);for(let i=0;i<o.length;
3++i)s[i]=o.charCodeAt(i);return s};async function Fe({username:e,config:t,clientMetadata:n,session:o,tokenOrchestrator:s}){const{userPoolId:i,userPoolEndpoint:r}=t,d=t.userPoolClientId,c=await(s==null?void 0:s.getDeviceMetadata(e));uo(c);const a=await Oe(c.deviceGroupKey),u={USERNAME:e,SRP_A:a.A.toString(16),DEVICE_KEY:c.deviceKey},h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:d,ChallengeResponses:u,ClientMetadata:n,Session:o},l=O({endpointResolver:v({endpointOverride:r})}),{ChallengeParameters:p,Session:f}=await l({region:R(i)},h);return Ra(e,p,n,f,a,t,s)}async function Ra(e,t,n,o,s,{userPoolId:i,userPoolClientId:r,userPoolEndpoint:d},c){const a=await(c==null?void 0:c.getDeviceMetadata(e));uo(a);const u=new E(t==null?void 0:t.SRP_B,16),h=new E(t==null?void 0:t.SALT,16),{deviceKey:l}=a,{deviceGroupKey:p}=a,f=await s.getPasswordAuthenticationKey({username:a.deviceKey,password:a.randomPassword,serverBValue:u,salt:h}),g=yo(),y={USERNAME:(t==null?void 0:t.USERNAME)??e,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:g,PASSWORD_CLAIM_SIGNATURE:Io({username:l,userPoolName:p,challengeParameters:t,dateNow:g,hkdf:f}),DEVICE_KEY:l},I=F({username:e,userPoolId:i,userPoolClientId:r}),L={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r,ChallengeResponses:y,Session:o,ClientMetadata:n,UserContextData:I};return O({endpointResolver:v({endpointOverride:d})})({region:R(i)},L)}async function wt(e,t,n,o,s,i,r){const{userPoolId:d,userPoolClientId:c,userPoolEndpoint:a}=i,u=(d==null?void 0:d.split("_")[1])||"",h=new E(t==null?void 0:t.SRP_B,16),l=new E(t==null?void 0:t.SALT,16),p=t==null?void 0:t.USER_ID_FOR_SRP;if(!p)throw new m({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const f=await s.getPasswordAuthenticationKey({username:p,password:e,serverBValue:h,salt:l}),g=yo(),y={USERNAME:p,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:g,PASSWORD_CLAIM_SIGNATURE:Io({username:p,userPoolName:u,challengeParameters:t,dateNow:g,hkdf:f})},I=await r.getDeviceMetadata(p);I&&I.deviceKey&&(y.DEVICE_KEY=I.deviceKey);const L=F({username:p,userPoolId:d,userPoolClientId:c}),ne={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:y,ClientMetadata:n,Session:o,ClientId:c,UserContextData:L},fe=await O({endpointResolver:v({endpointOverride:a})})({region:R(d)},ne);return fe.ChallengeName==="DEVICE_SRP_AUTH"?Fe({username:p,config:i,clientMetadata:n,session:fe.Session,tokenOrchestrator:r}):fe}async function Ae(e,t,n,o){try{return await e(...t)}catch(s){if(s instanceof m&&s.name==="ResourceNotFoundException"&&s.message.includes("Device does not exist."))return await o.clearDeviceMetadata(n),e(...t);throw s}}function he(e){const{dispatch:t}=$;t({type:"SET_USERNAME",value:e})}async function wo({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:i,preferredChallenge:r}){const{userPoolId:d,userPoolClientId:c,userPoolEndpoint:a}=o,u=(d==null?void 0:d.split("_")[1])||"",h=await Oe(u),l={USERNAME:e,SRP_A:h.A.toString(16)};i==="USER_AUTH"&&r&&(l.PREFERRED_CHALLENGE=r);const p=F({username:e,userPoolId:d,userPoolClientId:c}),f={AuthFlow:i,AuthParameters:l,ClientMetadata:n,ClientId:c,UserContextData:p},y=await De({endpointResolver:v({endpointOverride:a})})({region:R(d),userAgentValue:N(C.SignIn)},f),{ChallengeParameters:I,Session:L}=y,ne=(I==null?void 0:I.USERNAME)??e;return he(ne),y.ChallengeName==="PASSWORD_VERIFIER"?Ae(wt,[t,I,n,L,h,o,s],ne,s):y}async function va({username:e,session:t,selectedChallenge:n,config:o,clientMetadata:s}){return O({endpointResolver:v({endpointOverride:o.userPoolEndpoint})})({region:R(o.userPoolId),userAgentValue:N(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:{USERNAME:e,ANSWER:n},ClientId:o.userPoolClientId,Session:t,ClientMetadata:s})}async function Ta(e,t,n,o,s){var p;const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:d}=o,c={ANSWER:"PASSWORD",USERNAME:e,PASSWORD:t},a=F({username:e,userPoolId:i,userPoolClientId:r}),h=await O({endpointResolver:v({endpointOverride:d})})({region:R(i),userAgentValue:N(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:c,ClientId:r,ClientMetadata:n,Session:s,UserContextData:a}),l=((p=h.ChallengeParameters)==null?void 0:p.USERNAME)??e;return he(l),h}async function Aa(e,t,n,o,s,i){var y;const{userPoolId:r,userPoolClientId:d,userPoolEndpoint:c}=o,a=r.split("_")[1]||"",u=await Oe(a),h={ANSWER:"PASSWORD_SRP",USERNAME:e,SRP_A:u.A.toString(16)},l=F({username:e,userPoolId:r,userPoolClientId:d}),f=await O({endpointResolver:v({endpointOverride:c})})({region:R(r),userAgentValue:N(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:h,ClientId:d,ClientMetadata:n,Session:s,UserContextData:l}),g=((y=f.ChallengeParameters)==null?void 0:y.USERNAME)??e;return he(g),f.ChallengeName==="PASSWORD_VERIFIER"?Ae(wt,[t,f.ChallengeParameters,n,f.Session,u,o,i],g,i
3):f}const at="userAttributes.";function xa(e){return"isSignedIn"in e&&"nextStep"in e}async function Ca({challengeResponse:e,clientMetadata:t,session:n,username:o,config:s,tokenOrchestrator:i}){const{userPoolId:r,userPoolClientId:d,userPoolEndpoint:c}=s,a={USERNAME:o,ANSWER:e},u=await(i==null?void 0:i.getDeviceMetadata(o));u&&u.deviceKey&&(a.DEVICE_KEY=u.deviceKey);const h=F({username:o,userPoolId:r,userPoolClientId:d}),l={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:a,Session:n,ClientMetadata:t,ClientId:d,UserContextData:h},f=await O({endpointResolver:v({endpointOverride:c})})({region:R(r),userAgentValue:N(C.ConfirmSignIn)},l);return f.ChallengeName==="DEVICE_SRP_AUTH"?Fe({username:o,config:s,clientMetadata:t,session:f.Session,tokenOrchestrator:i}):f}async function Pa({challengeResponse:e,username:t,clientMetadata:n,session:o,deviceName:s,config:i}){const{userPoolId:r,userPoolClientId:d,userPoolEndpoint:c}=i;if(e==="EMAIL")return{ChallengeName:"MFA_SETUP",Session:o,ChallengeParameters:{MFAS_CAN_SETUP:'["EMAIL_OTP"]'},$metadata:{}};if(e==="TOTP")return{ChallengeName:"MFA_SETUP",Session:o,ChallengeParameters:{MFAS_CAN_SETUP:'["SOFTWARE_TOKEN_MFA"]'},$metadata:{}};const a={USERNAME:t};if(/^\d+$/.test(e)){const l=ji({endpointResolver:v({endpointOverride:c})}),{Session:p}=await l({region:R(r),userAgentValue:N(C.ConfirmSignIn)},{UserCode:e,Session:o,FriendlyDeviceName:s});$.dispatch({type:"SET_SIGN_IN_SESSION",value:p});const f={ChallengeName:"MFA_SETUP",ChallengeResponses:a,Session:p,ClientMetadata:n,ClientId:d};return O({endpointResolver:v({endpointOverride:c})})({region:R(r),userAgentValue:N(C.ConfirmSignIn)},f)}if(e.includes("@")){a.EMAIL=e;const l={ChallengeName:"MFA_SETUP",ChallengeResponses:a,Session:o,ClientMetadata:n,ClientId:d};return O({endpointResolver:v({endpointOverride:c})})({region:R(r),userAgentValue:N(C.ConfirmSignIn)},l)}throw new m({name:X.SignInException,message:`Cannot proceed with MFA setup using challengeResponse: ${e}`,recoverySuggestion:'Try passing "EMAIL", "TOTP", a valid email, or OTP code as the challengeResponse.'})}async function _a({challengeResponse:e,username:t,clientMetadata:n,session:o,config:s}){const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:d}=s;M(e==="TOTP"||e==="SMS"||e==="EMAIL",S.IncorrectMFAMethod);const c={USERNAME:t,ANSWER:Ba(e)},a=F({username:t,userPoolId:i,userPoolClientId:r}),u={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:c,Session:o,ClientMetadata:n,ClientId:r,UserContextData:a};return O({endpointResolver:v({endpointOverride:d})})({region:R(i),userAgentValue:N(C.ConfirmSignIn)},u)}async function Na({challengeResponse:e,clientMetadata:t,session:n,username:o,requiredAttributes:s,config:i}){const{userPoolId:r,userPoolClientId:d,userPoolEndpoint:c}=i,a={...La(s),NEW_PASSWORD:e,USERNAME:o},u=F({username:o,userPoolId:r,userPoolClientId:d}),h={ChallengeName:"NEW_PASSWORD_REQUIRED",ChallengeResponses:a,ClientMetadata:t,Session:n,ClientId:d,UserContextData:u};return O({endpointResolver:v({endpointOverride:c})})({region:R(r),userAgentValue:N(C.ConfirmSignIn)},h)}async function ba(e,t,n,o,s){var g,y;const{userPoolClientId:i,userPoolId:r,userPoolEndpoint:d}=o,c={USERNAME:e,PASSWORD:t},a=await s.getDeviceMetadata(e);a&&a.deviceKey&&(c.DEVICE_KEY=a.deviceKey);const u=F({username:e,userPoolId:r,userPoolClientId:i}),h={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:c,ClientMetadata:n,ClientId:i,UserContextData:u},p=await De({endpointResolver:v({endpointOverride:d})})({region:R(r),userAgentValue:N(C.SignIn)},h),f=((g=p.ChallengeParameters)==null?void 0:g.USERNAME)??((y=p.ChallengeParameters)==null?void 0:y.USER_ID_FOR_SRP)??e;return he(f),p.ChallengeName==="DEVICE_SRP_AUTH"?Fe({username:f,config:o,clientMetadata:n,session:p.Session,tokenOrchestrator:s}):p}async function Ma(e,t,n,o,s){return wo({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:"USER_SRP_AUTH"})}async function Ua(e,t,n,o){var f;const{userPoolClientId:s,userPoolId:i,userPoolEndpoint:r}=n,d={USERNAME:e},c=await o.getDeviceMetadata(e);c&&c.deviceKey&&(d.DEVICE_KEY=c.deviceKey);const a=F({username:e,userPoolId:i,userPoolClientId:s}),u={AuthFlow:"CUSTOM_AUTH",AuthParameters:d,ClientMetadata:t,ClientId:s,UserContextData:a},l=await De({endpointResolver:v({endpointOverride:r})})({region:R(i),userAgentValue:N(C.SignIn)},u),p=((f=l.ChallengeParameters)==null?void 0:f.USERNAME)??e;return he(p),l.ChallengeName==="DEVICE_SRP_AUTH"?Fe({username:p,config:n,clientMetadata:t,session:l.Session,tokenOrchestrator:o}):l}async function Da(e,t,n,o,s){w(o);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:d}=o,c=(i==null?void 0:i.split("_")[1])||"",a=await Oe(c),u={USERNAME:e,SRP_A:a.A.toString(16),CHALLENGE_NAME:"SRP_A"},h=F({username:e,userPoolId:i,userPoolClientId:r}),l={AuthFlow:"CUSTOM_AUTH",AuthParameters:u,ClientMetadata:n,ClientId:r,UserContextData:h},p=De({endpointResolver:v({endpointOverride:d})}),{ChallengeParameters:f,Session:g}=await p({region:R(i),userAgentValue:N(C.SignIn)},l),y=(f==null?void 0:f.USERNAME)??e;return he(y),Ae(wt,[t,f,n,g,a,o,s],y,s)}async function pe(e){var i;const{challengeName:t,challengeParameters:n,availableChallenges:o}=e,s=(i=z.getConfig().Auth)==null?void 0:i.Cognito;switch(w(s),t){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:n}};case"MFA_SETUP":{const{signInSession:r,username:d}=$.getState(),c=Wn(qn(n.MFAS_CAN_SETUP))||[],a=Wa(c),u=a.includes("TOTP"),h=a.includes("EMAIL");if(u&&h)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:a}};if(h)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(u){const l=Yi({endpointResolver:v({endpointOverride:s.userPoolEndpoint})}),{Session:p,SecretCode:f}=await l({region:R(s.userPoolId)},{Session:r});return $.dispatch({type:"SET_SIGN_IN_SESSION",value:p}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:Oa(f,d)}}}
3throw new m({name:X.SignInException,message:`Cannot initiate MFA setup from available types: ${c}`})}case"NEW_PASSWORD_REQUIRED":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED",missingAttributes:Fa(n.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:Wn(qn(n.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:n.CODE_DELIVERY_DELIVERY_MEDIUM,destination:n.CODE_DELIVERY_DESTINATION}}};case"SOFTWARE_TOKEN_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_TOTP_CODE"}};case"EMAIL_OTP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_EMAIL_CODE",codeDeliveryDetails:{deliveryMedium:n.CODE_DELIVERY_DELIVERY_MEDIUM,destination:n.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{const r=await Sa(n);return xa(r)?r:pe(r)}case"PASSWORD":case"PASSWORD_SRP":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_PASSWORD"}};case"SELECT_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_FIRST_FACTOR_SELECTION",availableChallenges:o}}}throw new m({name:X.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function Oa(e,t){return{sharedSecret:e,getSetupUri:(n,o)=>{const s=`otpauth://totp/${n}:${o??t}?secret=${e}&issuer=${n}`;return new ht(s)}}}function xe(e){if(e===$e.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===$e.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function Fa(e){return e?JSON.parse(e).map(n=>n.includes(at)?n.replace(at,""):n):[]}function La(e){if(!e)return{};const t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${at}${n}`]=o)}),t}async function ka(e,t,n,o,s,i,r,d){const c=d==null?void 0:d.userAttributes,a=d==null?void 0:d.friendlyDeviceName;switch(t){case"WEB_AUTHN":case"SELECT_CHALLENGE":return o==="PASSWORD_SRP"||o==="PASSWORD"?{ChallengeName:o,Session:n,$metadata:{}}:va({username:e,session:n,selectedChallenge:o,config:s,clientMetadata:r});case"SELECT_MFA_TYPE":return _a({challengeResponse:o,clientMetadata:r,session:n,username:e,config:s});case"MFA_SETUP":return Pa({challengeResponse:o,clientMetadata:r,session:n,username:e,deviceName:a,config:s});case"NEW_PASSWORD_REQUIRED":return Na({challengeResponse:o,clientMetadata:r,session:n,username:e,requiredAttributes:c,config:s});case"CUSTOM_CHALLENGE":return Ae(Ca,[{challengeResponse:o,clientMetadata:r,session:n,username:e,config:s,tokenOrchestrator:i}],e,i);case"SMS_MFA":case"SOFTWARE_TOKEN_MFA":case"SMS_OTP":case"EMAIL_OTP":return Ha({challengeName:t,challengeResponse:o,clientMetadata:r,session:n,username:e,config:s,tokenOrchestrator:i});case"PASSWORD":return Ta(e,o,r,s,n);case"PASSWORD_SRP":return Aa(e,o,r,s,n,i)}throw new m({name:X.SignInException,message:`An error occurred during the sign in process. 4 ${t} challengeName returned by the underlying service was not addressed.`})}function Ba(e){let t="SMS_MFA";return e==="TOTP"&&(t="SOFTWARE_TOKEN_MFA"),e==="EMAIL"&&(t="EMAIL_OTP"),t}function Ka(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function Wn(e){if(e)return e.map(Ka).filter(Boolean)}function qn(e){return e?JSON.parse(e):[]}function Wa(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function qa(){let e;try{e=await ho()}catch{}if(e&&e.userId&&e.username)throw new m({name:Pi,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function Le(e){return $.getState().username??e}async function Ha({challengeName:e,challengeResponse:t,clientMetadata:n,session:o,username:s,config:i,tokenOrchestrator:r}){const{userPoolId:d,userPoolClientId:c,userPoolEndpoint:a}=i,u={USERNAME:s};e==="EMAIL_OTP"&&(u.EMAIL_OTP_CODE=t),e==="SMS_MFA"&&(u.SMS_MFA_CODE=t),e==="SMS_OTP"&&(u.SMS_OTP_CODE=t),e==="SOFTWARE_TOKEN_MFA"&&(u.SOFTWARE_TOKEN_MFA_CODE=t);const h=await(r==null?void 0:r.getDeviceMetadata(s));h&&h.deviceKey&&(u.DEVICE_KEY=h.deviceKey);const l=F({username:s,userPoolId:d,userPoolClientId:c}),p={ChallengeName:e,ChallengeResponses:u,Session:o,ClientMetadata:n,ClientId:c,UserContextData:l}
4,g=await O({endpointResolver:v({endpointOverride:a})})({region:R(d),userAgentValue:N(C.ConfirmSignIn)},p);return g.ChallengeName==="DEVICE_SRP_AUTH"?Fe({username:s,config:i,clientMetadata:n,session:g.Session,tokenOrchestrator:r}):g}async function Va(e){var d;const t=(d=z.getConfig().Auth)==null?void 0:d.Cognito;w(t);const{username:n,password:o,options:s}=e,i={loginId:n,authFlowType:"CUSTOM_WITHOUT_SRP"},r=s==null?void 0:s.clientMetadata;M(!!n,S.EmptySignInUsername),M(!o,S.CustomAuthSignInPassword);try{const{ChallengeName:c,ChallengeParameters:a,AuthenticationResult:u,Session:h}=await Ae(Ua,[n,r,t,Q],n,Q),l=Le(n);return ue({signInSession:h,username:l,challengeName:c,signInDetails:i}),u?(await ce({username:l,...u,NewDeviceMetadata:await le({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),K(),await de(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:c,challengeParameters:a})}catch(c){K(),te(c);const a=xe(c.name);if(a)return a;throw c}}async function $a(e){var d;const{username:t,password:n,options:o}=e,s={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=(d=z.getConfig().Auth)==null?void 0:d.Cognito;w(i);const r=o==null?void 0:o.clientMetadata;M(!!t,S.EmptySignInUsername),M(!!n,S.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:a,AuthenticationResult:u,Session:h}=await Da(t,n,r,i,Q),l=Le(t);return ue({signInSession:h,username:l,challengeName:c,signInDetails:s}),u?(await ce({username:l,...u,NewDeviceMetadata:await le({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),K(),await de(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:c,challengeParameters:a})}catch(c){K(),te(c);const a=xe(c.name);if(a)return a;throw c}}function ae(e=!0){go.dispatch({type:"RESET"})}async function Hn(e){var r,d;const{username:t,password:n}=e,o=(r=z.getConfig().Auth)==null?void 0:r.Cognito,s={loginId:t,authFlowType:"USER_SRP_AUTH"};w(o);const i=(d=e.options)==null?void 0:d.clientMetadata;M(!!t,S.EmptySignInUsername),M(!!n,S.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:a,AuthenticationResult:u,Session:h}=await Ma(t,n,i,o,Q),l=Le(t);return ue({signInSession:h,username:l,challengeName:c,signInDetails:s}),u?(await ce({username:l,...u,NewDeviceMetadata:await le({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),K(),await de(),ae(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:c,challengeParameters:a})}catch(c){K(),ae(),te(c);const a=xe(c.name);if(a)return a;throw c}}async function za(e){var d;const{username:t,password:n,options:o}=e,s=(d=z.getConfig().Auth)==null?void 0:d.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};w(s);const r=o==null?void 0:o.clientMetadata;M(!!t,S.EmptySignInUsername),M(!!n,S.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:a,AuthenticationResult:u,Session:h}=await Ae(ba,[t,n,r,s,Q],t,Q),l=Le(t);return ue({signInSession:h,username:l,challengeName:c,signInDetails:i}
4),u?(await ce({...u,username:l,NewDeviceMetadata:await le({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),K(),await de(),ae(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:c,challengeParameters:a})}catch(c){K(),ae(),te(c);const a=xe(c.name);if(a)return a;throw c}}async function Ga({username:e,clientMetadata:t,config:n,tokenOrchestrator:o,preferredChallenge:s,password:i,session:r}){const{userPoolId:d,userPoolClientId:c,userPoolEndpoint:a}=n,u=F({username:e,userPoolId:d,userPoolClientId:c}),h={USERNAME:e};if(s){if(n.passwordless&&(s==="EMAIL_OTP"&&!n.passwordless.emailOtpEnabled||s==="SMS_OTP"&&!n.passwordless.smsOtpEnabled||s==="WEB_AUTHN"&&!n.passwordless.webAuthn)&&M(!1,S.InvalidPreferredChallenge),s==="PASSWORD_SRP")return M(!!i,S.EmptySignInPassword),wo({username:e,password:i,clientMetadata:t,config:n,tokenOrchestrator:o,authFlow:"USER_AUTH",preferredChallenge:s});s==="PASSWORD"&&(M(!!i,S.EmptySignInPassword),h.PASSWORD=i),h.PREFERRED_CHALLENGE=s}const l={AuthFlow:"USER_AUTH",AuthParameters:h,ClientMetadata:t,ClientId:c,UserContextData:u};r&&(l.Session=r);const f=await De({endpointResolver:v({endpointOverride:a})})({region:R(d),userAgentValue:N(C.SignIn)},l);return he(e),f}async function ja(e){var c,a;const{username:t,password:n,options:o}=e,s=(c=z.getConfig().Auth)==null?void 0:c.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};w(s);const r=o==null?void 0:o.clientMetadata,d=(o==null?void 0:o.preferredChallenge)??((a=s==null?void 0:s.passwordless)==null?void 0:a.preferredChallenge);M(!!t,S.EmptySignInUsername);try{const u={username:t,config:s,tokenOrchestrator:Q,clientMetadata:r,preferredChallenge:d,password:n},h=go.getState();h.active&&h.username===t&&(u.session=h.session);const l=await Ga(u),p=Le(t);return ue({signInSession:l.Session,username:p,challengeName:l.ChallengeName,signInDetails:i}
4),l.AuthenticationResult?(await ce({username:p,...l.AuthenticationResult,NewDeviceMetadata:await le({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:l.AuthenticationResult.NewDeviceMetadata,accessToken:l.AuthenticationResult.AccessToken}),signInDetails:i}),K(),await de(),ae(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:l.ChallengeName,challengeParameters:l.ChallengeParameters,availableChallenges:"AvailableChallenges"in l?l.AvailableChallenges:void 0})}catch(u){K(),ae(),te(u);const h=xe(u.name);if(h)return h;throw u}}async function rc(e){var n;ae(!1);const t=(n=e.options)==null?void 0:n.authFlowType;switch(await qa(),t){case"USER_SRP_AUTH":return Hn(e);case"USER_PASSWORD_AUTH":return za(e);case"CUSTOM_WITHOUT_SRP":return Va(e);case"CUSTOM_WITH_SRP":return $a(e);case"USER_AUTH":return ja(e);default:return Hn(e)}}async function ac(e){var a;const{challengeResponse:t,options:n}=e,{username:o,challengeName:s,signInSession:i,signInDetails:r}=$.getState(),d=(a=z.getConfig().Auth)==null?void 0:a.Cognito;w(d);const c=n==null?void 0:n.clientMetadata;if(M(!!t,S.EmptyChallengeResponse),!o||!s||!i)throw new m({name:X.SignInException,message:` 5 An error occurred during the sign in process. 6 7 This most likely occurred due to: 8 1. signIn was not called before confirmSignIn. 9 2. signIn threw an exception. 10 3. page was refreshed during the sign in flow and session has expired. 11 `,recoverySuggestion:"Make sure a successful call to signIn is made before calling confirmSignInand that the session has not expired."});try{const{Session:u,ChallengeName:h,AuthenticationResult:l,ChallengeParameters:p}=await ka(o,s,i,t,d,Q,c,n);return ue({signInSession:u,username:o,challengeName:h,signInDetails:r}),l?(await ce({username:o,...l,NewDeviceMetadata:await le({userPoolId:d.userPoolId,userPoolEndpoint:d.userPoolEndpoint,newDeviceMetadata:l.NewDeviceMetadata,accessToken:l.AccessToken}),signInDetails:r}),K(),await de(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):pe({challengeName:h,challengeParameters:p})}catch(u){te(u);const h=xe(u.name);if(h)return h;throw u}}export{qa as $,z as A,R as B,go as C,Re as D,v as E,Ie as F,cn as G,Xa as H,V as I,X as J,Dn as K,Ee as L,ce as M,Q as N,ic as O,He as P,be as Q,de as R,xn as S,nc as T,Ja as U,tc as V,Qa as W,Xn as X,qo as Y,Ve as Z,Ue as _,no as a,ir as a0,oc as a1,Bi as a2,co as a3,Za as a4,fo as a5,ec as a6,sc as a7,as as a8,dr as a9,Se as b,ac as c,Jn as d,eo as e,Qn as f,ei as g,ht as h,gi as i,Xs as j,Uo as k,ye as l,we as m,te as n,S as o,Zn as p,m as q,ae as r,rc as s,w as t,fi as u,Ci as v,M as w,F as x,N as y,C as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.