const $s="Logging",Gs="x-amz-user-agent",zs="NoHubcallbackProvidedException";var X;(function(e){e.DEBUG="DEBUG",e.ERROR="ERROR",e.INFO="INFO",e.WARN="WARN",e.VERBOSE="VERBOSE",e.NONE="NONE"})(X||(X={}));const vn={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};class z{constructor(t,n=X.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;z.LOG_LEVEL&&(o=z.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(o=window.LOG_LEVEL);const s=vn[o];if(!(vn[t]>=s))return;let r=console.log.bind(console);t===X.ERROR&&console.error&&(r=console.error.bind(console)),t===X.WARN&&console.warn&&(r=console.warn.bind(console)),z.BIND_ALL_LOG_LEVELS&&(t===X.INFO&&console.info&&(r=console.info.bind(console)),t===X.DEBUG&&console.debug&&(r=console.debug.bind(console)));const a=`[${t}] ${this._ts()} ${this.name}`;let c="";if(n.length===1&&typeof n[0]=="string")c=`${a} - ${n[0]}`,r(c);else if(n.length===1)c=`${a} ${n[0]}`,r(a,n[0]);else if(typeof n[0]=="string"){let d=n.slice(1);d.length===1&&(d=d[0]),c=`${a} - ${n[0]} ${d}`,r(`${a} - ${n[0]}`,d)}else c=`${a} ${n}`,r(a,n);for(const d of this._pluggables){const u={message:c,timestamp:Date.now()};d.pushLogs([u])}}log(...t){this._log(X.INFO,...t)}info(...t){this._log(X.INFO,...t)}warn(...t){this._log(X.WARN,...t)}error(...t){this._log(X.ERROR,...t)}debug(...t){this._log(X.DEBUG,...t)}verbose(...t){this._log(X.VERBOSE,...t)}addPluggable(t){t&&t.getCategoryName()===$s&&(this._pluggables.push(t),t.configure(this._config))}listPluggables(){return this._pluggables}}z.LOG_LEVEL=null;z.BIND_ALL_LOG_LEVELS=!1;class Y 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:a,requestId:c}=i;this.metadata={extendedRequestId:r,httpStatusCode:a,requestId:c}}this.constructor=Y,Object.setPrototypeOf(this,Y.prototype)}}var xe;(function(e){e.NoEndpointId="NoEndpointId",e.PlatformNotSupported="PlatformNotSupported",e.Unknown="Unknown",e.NetworkError="NetworkError"})(xe||(xe={}));const zt=(e,t=Y)=>(n,o,s)=>{const{message:i,recoverySuggestion:r}=e[o];if(!n)throw new t({name:o,message:s?`${i} ${s}`:i,recoverySuggestion:r})},ue=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",Ge=new z("Hub");class bo{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){Ge.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===ue||Ge.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){Ge.error(r)}}listen(t,n,o="noname"){let s;if(typeof n!="function")throw new Y({name:zs,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=>{Ge.debug(`Dispatching to ${n} with `,o);try{i.callback(t)}catch(r){Ge.error(r)}})}}const Se=new bo("__default__"),Et=new bo("internal-hub"),jt=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new Y({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},js=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new Y({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},Ys=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new Y({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})},Yt={convert(e,t){let n=e;return t!=null&&t.urlSafe&&(n=n.replace(/-/g,"+").replace(/_/g,"/")),Ys()(n)}};var ce;(function(e){e.AuthTokenConfigException="AuthTokenConfigException",e.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",e.AuthUserPoolException="AuthUserPoolException",e.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",e.OAuthNotConfigureException="OAuthNotConfigureException"})(ce||(ce={}));const Js={[ce.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[ce.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[ce.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[ce.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[ce.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},Jt=zt(Js);function S(e){let t=!0;e?t=!!e.userPoolId&&!!e.userPoolClientId:t=!1,Jt(t,ce.AuthUserPoolException)}function yt(e){var n,o,s,i,r,a,c,d;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)&&!!((a=(r=e==null?void 0:e.loginWith)==null?void 0:r.oauth)!=null&&a.redirectSignIn)&&!!((d=(c=e==null?void 0:e.loginWith)==null?void 0:c.oauth)!=null&&d.responseType);Jt(t,ce.OAuthNotConfigureException)}function lt(e){const t=!!(e!=null&&e.identityPoolId);Jt(t,ce.InvalidIdentityPoolIdException)}function le(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(Yt.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 Uo=e=>{const t=Reflect.ownKeys(e);for(const n of t){const o=e[n];(o&&typeof o=="object"||typeof o=="function")&&Uo(o)}return Object.freeze(e)},Xs=new z("parseAWSExports"),Qs={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},Zs=(e={})=>{var En,mn,Sn,yn,In,wn;if(!Object.prototype.hasOwnProperty.call(e,"aws_project_region"))throw new Y({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_region:s,aws_bots_config:i,aws_cognito_identity_pool_id:r,aws_cognito_sign_up_verification_method:a,aws_cognito_mfa_configuration:c,aws_cognito_mfa_types:d,aws_cognito_password_protection_settings:u,aws_cognito_verification_mechanisms:l,aws_cognito_signup_attributes:h,aws_cognito_social_providers:g,aws_cognito_username_attributes:f,aws_mandatory_sign_in:E,aws_mobile_analytics_app_id:A,aws_mobile_analytics_app_region:v,aws_user_files_s3_bucket:O,aws_user_files_s3_bucket_region:ee,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:Ie,aws_user_pools_id:te,aws_user_pools_web_client_id:fe,geo:D,oauth:qe,predictions:J,aws_cloud_logic_custom:st,Notifications:it,modelIntrospection:$e}=e,B={};A&&(B.Analytics={Pinpoint:{appId:A,region:v}});const{InAppMessaging:Re,Push:Pe}=it??{};if(Re!=null&&Re.AWSPinpoint||Pe!=null&&Pe.AWSPinpoint){if(Re!=null&&Re.AWSPinpoint){const{appId:F,region:_e}=Re.AWSPinpoint;B.Notifications={InAppMessaging:{Pinpoint:{appId:F,region:_e}}}}if(Pe!=null&&Pe.AWSPinpoint){const{appId:F,region:_e}=Pe.AWSPinpoint;B.Notifications={...B.Notifications,PushNotification:{Pinpoint:{appId:F,region:_e}}}}}if(Array.isArray(i)&&(B.Interactions={LexV1:Object.fromEntries(i.map(F=>[F.name,F]))}),o){const F=Qs[n];F||Xs.debug(`Invalid authentication type ${n}. Falling back to IAM.`),B.API={GraphQL:{endpoint:o,apiKey:t,region:s,defaultAuthMode:F??"iam"}},$e&&(B.API.GraphQL.modelIntrospection=$e)}const Ls=c?{status:c&&c.toLowerCase(),totpEnabled:(d==null?void 0:d.includes("TOTP"))??!1,smsEnabled:(d==null?void 0:d.includes("SMS"))??!1}:void 0,Ws=u?{minLength:u.passwordPolicyMinLength,requireLowercase:((En=u.passwordPolicyCharacters)==null?void 0:En.includes("REQUIRES_LOWERCASE"))??!1,requireUppercase:((mn=u.passwordPolicyCharacters)==null?void 0:mn.includes("REQUIRES_UPPERCASE"))??!1,requireNumbers:((Sn=u.passwordPolicyCharacters)==null?void 0:Sn.includes("REQUIRES_NUMBERS"))??!1,requireSpecialCharacters:((yn=u.passwordPolicyCharacters)==null?void 0:yn.includes("REQUIRES_SYMBOLS"))??!1}:void 0,Ks=Array.from(new Set([...l??[],...h??[]])).reduce((F,_e)=>({...F,[_e.toLowerCase()]:{required:!0}}),{}),fn=(f==null?void 0:f.includes("EMAIL"))??!1,pn=(f==null?void 0:f.includes("PHONE_NUMBER"))??!1;(r||te)&&(B.Auth={Cognito:{identityPoolId:r,allowGuestAccess:E!=="enable",signUpVerificationMethod:a,userAttributes:Ks,userPoolClientId:fe,userPoolId:te,mfa:Ls,passwordFormat:Ws,loginWith:{username:!(fn||pn),email:fn,phone:pn}}});const Vs=qe?Object.keys(qe).length>0:!1,Bs=g?g.length>0:!1;if(B.Auth&&Vs&&(B.Auth.Cognito.loginWith={...B.Auth.Cognito.loginWith,oauth:{...ei(qe),...Bs&&{providers:ti(g)}}}),O&&(B.Storage={S3:{bucket:O,region:ee,dangerouslyConnectToHttpEndpointForTesting:Ie}}),D){const{amazon_location_service:F}=D;B.Geo={LocationService:{maps:F.maps,geofenceCollections:F.geofenceCollections,searchIndices:F.search_indices,region:F.region}}}if(st&&(B.API={...B.API,REST:st.reduce((F,_e)=>{const{name:Hs,endpoint:qs,region:Cn,service:An}=_e;return{...F,[Hs]:{endpoint:qs,...An?{service:An}:void 0,...Cn?{region:Cn}:void 0}}},{})}),J){const{VoiceId:F}=((wn=(In=J==null?void 0:J.convert)==null?void 0:In.speechGenerator)==null?void 0:wn.defaults)??{};B.Predictions=F?{...J,convert:{...J.convert,speechGenerator:{...J.convert.speechGenerator,defaults:{voiceId:F}}}}:J}return B},Tn=e=>(e==null?void 0:e.split(","))??[],ei=({domain:e,scope:t,redirectSignIn:n,redirectSignOut:o,responseType:s})=>({domain:e,scopes:t,redirectSignIn:Tn(n),redirectSignOut:Tn(o),responseType:s}),ti=e=>e.map(t=>{const n=t.toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)}),Mo=Symbol("oauth-listener"),H=[];for(let e=0;e<256;++e)H.push((e+256).toString(16).slice(1));function ni(e,t=0){return(H[e[t+0]]+H[e[t+1]]+H[e[t+2]]+H[e[t+3]]+"-"+H[e[t+4]]+H[e[t+5]]+"-"+H[e[t+6]]+H[e[t+7]]+"-"+H[e[t+8]]+H[e[t+9]]+"-"+H[e[t+10]]+H[e[t+11]]+H[e[t+12]]+H[e[t+13]]+H[e[t+14]]+H[e[t+15]]).toLowerCase()}let Pt;const oi=new Uint8Array(16);function si(){if(!Pt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Pt=crypto.getRandomValues.bind(crypto)}return Pt(oi)}const ii=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Rn={randomUUID:ii};function ri(e,t,n){var s;if(Rn.randomUUID&&!t&&!e)return Rn.randomUUID();e=e||{};const o=e.random??((s=e.rng)==null?void 0:s.call(e))??si();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 ni(o)}function ai(e){const{version:t}=e;return t?t.startsWith("1"):!1}function ci(e){if(!e)return;const{bucket_name:t,aws_region:n,buckets:o}=e;return{S3:{bucket:t,region:n,buckets:o&&yi(o)}}}function di(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:a,oauth:c,username_attributes:d,standard_required_attributes:u,groups:l,passwordless:h}=e,g={Cognito:{userPoolId:t,userPoolClientId:n,groups:l}};return o&&(g.Cognito={...g.Cognito,identityPoolId:o}),s&&(g.Cognito.passwordFormat={requireLowercase:s.require_lowercase,requireNumbers:s.require_numbers,requireUppercase:s.require_uppercase,requireSpecialCharacters:s.require_symbols,minLength:s.min_length??6}),i&&(g.Cognito.mfa={status:Si(i),smsEnabled:r==null?void 0:r.includes("SMS"),totpEnabled:r==null?void 0:r.includes("TOTP")}),a&&(g.Cognito.allowGuestAccess=a),c&&(g.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:mi(c.identity_providers)}}),d&&(g.Cognito.loginWith={...g.Cognito.loginWith,email:d.includes("email"),phone:d.includes("phone_number"),username:d.includes("username")}),u&&(g.Cognito.userAttributes=u.reduce((f,E)=>({...f,[E]:{required:!0}}),{})),h&&(g.Cognito.passwordless={emailOtpEnabled:h.email_otp_enabled,smsOtpEnabled:h.sms_otp_enabled,webAuthn:h.web_authn?{relyingPartyId:h.web_authn.relying_party_id,userVerification:h.web_authn.user_verification}:void 0,preferredChallenge:h.preferred_challenge}),g}function ui(e){if(!(e!=null&&e.amazon_pinpoint))return;const{amazon_pinpoint:t}=e;return{Pinpoint:{appId:t.app_id,region:t.aws_region}}}function li(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 hi(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:Do(n),region:t,apiKey:s,modelIntrospection:i}}}function gi(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:Do(s),region:n,apiKey:o}}}function fi(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 pi(e){const t={};if(e.storage&&(t.Storage=ci(e.storage)),e.auth&&(t.Auth=di(e.auth)),e.analytics&&(t.Analytics=ui(e.analytics)),e.geo&&(t.Geo=li(e.geo)),e.data&&(t.API=hi(e.data)),e.custom){const n=gi(e.custom);n&&"Events"in n&&(t.API={...t.API,...n})}return e.notifications&&(t.Notifications=fi(e.notifications)),t}const Ei={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};function Do(e){return Ei[e]}const Pn={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"};function mi(e=[]){return e.reduce((t,n)=>(Pn[n]!==void 0&&t.push(Pn[n]),t),[])}function Si(e){return e==="OPTIONAL"?"optional":e==="REQUIRED"?"on":"off"}function yi(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((a,[c,d])=>(d!==void 0&&(a[c]=d),a),{}):void 0;t[n]={bucketName:o,region:s,paths:r}}),t}const Oo=e=>Object.keys(e).some(t=>t.startsWith("aws_"))?Zs(e):ai(e)?pi(e):e;var Ut=function(e,t){return Ut=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},Ut(e,t)};function nl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ut(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var _n=function(){return _n=Object.assign||function(t){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},_n.apply(this,arguments)};function ol(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]]);return n}function Ii(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 a(u){try{d(o.next(u))}catch(l){r(l)}}function c(u){try{d(o.throw(u))}catch(l){r(l)}}function d(u){u.done?i(u.value):s(u.value).then(a,c)}d((o=o.apply(e,t||[])).next())})}function wi(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=a(0),r.throw=a(1),r.return=a(2),typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function a(d){return function(u){return c([d,u])}}function c(d){if(o)throw new TypeError("Generator is already executing.");for(;r&&(r=0,d[0]&&(n=0)),n;)try{if(o=1,s&&(i=d[0]&2?s.return:d[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,d[1])).done)return i;switch(s=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return n.label++,{value:d[1],done:!1};case 5:n.label++,s=d[1],d=[0];continue;case 7:d=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){n=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){n.label=d[1];break}if(d[0]===6&&n.label<i[1]){n.label=i[1],i=d;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(d);break}i[2]&&n.ops.pop(),n.trys.pop();continue}d=t.call(e,n)}catch(u){d=[6,u],s=0}finally{o=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function sl(e,t,n){if(n||arguments.length===2)for(var o=0,s=t.length,i;o<s;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var ne=64,Ci=32,Ai=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,2756734187,3204031479,3329325298]),vi=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],Ti=Math.pow(2,53)-1,ht=function(){function e(){this.state=Int32Array.from(vi),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>Ti)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;o>0;)this.buffer[this.bufferLength++]=t[n++],o--,this.bufferLength===ne&&(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%ne>=ne-8){for(var s=this.bufferLength;s<ne;s++)n.setUint8(s,0);this.hashBuffer(),this.bufferLength=0}for(var s=this.bufferLength;s<ne-8;s++)n.setUint8(s,0);n.setUint32(ne-8,Math.floor(t/4294967296),!0),n.setUint32(ne-4,t),this.hashBuffer(),this.finished=!0}for(var i=new Uint8Array(Ci),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],a=o[3],c=o[4],d=o[5],u=o[6],l=o[7],h=0;h<ne;h++){if(h<16)this.temp[h]=(n[h*4]&255)<<24|(n[h*4+1]&255)<<16|(n[h*4+2]&255)<<8|n[h*4+3]&255;else{var g=this.temp[h-2],f=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10;g=this.temp[h-15];var E=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3;this.temp[h]=(f+this.temp[h-7]|0)+(E+this.temp[h-16]|0)}var A=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&d^~c&u)|0)+(l+(Ai[h]+this.temp[h]|0)|0)|0,v=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&i^s&r^i&r)|0;l=u,u=d,d=c,c=a+A|0,a=r,r=i,i=s,s=A+v|0}o[0]+=s,o[1]+=i,o[2]+=r,o[3]+=a,o[4]+=c,o[5]+=d,o[6]+=u,o[7]+=l},e}();const Ri=e=>new TextEncoder().encode(e);var Pi=typeof Buffer<"u"&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:Ri;function Fo(e){return e instanceof Uint8Array?e:typeof e=="string"?Pi(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}function _i(e){return typeof e=="string"?e.length===0:e.byteLength===0}var Je=function(){function e(t){this.secret=t,this.hash=new ht,this.reset()}return e.prototype.update=function(t){if(!(_i(t)||this.error))try{this.hash.update(Fo(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 Ii(this,void 0,void 0,function(){return wi(this,function(t){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new ht,this.secret){this.outer=new ht;var t=xi(this.secret),n=new Uint8Array(ne);n.set(t);for(var o=0;o<ne;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 xi(e){var t=Fo(e);if(t.byteLength>ne){var n=new ht;n.update(t),t=n.digest()}var o=new Uint8Array(ne);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 L;(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"})(L||(L={}));var Mt;(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"})(Mt||(Mt={}));var xn;(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"})(xn||(xn={}));var Nn;(function(e){e.Record="1",e.IdentifyUser="2"})(Nn||(Nn={}));var bn;(function(e){e.GraphQl="1",e.Get="2",e.Post="3",e.Put="4",e.Patch="5",e.Del="6",e.Head="7"})(bn||(bn={}));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 Un;(function(e){e.Subscribe="1",e.GraphQl="2"})(Un||(Un={}));var Mn;(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"})(Mn||(Mn={}));var Dn;(function(e){e.SyncMessages="1",e.IdentifyUser="2",e.NotifyMessageInteraction="3"})(Dn||(Dn={}));var On;(function(e){e.None="0"})(On||(On={}));var Fn;(function(e){e.Convert="1",e.Identify="2",e.Interpret="3"})(Fn||(Fn={}));var kn;(function(e){e.Subscribe="1"})(kn||(kn={}));var Ln;(function(e){e.InitializePushNotifications="1",e.IdentifyUser="2"})(Ln||(Ln={}));var Wn;(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"})(Wn||(Wn={}));const Ni="6.18.0",It=()=>typeof global<"u",Le=()=>typeof window<"u",ko=()=>typeof document<"u",Xt=()=>typeof process<"u",Xe=(e,t)=>!!Object.keys(e).find(n=>n.startsWith(t));var Kn={};function bi(){const e=o=>o.startsWith("_react")||o.startsWith("__react"),t=o=>Object.keys(o).find(e),n=()=>Array.from(document.querySelectorAll("[id]"));return ko()&&n().some(t)}function Ui(){return Xt()&&typeof Kn<"u"&&!!Object.keys(Kn).find(e=>e.includes("react"))}function Mi(){return Le()&&Xe(window,"__VUE")}function Di(){return It()&&Xe(global,"__VUE")}var Vn={};function Oi(){return Le()&&Xe(window,"__SVELTE")}function Fi(){return Xt()&&typeof Vn<"u"&&!!Object.keys(Vn).find(e=>e.includes("svelte"))}function ki(){return Le()&&window.next&&typeof window.next=="object"}function Li(){return It()&&(Xe(global,"__next")||Xe(global,"__NEXT"))}function Wi(){return Le()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function Ki(){return It()&&typeof global.__NUXT_PATHS__<"u"}var Bn={};function Vi(){const e=!!(ko()&&document.querySelector("[ng-version]")),t=!!(Le()&&typeof window.ng<"u");return e||t}function Bi(){var e;return Xt()&&typeof Bn=="object"&&((e=Bn.npm_lifecycle_script)==null?void 0:e.startsWith("ng "))||!1}function Hi(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}function qi(){return It()&&typeof global.expo<"u"}function $i(){return Le()}const Gi=[{platform:L.Expo,detectionMethod:qi},{platform:L.ReactNative,detectionMethod:Hi},{platform:L.NextJs,detectionMethod:ki},{platform:L.Nuxt,detectionMethod:Wi},{platform:L.Angular,detectionMethod:Vi},{platform:L.React,detectionMethod:bi},{platform:L.VueJs,detectionMethod:Mi},{platform:L.Svelte,detectionMethod:Oi},{platform:L.WebUnknown,detectionMethod:$i},{platform:L.NextJsSSR,detectionMethod:Li},{platform:L.NuxtSSR,detectionMethod:Ki},{platform:L.ReactSSR,detectionMethod:Ui},{platform:L.VueJsSSR,detectionMethod:Di},{platform:L.AngularSSR,detectionMethod:Bi},{platform:L.SvelteSSR,detectionMethod:Fi}];function zi(){var e;return((e=Gi.find(t=>t.detectionMethod()))==null?void 0:e.platform)||L.ServerSideUnknown}let je;const _t=[];let Dt=!1;const ji=10,Yi=10,Ji=1e3,Lo=()=>{var e;if(!je){if(je=zi(),Dt)for(;_t.length;)(e=_t.pop())==null||e();else _t.forEach(t=>{t()});Hn(L.ServerSideUnknown,ji),Hn(L.WebUnknown,Yi)}return je};function Xi(){je=void 0}function Hn(e,t){je===e&&!Dt&&setTimeout(()=>{Xi(),Dt=!0,setTimeout(Lo,Ji)},t)}const Qi={},Zi=(e,t)=>{var n,o;return(o=(n=Qi[e])==null?void 0:n[t])==null?void 0:o.additionalDetails},er="aws-amplify",tr=e=>e.replace(/\+.*/,""),nr=({category:e,action:t}={})=>{const n=[[er,tr(Ni)]];if(e&&n.push([e,t]),n.push(["framework",Lo()]),e&&t){const o=Zi(e,t);o&&o.forEach(s=>{n.push(s)})}return n},wt=e=>nr(e).map(([o,s])=>o&&s?`${o}/${s}`:o).join(" "),Ct=()=>typeof window<"u"&&typeof window.document<"u",qn=new z("Auth");class or{configure(t,n){var o,s;this.authConfig=t,this.authOptions=n,t&&((o=t.Cognito)!=null&&o.userPoolEndpoint)&&qn.warn($n("Amazon Cognito User Pool")),t&&((s=t.Cognito)!=null&&s.identityPoolEndpoint)&&qn.warn($n("Amazon Cognito Identity Pool"))}async fetchAuthSession(t={}){var i,r,a,c,d,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=(a=this.authOptions)==null?void 0:a.credentialsProvider)==null?void 0:c.getCredentialsAndIdentityId({authConfig:this.authConfig,tokens:s,authenticated:!0,forceRefresh:t.forceRefresh}))):n=await((u=(d=this.authOptions)==null?void 0:d.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 $n=e=>`You are using a custom Amazon ${e} endpoint, ensure the endpoint is correct.`;class sr{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new or}configure(t,n){var s,i,r,a,c;const o=Oo(t);this.resourcesConfig=o,n&&(this.libraryOptions=n),this.resourcesConfig=Uo(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=(a=this.resourcesConfig.Notifications)==null?void 0:a.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."),Se.dispatch("core",{event:"configure",data:this.resourcesConfig},"Configure",ue),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}[Mo](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 R=new sr,Wo=(e,t)=>e.Auth.fetchAuthSession(t),$=e=>Wo(R,e);function Ko(){return R.Auth.clearCredentials()}const At=e=>{const{headers:t,statusCode:n}=e;return{...ir(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"]}},ir=e=>typeof(e==null?void 0:e.$metadata)=="object",Ne=async e=>{if(!e||e.statusCode<300)return;const t=await Qe(e),o=(r=>{const[a]=r.toString().split(/[,:]+/);return a.includes("#")?a.split("#")[1]:a})(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:At(e)})},Qe=async e=>{if(!e.body)throw new Error("Missing response payload");const t=await e.body.json();return Object.assign(t,{$metadata:At(e)})},P=(e,t,n,o)=>async(s,i)=>{const r={...o,...s},a=await r.endpointResolver(r,i),c=await t(i,a),d=await e(c,{...r});return n(d)},rr=5*60*1e3;function ar(e=rr){return o=>{const s=2**o*100+100*Math.random();return s>e?!1:s}}const Vo=3,Gn="amz-sdk-invocation-id",cr="amz-sdk-request",zn=5*60*1e3,Bo=e=>{const n=ar(zn)(e);return n===!1?zn:n},dr=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],ur=e=>!!e&&dr.includes(e),Ho=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:fr(n)||gr(i,s)||ur(s)||pr(i,s)}},lr=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],hr=["TimeoutError","RequestTimeout","RequestTimeoutException"],gr=(e,t)=>e===429||!!t&&lr.includes(t),fr=e=>[xe.NetworkError,"ERR_NETWORK"].includes(e==null?void 0:e.name),pr=(e,t)=>!!e&&[500,502,503,504].includes(e)||!!t&&hr.includes(t),qo="cognito-identity",$o={service:qo,retryDecider:Ho(Ne),computeDelay:Bo,cache:"no-store"},Er=({maxAttempts:e=Vo,retryDecider:t,computeDelay:n,abortSignal:o})=>{if(e<1)throw new Error("maxAttempts must be greater than 0");return(s,i)=>async function(a){let c,d=i.attemptsCount??0,u;const l=()=>{if(u)return jn(u,d),u;throw jn(c,d),c};for(;!(o!=null&&o.aborted)&&d<e;){try{u=await s(a),c=void 0}catch(f){c=f,u=void 0}d=(i.attemptsCount??0)>d?i.attemptsCount??0:d+1,i.attemptsCount=d;const{isCredentialsExpiredError:h,retryable:g}=await t(u,c,i);if(g){if(i.isCredentialsExpired=!!h,!(o!=null&&o.aborted)&&d<e){const f=n(d);await mr(f,o)}continue}else return l()}if(o!=null&&o.aborted)throw new Error("Request aborted.");return l()}},mr=(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},jn=(e,t)=>{Object.prototype.toString.call(e)==="[object Object]"&&(e.$metadata={...e.$metadata??{},attempts:t})},Sr=ri,yr=()=>e=>async function(n){return n.headers[Gn]||(n.headers[Gn]=Sr()),e(n)},Ir=({maxAttempts:e=Vo})=>(t,n)=>async function(s){const i=n.attemptsCount??0;return s.headers[cr]=`attempt=${i+1}; max=${e}`,t(s)},wr=({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)}},Qt=(e,t)=>(n,o)=>{const s={};let i=r=>e(r,o);for(let r=t.length-1;r>=0;r--){const a=t[r];i=a(o)(i,s)}return i(n)},xt=e=>{let t;return()=>(t||(t=e()),t)},Cr=e=>!["HEAD","GET"].includes(e.toUpperCase()),Ar=async({url:e,method:t,headers:n,body:o},{abortSignal:s,cache:i,withCrossDomainCredentials:r})=>{var l;let a;try{a=await fetch(e,{method:t,headers:n,body:Cr(t)?o:void 0,signal:s,cache:i,credentials:r?"include":"same-origin"})}catch(h){throw h instanceof TypeError?new Y({name:xe.NetworkError,message:"A network error has occurred.",underlyingError:h}):h}const c={};(l=a.headers)==null||l.forEach((h,g)=>{c[g.toLowerCase()]=h});const d={statusCode:a.status,headers:c,body:null},u=Object.assign(a.body??{},{text:xt(()=>a.text()),blob:xt(()=>a.blob()),json:xt(()=>a.json())});return{...d,body:u}},Go=Qt(Ar,[wr,yr,Er,Ir]),vr=()=>e=>async function(n){return n.headers["cache-control"]="no-store",e(n)},zo=Qt(Go,[vr]),jo=e=>(t,n)=>{const o=Tr(e),s=JSON.stringify(t);return Rr(n,o,s)},Tr=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),Rr=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"}),Yn=e=>P(zo,jo("GetCredentialsForIdentity"),Pr,{...$o,...e,userAgentValue:wt()}),Pr=async e=>{if(e.statusCode>=300)throw await Ne(e);const t=await Qe(e);return{IdentityId:t.IdentityId,Credentials:_r(t.Credentials),$metadata:At(e)}},_r=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)}),xr=e=>P(zo,jo("GetId"),Nr,{...$o,...e,userAgentValue:wt()}),Nr=async e=>{if(e.statusCode>=300)throw await Ne(e);return{IdentityId:(await Qe(e)).IdentityId,$metadata:At(e)}},Yo={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},br={partitions:[Yo,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]},Jo=e=>{const{partitions:t}=br;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 Yo.outputs.dnsSuffix},ve=URL,Ur=({region:e})=>({url:new ve(`https://${qo}.${e}.${Jo(e)}`)});class ze extends Y{constructor(){super({name:xe.PlatformNotSupported,message:"Function not supported on current platform"})}}class Xo{constructor(t){this.storage=t}async setItem(t,n){if(!this.storage)throw new ze;this.storage.setItem(t,n)}async getItem(t){if(!this.storage)throw new ze;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new ze;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new ze;this.storage.clear()}}class Qo{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 Zo=new z("CoreStorageUtils"),Mr=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{Zo.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new Qo},es=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return Zo.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new Qo}};class Dr extends Xo{constructor(){super(Mr())}}class Or extends Xo{constructor(){super(es())}}class Fr{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new ze;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()}}class kr extends Fr{constructor(){super(es())}}/*! js-cookie v3.0.8 | MIT */function rt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)o!=="__proto__"&&(e[o]=n[o])}return e}var Lr={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Ot(e,t){function n(s,i,r){if(!(typeof document>"u")){r=rt({},t,r),typeof r.expires=="number"&&(r.expires=new Date(Date.now()+r.expires*864e5)),r.expires&&(r.expires=r.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in r)r[c]&&(a+="; "+c,r[c]!==!0&&(a+="="+r[c].split(";")[0]));return document.cookie=s+"="+e.write(i,s)+a}}function o(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],r={},a=0;a<i.length;a++){var c=i[a].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(u in r||(r[u]=e.read(d,u)),s===u)break}catch{}}return s?r[s]:r}}return Object.create({set:n,get:o,remove:function(s,i){n(s,"",rt({},i,{expires:-1}))},withAttributes:function(s){return Ot(this.converter,rt({},this.attributes,s))},withConverter:function(s){return Ot(rt({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var at=Ot(Lr,{path:"/"});class Wr{constructor(t={}){const{path:n,domain:o,expires:s,sameSite:i,secure:r}=t;if(this.domain=o,this.path=n||"/",this.expires=Object.prototype.hasOwnProperty.call(t,"expires")?s:365,this.secure=Object.prototype.hasOwnProperty.call(t,"secure")?r:!0,Object.prototype.hasOwnProperty.call(t,"sameSite")){if(!i||!["strict","lax","none"].includes(i))throw new Error('The sameSite value of cookieStorage must be "lax", "strict" or "none".');if(i==="none"&&!this.secure)throw new Error("sameSite = None requires the Secure attribute in latest browser versions.");this.sameSite=i}}async setItem(t,n){at.set(t,n,this.getData())}async getItem(t){return at.get(t)??null}async removeItem(t){at.remove(t,this.getData())}async clear(){const t=at.get(),n=Object.keys(t).map(o=>this.removeItem(o));await Promise.all(n)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}}const Ze=new Dr;new Or;const Ee=new kr,Kr=e=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=[],o=new Uint8Array(e);jt().getRandomValues(o);for(const s of o)n.push(t[s%t.length]);return n.join("")};function Vr(e){return(e.match(/.{2}/g)||[]).map(n=>String.fromCharCode(parseInt(n,16))).join("")}function Br(e){return e.split("").map(t=>t.charCodeAt(0).toString(16).padStart(2,"0")).join("")}const Hr=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 Jn({expiresAt:e,clockDrift:t,tolerance:n=5e3}){return Date.now()+t+n>e}const qr=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 $r(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}const Oe={convert(e,t={urlSafe:!1,skipPadding:!1}){const n=typeof e=="string"?e:$r(e);let o=js()(n);return t.urlSafe&&(o=o.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(o=o.replace(/=/g,"")),o}};function Gr(){return jt().getRandomValues(new Uint32Array(1))[0]}function zr(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 Zt{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(Gr());return new Zt(n,t)}toString(){return zr(this)}}var y;(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"})(y||(y={}));const ts={[y.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[y.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[y.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[y.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[y.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[y.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[y.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[y.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[y.EmptySignInPassword]:{message:"password is required to signIn"},[y.EmptySignInUsername]:{message:"username is required to signIn"},[y.EmptySignUpPassword]:{message:"password is required to signUp"},[y.EmptySignUpUsername]:{message:"username is required to signUp"},[y.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[y.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"},[y.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[y.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[y.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"},[y.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 K;(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"})(K||(K={}));var he;(function(e){e.SignInException="SignInException",e.OAuthSignInError="OAuthSignInException"})(he||(he={}));class m extends Y{constructor(t){super(t),this.constructor=m,Object.setPrototypeOf(this,m.prototype)}}function U(e,t){const{message:n,recoverySuggestion:o}=ts[t];if(!e)throw new m({name:t,message:n,recoverySuggestion:o})}function I(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 Ft(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]}function kt(e){return Object.entries(e).map(([t,n])=>({Name:t,Value:n}))}function jr(e){const t={};return e==null||e.forEach(n=>{n.Name&&(t[n.Name]=n.Value)}),t}var Xn;(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(Xn||(Xn={}));var Qn;(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"})(Qn||(Qn={}));var Zn;(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"})(Zn||(Zn={}));var eo;(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"})(eo||(eo={}));var to;(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"})(to||(to={}));var no;(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"})(no||(no={}));var oo;(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"})(oo||(oo={}));var so;(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"})(so||(so={}));var io;(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.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(io||(io={}));var ro;(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"})(ro||(ro={}));var ao;(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"})(ao||(ao={}));var co;(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"})(co||(co={}));var uo;(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"})(uo||(uo={}));var lo;(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"})(lo||(lo={}));var mt;(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"})(mt||(mt={}));var ho;(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.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UnexpectedLambdaException="UnexpectedLambdaException",e.UserLambdaValidationException="UserLambdaValidationException",e.UserNotFoundException="UserNotFoundException"})(ho||(ho={}));var go;(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"})(go||(go={}));var fo;(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"})(fo||(fo={}));var Lt;(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"})(Lt||(Lt={}));var po;(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"})(po||(po={}));var Eo;(function(e){e.CodeMismatchException="CodeMismatchException",e.EnableSoftwareTokenMFAException="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"})(Eo||(Eo={}));var mo;(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"})(mo||(mo={}));var So;(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"})(So||(So={}));var yo;(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"})(yo||(yo={}));const Yr="SetUpTOTPException",vt="UserUnAuthenticatedException",Jr="UserAlreadyAuthenticatedException",Xr="DeviceMetadataNotFoundException",ns="AutoSignInException",Qr="InvalidRedirectException",Zr="InvalidAppSchemeException",ea="InvalidPreferredRedirectUrlException",ta=new m({name:Qr,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:Zr,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."});const na=new m({name:ea,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."}),oa="InvalidOriginException",sa=new m({name:oa,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."}),ia="OAuthSignOutException",ra="TokenRefreshException",aa="UnexpectedSignInInterruptionException";function W(e){if(!e||!e.accessToken)throw new m({name:vt,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function ca(e){if(!e||!e.idToken)throw new m({name:vt,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}const da=new m({name:ra,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow.
Please change your oauth configuration to use 'code grant' flow.`,recoverySuggestion:`Please logout and change your Amplify configuration to use "code grant" flow.
E.g { responseType: 'code' }`}),ua=new m({name:vt,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function os(e){if(ga(e))throw da;if(!ha(e))throw ua}function Tt(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new m({name:Xr,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 la={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function ss(e){return(e==null?void 0:e.accessToken)||(e==null?void 0:e.idToken)}function ha(e){return ss(e)&&(e==null?void 0:e.refreshToken)}function ga(e){return ss(e)&&!(e!=null&&e.refreshToken)}const fa=async e=>{var a,c;const t=(a=e.getConfig().Auth)==null?void 0:a.Cognito;S(t);const n=await e.Auth.getTokens({forceRefresh:!1});W(n);const{"cognito:username":o,sub:s}=((c=n.idToken)==null?void 0:c.payload)??{},i={username:o,userId:s},r=pa(n);return r&&(i.signInDetails=r),i};function pa(e){return e==null?void 0:e.signInDetails}const en=async()=>fa(R),T=(e,t)=>wt({category:Mt.Auth,action:e,...t}),x=e=>(t,n)=>{const o=Ea(e),s=JSON.stringify(t);return ma(n,o,s)},Ea=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}),ma=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"});function Q(e){if(!e||e.name==="Error"||e instanceof TypeError)throw new m({name:xe.Unknown,message:"An unknown error has occurred.",underlyingError:e})}const M=()=>async e=>{if(e.statusCode>=300){const t=await Ne(e);throw Q(t),new m({name:t.name,message:t.message,metadata:t.$metadata})}return Qe(e)},Sa=()=>(e,t)=>async function(o){var s,i,r;return o.headers={...o.headers,"cache-control":"no-store",...await((r=(i=(s=R.libraryOptions)==null?void 0:s.Auth)==null?void 0:i.headers)==null?void 0:r.call(i))},e(o)},N=Qt(Go,[Sa]),is="cognito-idp",b={service:is,retryDecider:Ho(Ne),computeDelay:Bo,get userAgentValue(){return wt()},cache:"no-store"},et=e=>P(N,x("InitiateAuth"),M(),{...b,...e}),Z=e=>P(N,x("RespondToAuthChallenge"),M(),{...b,...e}),rs=e=>P(N,x("VerifySoftwareToken"),M(),{...b,...e}),as=e=>P(N,x("AssociateSoftwareToken"),M(),{...b,...e}),ya=({region:e})=>({url:new ve(`https://${is}.${e}.${Jo(e)}`)}),w=({endpointOverride:e})=>t=>e?{url:new ve(e)}:ya(t),Ia=e=>P(N,x("GetTokensFromRefreshToken"),M(),{...b,...e}),wa=async({tokens:e,authConfig:t,username:n,clientMetadata:o})=>{var f;S(t==null?void 0:t.Cognito);const{userPoolId:s,userPoolClientId:i,userPoolEndpoint:r}=t.Cognito,a=I(s);os(e);const c=Ia({endpointResolver:w({endpointOverride:r})}),{AuthenticationResult:d}=await c({region:a},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:(f=e.deviceMetadata)==null?void 0:f.deviceKey,ClientMetadata:o}),u=le((d==null?void 0:d.AccessToken)??""),l=d!=null&&d.IdToken?le(d.IdToken):void 0,{iat:h}=u.payload;if(!h)throw new m({name:"iatNotFoundException",message:"iat not found in access token"});const g=h*1e3-new Date().getTime();return{accessToken:u,idToken:l,clockDrift:g,refreshToken:(d==null?void 0:d.RefreshToken)??e.refreshToken,username:n}},Ca=Hr(wa),Aa={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var St;(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(St||(St={}));const va={[St.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},Ta=zt(va),Io="CognitoIdentityServiceProvider";class Ra{getKeyValueStorage(){if(!this.keyValueStorage)throw new m({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=le(n),s=await this.getKeyValueStorage().getItem(t.idToken),i=s?le(s):void 0,r=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",c=Number.parseInt(a),d=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 d&&(u.signInDetails=JSON.parse(d)),u}catch{return null}}async storeTokens(t){Ta(t!==void 0,St.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;S((o=this.authConfig)==null?void 0:o.Cognito);const n=t??await this.getLastAuthUser();return Pa(Io,`${this.authConfig.Cognito.userPoolClientId}.${n}`)}getLastAuthUserKey(){var n;S((n=this.authConfig)==null?void 0:n.Cognito);const t=this.authConfig.Cognito.userPoolClientId;return`${Io}.${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 Pa=(e,t)=>tn(Aa)(`${e}`,t);function tn(e){const t=Object.values({...e});return(n,o)=>t.reduce((s,i)=>({...s,[i]:`${n}.${o}.${i}`}),{})}const wo="amplify-signin-with-hostedUI",re="CognitoIdentityServiceProvider";class cs{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(t.inflightOAuth),this.keyValueStorage.removeItem(t.oauthPKCE),this.keyValueStorage.removeItem(t.oauthState)])}async clearOAuthData(){S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(wo),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){S(this.cognitoConfig);const n=ae(re,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthState,t)}loadPKCE(){S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){S(this.cognitoConfig);const n=ae(re,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){S(this.cognitoConfig);const n=ae(re,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(n.inflightOAuth,`${t}`)}async loadOAuthSignIn(){var i;S(this.cognitoConfig);const t=ae(re,this.cognitoConfig.userPoolClientId),n=await this.keyValueStorage.getItem(wo),[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){S(this.cognitoConfig);const o=ae(re,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.oauthSignIn,`${t},${n}`)}}const ae=(e,t)=>tn(la)(e,t),G=new cs(Ze),Wt=[],_a=e=>{Wt.push(e)},ds=()=>{var e;for(;Wt.length;)(e=Wt.pop())==null||e()};class xa{constructor(){this.waitForInflightOAuth=Ct()?async()=>{if(await G.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,n)=>{_a(t)}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){G.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,a,c,d,u,l;let n;try{S((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)&&Jn({expiresAt:(((c=(a=n.idToken)==null?void 0:a.payload)==null?void 0:c.exp)??0)*1e3,clockDrift:n.clockDrift??0}),i=Jn({expiresAt:(((u=(d=n.accessToken)==null?void 0:d.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((l=this.clientMetadataProvider)==null?void 0:l.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}),Se.dispatch("auth",{event:"tokenRefresh"},"Auth",ue),i}catch(s){return this.handleErrors(s)}}handleErrors(t){if(Q(t),this.isAuthenticationError(t)&&this.clearTokens(),Se.dispatch("auth",{event:"tokenRefresh_failure",data:{error:t}},"Auth",ue),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 Na{constructor(){this.authTokenStore=new Ra,this.authTokenStore.setKeyValueStorage(Ze),this.tokenOrchestrator=new xa,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(Ca)}getTokens(t={}){return this.tokenOrchestrator.getTokens(t)}setKeyValueStorage(t){this.authTokenStore.setKeyValueStorage(t)}setClientMetadataProvider(t){this.tokenOrchestrator.setClientMetadataProvider(t)}setAuthConfig(t){this.authTokenStore.setAuthConfig(t),this.tokenOrchestrator.setAuthConfig(t)}}const gt=new Na,{tokenOrchestrator:k}=gt;async function ye(e){if(e.AccessToken){const t=le(e.AccessToken),n=(t.payload.iat||0)*1e3,o=new Date().getTime(),s=n>0?n-o:0;let i,r,a;e.RefreshToken&&(r=e.RefreshToken),e.IdToken&&(i=le(e.IdToken)),e!=null&&e.NewDeviceMetadata&&(a=e.NewDeviceMetadata);const c={accessToken:t,idToken:i,refreshToken:r,clockDrift:s,deviceMetadata:a,username:e.username};e!=null&&e.signInDetails&&(c.signInDetails=e.signInDetails),await k.setTokens({tokens:c})}else throw new Y({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const ba="Unable to get user session following successful sign-in.",Te=async()=>{try{Se.dispatch("auth",{event:"signedIn",data:await en()},"Auth",ue)}catch(e){throw e.name===vt?new m({name:aa,message:ba,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 us(){return{active:!1}}const Ua=(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 us();default:return e}},Ma=e=>{let t=e(us(),{type:"RESET"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},we=Ma(Ua),Da=3*60*1e3,ct="CognitoSignInState",me={username:`${ct}.username`,challengeName:`${ct}.challengeName`,signInSession:`${ct}.signInSession`,expiry:`${ct}.expiry`},Oa=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return dt({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return dt(t.value),{...t.value};case"SET_CHALLENGE_NAME":return dt({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return dt({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return ka();case"RESET_STATE":return ls(),nn();default:return e}},Fa=e=>{const t=Number(e),n=Date.now();return t<=n},ie=()=>{ge.dispatch({type:"RESET_STATE"})},ls=()=>{for(const e of Object.values(me))Ee.removeItem(e)},nn=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),ka=()=>{const e=Ee.getItem(me.expiry);if(!e||Fa(e))return ls(),nn();const t=Ee.getItem(me.username)??void 0,n=Ee.getItem(me.challengeName)??void 0,o=Ee.getItem(me.signInSession)??void 0;return{username:t,challengeName:n,signInSession:o}},La=e=>{let t=e(nn(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},ge=La(Oa);function be(e){ge.dispatch({type:"SET_SIGN_IN_STATE",value:e})}const dt=({challengeName:e,signInSession:t,username:n})=>{n&&Ee.setItem(me.username,n),e&&Ee.setItem(me.challengeName,e),t&&(Ee.setItem(me.signInSession,t),Ee.setItem(me.expiry,String(Date.now()+Da)))},Co="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 se extends Y{constructor(t){super(t),this.constructor=se,Object.setPrototypeOf(this,se.prototype)}}var _;(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"})(_||(_={}));const Nt="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",Ao="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Fe={[_.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:Co},[_.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:Ao},[_.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:Ao},[_.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:Co},[_.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."},[_.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[_.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:Nt},[_.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:Nt},[_.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:Nt},[_.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},We=zt(Fe,se),hs=e=>{if(e instanceof Error){if(e.name==="AbortError"){const{message:t,recoverySuggestion:n}=Fe[_.PasskeyOperationAborted];return new se({name:_.PasskeyOperationAborted,message:t,recoverySuggestion:n,underlyingError:e})}if(e.name==="SecurityError"){const{message:t,recoverySuggestion:n}=Fe[_.RelyingPartyMismatch];return new se({name:_.RelyingPartyMismatch,message:t,recoverySuggestion:n,underlyingError:e})}}return new se({name:xe.Unknown,message:"An unknown error has occurred.",underlyingError:e})},Wa=e=>{if(e instanceof se)return e;if(e instanceof Error&&e.name==="NotAllowedError"){const{message:t,recoverySuggestion:n}=Fe[_.PasskeyAuthenticationCanceled];return new se({name:_.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:n,underlyingError:e})}return hs(e)},gs=()=>Ct()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",de=e=>Oe.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0}),Ye=e=>Uint8Array.from(Yt.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer,Ka=e=>{const t=Ye(e.user.id),n=Ye(e.challenge),o=(e.excludeCredentials||[]).map(s=>({...s,id:Ye(s.id)}));return{...e,excludeCredentials:o,challenge:n,user:{...e.user,id:t}}},Va=e=>{const t={clientDataJSON:de(e.response.clientDataJSON),attestationObject:de(e.response.attestationObject),transports:e.response.getTransports(),publicKeyAlgorithm:e.response.getPublicKeyAlgorithm(),authenticatorData:de(e.response.getAuthenticatorData())},n=e.response.getPublicKey();n&&(t.publicKey=de(n));const o={type:e.type,id:e.id,rawId:de(e.rawId),clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(o.authenticatorAttachment=e.authenticatorAttachment),o},Ba=e=>{const t=Ye(e.challenge),n=(e.allowCredentials||[]).map(o=>({...o,id:Ye(o.id)}));return{...e,challenge:t,allowCredentials:n}},Ha=e=>{const t={clientDataJSON:de(e.response.clientDataJSON),authenticatorData:de(e.response.authenticatorData),signature:de(e.response.signature)};e.response.userHandle&&(t.userHandle=de(e.response.userHandle));const n={id:e.id,rawId:de(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(n.authenticatorAttachment=e.authenticatorAttachment),n};function qa(e){We([!!e,!!(e!=null&&e.challenge),!!(e!=null&&e.user),!!(e!=null&&e.rp),!!(e!=null&&e.pubKeyCredParams)].every(Boolean),_.InvalidPasskeyRegistrationOptions)}function $a(e){We(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAttestationResponse,_.PasskeyRegistrationFailed)}function Ga(e){We(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,_.PasskeyRetrievalFailed)}const za=async e=>{try{const t=gs();We(t,_.PasskeyNotSupported);const n=Ba(e),o=await navigator.credentials.get({publicKey:n});return Ga(o),Ha(o)}catch(t){throw Wa(t)}},ja=e=>P(N,x("ConfirmDevice"),M(),{...b,...e}),ft={convert(e){return new TextEncoder().encode(e)}};function p(e,t){e!=null&&this.fromString(e,t)}function q(){return new p(null,null)}let Ce;const Ya=0xdeadbeefcafe,vo=(Ya&16777215)===15715070;function Ja(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 Xa(e,t,n,o,s,i){const r=t&32767,a=t>>15;for(;--i>=0;){let c=this[e]&32767;const d=this[e++]>>15,u=a*c+d*r;c=r*c+((u&32767)<<15)+n[o]+(s&1073741823),s=(c>>>30)+(u>>>15)+a*d+(s>>>30),n[o++]=c&1073741823}return s}function Qa(e,t,n,o,s,i){const r=t&16383,a=t>>14;for(;--i>=0;){let c=this[e]&16383;const d=this[e++]>>14,u=a*c+d*r;c=r*c+((u&16383)<<14)+n[o]+s,s=(c>>28)+(u>>14)+a*d,n[o++]=c&268435455}return s}const To=typeof navigator<"u";To&&vo&&navigator.appName==="Microsoft Internet Explorer"?(p.prototype.am=Xa,Ce=30):To&&vo&&navigator.appName!=="Netscape"?(p.prototype.am=Ja,Ce=26):(p.prototype.am=Qa,Ce=28);p.prototype.DB=Ce;p.prototype.DM=(1<<Ce)-1;p.prototype.DV=1<<Ce;const on=52;p.prototype.FV=Math.pow(2,on);p.prototype.F1=on-Ce;p.prototype.F2=2*Ce-on;const Za="0123456789abcdefghijklmnopqrstuvwxyz",Rt=[];let Ke,oe;Ke=48;for(oe=0;oe<=9;++oe)Rt[Ke++]=oe;Ke=97;for(oe=10;oe<36;++oe)Rt[Ke++]=oe;Ke=65;for(oe=10;oe<36;++oe)Rt[Ke++]=oe;function Ro(e){return Za.charAt(e)}function ec(e,t){const n=Rt[e.charCodeAt(t)];return n??-1}function tc(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function nc(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 sn(e){const t=q();return t.fromInt(e),t}function oc(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=ec(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&&p.ZERO.subTo(this,this)}function sc(){const e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function ic(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,a=this.DB-r*this.DB%t;if(r-- >0)for(a<this.DB&&(o=this[r]>>a)>0&&(s=!0,i=Ro(o));r>=0;)a<t?(o=(this[r]&(1<<a)-1)<<t-a,o|=this[--r]>>(a+=this.DB-t)):(o=this[r]>>(a-=t)&n,a<=0&&(a+=this.DB,--r)),o>0&&(s=!0),s&&(i+=Ro(o));return s?i:"0"}function rc(){const e=q();return p.ZERO.subTo(this,e),e}function ac(){return this.s<0?this.negate():this}function cc(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 rn(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 dc(){return this.t<=0?0:this.DB*(this.t-1)+rn(this[this.t-1]^this.s&this.DM)}function uc(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 lc(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 hc(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,a;for(a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>o|r,r=(this[a]&s)<<n;for(a=i-1;a>=0;--a)t[a]=0;t[i]=r,t.t=this.t+i+1,t.s=this.s,t.clamp()}function gc(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 fc(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 pc(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&&p.ZERO.subTo(t,t)}function Ec(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 mc(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=q());const i=q(),r=this.s,a=e.s,c=this.DB-rn(o[o.t-1]);c>0?(o.lShiftTo(c,i),s.lShiftTo(c,n)):(o.copyTo(i),s.copyTo(n));const d=i.t,u=i[d-1];if(u===0)return;const l=u*(1<<this.F1)+(d>1?i[d-2]>>this.F2:0),h=this.FV/l,g=(1<<this.F1)/l,f=1<<this.F2;let E=n.t,A=E-d;const v=t===null?q():t;for(i.dlShiftTo(A,v),n.compareTo(v)>=0&&(n[n.t++]=1,n.subTo(v,n)),p.ONE.dlShiftTo(d,v),v.subTo(i,i);i.t<d;)i[i.t++]=0;for(;--A>=0;){let O=n[--E]===u?this.DM:Math.floor(n[E]*h+(n[E-1]+f)*g);if((n[E]+=i.am(0,O,n,A,0,d))<O)for(i.dlShiftTo(A,v),n.subTo(v,n);n[E]<--O;)n.subTo(v,n)}t!==null&&(n.drShiftTo(d,t),r!==a&&p.ZERO.subTo(t,t)),n.t=d,n.clamp(),c>0&&n.rShiftTo(c,n),r<0&&p.ZERO.subTo(n,n)}function Sc(e){const t=q();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(p.ZERO)>0&&e.subTo(t,t),t}function yc(){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 Ic(e){return this.compareTo(e)===0}function wc(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 Cc(e){const t=q();return this.addTo(e,t),t}function Ac(e){const t=q();return this.subTo(e,t),t}function vc(e){const t=q();return this.multiplyTo(e,t),t}function Tc(e){const t=q();return this.divRemTo(e,t,null),t}function Ve(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 Rc(e){const t=q();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(p.ZERO)>0&&this.m.subTo(t,t),t}function Pc(e){const t=q();return e.copyTo(t),this.reduce(t),t}function _c(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 xc(e,t){e.squareTo(t),this.reduce(t)}function Nc(e,t,n){e.multiplyTo(t,n),this.reduce(n)}Ve.prototype.convert=Rc;Ve.prototype.revert=Pc;Ve.prototype.reduce=_c;Ve.prototype.mulTo=Nc;Ve.prototype.sqrTo=xc;function bc(e,t,n){let o=e.bitLength(),s,i=sn(1);const r=new Ve(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 a=[];let c=3;const d=s-1,u=(1<<s)-1;if(a[1]=r.convert(this),s>1){const v=q();for(r.sqrTo(a[1],v);c<=u;)a[c]=q(),r.mulTo(v,a[c-2],a[c]),c+=2}let l=e.t-1,h,g=!0,f=q(),E;for(o=rn(e[l])-1;l>=0;){for(o>=d?h=e[l]>>o-d&u:(h=(e[l]&(1<<o+1)-1)<<d-o,l>0&&(h|=e[l-1]>>this.DB+o-d)),c=s;!(h&1);)h>>=1,--c;if((o-=c)<0&&(o+=this.DB,--l),g)a[h].copyTo(i),g=!1;else{for(;c>1;)r.sqrTo(i,f),r.sqrTo(f,i),c-=2;c>0?r.sqrTo(i,f):(E=i,i=f,f=E),r.mulTo(f,a[h],i)}for(;l>=0&&!(e[l]&1<<o);)r.sqrTo(i,f),E=i,i=f,f=E,--o<0&&(o=this.DB-1,--l)}const A=r.revert(i);return n(null,A),A}p.prototype.copyTo=tc;p.prototype.fromInt=nc;p.prototype.fromString=oc;p.prototype.clamp=sc;p.prototype.dlShiftTo=uc;p.prototype.drShiftTo=lc;p.prototype.lShiftTo=hc;p.prototype.rShiftTo=gc;p.prototype.subTo=fc;p.prototype.multiplyTo=pc;p.prototype.squareTo=Ec;p.prototype.divRemTo=mc;p.prototype.invDigit=yc;p.prototype.addTo=wc;p.prototype.toString=ic;p.prototype.negate=rc;p.prototype.abs=ac;p.prototype.compareTo=cc;p.prototype.bitLength=dc;p.prototype.mod=Sc;p.prototype.equals=Ic;p.prototype.add=Cc;p.prototype.subtract=Ac;p.prototype.multiply=vc;p.prototype.divide=Tc;p.prototype.modPow=bc;p.ZERO=sn(0);p.ONE=sn(1);const Uc=async({a:e,g:t,k:n,x:o,B:s,N:i,U:r})=>new Promise((a,c)=>{t.modPow(o,i,(d,u)=>{if(d){c(d);return}s.subtract(n.multiply(u)).modPow(e.add(r.multiply(o)),i,(l,h)=>{if(l){c(l);return}a(h.mod(i))})})}),Mc="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",fs={},Kt={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),fs[e]=t,Kt[t]=e}const ke=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 Kt)t[n/2]=Kt[o];else throw new Error(`Cannot decode unrecognized sequence ${o} as hexadecimal`)}return t},an=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=fs[e[n]];return t},Vt=e=>{const t=new Je;t.update(e);const n=t.digestSync(),o=an(n);return new Array(64-o.length).join("0")+o},pt=e=>Vt(ke(e)),Dc=/^[89a-f]/i,pe=e=>{if(!(e instanceof p))throw new Error("Not a BigInteger");const t=e.compareTo(p.ZERO)<0;let n=e.abs().toString(16);if(n=n.length%2!==0?`0${n}`:n,n=Dc.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 p(o,16).add(p.ONE).toString(16),n.toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},Oc=({A:e,B:t})=>{const n=new p(pt(pe(e)+pe(t)),16);if(n.equals(p.ZERO))throw new Error("U cannot be zero.");return n},Fc=(e,t,n)=>{const o=new Je(t);o.update(e);const s=o.digestSync(),i=new Je(s);return i.update(n),i.digestSync().slice(0,16)},cn=e=>{const t=new Zt().random(e).toString();return ke(t)},kc=()=>Oe.convert(cn(40));class Lc{constructor({userPoolName:t,a:n,g:o,A:s,N:i}){this.encoder=ft,this.userPoolName=t,this.a=n,this.g=o,this.A=s,this.N=i,this.k=new p(pt(`${pe(i)}${pe(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=kc();const o=`${t}${n}:${this.randomPassword}`,s=Vt(o),i=an(cn(16));return this.saltToHashDevices=pe(new p(i,16)),new Promise((r,a)=>{this.g.modPow(new p(pt(this.saltToHashDevices+s),16),this.N,(c,d)=>{if(c){a(c);return}this.verifierDevices=pe(d),r()})})}async getPasswordAuthenticationKey({username:t,password:n,serverBValue:o,salt:s}){if(o.mod(this.N).equals(p.ZERO))throw new Error("B cannot be zero.");const i=Oc({A:this.A,B:o}),r=`${this.userPoolName}${t}:${n}`,a=Vt(r),c=new p(pt(pe(s)+a),16),d=await Uc({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"),l=this.encoder.convert(""),h=new Uint8Array(u.byteLength+l.byteLength);return h.set(u,0),h.set(l,u.byteLength),Fc(ke(pe(d)),ke(pe(i)),h)}}const Wc=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(p.ZERO)){s(new Error("Illegal parameter. A mod N cannot be 0."));return}o(r)})}),tt=async e=>{const t=new p(Mc,16),n=new p("2",16),o=Kc(),s=await Wc({a:o,g:n,N:t});return new Lc({userPoolName:e,a:o,g:n,A:s,N:t})},Kc=()=>{const e=an(cn(128));return new p(e,16)};async function Ue({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:n,accessToken:o}){if(!n)return;const s=e.split("_")[1]||"",i=await tt(s),r=n==null?void 0:n.DeviceKey,a=n==null?void 0:n.DeviceGroupKey;try{await i.generateHashDevice(a??"",r??"")}catch{return}const c={Salt:Oe.convert(ke(i.getSaltToHashDevices())),PasswordVerifier:Oe.convert(ke(i.getVerifierDevices()))},d=i.getRandomPassword();try{return await ja({endpointResolver:w({endpointOverride:t})})({region:I(e)},{AccessToken:o,DeviceName:await qr(),DeviceKey:n==null?void 0:n.DeviceKey,DeviceSecretVerifierConfig:c}),{deviceKey:r,deviceGroupKey:a,randomPassword:d}}catch{return}}async function Vc(e){var g;const t=(g=R.getConfig().Auth)==null?void 0:g.Cognito;S(t);const{username:n,signInSession:o,signInDetails:s,challengeName:i}=ge.getState();if(i!=="WEB_AUTHN"||!n)throw new m({name:he.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:r}=e;We(!!r,_.InvalidPasskeyAuthenticationOptions);const a=await za(JSON.parse(r)),c=Z({endpointResolver:w({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:d,ChallengeParameters:u,AuthenticationResult:l,Session:h}=await c({region:I(t.userPoolId),userAgentValue:T(C.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:n,CREDENTIAL:JSON.stringify(a)},ClientId:t.userPoolClientId,Session:o});if(be({signInSession:h,username:n,challengeName:d,signInDetails:s}),l)return await ye({...l,username:n,NewDeviceMetadata:await Ue({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:l.NewDeviceMetadata,accessToken:l.AccessToken}),signInDetails:s}),ge.dispatch({type:"RESET_STATE"}),await Te(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(d==="WEB_AUTHN")throw new m({name:he.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:d,challengeParameters:u}}function V({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 Bc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Hc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ps=()=>{const e=new Date,t=Hc[e.getUTCDay()],n=Bc[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 a=e.getUTCFullYear();return`${t} ${n} ${o} ${s}:${i}:${r} UTC ${a}`},Es=({userPoolName:e,username:t,challengeParameters:n,dateNow:o,hkdf:s})=>{const i=ft.convert(e),r=ft.convert(t),a=qc(n.SECRET_BLOCK),c=ft.convert(o),d=new Uint8Array(i.byteLength+r.byteLength+a.byteLength+c.byteLength);d.set(i,0),d.set(r,i.byteLength),d.set(a,i.byteLength+r.byteLength),d.set(c,i.byteLength+r.byteLength+a.byteLength);const u=new Je(s);u.update(d);const l=u.digestSync();return Oe.convert(l)},qc=e=>{const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),o=Yt.convert(n),s=new Uint8Array(o.length);for(let i=0;i<o.length;++i)s[i]=o.charCodeAt(i);return s};async function nt({username:e,config:t,clientMetadata:n,session:o,tokenOrchestrator:s}){const{userPoolId:i,userPoolEndpoint:r}=t,a=t.userPoolClientId,c=await(s==null?void 0:s.getDeviceMetadata(e));Tt(c);const d=await tt(c.deviceGroupKey),u={USERNAME:e,SRP_A:d.A.toString(16),DEVICE_KEY:c.deviceKey},l={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:u,ClientMetadata:n,Session:o},h=Z({endpointResolver:w({endpointOverride:r})}),{ChallengeParameters:g,Session:f}=await h({region:I(i)},l);return $c(e,g,n,f,d,t,s)}async function $c(e,t,n,o,s,{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a},c){const d=await(c==null?void 0:c.getDeviceMetadata(e));Tt(d);const u=new p(t==null?void 0:t.SRP_B,16),l=new p(t==null?void 0:t.SALT,16),{deviceKey:h}=d,{deviceGroupKey:g}=d,f=await s.getPasswordAuthenticationKey({username:d.deviceKey,password:d.randomPassword,serverBValue:u,salt:l}),E=ps(),A={USERNAME:(t==null?void 0:t.USERNAME)??e,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:E,PASSWORD_CLAIM_SIGNATURE:Es({username:h,userPoolName:g,challengeParameters:t,dateNow:E,hkdf:f}),DEVICE_KEY:h},v=V({username:e,userPoolId:i,userPoolClientId:r}),O={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r,ChallengeResponses:A,Session:o,ClientMetadata:n,UserContextData:v};return Z({endpointResolver:w({endpointOverride:a})})({region:I(i)},O)}async function dn(e,t,n,o,s,i,r){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=i,u=(a==null?void 0:a.split("_")[1])||"",l=new p(t==null?void 0:t.SRP_B,16),h=new p(t==null?void 0:t.SALT,16),g=t==null?void 0:t.USER_ID_FOR_SRP;if(!g)throw new m({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const f=await s.getPasswordAuthenticationKey({username:g,password:e,serverBValue:l,salt:h}),E=ps(),A={USERNAME:g,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:E,PASSWORD_CLAIM_SIGNATURE:Es({username:g,userPoolName:u,challengeParameters:t,dateNow:E,hkdf:f})},v=await r.getDeviceMetadata(g);v&&v.deviceKey&&(A.DEVICE_KEY=v.deviceKey);const O=V({username:g,userPoolId:a,userPoolClientId:c}),ee={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:A,ClientMetadata:n,Session:o,ClientId:c,UserContextData:O},te=await Z({endpointResolver:w({endpointOverride:d})})({region:I(a)},ee);return te.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:g,config:i,clientMetadata:n,session:te.Session,tokenOrchestrator:r}):te}async function Be(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 Me(e){const{dispatch:t}=ge;t({type:"SET_USERNAME",value:e})}async function ms({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:i,preferredChallenge:r}){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=o,u=(a==null?void 0:a.split("_")[1])||"",l=await tt(u),h={USERNAME:e,SRP_A:l.A.toString(16)};i==="USER_AUTH"&&r&&(h.PREFERRED_CHALLENGE=r);const g=V({username:e,userPoolId:a,userPoolClientId:c}),f={AuthFlow:i,AuthParameters:h,ClientMetadata:n,ClientId:c,UserContextData:g},A=await et({endpointResolver:w({endpointOverride:d})})({region:I(a),userAgentValue:T(C.SignIn)},f),{ChallengeParameters:v,Session:O}=A,ee=(v==null?void 0:v.USERNAME)??e;return Me(ee),A.ChallengeName==="PASSWORD_VERIFIER"?Be(dn,[t,v,n,O,l,o,s],ee,s):A}async function Gc({username:e,session:t,selectedChallenge:n,config:o,clientMetadata:s}){return Z({endpointResolver:w({endpointOverride:o.userPoolEndpoint})})({region:I(o.userPoolId),userAgentValue:T(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:{USERNAME:e,ANSWER:n},ClientId:o.userPoolClientId,Session:t,ClientMetadata:s})}async function zc(e,t,n,o,s){var g;const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a}=o,c={ANSWER:"PASSWORD",USERNAME:e,PASSWORD:t},d=V({username:e,userPoolId:i,userPoolClientId:r}),l=await Z({endpointResolver:w({endpointOverride:a})})({region:I(i),userAgentValue:T(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:c,ClientId:r,ClientMetadata:n,Session:s,UserContextData:d}),h=((g=l.ChallengeParameters)==null?void 0:g.USERNAME)??e;return Me(h),l}async function jc(e,t,n,o,s,i){var A;const{userPoolId:r,userPoolClientId:a,userPoolEndpoint:c}=o,d=r.split("_")[1]||"",u=await tt(d),l={ANSWER:"PASSWORD_SRP",USERNAME:e,SRP_A:u.A.toString(16)},h=V({username:e,userPoolId:r,userPoolClientId:a}),f=await Z({endpointResolver:w({endpointOverride:c})})({region:I(r),userAgentValue:T(C.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:l,ClientId:a,ClientMetadata:n,Session:s,UserContextData:h}),E=((A=f.ChallengeParameters)==null?void 0:A.USERNAME)??e;return Me(E),f.ChallengeName==="PASSWORD_VERIFIER"?Be(dn,[t,f.ChallengeParameters,n,f.Session,u,o,i],E,i):f}const Bt="userAttributes.";function Yc(e){return"isSignedIn"in e&&"nextStep"in e}async function Jc({challengeResponse:e,clientMetadata:t,session:n,username:o,config:s,tokenOrchestrator:i}){const{userPoolId:r,userPoolClientId:a,userPoolEndpoint:c}=s,d={USERNAME:o,ANSWER:e},u=await(i==null?void 0:i.getDeviceMetadata(o));u&&u.deviceKey&&(d.DEVICE_KEY=u.deviceKey);const l=V({username:o,userPoolId:r,userPoolClientId:a}),h={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:d,Session:n,ClientMetadata:t,ClientId:a,UserContextData:l},f=await Z({endpointResolver:w({endpointOverride:c})})({region:I(r),userAgentValue:T(C.ConfirmSignIn)},h);return f.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:o,config:s,clientMetadata:t,session:f.Session,tokenOrchestrator:i}):f}async function Xc({challengeResponse:e,username:t,clientMetadata:n,session:o,deviceName:s,config:i}){const{userPoolId:r,userPoolClientId:a,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 d={USERNAME:t};if(/^\d+$/.test(e)){const h=rs({endpointResolver:w({endpointOverride:c})}),{Session:g}=await h({region:I(r),userAgentValue:T(C.ConfirmSignIn)},{UserCode:e,Session:o,FriendlyDeviceName:s});ge.dispatch({type:"SET_SIGN_IN_SESSION",value:g});const f={ChallengeName:"MFA_SETUP",ChallengeResponses:d,Session:g,ClientMetadata:n,ClientId:a};return Z({endpointResolver:w({endpointOverride:c})})({region:I(r),userAgentValue:T(C.ConfirmSignIn)},f)}if(e.includes("@")){d.EMAIL=e;const h={ChallengeName:"MFA_SETUP",ChallengeResponses:d,Session:o,ClientMetadata:n,ClientId:a};return Z({endpointResolver:w({endpointOverride:c})})({region:I(r),userAgentValue:T(C.ConfirmSignIn)},h)}throw new m({name:he.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 Qc({challengeResponse:e,username:t,clientMetadata:n,session:o,config:s}){const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a}=s;U(e==="TOTP"||e==="SMS"||e==="EMAIL",y.IncorrectMFAMethod);const c={USERNAME:t,ANSWER:ad(e)},d=V({username:t,userPoolId:i,userPoolClientId:r}),u={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:c,Session:o,ClientMetadata:n,ClientId:r,UserContextData:d};return Z({endpointResolver:w({endpointOverride:a})})({region:I(i),userAgentValue:T(C.ConfirmSignIn)},u)}async function Zc({challengeResponse:e,clientMetadata:t,session:n,username:o,requiredAttributes:s,config:i}){const{userPoolId:r,userPoolClientId:a,userPoolEndpoint:c}=i,d={...id(s),NEW_PASSWORD:e,USERNAME:o},u=V({username:o,userPoolId:r,userPoolClientId:a}),l={ChallengeName:"NEW_PASSWORD_REQUIRED",ChallengeResponses:d,ClientMetadata:t,Session:n,ClientId:a,UserContextData:u};return Z({endpointResolver:w({endpointOverride:c})})({region:I(r),userAgentValue:T(C.ConfirmSignIn)},l)}async function ed(e,t,n,o,s){var E,A;const{userPoolClientId:i,userPoolId:r,userPoolEndpoint:a}=o,c={USERNAME:e,PASSWORD:t},d=await s.getDeviceMetadata(e);d&&d.deviceKey&&(c.DEVICE_KEY=d.deviceKey);const u=V({username:e,userPoolId:r,userPoolClientId:i}),l={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:c,ClientMetadata:n,ClientId:i,UserContextData:u},g=await et({endpointResolver:w({endpointOverride:a})})({region:I(r),userAgentValue:T(C.SignIn)},l),f=((E=g.ChallengeParameters)==null?void 0:E.USERNAME)??((A=g.ChallengeParameters)==null?void 0:A.USER_ID_FOR_SRP)??e;return Me(f),g.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:f,config:o,clientMetadata:n,session:g.Session,tokenOrchestrator:s}):g}async function td(e,t,n,o,s){return ms({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:"USER_SRP_AUTH"})}async function nd(e,t,n,o){var f;const{userPoolClientId:s,userPoolId:i,userPoolEndpoint:r}=n,a={USERNAME:e},c=await o.getDeviceMetadata(e);c&&c.deviceKey&&(a.DEVICE_KEY=c.deviceKey);const d=V({username:e,userPoolId:i,userPoolClientId:s}),u={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:t,ClientId:s,UserContextData:d},h=await et({endpointResolver:w({endpointOverride:r})})({region:I(i),userAgentValue:T(C.SignIn)},u),g=((f=h.ChallengeParameters)==null?void 0:f.USERNAME)??e;return Me(g),h.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:g,config:n,clientMetadata:t,session:h.Session,tokenOrchestrator:o}):h}async function od(e,t,n,o,s){S(o);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a}=o,c=(i==null?void 0:i.split("_")[1])||"",d=await tt(c),u={USERNAME:e,SRP_A:d.A.toString(16),CHALLENGE_NAME:"SRP_A"},l=V({username:e,userPoolId:i,userPoolClientId:r}),h={AuthFlow:"CUSTOM_AUTH",AuthParameters:u,ClientMetadata:n,ClientId:r,UserContextData:l},g=et({endpointResolver:w({endpointOverride:a})}),{ChallengeParameters:f,Session:E}=await g({region:I(i),userAgentValue:T(C.SignIn)},h),A=(f==null?void 0:f.USERNAME)??e;return Me(A),Be(dn,[t,f,n,E,d,o,s],A,s)}async function De(e){var i;const{challengeName:t,challengeParameters:n,availableChallenges:o}=e,s=(i=R.getConfig().Auth)==null?void 0:i.Cognito;switch(S(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:a}=ge.getState(),c=Ht(Po(n.MFAS_CAN_SETUP))||[],d=cd(c),u=d.includes("TOTP"),l=d.includes("EMAIL");if(u&&l)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:d}};if(l)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(u){const h=as({endpointResolver:w({endpointOverride:s.userPoolEndpoint})}),{Session:g,SecretCode:f}=await h({region:I(s.userPoolId)},{Session:r});return ge.dispatch({type:"SET_SIGN_IN_SESSION",value:g}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:Ss(f,a)}}}throw new m({name:he.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:sd(n.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:Ht(Po(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 Vc(n);return Yc(r)?r:De(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:he.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function Ss(e,t){return{sharedSecret:e,getSetupUri:(n,o)=>{const s=`otpauth://totp/${n}:${o??t}?secret=${e}&issuer=${n}`;return new ve(s)}}}function He(e){if(e===mt.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===mt.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function sd(e){return e?JSON.parse(e).map(n=>n.includes(Bt)?n.replace(Bt,""):n):[]}function id(e){if(!e)return{};const t={};return Object.entries(e).forEach(([n,o])=>{o&&(t[`${Bt}${n}`]=o)}),t}async function rd(e,t,n,o,s,i,r,a){const c=a==null?void 0:a.userAttributes,d=a==null?void 0:a.friendlyDeviceName;switch(t){case"WEB_AUTHN":case"SELECT_CHALLENGE":return o==="PASSWORD_SRP"||o==="PASSWORD"?{ChallengeName:o,Session:n,$metadata:{}}:Gc({username:e,session:n,selectedChallenge:o,config:s,clientMetadata:r});case"SELECT_MFA_TYPE":return Qc({challengeResponse:o,clientMetadata:r,session:n,username:e,config:s});case"MFA_SETUP":return Xc({challengeResponse:o,clientMetadata:r,session:n,username:e,deviceName:d,config:s});case"NEW_PASSWORD_REQUIRED":return Zc({challengeResponse:o,clientMetadata:r,session:n,username:e,requiredAttributes:c,config:s});case"CUSTOM_CHALLENGE":return Be(Jc,[{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 dd({challengeName:t,challengeResponse:o,clientMetadata:r,session:n,username:e,config:s,tokenOrchestrator:i});case"PASSWORD":return zc(e,o,r,s,n);case"PASSWORD_SRP":return jc(e,o,r,s,n,i)}throw new m({name:he.SignInException,message:`An error occurred during the sign in process.
${t} challengeName returned by the underlying service was not addressed.`})}function ad(e){let t="SMS_MFA";return e==="TOTP"&&(t="SOFTWARE_TOKEN_MFA"),e==="EMAIL"&&(t="EMAIL_OTP"),t}function ys(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function Ht(e){if(e)return e.map(ys).filter(Boolean)}function Po(e){return e?JSON.parse(e):[]}function cd(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function Is(){let e;try{e=await en()}catch{}if(e&&e.userId&&e.username)throw new m({name:Jr,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function ot(e){return ge.getState().username??e}async function dd({challengeName:e,challengeResponse:t,clientMetadata:n,session:o,username:s,config:i,tokenOrchestrator:r}){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=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 l=await(r==null?void 0:r.getDeviceMetadata(s));l&&l.deviceKey&&(u.DEVICE_KEY=l.deviceKey);const h=V({username:s,userPoolId:a,userPoolClientId:c}),g={ChallengeName:e,ChallengeResponses:u,Session:o,ClientMetadata:n,ClientId:c,UserContextData:h},E=await Z({endpointResolver:w({endpointOverride:d})})({region:I(a),userAgentValue:T(C.ConfirmSignIn)},g);return E.ChallengeName==="DEVICE_SRP_AUTH"?nt({username:s,config:i,clientMetadata:n,session:E.Session,tokenOrchestrator:r}):E}async function ud(e){var a;const t=(a=R.getConfig().Auth)==null?void 0:a.Cognito;S(t);const{username:n,password:o,options:s}=e,i={loginId:n,authFlowType:"CUSTOM_WITHOUT_SRP"},r=s==null?void 0:s.clientMetadata;U(!!n,y.EmptySignInUsername),U(!o,y.CustomAuthSignInPassword);try{const{ChallengeName:c,ChallengeParameters:d,AuthenticationResult:u,Session:l}=await Be(nd,[n,r,t,k],n,k),h=ot(n);return be({signInSession:l,username:h,challengeName:c,signInDetails:i}),u?(await ye({username:h,...u,NewDeviceMetadata:await Ue({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),ie(),await Te(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:c,challengeParameters:d})}catch(c){ie(),Q(c);const d=He(c.name);if(d)return d;throw c}}async function ld(e){var a;const{username:t,password:n,options:o}=e,s={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=(a=R.getConfig().Auth)==null?void 0:a.Cognito;S(i);const r=o==null?void 0:o.clientMetadata;U(!!t,y.EmptySignInUsername),U(!!n,y.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:d,AuthenticationResult:u,Session:l}=await od(t,n,r,i,k),h=ot(t);return be({signInSession:l,username:h,challengeName:c,signInDetails:s}),u?(await ye({username:h,...u,NewDeviceMetadata:await Ue({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),ie(),await Te(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:c,challengeParameters:d})}catch(c){ie(),Q(c);const d=He(c.name);if(d)return d;throw c}}const ws=async()=>{throw new m({name:ns,message:"The autoSignIn flow has not started, or has been cancelled/completed.",recoverySuggestion:"Please try to use the signIn API or log out before starting a new autoSignIn flow."})};let un=ws;function qt(e){un=e}function j(e=!0){e&&(un=ws),we.dispatch({type:"RESET"})}async function _o(e){var r,a;const{username:t,password:n}=e,o=(r=R.getConfig().Auth)==null?void 0:r.Cognito,s={loginId:t,authFlowType:"USER_SRP_AUTH"};S(o);const i=(a=e.options)==null?void 0:a.clientMetadata;U(!!t,y.EmptySignInUsername),U(!!n,y.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:d,AuthenticationResult:u,Session:l}=await td(t,n,i,o,k),h=ot(t);return be({signInSession:l,username:h,challengeName:c,signInDetails:s}),u?(await ye({username:h,...u,NewDeviceMetadata:await Ue({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),ie(),await Te(),j(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:c,challengeParameters:d})}catch(c){ie(),j(),Q(c);const d=He(c.name);if(d)return d;throw c}}async function hd(e){var a;const{username:t,password:n,options:o}=e,s=(a=R.getConfig().Auth)==null?void 0:a.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};S(s);const r=o==null?void 0:o.clientMetadata;U(!!t,y.EmptySignInUsername),U(!!n,y.EmptySignInPassword);try{const{ChallengeName:c,ChallengeParameters:d,AuthenticationResult:u,Session:l}=await Be(ed,[t,n,r,s,k],t,k),h=ot(t);return be({signInSession:l,username:h,challengeName:c,signInDetails:i}),u?(await ye({...u,username:h,NewDeviceMetadata:await Ue({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),ie(),await Te(),j(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:c,challengeParameters:d})}catch(c){ie(),j(),Q(c);const d=He(c.name);if(d)return d;throw c}}async function gd({username:e,clientMetadata:t,config:n,tokenOrchestrator:o,preferredChallenge:s,password:i,session:r}){const{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=n,u=V({username:e,userPoolId:a,userPoolClientId:c}),l={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)&&U(!1,y.InvalidPreferredChallenge),s==="PASSWORD_SRP")return U(!!i,y.EmptySignInPassword),ms({username:e,password:i,clientMetadata:t,config:n,tokenOrchestrator:o,authFlow:"USER_AUTH",preferredChallenge:s});s==="PASSWORD"&&(U(!!i,y.EmptySignInPassword),l.PASSWORD=i),l.PREFERRED_CHALLENGE=s}const h={AuthFlow:"USER_AUTH",AuthParameters:l,ClientMetadata:t,ClientId:c,UserContextData:u};r&&(h.Session=r);const f=await et({endpointResolver:w({endpointOverride:d})})({region:I(a),userAgentValue:T(C.SignIn)},h);return Me(e),f}async function Cs(e){var c,d;const{username:t,password:n,options:o}=e,s=(c=R.getConfig().Auth)==null?void 0:c.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};S(s);const r=o==null?void 0:o.clientMetadata,a=(o==null?void 0:o.preferredChallenge)??((d=s==null?void 0:s.passwordless)==null?void 0:d.preferredChallenge);U(!!t,y.EmptySignInUsername);try{const u={username:t,config:s,tokenOrchestrator:k,clientMetadata:r,preferredChallenge:a,password:n},l=we.getState();l.active&&l.username===t&&(u.session=l.session);const h=await gd(u),g=ot(t);return be({signInSession:h.Session,username:g,challengeName:h.ChallengeName,signInDetails:i}),h.AuthenticationResult?(await ye({username:g,...h.AuthenticationResult,NewDeviceMetadata:await Ue({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:h.AuthenticationResult.NewDeviceMetadata,accessToken:h.AuthenticationResult.AccessToken}),signInDetails:i}),ie(),await Te(),j(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:h.ChallengeName,challengeParameters:h.ChallengeParameters,availableChallenges:"AvailableChallenges"in h?h.AvailableChallenges:void 0})}catch(u){ie(),j(),Q(u);const l=He(u.name);if(l)return l;throw u}}async function ln(e){var n;j(!1);const t=(n=e.options)==null?void 0:n.authFlowType;switch(await Is(),t){case"USER_SRP_AUTH":return _o(e);case"USER_PASSWORD_AUTH":return hd(e);case"CUSTOM_WITHOUT_SRP":return ud(e);case"CUSTOM_WITH_SRP":return ld(e);case"USER_AUTH":return Cs(e);default:return _o(e)}}const As=3*60*1e3;function fd(e){const t=Et.listen("auth-internal",async({payload:o})=>{switch(o.event){case"confirmSignUp":{const s=o.data;s!=null&&s.isSignUpComplete&&(Et.dispatch("auth-internal",{event:"autoSignIn"}),qt(Ts(e)),t())}}}),n=setTimeout(()=>{t(),clearTimeout(n),j()},As)}function vs(e,t){let n;return o=>{n||e(...o),clearTimeout(n),n=setTimeout(()=>{n=void 0},t)}}function pd(e,t,n){const o=Date.now(),s=setInterval(async()=>{if(Date.now()-o>As)clearInterval(s),n(new m({name:ns,message:"The account was not confirmed on time.",recoverySuggestion:"Try to verify your account by clicking the link sent your email or phone and then login manually."})),j();else try{const a=await ln(e);a.nextStep.signInStep!=="CONFIRM_SIGN_UP"&&(t(a),clearInterval(s),j())}catch(a){clearInterval(s),n(a),j()}},5e3)}const Ed=vs(pd,300),md=vs(yd,300);function Sd(e){return async()=>new Promise((t,n)=>{Ed([e,t,n])})}async function yd(e,t,n){var o;try{const s=((o=e==null?void 0:e.options)==null?void 0:o.authFlowType)==="USER_AUTH"?await Cs(e):await ln(e);t(s),j()}catch(s){n(s),j()}}function Ts(e){return async()=>new Promise((t,n)=>{md([e,t,n])})}const Id=Ts,wd=()=>async e=>{if(e.statusCode>=300){const t=await Ne(e);if(Q(t),t.name===Lt.InvalidParameterException&&/'password'/.test(t.message)&&/Member must not be null/.test(t.message)){const n=y.EmptySignUpPassword,{message:o,recoverySuggestion:s}=ts[n];throw new m({name:n,message:o,recoverySuggestion:s})}throw new m({name:t.name,message:t.message})}return Qe(e)},Cd=e=>P(N,x("SignUp"),wd(),{...b,...e});async function Ad(e){var D;const{username:t,password:n,options:o}=e,s=(D=R.getConfig().Auth)==null?void 0:D.Cognito,i=(s==null?void 0:s.signUpVerificationMethod)??"code",{clientMetadata:r,validationData:a,autoSignIn:c}=e.options??{};S(s),U(!!t,y.EmptySignUpUsername);const d=typeof c!="boolean"?c:void 0,u={username:t,options:d};(d==null?void 0:d.authFlowType)!=="CUSTOM_WITHOUT_SRP"&&(u.password=n);const{userPoolId:l,userPoolClientId:h,userPoolEndpoint:g}=s,f=Cd({endpointResolver:w({endpointOverride:g})}),E={Username:t,Password:void 0,UserAttributes:(o==null?void 0:o.userAttributes)&&kt(o==null?void 0:o.userAttributes),ClientMetadata:r,ValidationData:a&&kt(a),ClientId:h,UserContextData:V({username:t,userPoolId:l,userPoolClientId:h})};n&&(E.Password=n);const{UserSub:A,CodeDeliveryDetails:v,UserConfirmed:O,Session:ee}=await f({region:I(l),userAgentValue:T(C.SignUp)},E);(d||c===!0)&&(we.dispatch({type:"START"}),we.dispatch({type:"SET_USERNAME",value:t}),we.dispatch({type:"SET_SESSION",value:ee}));const Ie={destination:v==null?void 0:v.Destination,deliveryMedium:v==null?void 0:v.DeliveryMedium,attributeName:v==null?void 0:v.AttributeName},te=!!O,fe=we.getState().active;if(te)return fe?(qt(Id(u)),{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:A}):{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:A};if(fe){if(i==="link")return qt(Sd(u)),{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:Ie},userId:A};fd(u)}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:Ie},userId:A}}const vd=e=>P(N,x("ForgotPassword"),M(),{...b,...e});async function Td(e){var l,h;const{username:t}=e;U(!!t,y.EmptyResetPasswordUsername);const n=(l=R.getConfig().Auth)==null?void 0:l.Cognito;S(n);const{userPoolClientId:o,userPoolId:s,userPoolEndpoint:i}=n,r=(h=e.options)==null?void 0:h.clientMetadata,a=V({username:t,userPoolId:s,userPoolClientId:o}),u=(await vd({endpointResolver:w({endpointOverride:i})})({region:I(s),userAgentValue:T(C.ResetPassword)},{Username:t,ClientMetadata:r,ClientId:o,UserContextData:a})).CodeDeliveryDetails;return{isPasswordReset:!1,nextStep:{resetPasswordStep:"CONFIRM_RESET_PASSWORD_WITH_CODE",codeDeliveryDetails:{deliveryMedium:u==null?void 0:u.DeliveryMedium,destination:u==null?void 0:u.Destination,attributeName:u==null?void 0:u.AttributeName}}}}const Rd=e=>P(N,x("ConfirmForgotPassword"),M(),{...b,...e});async function Pd(e){var l,h;const t=(l=R.getConfig().Auth)==null?void 0:l.Cognito;S(t);const{userPoolClientId:n,userPoolId:o,userPoolEndpoint:s}=t,{username:i,newPassword:r}=e;U(!!i,y.EmptyConfirmResetPasswordUsername),U(!!r,y.EmptyConfirmResetPasswordNewPassword);const a=e.confirmationCode;U(!!a,y.EmptyConfirmResetPasswordConfirmationCode);const c=(h=e.options)==null?void 0:h.clientMetadata,d=V({username:i,userPoolId:o,userPoolClientId:n});await Rd({endpointResolver:w({endpointOverride:s})})({region:I(t.userPoolId),userAgentValue:T(C.ConfirmResetPassword)},{Username:i,ConfirmationCode:a,Password:r,ClientMetadata:c,ClientId:t.userPoolClientId,UserContextData:d})}const _d=e=>P(N,x("ResendConfirmationCode"),M(),{...b,...e});async function xd(e){var g,f;const{username:t}=e;U(!!t,y.EmptySignUpUsername);const n=(g=R.getConfig().Auth)==null?void 0:g.Cognito;S(n);const{userPoolClientId:o,userPoolId:s,userPoolEndpoint:i}=n,r=(f=e.options)==null?void 0:f.clientMetadata,a=V({username:t,userPoolId:s,userPoolClientId:o}),c=_d({endpointResolver:w({endpointOverride:i})}),{CodeDeliveryDetails:d}=await c({region:I(n.userPoolId),userAgentValue:T(C.ResendSignUpCode)},{Username:t,ClientMetadata:r,ClientId:n.userPoolClientId,UserContextData:a}),{DeliveryMedium:u,AttributeName:l,Destination:h}={...d};return{destination:h,deliveryMedium:u,attributeName:l||void 0}}const Nd=e=>P(N,x("ConfirmSignUp"),M(),{...b,...e});async function bd(e){var h;const{username:t,confirmationCode:n,options:o}=e,s=(h=R.getConfig().Auth)==null?void 0:h.Cognito;S(s);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:a}=s,c=o==null?void 0:o.clientMetadata;U(!!t,y.EmptyConfirmSignUpUsername),U(!!n,y.EmptyConfirmSignUpCode);const d=V({username:t,userPoolId:i,userPoolClientId:r}),u=Nd({endpointResolver:w({endpointOverride:a})}),{Session:l}=await u({region:I(s.userPoolId),userAgentValue:T(C.ConfirmSignUp)},{Username:t,ConfirmationCode:n,ClientMetadata:c,ForceAliasCreation:o==null?void 0:o.forceAliasCreation,ClientId:s.userPoolClientId,UserContextData:d});return new Promise((g,f)=>{try{const E={isSignUpComplete:!0,nextStep:{signUpStep:"DONE"}},A=we.getState();if(!A.active||A.username!==t){g(E),j();return}we.dispatch({type:"SET_SESSION",value:l});const v=Et.listen("auth-internal",({payload:O})=>{switch(O.event){case"autoSignIn":g({isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"}}),v()}});Et.dispatch("auth-internal",{event:"confirmSignUp",data:E})}catch(E){f(E)}})}async function Ud(e){var d;const{challengeResponse:t,options:n}=e,{username:o,challengeName:s,signInSession:i,signInDetails:r}=ge.getState(),a=(d=R.getConfig().Auth)==null?void 0:d.Cognito;S(a);const c=n==null?void 0:n.clientMetadata;if(U(!!t,y.EmptyChallengeResponse),!o||!s||!i)throw new m({name:he.SignInException,message:`
An error occurred during the sign in process.
This most likely occurred due to:
1. signIn was not called before confirmSignIn.
2. signIn threw an exception.
3. page was refreshed during the sign in flow and session has expired.
`,recoverySuggestion:"Make sure a successful call to signIn is made before calling confirmSignInand that the session has not expired."});try{const{Session:u,ChallengeName:l,AuthenticationResult:h,ChallengeParameters:g}=await rd(o,s,i,t,a,k,c,n);return be({signInSession:u,username:o,challengeName:l,signInDetails:r}),h?(await ye({username:o,...h,NewDeviceMetadata:await Ue({userPoolId:a.userPoolId,userPoolEndpoint:a.userPoolEndpoint,newDeviceMetadata:h.NewDeviceMetadata,accessToken:h.AccessToken}),signInDetails:r}),ie(),await Te(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):De({challengeName:l,challengeParameters:g})}catch(u){Q(u);const l=He(u.name);if(l)return l;throw u}}const Md=e=>P(N,x("SetUserMFAPreference"),M(),{...b,...e});async function Dd(e){var d;const{sms:t,totp:n,email:o}=e,s=(d=R.getConfig().Auth)==null?void 0:d.Cognito;S(s);const{userPoolEndpoint:i,userPoolId:r}=s,{tokens:a}=await $({forceRefresh:!1});W(a),await Md({endpointResolver:w({endpointOverride:i})})({region:I(r),userAgentValue:T(C.UpdateMFAPreference)},{AccessToken:a.accessToken.toString(),SMSMfaSettings:bt(t),SoftwareTokenMfaSettings:bt(n),EmailMfaSettings:bt(o)})}function bt(e){if(e==="DISABLED")return{Enabled:!1};if(e==="PREFERRED")return{Enabled:!0,PreferredMfa:!0};if(e==="ENABLED")return{Enabled:!0};if(e==="NOT_PREFERRED")return{Enabled:!0,PreferredMfa:!1}}const Rs=e=>P(N,x("GetUser"),M(),{...b,...e});async function Od(){var a;const e=(a=R.getConfig().Auth)==null?void 0:a.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $({forceRefresh:!1});W(o);const s=Rs({endpointResolver:w({endpointOverride:t})}),{PreferredMfaSetting:i,UserMFASettingList:r}=await s({region:I(n),userAgentValue:T(C.FetchMFAPreference)},{AccessToken:o.accessToken.toString()});return{preferred:ys(i),enabled:Ht(r)}}async function Fd(e){var c;const t=(c=R.getConfig().Auth)==null?void 0:c.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{code:s,options:i}=e;U(!!s,y.EmptyVerifyTOTPSetupCode);const{tokens:r}=await $({forceRefresh:!1});W(r),await rs({endpointResolver:w({endpointOverride:n})})({region:I(o),userAgentValue:T(C.VerifyTOTPSetup)},{AccessToken:r.accessToken.toString(),UserCode:s,FriendlyDeviceName:i==null?void 0:i.friendlyDeviceName})}const kd=e=>P(N,x("ChangePassword"),M(),{...b,...e});async function Ld(e){var c;const t=(c=R.getConfig().Auth)==null?void 0:c.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{oldPassword:s,newPassword:i}=e;U(!!s,y.EmptyUpdatePassword),U(!!i,y.EmptyUpdatePassword);const{tokens:r}=await $({forceRefresh:!1});W(r),await kd({endpointResolver:w({endpointOverride:n})})({region:I(o),userAgentValue:T(C.UpdatePassword)},{AccessToken:r.accessToken.toString(),PreviousPassword:s,ProposedPassword:i})}async function Wd(){var a,c;const e=(a=R.getConfig().Auth)==null?void 0:a.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $({forceRefresh:!1});W(o);const s=((c=o.idToken)==null?void 0:c.payload["cognito:username"])??"",i=as({endpointResolver:w({endpointOverride:t})}),{SecretCode:r}=await i({region:I(n),userAgentValue:T(C.SetUpTOTP)},{AccessToken:o.accessToken.toString()});if(!r)throw new m({name:Yr,message:"Failed to set up TOTP."});return Ss(r,JSON.stringify(s))}const Kd=e=>P(N,x("UpdateUserAttributes"),M(),{...b,...e}),Ps=async e=>{var u;const{userAttributes:t,options:n}=e,o=(u=R.getConfig().Auth)==null?void 0:u.Cognito,s=n==null?void 0:n.clientMetadata;S(o);const{userPoolEndpoint:i,userPoolId:r}=o,{tokens:a}=await $({forceRefresh:!1});W(a);const c=Kd({endpointResolver:w({endpointOverride:i})}),{CodeDeliveryDetailsList:d}=await c({region:I(r),userAgentValue:T(C.UpdateUserAttributes)},{AccessToken:a.accessToken.toString(),ClientMetadata:s,UserAttributes:kt(t)});return{...Vd(t),...Bd(d)}};function Vd(e){var n;const t={};return(n=Object.keys(e))==null||n.forEach(o=>{t[o]={isUpdated:!0,nextStep:{updateAttributeStep:"DONE"}}}),t}function Bd(e){const t={};return e==null||e.forEach(n=>{const{AttributeName:o,DeliveryMedium:s,Destination:i}=n;o&&(t[o]={isUpdated:!1,nextStep:{updateAttributeStep:"CONFIRM_ATTRIBUTE_WITH_CODE",codeDeliveryDetails:{attributeName:o,deliveryMedium:s,destination:i}}})}),t}const Hd=async e=>{const{userAttribute:{attributeKey:t,value:n},options:o}=e,s=await Ps({userAttributes:{[t]:n},options:o});return Object.values(s)[0]},qd=e=>P(N,x("VerifyUserAttribute"),M(),{...b,...e});async function $d(e){var c;const t=(c=R.getConfig().Auth)==null?void 0:c.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{confirmationCode:s,userAttributeKey:i}=e;U(!!s,y.EmptyConfirmUserAttributeCode);const{tokens:r}=await $({forceRefresh:!1});W(r),await qd({endpointResolver:w({endpointOverride:n})})({region:I(o),userAgentValue:T(C.ConfirmUserAttribute)},{AccessToken:r.accessToken.toString(),AttributeName:i,Code:s})}new z("AuthError");const Gd={oauthSignInError:{message:K.OAUTH_ERROR,log:"Make sure Cognito Hosted UI has been configured correctly"},noConfig:{message:K.DEFAULT_MSG},missingAuthConfig:{message:K.DEFAULT_MSG},emptyUsername:{message:K.EMPTY_USERNAME},invalidUsername:{message:K.INVALID_USERNAME},emptyPassword:{message:K.EMPTY_PASSWORD},emptyCode:{message:K.EMPTY_CODE},signUpError:{message:K.SIGN_UP_ERROR},noMFA:{message:K.NO_MFA},invalidMFA:{message:K.INVALID_MFA},emptyChallengeResponse:{message:K.EMPTY_CHALLENGE},noUserSession:{message:K.NO_USER_SESSION},deviceConfig:{message:K.DEVICE_CONFIG},networkError:{message:K.NETWORK_ERROR},autoSignInError:{message:K.AUTOSIGNIN_ERROR},default:{message:K.DEFAULT_MSG}},Ae=(e,t)=>new m({message:e??"An error has occurred during the oauth process.",name:he.OAuthSignInError,recoverySuggestion:Gd.oauthSignInError.log});var $t;(function(e){e.NoConfig="noConfig",e.MissingAuthConfig="missingAuthConfig",e.EmptyUsername="emptyUsername",e.InvalidUsername="invalidUsername",e.EmptyPassword="emptyPassword",e.EmptyCode="emptyCode",e.SignUpError="signUpError",e.NoMFA="noMFA",e.InvalidMFA="invalidMFA",e.EmptyChallengeResponse="emptyChallengeResponse",e.NoUserSession="noUserSession",e.Default="default",e.DeviceConfig="deviceConfig",e.NetworkError="networkError",e.AutoSignInError="autoSignInError",e.OAuthSignInError="oauthSignInError"})($t||($t={}));const zd="`signInWithRedirect` has been canceled.",jd="An error occurred while validating the state.",Yd="Try to initiate an OAuth flow from Amplify",_s=async e=>{const t=await G.loadOAuthState(),n=e===t?t:void 0;if(!n)throw new m({name:$t.OAuthSignInError,message:e===null?zd:jd,recoverySuggestion:e===null?void 0:Yd});return n},xs=async({currentUrl:e,userAgentValue:t,clientId:n,redirectUri:o,responseType:s,domain:i,preferPrivateSession:r})=>{const a=new ve(e),c=a.searchParams.get("error"),d=a.searchParams.get("error_description");if(c)throw Ae(d??c);return s==="code"?Jd({currentUrl:e,userAgentValue:t,clientId:n,redirectUri:o,domain:i,preferPrivateSession:r}):Xd({currentUrl:e,redirectUri:o,preferPrivateSession:r})},Jd=async({currentUrl:e,userAgentValue:t,clientId:n,redirectUri:o,domain:s,preferPrivateSession:i})=>{const r=new ve(e),a=r.searchParams.get("code"),c=r.searchParams.get("state");if(!a||!c)throw Ae("User cancelled OAuth flow.");const d=await _s(c),u="https://"+s+"/oauth2/token",l=await G.loadPKCE(),h={grant_type:"authorization_code",code:a,client_id:n,redirect_uri:o,...l?{code_verifier:l}:{}},g=Object.entries(h).map(([fe,D])=>`${encodeURIComponent(fe)}=${encodeURIComponent(D)}`).join("&"),{access_token:f,refresh_token:E,id_token:A,error:v,error_message:O,token_type:ee,expires_in:Ie}=await(await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",[Gs]:t},body:g})).json();if(v)throw Ae(O??v);const te=(f&&le(f).payload.username)??"username";return await ye({username:te,AccessToken:f,IdToken:A,RefreshToken:E}),Ns({redirectUri:o,state:d,preferPrivateSession:i})},Xd=async({currentUrl:e,redirectUri:t,preferPrivateSession:n})=>{const o=new ve(e),{id_token:s,access_token:i,state:r,token_type:a,expires_in:c,error_description:d,error:u}=(o.hash??"#").substring(1).split("&").map(g=>g.split("=")).reduce((g,[f,E])=>({...g,[f]:E}),{id_token:void 0,access_token:void 0,state:void 0,token_type:void 0,expires_in:void 0,error_description:void 0,error:void 0});if(u)throw Ae(d??u);if(!i)throw Ae("No access token returned from OAuth flow.");const l=await _s(r),h=(i&&le(i).payload.username)??"username";return await ye({username:h,AccessToken:i,IdToken:s}),Ns({redirectUri:t,state:l,preferPrivateSession:n})},Ns=async({redirectUri:e,state:t,preferPrivateSession:n})=>{await k.setOAuthMetadata({oauthSignIn:!0}),await G.clearOAuthData(),await G.storeOAuthSignIn(!0,n),ds(),eu(e),Qd(t)&&Se.dispatch("auth",{event:"customOAuthState",data:Vr(Zd(t))},"Auth",ue),Se.dispatch("auth",{event:"signInWithRedirect"},"Auth",ue),await Te()},Qd=e=>/-/.test(e),Zd=e=>e.split("-").splice(1).join("-"),eu=e=>{typeof window<"u"&&typeof window.history<"u"&&window.history.replaceState(window.history.state,"",e)};function hn(e,t){if(t){const n=e==null?void 0:e.find(o=>o===t);if(!n)throw na;return n}else{const n=(e==null?void 0:e.find(tu))??(e==null?void 0:e.find(nu)),o=(e==null?void 0:e.find(su))??(e==null?void 0:e.find(ou));if(n)return n;throw o?sa:ta}}const tu=e=>e.startsWith(String(window.location.origin+(window.location.pathname||"/"))),nu=e=>e.includes(String(window.location.hostname)),ou=e=>e.startsWith("http://"),su=e=>e.startsWith("https://"),gn=async e=>{ds(),await G.clearOAuthInflightData(),Se.dispatch("auth",{event:"signInWithRedirect_failure",data:{error:e}},"Auth",ue)},iu=async e=>{try{S(e),yt(e),G.setAuthConfig(e)}catch{return}if(await G.loadOAuthInFlight())try{const t=window.location.href,{loginWith:n,userPoolClientId:o}=e,{domain:s,redirectSignIn:i,responseType:r}=n.oauth,a=hn(i);await xs({currentUrl:t,clientId:o,domain:s,redirectUri:a,responseType:r,userAgentValue:T(C.SignInWithRedirect)})}catch(t){await gn(t)}};Ct()&&R[Mo](iu);const ru={Google:"Google",Facebook:"Facebook",Amazon:"LoginWithAmazon",Apple:"SignInWithApple"},bs=async e=>{window!=null&&window.location&&(window.location.href=e.replace("http://","https://"))},xo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",au=e=>{const t=new Uint8Array(e);jt().getRandomValues(t);let n="",o;for(const s of t)n+=xo.charAt(s%xo.length);return{value:n,method:"S256",toCodeChallenge(){return o||(o=cu(n),o)}}};function cu(e){const t=new Je;return t.update(e),du(Oe.convert(t.digestSync(),{urlSafe:!0}))}function du(e){return e.replace(/=/g,"")}const uu=()=>Kr(32),lu=e=>{async function t(n){if(n.persisted&&await e.loadOAuthInFlight()){const s=Ae("User cancelled OAuth flow.");await gn(s)}window.removeEventListener("pageshow",t)}window.addEventListener("pageshow",t)};async function hu(e){var s,i,r,a,c,d,u,l,h,g;const t=(s=R.getConfig().Auth)==null?void 0:s.Cognito;S(t),yt(t),G.setAuthConfig(t),(i=e==null?void 0:e.options)!=null&&i.prompt||await Is();let n="COGNITO",o;return typeof(e==null?void 0:e.provider)=="string"?n=ru[e.provider]:(r=e==null?void 0:e.provider)!=null&&r.custom?n=e.provider.custom:(a=e==null?void 0:e.provider)!=null&&a.idpIdentifier&&({idpIdentifier:o}=e.provider),gu({oauthConfig:t.loginWith.oauth,clientId:t.userPoolClientId,provider:n,idpIdentifier:o,customState:e==null?void 0:e.customState,preferPrivateSession:(c=e==null?void 0:e.options)==null?void 0:c.preferPrivateSession,options:{loginHint:(d=e==null?void 0:e.options)==null?void 0:d.loginHint,lang:(u=e==null?void 0:e.options)==null?void 0:u.lang,nonce:(l=e==null?void 0:e.options)==null?void 0:l.nonce,prompt:(h=e==null?void 0:e.options)==null?void 0:h.prompt},authSessionOpener:(g=e==null?void 0:e.options)==null?void 0:g.authSessionOpener})}const gu=async({oauthConfig:e,provider:t,idpIdentifier:n,clientId:o,customState:s,preferPrivateSession:i,options:r,authSessionOpener:a})=>{const{domain:c,redirectSignIn:d,responseType:u,scopes:l}=e,{loginHint:h,lang:g,nonce:f,prompt:E}=r??{},A=uu(),v=a||bs,O=s?`${A}-${Br(s)}`:A,{value:ee,method:Ie,toCodeChallenge:te}=au(128),fe=hn(e.redirectSignIn);Ct()&&G.storeOAuthInFlight(!0),G.storeOAuthState(O),G.storePKCE(ee);const D=new URLSearchParams;D.append("redirect_uri",fe),D.append("response_type",u),D.append("client_id",o),n?D.append("idp_identifier",n):D.append("identity_provider",t),D.append("scope",l.join(" ")),h&&D.append("login_hint",h),g&&D.append("lang",g),f&&D.append("nonce",f),E&&D.append("prompt",E.toLowerCase()),D.append("state",O),u==="code"&&(D.append("code_challenge",te()),D.append("code_challenge_method",Ie));const qe=`https://${c}/oauth2/authorize?${D.toString()}`;lu(G);const{type:J,error:st,url:it}=await v(qe,d,i)??{};try{if(J==="error")throw Ae(String(st));if(J==="canceled")throw Ae(String(J));J==="success"&&it&&await xs({currentUrl:it,clientId:o,domain:c,redirectUri:fe,responseType:u,userAgentValue:T(C.SignInWithRedirect),preferPrivateSession:i})}catch($e){throw await gn($e),$e}},fu=async e=>{var a;const t=(a=e.getConfig().Auth)==null?void 0:a.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{tokens:s}=await Wo(e,{forceRefresh:!1});W(s);const i=Rs({endpointResolver:w({endpointOverride:n})}),{UserAttributes:r}=await i({region:I(o),userAgentValue:T(C.FetchUserAttributes)},{AccessToken:s.accessToken.toString()});return jr(r)},pu=()=>fu(R),Eu=async e=>{await e.clearOAuthData(),k.clearTokens(),await Ko(),Se.dispatch("auth",{event:"signedOut"},"Auth",ue)},mu=async(e,t=!1,n)=>{yt(e);const{loginWith:o,userPoolClientId:s}=e,{domain:i,redirectSignOut:r}=o.oauth,a=hn(r,n),c=`https://${i}/logout?${Object.entries({client_id:s,logout_uri:encodeURIComponent(a)}).map(([d,u])=>`${d}=${u}`).join("&")}`;return bs(c)},Su=async(e,t,n,o)=>{const{isOAuthSignIn:s}=await t.loadOAuthSignIn(),i=await n.getOAuthMetadata();if(await Eu(t),s||i!=null&&i.oauthSignIn)return mu(e,!1,o)},yu=e=>P(N,x("RevokeToken"),M(),{...b,...e}),Iu=e=>P(N,x("GlobalSignOut"),M(),{...b,...e}),Us=new z("Auth");async function Ms(e){var o,s;const t=(o=R.getConfig().Auth)==null?void 0:o.Cognito;S(t),e!=null&&e.global?await Cu(t):await wu(t);let n;try{yt(t),n=!0}catch{n=!1}if(n){const i=new cs(Ze);i.setAuthConfig(t);const{type:r}=await Su(t,i,k,(s=e==null?void 0:e.oauth)==null?void 0:s.redirectUrl)??{};if(r==="error")throw new m({name:ia,message:"An error occurred when attempting to log out from OAuth provider."})}else k.clearTokens(),await Ko(),Se.dispatch("auth",{event:"signedOut"},"Auth",ue)}async function wu(e){try{const{userPoolEndpoint:t,userPoolId:n,userPoolClientId:o}=e,s=await k.getTokenStore().loadTokens();os(s),Au(s.accessToken)&&await yu({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.SignOut)},{ClientId:o,Token:s.refreshToken})}catch{Us.debug("Client signOut error caught but will proceed with token removal")}}async function Cu(e){try{const{userPoolEndpoint:t,userPoolId:n}=e,o=await k.getTokenStore().loadTokens();W(o),await Iu({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.SignOut)},{AccessToken:o.accessToken.toString()})}catch{Us.debug("Global signOut error caught but will proceed with token removal")}}const Au=e=>{var t;return!!((t=e==null?void 0:e.payload)!=null&&t.origin_jti)},vu=e=>P(N,x("GetUserAttributeVerificationCode"),M(),{...b,...e}),Tu=async e=>{var g;const{userAttributeKey:t,options:n}=e,o=(g=R.getConfig().Auth)==null?void 0:g.Cognito,s=n==null?void 0:n.clientMetadata;S(o);const{userPoolEndpoint:i,userPoolId:r}=o,{tokens:a}=await $({forceRefresh:!1});W(a);const c=vu({endpointResolver:w({endpointOverride:i})}),{CodeDeliveryDetails:d}=await c({region:I(r),userAgentValue:T(C.SendUserAttributeVerificationCode)},{AccessToken:a.accessToken.toString(),ClientMetadata:s,AttributeName:t}),{DeliveryMedium:u,AttributeName:l,Destination:h}={...d};return{destination:h,deliveryMedium:u,attributeName:l}},Ru=e=>P(N,x("DeleteUserAttributes"),M(),{...b,...e});async function Pu(e){var a;const t=(a=R.getConfig().Auth)==null?void 0:a.Cognito;S(t);const{userAttributeKeys:n}=e,{userPoolEndpoint:o,userPoolId:s}=t,{tokens:i}=await $({forceRefresh:!1});W(i),await Ru({endpointResolver:w({endpointOverride:o})})({region:I(s),userAgentValue:T(C.DeleteUserAttributes)},{AccessToken:i.accessToken.toString(),UserAttributeNames:n})}const Ds=()=>async e=>{if(e.statusCode>=300){const t=await Ne(e);throw Q(t),new m({name:t.name,message:t.message})}else return},_u=e=>P(N,x("DeleteUser"),Ds(),{...b,...e});async function xu(){var i;const e=(i=R.getConfig().Auth)==null?void 0:i.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $();W(o),await _u({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.DeleteUser)},{AccessToken:o.accessToken.toString()}),await k.clearDeviceMetadata(),await Ms()}const Nu=e=>P(N,x("UpdateDeviceStatus"),M(),{...b,...e});async function bu(){var r;const e=(r=R.getConfig().Auth)==null?void 0:r.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $();W(o);const s=await(k==null?void 0:k.getDeviceMetadata());Tt(s),await Nu({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.RememberDevice)},{AccessToken:o.accessToken.toString(),DeviceKey:s.deviceKey,DeviceRememberedStatus:"remembered"})}const Uu=e=>P(N,x("ForgetDevice"),Ds(),{...b,...e});async function Mu(e){var d;const{device:{id:t}={id:void 0}}=e??{},n=(d=R.getConfig().Auth)==null?void 0:d.Cognito;S(n);const{userPoolEndpoint:o,userPoolId:s}=n,{tokens:i}=await $();W(i);const r=await k.getDeviceMetadata(),a=r==null?void 0:r.deviceKey;t||Tt(r),await Uu({endpointResolver:w({endpointOverride:o})})({region:I(s),userAgentValue:T(C.ForgetDevice)},{AccessToken:i.accessToken.toString(),DeviceKey:t??a}),(!t||t===a)&&await k.clearDeviceMetadata()}const Du=e=>P(N,x("ListDevices"),M(),{...b,...e}),Ou=60;async function Fu(){var r;const e=(r=R.getConfig().Auth)==null?void 0:r.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $();W(o);const i=await Du({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.FetchDevices)},{AccessToken:o.accessToken.toString(),Limit:Ou});return ku(i.Devices??[])}const ku=async e=>e.map(({DeviceKey:t="",DeviceAttributes:n=[],DeviceCreateDate:o,DeviceLastModifiedDate:s,DeviceLastAuthenticatedDate:i})=>{let r;const a=n.reduce((d,{Name:u,Value:l})=>(u&&l&&(u==="device_name"&&(r=l),d[u]=l),d),{});return{id:t,name:r,attributes:a,createDate:o?new Date(o*1e3):void 0,lastModifiedDate:s?new Date(s*1e3):void 0,lastAuthenticatedDate:i?new Date(i*1e3):void 0}}),Lu={identityId:"identityId"},Wu=new z("DefaultIdentityIdStore");class Os{setAuthConfig(t){lt(t.Cognito),this.authConfig=t,this._authKeys=Ku("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){var t;lt((t=this.authConfig)==null?void 0:t.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{const n=await this.keyValueStorage.getItem(this._authKeys.identityId);return n?(this._hasGuestIdentityId=!0,{id:n,type:"guest"}):null}}catch(n){return Wu.log("Error getting stored IdentityId.",n),null}}async storeIdentityId(t){var n;lt((n=this.authConfig)==null?void 0:n.Cognito),t.type==="guest"?(this.keyValueStorage.setItem(this._authKeys.identityId,t.id),this._primaryIdentityId=void 0,this._hasGuestIdentityId=!0):(this._primaryIdentityId=t.id,this._hasGuestIdentityId&&(this.keyValueStorage.removeItem(this._authKeys.identityId),this._hasGuestIdentityId=!1))}async clearIdentityId(){this._primaryIdentityId=void 0,await this.keyValueStorage.removeItem(this._authKeys.identityId)}}const Ku=(e,t)=>tn(Lu)(`com.amplify.${e}`,t),Gt=({endpointOverride:e})=>t=>e?{url:new ve(e)}:Ur(t);function Fs(e){const t=le(e).payload.iss,n={};if(!t)throw new m({name:"InvalidIdTokenException",message:"Invalid Idtoken."});const o=t.replace(/(^\w+:|^)\/\//,"");return n[o]=e,n}async function Vu({tokens:e,authConfig:t,identityIdStore:n}){n.setAuthConfig({Cognito:t});const o=await n.loadIdentityId();if(o)return o.id;const s=e!=null&&e.idToken?Fs(e.idToken.toString()):{},i=await Bu(s,t);return n.storeIdentityId({id:i,type:e?"primary":"guest"}),i}async function Bu(e,t){const n=t==null?void 0:t.identityPoolId,o=Ft(n),s=xr({endpointResolver:Gt({endpointOverride:t.identityPoolEndpoint})});let i;try{i=(await s({region:o},{IdentityPoolId:n,Logins:e})).IdentityId}catch(r){throw Q(r),new m(r)}if(!i)throw new m({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return i}const ut=new z("CognitoCredentialsProvider"),No=50*60*1e3;class ks{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){ut.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){ut.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){const n=t.authenticated,{tokens:o}=t,{authConfig:s}=t;try{lt(s==null?void 0:s.Cognito)}catch{return}if(!n&&!s.Cognito.allowGuestAccess)return;const{forceRefresh:i}=t,r=this.hasTokenChanged(o),a=await Vu({tokens:o,authConfig:s.Cognito,identityIdStore:this._identityIdStore});return(i||r)&&this.clearCredentials(),n?(ca(o),this.credsForOIDCTokens(s.Cognito,o,a)):this.getGuestCredentials(a,s.Cognito)}async getGuestCredentials(t,n){var r,a;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return ut.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const o=Ft(n.identityPoolId),s=Yn({endpointResolver:Gt({endpointOverride:n.identityPoolEndpoint})});let i;try{i=await s({region:o},{IdentityId:t})}catch(c){throw Q(c),new m(c)}if((r=i==null?void 0:i.Credentials)!=null&&r.AccessKeyId&&((a=i==null?void 0:i.Credentials)!=null&&a.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+No;const c={credentials:{accessKeyId:i.Credentials.AccessKeyId,secretAccessKey:i.Credentials.SecretKey,sessionToken:i.Credentials.SessionToken,expiration:i.Credentials.Expiration},identityId:t};return i.IdentityId&&(c.identityId=i.IdentityId,this._identityIdStore.storeIdentityId({id:i.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...c,isAuthenticatedCreds:!1},c}else throw new m({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,n,o){var c,d,u;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return ut.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const s=n.idToken?Fs(n.idToken.toString()):{},i=Ft(t.identityPoolId),r=Yn({endpointResolver:Gt({endpointOverride:t.identityPoolEndpoint})});let a;try{a=await r({region:i},{IdentityId:o,Logins:s})}catch(l){throw Q(l),new m(l)}if((c=a==null?void 0:a.Credentials)!=null&&c.AccessKeyId&&((d=a==null?void 0:a.Credentials)!=null&&d.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+No;const l={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:o};return a.IdentityId&&(l.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...l,isAuthenticatedCreds:!0,associatedIdToken:(u=n.idToken)==null?void 0:u.toString()},l}else throw new m({name:"CredentialsException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}isPastTTL(){return this._nextCredentialsRefresh===void 0?!0:this._nextCredentialsRefresh<=Date.now()}hasTokenChanged(t){var n,o;return!!t&&!!((n=this._credentialsAndIdentityId)!=null&&n.associatedIdToken)&&((o=t.idToken)==null?void 0:o.toString())!==this._credentialsAndIdentityId.associatedIdToken}}const Hu=new ks(new Os(Ze)),il={configure(e,t){const n=Oo(e),o=new Wr({sameSite:"lax"}),s=t!=null&&t.ssr?o:Ze,i=t!=null&&t.ssr?new ks(new Os(o)):Hu;if(!n.Auth||t!=null&&t.Auth){R.configure(n,t);return}gt.setAuthConfig(n.Auth),gt.setKeyValueStorage(s),R.configure(n,{...t,Auth:{tokenProvider:gt,credentialsProvider:i}})},getConfig(){return R.getConfig()}},qu=e=>{if(e instanceof se)return e;if(e instanceof Error){if(e.name==="InvalidStateError"){const{message:t,recoverySuggestion:n}=Fe[_.PasskeyAlreadyExists];return new se({name:_.PasskeyAlreadyExists,message:t,recoverySuggestion:n,underlyingError:e})}if(e.name==="NotAllowedError"){const{message:t,recoverySuggestion:n}=Fe[_.PasskeyRegistrationCanceled];return new se({name:_.PasskeyRegistrationCanceled,message:t,recoverySuggestion:n,underlyingError:e})}}return hs(e)},$u=async e=>{try{const t=gs();We(t,_.PasskeyNotSupported);const n=Ka(e),o=await navigator.credentials.create({publicKey:n});return $a(o),Va(o)}catch(t){throw qu(t)}},Gu=e=>P(N,x("StartWebAuthnRegistration"),M(),{...b,...e}),zu=e=>P(N,x("CompleteWebAuthnRegistration"),M(),{...b,...e});async function ju(){var c;const e=(c=R.getConfig().Auth)==null?void 0:c.Cognito;S(e);const{userPoolEndpoint:t,userPoolId:n}=e,{tokens:o}=await $();W(o);const s=Gu({endpointResolver:w({endpointOverride:t})}),{CredentialCreationOptions:i}=await s({region:I(n),userAgentValue:T(C.StartWebAuthnRegistration)},{AccessToken:o.accessToken.toString()});qa(i);const r=await $u(i);await zu({endpointResolver:w({endpointOverride:t})})({region:I(n),userAgentValue:T(C.CompleteWebAuthnRegistration)},{AccessToken:o.accessToken.toString(),Credential:r})}const Yu=e=>P(N,x("ListWebAuthnCredentials"),M(),{...b,...e});async function Ju(e,t){var u;const n=(u=e.getConfig().Auth)==null?void 0:u.Cognito;S(n);const{userPoolEndpoint:o,userPoolId:s}=n,{tokens:i}=await e.Auth.fetchAuthSession();W(i);const r=Yu({endpointResolver:w({endpointOverride:o})}),{Credentials:a=[],NextToken:c}=await r({region:I(s),userAgentValue:T(C.ListWebAuthnCredentials)},{AccessToken:i.accessToken.toString(),MaxResults:t==null?void 0:t.pageSize,NextToken:t==null?void 0:t.nextToken});return{credentials:a.map(l=>({credentialId:l.CredentialId,friendlyCredentialName:l.FriendlyCredentialName,relyingPartyId:l.RelyingPartyId,authenticatorAttachment:l.AuthenticatorAttachment,authenticatorTransports:l.AuthenticatorTransports,createdAt:l.CreatedAt?new Date(l.CreatedAt*1e3):void 0})),nextToken:c}}async function Xu(e){return Ju(R,e)}const Qu=e=>P(N,x("DeleteWebAuthnCredential"),M(),{...b,...e});async function Zu(e,t){var a;const n=(a=e.getConfig().Auth)==null?void 0:a.Cognito;S(n);const{userPoolEndpoint:o,userPoolId:s}=n,{tokens:i}=await e.Auth.fetchAuthSession();W(i),await Qu({endpointResolver:w({endpointOverride:o})})({region:I(s),userAgentValue:T(C.DeleteWebAuthnCredential)},{AccessToken:i.accessToken.toString(),CredentialId:t.credentialId})}async function el(e){return Zu(R,e)}const rl=Object.freeze(Object.defineProperty({__proto__:null,AuthError:m,associateWebAuthnCredential:ju,get autoSignIn(){return un},confirmResetPassword:Pd,confirmSignIn:Ud,confirmSignUp:bd,confirmUserAttribute:$d,decodeJWT:le,deleteUser:xu,deleteUserAttributes:Pu,deleteWebAuthnCredential:el,fetchAuthSession:$,fetchDevices:Fu,fetchMFAPreference:Od,fetchUserAttributes:pu,forgetDevice:Mu,getCurrentUser:en,listWebAuthnCredentials:Xu,rememberDevice:bu,resendSignUpCode:xd,resetPassword:Td,sendUserAttributeVerificationCode:Tu,setUpTOTP:Wd,signIn:ln,signInWithRedirect:hu,signOut:Ms,signUp:Ad,updateMFAPreference:Dd,updatePassword:Ld,updateUserAttribute:Hd,updateUserAttributes:Ps,verifyTOTPSetup:Fd},Symbol.toStringTag,{value:"Module"}));export{il as D,Se as H,_n as _,ol as a,sl as b,at as c,pu as d,ln as e,$ as f,en as g,Pd as h,Td as i,bd as j,Ad as k,nl as l,rl as m,xd as r,Ms as s,Ps as u};