const ls="Logging",hs="NoHubcallbackProvidedException";var W;(function(e){e.DEBUG="DEBUG",e.ERROR="ERROR",e.INFO="INFO",e.WARN="WARN",e.VERBOSE="VERBOSE",e.NONE="NONE"})(W||(W={}));const tn={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6};class V{constructor(t,n=W.WARN){this.name=t,this.level=n,this._pluggables=[]}_padding(t){return t<10?"0"+t:""+t}_ts(){const t=new Date;return[this._padding(t.getMinutes()),this._padding(t.getSeconds())].join(":")+"."+t.getMilliseconds()}configure(t){return t?(this._config=t,this._config):this._config}_log(t,...n){let o=this.level;V.LOG_LEVEL&&(o=V.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(o=window.LOG_LEVEL);const s=tn[o];if(!(tn[t]>=s))return;let r=console.log.bind(console);t===W.ERROR&&console.error&&(r=console.error.bind(console)),t===W.WARN&&console.warn&&(r=console.warn.bind(console)),V.BIND_ALL_LOG_LEVELS&&(t===W.INFO&&console.info&&(r=console.info.bind(console)),t===W.DEBUG&&console.debug&&(r=console.debug.bind(console)));const c=`[${t}] ${this._ts()} ${this.name}`;let a="";if(n.length===1&&typeof n[0]=="string")a=`${c} - ${n[0]}`,r(a);else if(n.length===1)a=`${c} ${n[0]}`,r(c,n[0]);else if(typeof n[0]=="string"){let d=n.slice(1);d.length===1&&(d=d[0]),a=`${c} - ${n[0]} ${d}`,r(`${c} - ${n[0]}`,d)}else a=`${c} ${n}`,r(c,n);for(const d of this._pluggables){const u={message:a,timestamp:Date.now()};d.pushLogs([u])}}log(...t){this._log(W.INFO,...t)}info(...t){this._log(W.INFO,...t)}warn(...t){this._log(W.WARN,...t)}error(...t){this._log(W.ERROR,...t)}debug(...t){this._log(W.DEBUG,...t)}verbose(...t){this._log(W.VERBOSE,...t)}addPluggable(t){t&&t.getCategoryName()===ls&&(this._pluggables.push(t),t.configure(this._config))}listPluggables(){return this._pluggables}}V.LOG_LEVEL=null;V.BIND_ALL_LOG_LEVELS=!1;class K 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:c,requestId:a}=i;this.metadata={extendedRequestId:r,httpStatusCode:c,requestId:a}}this.constructor=K,Object.setPrototypeOf(this,K.prototype)}}var he;(function(e){e.NoEndpointId="NoEndpointId",e.PlatformNotSupported="PlatformNotSupported",e.Unknown="Unknown",e.NetworkError="NetworkError"})(he||(he={}));const At=(e,t=K)=>(n,o,s)=>{const{message:i,recoverySuggestion:r}=e[o];if(!n)throw new t({name:o,message:s?`${i} ${s}`:i,recoverySuggestion:r})},fe=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",Ae=new V("Hub");class fo{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){Ae.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===fe||Ae.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){Ae.error(r)}}listen(t,n,o="noname"){let s;if(typeof n!="function")throw new K({name:hs,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=>{Ae.debug(`Dispatching to ${n} with `,o);try{i.callback(t)}catch(r){Ae.error(r)}})}}const ge=new fo("__default__"),Qe=new fo("internal-hub"),fs=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new K({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},ps=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new K({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},gs=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new K({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})},Pt={convert(e,t){let n=e;return t!=null&&t.urlSafe&&(n=n.replace(/-/g,"+").replace(/_/g,"/")),gs()(n)}};var X;(function(e){e.AuthTokenConfigException="AuthTokenConfigException",e.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",e.AuthUserPoolException="AuthUserPoolException",e.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",e.OAuthNotConfigureException="OAuthNotConfigureException"})(X||(X={}));const Es={[X.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[X.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[X.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[X.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[X.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},_t=At(Es);function S(e){let t=!0;e?t=!!e.userPoolId&&!!e.userPoolClientId:t=!1,_t(t,X.AuthUserPoolException)}function po(e){var n,o,s,i,r,c,a,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)&&!!((c=(r=e==null?void 0:e.loginWith)==null?void 0:r.oauth)!=null&&c.redirectSignIn)&&!!((d=(a=e==null?void 0:e.loginWith)==null?void 0:a.oauth)!=null&&d.responseType);_t(t,X.OAuthNotConfigureException)}function je(e){const t=!!(e!=null&&e.identityPoolId);_t(t,X.InvalidIdentityPoolIdException)}function pe(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(Pt.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 go=e=>{const t=Reflect.ownKeys(e);for(const n of t){const o=e[n];(o&&typeof o=="object"||typeof o=="function")&&go(o)}return Object.freeze(e)},ms=new V("parseAWSExports"),ys={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},Is=(e={})=>{var Gt,jt,Yt,Jt,Xt,Zt;if(!Object.prototype.hasOwnProperty.call(e,"aws_project_region"))throw new K({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:c,aws_cognito_mfa_configuration:a,aws_cognito_mfa_types:d,aws_cognito_password_protection_settings:u,aws_cognito_verification_mechanisms:h,aws_cognito_signup_attributes:l,aws_cognito_social_providers:f,aws_cognito_username_attributes:g,aws_mandatory_sign_in:I,aws_mobile_analytics_app_id:y,aws_mobile_analytics_app_region:w,aws_user_files_s3_bucket:M,aws_user_files_s3_bucket_region:j,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:We,aws_user_pools_id:Q,aws_user_pools_web_client_id:Ve,geo:Vt,oauth:ht,predictions:ie,aws_cloud_logic_custom:Ht,Notifications:os,modelIntrospection:qt}=e,N={};y&&(N.Analytics={Pinpoint:{appId:y,region:w}});const{InAppMessaging:de,Push:ue}=os??{};if(de!=null&&de.AWSPinpoint||ue!=null&&ue.AWSPinpoint){if(de!=null&&de.AWSPinpoint){const{appId:R,region:le}=de.AWSPinpoint;N.Notifications={InAppMessaging:{Pinpoint:{appId:R,region:le}}}}if(ue!=null&&ue.AWSPinpoint){const{appId:R,region:le}=ue.AWSPinpoint;N.Notifications={...N.Notifications,PushNotification:{Pinpoint:{appId:R,region:le}}}}}if(Array.isArray(i)&&(N.Interactions={LexV1:Object.fromEntries(i.map(R=>[R.name,R]))}),o){const R=ys[n];R||ms.debug(`Invalid authentication type ${n}. Falling back to IAM.`),N.API={GraphQL:{endpoint:o,apiKey:t,region:s,defaultAuthMode:R??"iam"}},qt&&(N.API.GraphQL.modelIntrospection=qt)}const ss=a?{status:a&&a.toLowerCase(),totpEnabled:(d==null?void 0:d.includes("TOTP"))??!1,smsEnabled:(d==null?void 0:d.includes("SMS"))??!1}:void 0,is=u?{minLength:u.passwordPolicyMinLength,requireLowercase:((Gt=u.passwordPolicyCharacters)==null?void 0:Gt.includes("REQUIRES_LOWERCASE"))??!1,requireUppercase:((jt=u.passwordPolicyCharacters)==null?void 0:jt.includes("REQUIRES_UPPERCASE"))??!1,requireNumbers:((Yt=u.passwordPolicyCharacters)==null?void 0:Yt.includes("REQUIRES_NUMBERS"))??!1,requireSpecialCharacters:((Jt=u.passwordPolicyCharacters)==null?void 0:Jt.includes("REQUIRES_SYMBOLS"))??!1}:void 0,rs=Array.from(new Set([...h??[],...l??[]])).reduce((R,le)=>({...R,[le.toLowerCase()]:{required:!0}}),{}),$t=(g==null?void 0:g.includes("EMAIL"))??!1,zt=(g==null?void 0:g.includes("PHONE_NUMBER"))??!1;(r||Q)&&(N.Auth={Cognito:{identityPoolId:r,allowGuestAccess:I!=="enable",signUpVerificationMethod:c,userAttributes:rs,userPoolClientId:Ve,userPoolId:Q,mfa:ss,passwordFormat:is,loginWith:{username:!($t||zt),email:$t,phone:zt}}});const as=ht?Object.keys(ht).length>0:!1,cs=f?f.length>0:!1;if(N.Auth&&as&&(N.Auth.Cognito.loginWith={...N.Auth.Cognito.loginWith,oauth:{...Ss(ht),...cs&&{providers:ws(f)}}}),M&&(N.Storage={S3:{bucket:M,region:j,dangerouslyConnectToHttpEndpointForTesting:We}}),Vt){const{amazon_location_service:R}=Vt;N.Geo={LocationService:{maps:R.maps,geofenceCollections:R.geofenceCollections,searchIndices:R.search_indices,region:R.region}}}if(Ht&&(N.API={...N.API,REST:Ht.reduce((R,le)=>{const{name:ds,endpoint:us,region:Qt,service:en}=le;return{...R,[ds]:{endpoint:us,...en?{service:en}:void 0,...Qt?{region:Qt}:void 0}}},{})}),ie){const{VoiceId:R}=((Zt=(Xt=ie==null?void 0:ie.convert)==null?void 0:Xt.speechGenerator)==null?void 0:Zt.defaults)??{};N.Predictions=R?{...ie,convert:{...ie.convert,speechGenerator:{...ie.convert.speechGenerator,defaults:{voiceId:R}}}}:ie}return N},nn=e=>(e==null?void 0:e.split(","))??[],Ss=({domain:e,scope:t,redirectSignIn:n,redirectSignOut:o,responseType:s})=>({domain:e,scopes:t,redirectSignIn:nn(n),redirectSignOut:nn(o),responseType:s}),ws=e=>e.map(t=>{const n=t.toLowerCase();return n.charAt(0).toUpperCase()+n.slice(1)}),vs=Symbol("oauth-listener"),b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function Cs(e,t=0){return(b[e[t+0]]+b[e[t+1]]+b[e[t+2]]+b[e[t+3]]+"-"+b[e[t+4]]+b[e[t+5]]+"-"+b[e[t+6]]+b[e[t+7]]+"-"+b[e[t+8]]+b[e[t+9]]+"-"+b[e[t+10]]+b[e[t+11]]+b[e[t+12]]+b[e[t+13]]+b[e[t+14]]+b[e[t+15]]).toLowerCase()}let ft;const xs=new Uint8Array(16);function Ts(){if(!ft){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ft=crypto.getRandomValues.bind(crypto)}return ft(xs)}const Rs=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),on={randomUUID:Rs};function As(e,t,n){var s;if(on.randomUUID&&!t&&!e)return on.randomUUID();e=e||{};const o=e.random??((s=e.rng)==null?void 0:s.call(e))??Ts();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 Cs(o)}function Ps(e){const{version:t}=e;return t?t.startsWith("1"):!1}function _s(e){if(!e)return;const{bucket_name:t,aws_region:n,buckets:o}=e;return{S3:{bucket:t,region:n,buckets:o&&Bs(o)}}}function Ns(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:c,oauth:a,username_attributes:d,standard_required_attributes:u,groups:h,passwordless:l}=e,f={Cognito:{userPoolId:t,userPoolClientId:n,groups:h}};return o&&(f.Cognito={...f.Cognito,identityPoolId:o}),s&&(f.Cognito.passwordFormat={requireLowercase:s.require_lowercase,requireNumbers:s.require_numbers,requireUppercase:s.require_uppercase,requireSpecialCharacters:s.require_symbols,minLength:s.min_length??6}),i&&(f.Cognito.mfa={status:Ks(i),smsEnabled:r==null?void 0:r.includes("SMS"),totpEnabled:r==null?void 0:r.includes("TOTP")}),c&&(f.Cognito.allowGuestAccess=c),a&&(f.Cognito.loginWith={oauth:{domain:a.domain,redirectSignIn:a.redirect_sign_in_uri,redirectSignOut:a.redirect_sign_out_uri,responseType:a.response_type==="token"?"token":"code",scopes:a.scopes,providers:Ls(a.identity_providers)}}),d&&(f.Cognito.loginWith={...f.Cognito.loginWith,email:d.includes("email"),phone:d.includes("phone_number"),username:d.includes("username")}),u&&(f.Cognito.userAttributes=u.reduce((g,I)=>({...g,[I]:{required:!0}}),{})),l&&(f.Cognito.passwordless={emailOtpEnabled:l.email_otp_enabled,smsOtpEnabled:l.sms_otp_enabled,webAuthn:l.web_authn?{relyingPartyId:l.web_authn.relying_party_id,userVerification:l.web_authn.user_verification}:void 0,preferredChallenge:l.preferred_challenge}),f}function bs(e){if(!(e!=null&&e.amazon_pinpoint))return;const{amazon_pinpoint:t}=e;return{Pinpoint:{appId:t.app_id,region:t.aws_region}}}function Us(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 Ms(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:Eo(n),region:t,apiKey:s,modelIntrospection:i}}}function Os(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:Eo(s),region:n,apiKey:o}}}function Ds(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 Fs(e){const t={};if(e.storage&&(t.Storage=_s(e.storage)),e.auth&&(t.Auth=Ns(e.auth)),e.analytics&&(t.Analytics=bs(e.analytics)),e.geo&&(t.Geo=Us(e.geo)),e.data&&(t.API=Ms(e.data)),e.custom){const n=Os(e.custom);n&&"Events"in n&&(t.API={...t.API,...n})}return e.notifications&&(t.Notifications=Ds(e.notifications)),t}const ks={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};function Eo(e){return ks[e]}const sn={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"};function Ls(e=[]){return e.reduce((t,n)=>(sn[n]!==void 0&&t.push(sn[n]),t),[])}function Ks(e){return e==="OPTIONAL"?"optional":e==="REQUIRED"?"on":"off"}function Bs(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((c,[a,d])=>(d!==void 0&&(c[a]=d),c),{}):void 0;t[n]={bucketName:o,region:s,paths:r}}),t}const mo=e=>Object.keys(e).some(t=>t.startsWith("aws_"))?Is(e):Ps(e)?Fs(e):e;var mt=function(e,t){return mt=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])},mt(e,t)};function od(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");mt(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rn=function(){return rn=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},rn.apply(this,arguments)};function sd(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 Ws(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 c(u){try{d(o.next(u))}catch(h){r(h)}}function a(u){try{d(o.throw(u))}catch(h){r(h)}}function d(u){u.done?i(u.value):s(u.value).then(c,a)}d((o=o.apply(e,t||[])).next())})}function Vs(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=c(0),r.throw=c(1),r.return=c(2),typeof Symbol=="function"&&(r[Symbol.iterator]=function(){return this}),r;function c(d){return function(u){return a([d,u])}}function a(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 id(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 q=64,Hs=32,qs=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]),$s=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],zs=Math.pow(2,53)-1,Ye=function(){function e(){this.state=Int32Array.from($s),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>zs)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;o>0;)this.buffer[this.bufferLength++]=t[n++],o--,this.bufferLength===q&&(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%q>=q-8){for(var s=this.bufferLength;s<q;s++)n.setUint8(s,0);this.hashBuffer(),this.bufferLength=0}for(var s=this.bufferLength;s<q-8;s++)n.setUint8(s,0);n.setUint32(q-8,Math.floor(t/4294967296),!0),n.setUint32(q-4,t),this.hashBuffer(),this.finished=!0}for(var i=new Uint8Array(Hs),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],c=o[3],a=o[4],d=o[5],u=o[6],h=o[7],l=0;l<q;l++){if(l<16)this.temp[l]=(n[l*4]&255)<<24|(n[l*4+1]&255)<<16|(n[l*4+2]&255)<<8|n[l*4+3]&255;else{var f=this.temp[l-2],g=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10;f=this.temp[l-15];var I=(f>>>7|f<<25)^(f>>>18|f<<14)^f>>>3;this.temp[l]=(g+this.temp[l-7]|0)+(I+this.temp[l-16]|0)}var y=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&d^~a&u)|0)+(h+(qs[l]+this.temp[l]|0)|0)|0,w=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&i^s&r^i&r)|0;h=u,u=d,d=a,a=c+y|0,c=r,r=i,i=s,s=y+w|0}o[0]+=s,o[1]+=i,o[2]+=r,o[3]+=c,o[4]+=a,o[5]+=d,o[6]+=u,o[7]+=h},e}();const Gs=e=>new TextEncoder().encode(e);var js=typeof Buffer<"u"&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:Gs;function yo(e){return e instanceof Uint8Array?e:typeof e=="string"?js(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}function Ys(e){return typeof e=="string"?e.length===0:e.byteLength===0}var et=function(){function e(t){this.secret=t,this.hash=new Ye,this.reset()}return e.prototype.update=function(t){if(!(Ys(t)||this.error))try{this.hash.update(yo(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 Ws(this,void 0,void 0,function(){return Vs(this,function(t){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new Ye,this.secret){this.outer=new Ye;var t=Js(this.secret),n=new Uint8Array(q);n.set(t);for(var o=0;o<q;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 Js(e){var t=yo(e);if(t.byteLength>q){var n=new Ye;n.update(t),t=n.digest()}var o=new Uint8Array(q);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 P;(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"})(P||(P={}));var yt;(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"})(yt||(yt={}));var an;(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"})(an||(an={}));var cn;(function(e){e.Record="1",e.IdentifyUser="2"})(cn||(cn={}));var dn;(function(e){e.GraphQl="1",e.Get="2",e.Post="3",e.Put="4",e.Patch="5",e.Del="6",e.Head="7"})(dn||(dn={}));var _;(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"})(_||(_={}));var un;(function(e){e.Subscribe="1",e.GraphQl="2"})(un||(un={}));var ln;(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"})(ln||(ln={}));var hn;(function(e){e.SyncMessages="1",e.IdentifyUser="2",e.NotifyMessageInteraction="3"})(hn||(hn={}));var fn;(function(e){e.None="0"})(fn||(fn={}));var pn;(function(e){e.Convert="1",e.Identify="2",e.Interpret="3"})(pn||(pn={}));var gn;(function(e){e.Subscribe="1"})(gn||(gn={}));var En;(function(e){e.InitializePushNotifications="1",e.IdentifyUser="2"})(En||(En={}));var mn;(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"})(mn||(mn={}));const Xs="6.18.0",st=()=>typeof global<"u",ye=()=>typeof window<"u",Io=()=>typeof document<"u",Nt=()=>typeof process<"u",be=(e,t)=>!!Object.keys(e).find(n=>n.startsWith(t));var yn={};function Zs(){const e=o=>o.startsWith("_react")||o.startsWith("__react"),t=o=>Object.keys(o).find(e),n=()=>Array.from(document.querySelectorAll("[id]"));return Io()&&n().some(t)}function Qs(){return Nt()&&typeof yn<"u"&&!!Object.keys(yn).find(e=>e.includes("react"))}function ei(){return ye()&&be(window,"__VUE")}function ti(){return st()&&be(global,"__VUE")}var In={};function ni(){return ye()&&be(window,"__SVELTE")}function oi(){return Nt()&&typeof In<"u"&&!!Object.keys(In).find(e=>e.includes("svelte"))}function si(){return ye()&&window.next&&typeof window.next=="object"}function ii(){return st()&&(be(global,"__next")||be(global,"__NEXT"))}function ri(){return ye()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function ai(){return st()&&typeof global.__NUXT_PATHS__<"u"}var Sn={};function ci(){const e=!!(Io()&&document.querySelector("[ng-version]")),t=!!(ye()&&typeof window.ng<"u");return e||t}function di(){var e;return Nt()&&typeof Sn=="object"&&((e=Sn.npm_lifecycle_script)==null?void 0:e.startsWith("ng "))||!1}function ui(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}function li(){return st()&&typeof global.expo<"u"}function hi(){return ye()}const fi=[{platform:P.Expo,detectionMethod:li},{platform:P.ReactNative,detectionMethod:ui},{platform:P.NextJs,detectionMethod:si},{platform:P.Nuxt,detectionMethod:ri},{platform:P.Angular,detectionMethod:ci},{platform:P.React,detectionMethod:Zs},{platform:P.VueJs,detectionMethod:ei},{platform:P.Svelte,detectionMethod:ni},{platform:P.WebUnknown,detectionMethod:hi},{platform:P.NextJsSSR,detectionMethod:ii},{platform:P.NuxtSSR,detectionMethod:ai},{platform:P.ReactSSR,detectionMethod:Qs},{platform:P.VueJsSSR,detectionMethod:ti},{platform:P.AngularSSR,detectionMethod:di},{platform:P.SvelteSSR,detectionMethod:oi}];function pi(){var e;return((e=fi.find(t=>t.detectionMethod()))==null?void 0:e.platform)||P.ServerSideUnknown}let Ne;const pt=[];let It=!1;const gi=10,Ei=10,mi=1e3,So=()=>{var e;if(!Ne){if(Ne=pi(),It)for(;pt.length;)(e=pt.pop())==null||e();else pt.forEach(t=>{t()});wn(P.ServerSideUnknown,gi),wn(P.WebUnknown,Ei)}return Ne};function yi(){Ne=void 0}function wn(e,t){Ne===e&&!It&&setTimeout(()=>{yi(),It=!0,setTimeout(So,mi)},t)}const Ii={},Si=(e,t)=>{var n,o;return(o=(n=Ii[e])==null?void 0:n[t])==null?void 0:o.additionalDetails},wi="aws-amplify",vi=e=>e.replace(/\+.*/,""),Ci=({category:e,action:t}={})=>{const n=[[wi,vi(Xs)]];if(e&&n.push([e,t]),n.push(["framework",So()]),e&&t){const o=Si(e,t);o&&o.forEach(s=>{n.push(s)})}return n},it=e=>Ci(e).map(([o,s])=>o&&s?`${o}/${s}`:o).join(" "),wo=()=>typeof window<"u"&&typeof window.document<"u",vn=new V("Auth");class xi{configure(t,n){var o,s;this.authConfig=t,this.authOptions=n,t&&((o=t.Cognito)!=null&&o.userPoolEndpoint)&&vn.warn(Cn("Amazon Cognito User Pool")),t&&((s=t.Cognito)!=null&&s.identityPoolEndpoint)&&vn.warn(Cn("Amazon Cognito Identity Pool"))}async fetchAuthSession(t={}){var i,r,c,a,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((a=(c=this.authOptions)==null?void 0:c.credentialsProvider)==null?void 0:a.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 Cn=e=>`You are using a custom Amazon ${e} endpoint, ensure the endpoint is correct.`;class Ti{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new xi}configure(t,n){var s,i,r,c,a;const o=mo(t);this.resourcesConfig=o,n&&(this.libraryOptions=n),this.resourcesConfig=go(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||(a=(c=this.resourcesConfig.Notifications)==null?void 0:c.PushNotification)!=null&&a.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."),ge.dispatch("core",{event:"configure",data:this.resourcesConfig},"Configure",fe),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}[vs](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 v=new Ti,vo=(e,t)=>e.Auth.fetchAuthSession(t),Co=e=>vo(v,e);function xo(){return v.Auth.clearCredentials()}const rt=e=>{const{headers:t,statusCode:n}=e;return{...Ri(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"]}},Ri=e=>typeof(e==null?void 0:e.$metadata)=="object",Ie=async e=>{if(!e||e.statusCode<300)return;const t=await Me(e),o=(r=>{const[c]=r.toString().split(/[,:]+/);return c.includes("#")?c.split("#")[1]:c})(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:rt(e)})},Me=async e=>{if(!e.body)throw new Error("Missing response payload");const t=await e.body.json();return Object.assign(t,{$metadata:rt(e)})},U=(e,t,n,o)=>async(s,i)=>{const r={...o,...s},c=await r.endpointResolver(r,i),a=await t(i,c),d=await e(a,{...r});return n(d)},Ai=5*60*1e3;function Pi(e=Ai){return o=>{const s=2**o*100+100*Math.random();return s>e?!1:s}}const To=3,xn="amz-sdk-invocation-id",_i="amz-sdk-request",Tn=5*60*1e3,Ro=e=>{const n=Pi(Tn)(e);return n===!1?Tn:n},Ni=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],bi=e=>!!e&&Ni.includes(e),Ao=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:Di(n)||Oi(i,s)||bi(s)||Fi(i,s)}},Ui=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],Mi=["TimeoutError","RequestTimeout","RequestTimeoutException"],Oi=(e,t)=>e===429||!!t&&Ui.includes(t),Di=e=>[he.NetworkError,"ERR_NETWORK"].includes(e==null?void 0:e.name),Fi=(e,t)=>!!e&&[500,502,503,504].includes(e)||!!t&&Mi.includes(t),Po="cognito-identity",_o={service:Po,retryDecider:Ao(Ie),computeDelay:Ro,cache:"no-store"},ki=({maxAttempts:e=To,retryDecider:t,computeDelay:n,abortSignal:o})=>{if(e<1)throw new Error("maxAttempts must be greater than 0");return(s,i)=>async function(c){let a,d=i.attemptsCount??0,u;const h=()=>{if(u)return Rn(u,d),u;throw Rn(a,d),a};for(;!(o!=null&&o.aborted)&&d<e;){try{u=await s(c),a=void 0}catch(g){a=g,u=void 0}d=(i.attemptsCount??0)>d?i.attemptsCount??0:d+1,i.attemptsCount=d;const{isCredentialsExpiredError:l,retryable:f}=await t(u,a,i);if(f){if(i.isCredentialsExpired=!!l,!(o!=null&&o.aborted)&&d<e){const g=n(d);await Li(g,o)}continue}else return h()}if(o!=null&&o.aborted)throw new Error("Request aborted.");return h()}},Li=(e,t)=>{if(t!=null&&t.aborted)return Promise.resolve();let n,o;const s=new Promise(i=>{o=i,n=setTimeout(i,e)});return t==null||t.addEventListener("abort",function i(r){clearTimeout(n),t==null||t.removeEventListener("abort",i),o()}),s},Rn=(e,t)=>{Object.prototype.toString.call(e)==="[object Object]"&&(e.$metadata={...e.$metadata??{},attempts:t})},Ki=As,Bi=()=>e=>async function(n){return n.headers[xn]||(n.headers[xn]=Ki()),e(n)},Wi=({maxAttempts:e=To})=>(t,n)=>async function(s){const i=n.attemptsCount??0;return s.headers[_i]=`attempt=${i+1}; max=${e}`,t(s)},Vi=({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)}},bt=(e,t)=>(n,o)=>{const s={};let i=r=>e(r,o);for(let r=t.length-1;r>=0;r--){const c=t[r];i=c(o)(i,s)}return i(n)},gt=e=>{let t;return()=>(t||(t=e()),t)},Hi=e=>!["HEAD","GET"].includes(e.toUpperCase()),qi=async({url:e,method:t,headers:n,body:o},{abortSignal:s,cache:i,withCrossDomainCredentials:r})=>{var h;let c;try{c=await fetch(e,{method:t,headers:n,body:Hi(t)?o:void 0,signal:s,cache:i,credentials:r?"include":"same-origin"})}catch(l){throw l instanceof TypeError?new K({name:he.NetworkError,message:"A network error has occurred.",underlyingError:l}):l}const a={};(h=c.headers)==null||h.forEach((l,f)=>{a[f.toLowerCase()]=l});const d={statusCode:c.status,headers:a,body:null},u=Object.assign(c.body??{},{text:gt(()=>c.text()),blob:gt(()=>c.blob()),json:gt(()=>c.json())});return{...d,body:u}},No=bt(qi,[Vi,Bi,ki,Wi]),$i=()=>e=>async function(n){return n.headers["cache-control"]="no-store",e(n)},bo=bt(No,[$i]),Uo=e=>(t,n)=>{const o=zi(e),s=JSON.stringify(t);return Gi(n,o,s)},zi=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),Gi=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"}),An=e=>U(bo,Uo("GetCredentialsForIdentity"),ji,{..._o,...e,userAgentValue:it()}),ji=async e=>{if(e.statusCode>=300)throw await Ie(e);const t=await Me(e);return{IdentityId:t.IdentityId,Credentials:Yi(t.Credentials),$metadata:rt(e)}},Yi=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)}),Ji=e=>U(bo,Uo("GetId"),Xi,{..._o,...e,userAgentValue:it()}),Xi=async e=>{if(e.statusCode>=300)throw await Ie(e);return{IdentityId:(await Me(e)).IdentityId,$metadata:rt(e)}},Mo={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},Zi={partitions:[Mo,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]},Oo=e=>{const{partitions:t}=Zi;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 Mo.outputs.dnsSuffix},Oe=URL,Qi=({region:e})=>({url:new Oe(`https://${Po}.${e}.${Oo(e)}`)});class _e extends K{constructor(){super({name:he.PlatformNotSupported,message:"Function not supported on current platform"})}}class Do{constructor(t){this.storage=t}async setItem(t,n){if(!this.storage)throw new _e;this.storage.setItem(t,n)}async getItem(t){if(!this.storage)throw new _e;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new _e;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new _e;this.storage.clear()}}class Fo{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 ko=new V("CoreStorageUtils"),er=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{ko.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new Fo},Lo=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return ko.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new Fo}};class tr extends Do{constructor(){super(er())}}class nr extends Do{constructor(){super(Lo())}}class or{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new _e;return this._storage}setItem(t,n){this.storage.setItem(t,n)}getItem(t){return this.storage.getItem(t)}removeItem(t){this.storage.removeItem(t)}clear(){this.storage.clear()}}class sr extends or{constructor(){super(Lo())}}/*! js-cookie v3.0.8 | MIT */function He(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 ir={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 St(e,t){function n(s,i,r){if(!(typeof document>"u")){r=He({},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 c="";for(var a in r)r[a]&&(c+="; "+a,r[a]!==!0&&(c+="="+r[a].split(";")[0]));return document.cookie=s+"="+e.write(i,s)+c}}function o(s){if(!(typeof document>"u"||arguments.length&&!s)){for(var i=document.cookie?document.cookie.split("; "):[],r={},c=0;c<i.length;c++){var a=i[c].split("="),d=a.slice(1).join("=");try{var u=decodeURIComponent(a[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,"",He({},i,{expires:-1}))},withAttributes:function(s){return St(this.converter,He({},this.attributes,s))},withConverter:function(s){return St(He({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var qe=St(ir,{path:"/"});class rr{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){qe.set(t,n,this.getData())}async getItem(t){return qe.get(t)??null}async removeItem(t){qe.remove(t,this.getData())}async clear(){const t=qe.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 De=new tr;new nr;const te=new sr,ar=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 Pn({expiresAt:e,clockDrift:t,tolerance:n=5e3}){return Date.now()+t+n>e}const cr=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(a=>`${a.brand}/${a.version}`).join(";");return[t,n,s,o,t,r].filter(a=>a).join(" ")||navigator.userAgent};function dr(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}const Ue={convert(e,t={urlSafe:!1,skipPadding:!1}){const n=typeof e=="string"?e:dr(e);let o=ps()(n);return t.urlSafe&&(o=o.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(o=o.replace(/=/g,"")),o}};function ur(){return fs().getRandomValues(new Uint32Array(1))[0]}function lr(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 Ut{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(ur());return new Ut(n,t)}toString(){return lr(this)}}var E;(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"})(E||(E={}));const Ko={[E.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[E.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[E.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[E.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[E.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[E.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[E.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[E.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[E.EmptySignInPassword]:{message:"password is required to signIn"},[E.EmptySignInUsername]:{message:"username is required to signIn"},[E.EmptySignUpPassword]:{message:"password is required to signUp"},[E.EmptySignUpUsername]:{message:"username is required to signUp"},[E.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[E.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"},[E.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[E.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[E.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"},[E.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 _n;(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"})(_n||(_n={}));var Ee;(function(e){e.SignInException="SignInException",e.OAuthSignInError="OAuthSignInException"})(Ee||(Ee={}));class m extends K{constructor(t){super(t),this.constructor=m,Object.setPrototypeOf(this,m.prototype)}}function C(e,t){const{message:n,recoverySuggestion:o}=Ko[t];if(!e)throw new m({name:t,message:n,recoverySuggestion:o})}function x(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 wt(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 vt(e){return Object.entries(e).map(([t,n])=>({Name:t,Value:n}))}function hr(e){const t={};return e==null||e.forEach(n=>{n.Name&&(t[n.Name]=n.Value)}),t}var Nn;(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(Nn||(Nn={}));var bn;(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"})(bn||(bn={}));var Un;(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"})(Un||(Un={}));var Mn;(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"})(Mn||(Mn={}));var On;(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"})(On||(On={}));var Dn;(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"})(Dn||(Dn={}));var Fn;(function(e){e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.PasswordResetRequiredException="PasswordResetRequiredException",e.ResourceNotFoundException="ResourceNotFoundException",e.TooManyRequestsException="TooManyRequestsException",e.UserNotConfirmedException="UserNotConfirmedException",e.UserNotFoundException="UserNotFoundException"})(Fn||(Fn={}));var kn;(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"})(kn||(kn={}));var Ln;(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"})(Ln||(Ln={}));var Kn;(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"})(Kn||(Kn={}));var Bn;(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"})(Bn||(Bn={}));var Wn;(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"})(Wn||(Wn={}));var Vn;(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"})(Vn||(Vn={}));var Hn;(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"})(Hn||(Hn={}));var tt;(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"})(tt||(tt={}));var qn;(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"})(qn||(qn={}));var $n;(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"})($n||($n={}));var zn;(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"})(zn||(zn={}));var Ct;(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"})(Ct||(Ct={}));var Gn;(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"})(Gn||(Gn={}));var jn;(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"})(jn||(jn={}));var Yn;(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"})(Yn||(Yn={}));var Jn;(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"})(Jn||(Jn={}));var Xn;(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"})(Xn||(Xn={}));const at="UserUnAuthenticatedException",fr="UserAlreadyAuthenticatedException",pr="DeviceMetadataNotFoundException",gr="InvalidRedirectException",Er="InvalidAppSchemeException",mr="InvalidPreferredRedirectUrlException",yr=new m({name:gr,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:Er,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 Ir=new m({name:mr,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."}),Sr="InvalidOriginException",wr=new m({name:Sr,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."}),vr="OAuthSignOutException",Cr="TokenRefreshException",xr="UnexpectedSignInInterruptionException";function Fe(e){if(!e||!e.accessToken)throw new m({name:at,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function Tr(e){if(!e||!e.idToken)throw new m({name:at,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}const Rr=new m({name:Cr,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' }`}),Ar=new m({name:at,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function Bo(e){if(Nr(e))throw Rr;if(!_r(e))throw Ar}function Wo(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new m({name:pr,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 Pr={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function Vo(e){return(e==null?void 0:e.accessToken)||(e==null?void 0:e.idToken)}function _r(e){return Vo(e)&&(e==null?void 0:e.refreshToken)}function Nr(e){return Vo(e)&&!(e!=null&&e.refreshToken)}const br=async e=>{var c,a;const t=(c=e.getConfig().Auth)==null?void 0:c.Cognito;S(t);const n=await e.Auth.getTokens({forceRefresh:!1});Fe(n);const{"cognito:username":o,sub:s}=((a=n.idToken)==null?void 0:a.payload)??{},i={username:o,userId:s},r=Ur(n);return r&&(i.signInDetails=r),i};function Ur(e){return e==null?void 0:e.signInDetails}const Ho=async()=>br(v),O=(e,t)=>it({category:yt.Auth,action:e,...t}),F=e=>(t,n)=>{const o=Mr(e),s=JSON.stringify(t);return Or(n,o,s)},Mr=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}),Or=({url:e},t,n)=>({headers:t,url:e,body:n,method:"POST"});function G(e){if(!e||e.name==="Error"||e instanceof TypeError)throw new m({name:he.Unknown,message:"An unknown error has occurred.",underlyingError:e})}const B=()=>async e=>{if(e.statusCode>=300){const t=await Ie(e);throw G(t),new m({name:t.name,message:t.message,metadata:t.$metadata})}return Me(e)},Dr=()=>(e,t)=>async function(o){var s,i,r;return o.headers={...o.headers,"cache-control":"no-store",...await((r=(i=(s=v.libraryOptions)==null?void 0:s.Auth)==null?void 0:i.headers)==null?void 0:r.call(i))},e(o)},k=bt(No,[Dr]),qo="cognito-idp",L={service:qo,retryDecider:Ao(Ie),computeDelay:Ro,get userAgentValue(){return it()},cache:"no-store"},ke=e=>U(k,F("InitiateAuth"),B(),{...L,...e}),ct=e=>U(k,F("RespondToAuthChallenge"),B(),{...L,...e}),Fr=e=>U(k,F("AssociateSoftwareToken"),B(),{...L,...e}),kr=({region:e})=>({url:new Oe(`https://${qo}.${e}.${Oo(e)}`)}),T=({endpointOverride:e})=>t=>e?{url:new Oe(e)}:kr(t),Lr=e=>U(k,F("GetTokensFromRefreshToken"),B(),{...L,...e}),Kr=async({tokens:e,authConfig:t,username:n,clientMetadata:o})=>{var g;S(t==null?void 0:t.Cognito);const{userPoolId:s,userPoolClientId:i,userPoolEndpoint:r}=t.Cognito,c=x(s);Bo(e);const a=Lr({endpointResolver:T({endpointOverride:r})}),{AuthenticationResult:d}=await a({region:c},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:(g=e.deviceMetadata)==null?void 0:g.deviceKey,ClientMetadata:o}),u=pe((d==null?void 0:d.AccessToken)??""),h=d!=null&&d.IdToken?pe(d.IdToken):void 0,{iat:l}=u.payload;if(!l)throw new m({name:"iatNotFoundException",message:"iat not found in access token"});const f=l*1e3-new Date().getTime();return{accessToken:u,idToken:h,clockDrift:f,refreshToken:(d==null?void 0:d.RefreshToken)??e.refreshToken,username:n}},Br=ar(Kr),Wr={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var nt;(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(nt||(nt={}));const Vr={[nt.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},Hr=At(Vr),Zn="CognitoIdentityServiceProvider";class qr{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=pe(n),s=await this.getKeyValueStorage().getItem(t.idToken),i=s?pe(s):void 0,r=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,c=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",a=Number.parseInt(c),d=await this.getKeyValueStorage().getItem(t.signInDetails),u={accessToken:o,idToken:i,refreshToken:r,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:a,username:await this.getLastAuthUser()};return d&&(u.signInDetails=JSON.parse(d)),u}catch{return null}}async storeTokens(t){Hr(t!==void 0,nt.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 $r(Zn,`${this.authConfig.Cognito.userPoolClientId}.${n}`)}getLastAuthUserKey(){var n;S((n=this.authConfig)==null?void 0:n.Cognito);const t=this.authConfig.Cognito.userPoolClientId;return`${Zn}.${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 $r=(e,t)=>Mt(Wr)(`${e}`,t);function Mt(e){const t=Object.values({...e});return(n,o)=>t.reduce((s,i)=>({...s,[i]:`${n}.${o}.${i}`}),{})}const Qn="amplify-signin-with-hostedUI",Y="CognitoIdentityServiceProvider";class $o{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){S(this.cognitoConfig);const t=J(Y,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=J(Y,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(Qn),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){S(this.cognitoConfig);const t=J(Y,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){S(this.cognitoConfig);const n=J(Y,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthState,t)}loadPKCE(){S(this.cognitoConfig);const t=J(Y,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){S(this.cognitoConfig);const n=J(Y,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(n.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){S(this.cognitoConfig);const t=J(Y,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){S(this.cognitoConfig);const n=J(Y,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(n.inflightOAuth,`${t}`)}async loadOAuthSignIn(){var i;S(this.cognitoConfig);const t=J(Y,this.cognitoConfig.userPoolClientId),n=await this.keyValueStorage.getItem(Qn),[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=J(Y,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.oauthSignIn,`${t},${n}`)}}const J=(e,t)=>Mt(Pr)(e,t),eo=new $o(De);class zr{constructor(){this.waitForInflightOAuth=wo()?async()=>{if(await eo.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,n)=>{}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){eo.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,c,a,d,u,h;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)&&Pn({expiresAt:(((a=(c=n.idToken)==null?void 0:c.payload)==null?void 0:a.exp)??0)*1e3,clockDrift:n.clockDrift??0}),i=Pn({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((h=this.clientMetadataProvider)==null?void 0:h.call(this))}),n===null)?null:{accessToken:n==null?void 0:n.accessToken,idToken:n==null?void 0:n.idToken,signInDetails:n==null?void 0:n.signInDetails}}async refreshTokens({tokens:t,username:n,clientMetadata:o}){try{const{signInDetails:s}=t,i=await this.getTokenRefresher()({tokens:t,authConfig:this.authConfig,username:n,clientMetadata:o});return i.signInDetails=s,await this.setTokens({tokens:i}),ge.dispatch("auth",{event:"tokenRefresh"},"Auth",fe),i}catch(s){return this.handleErrors(s)}}handleErrors(t){if(G(t),this.isAuthenticationError(t)&&this.clearTokens(),ge.dispatch("auth",{event:"tokenRefresh_failure",data:{error:t}},"Auth",fe),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 Gr{constructor(){this.authTokenStore=new qr,this.authTokenStore.setKeyValueStorage(De),this.tokenOrchestrator=new zr,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(Br)}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 Je=new Gr,{tokenOrchestrator:H}=Je;async function Se(e){if(e.AccessToken){const t=pe(e.AccessToken),n=(t.payload.iat||0)*1e3,o=new Date().getTime(),s=n>0?n-o:0;let i,r,c;e.RefreshToken&&(r=e.RefreshToken),e.IdToken&&(i=pe(e.IdToken)),e!=null&&e.NewDeviceMetadata&&(c=e.NewDeviceMetadata);const a={accessToken:t,idToken:i,refreshToken:r,clockDrift:s,deviceMetadata:c,username:e.username};e!=null&&e.signInDetails&&(a.signInDetails=e.signInDetails),await H.setTokens({tokens:a})}else throw new K({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}const jr="Unable to get user session following successful sign-in.",we=async()=>{try{ge.dispatch("auth",{event:"signedIn",data:await Ho()},"Auth",fe)}catch(e){throw e.name===at?new m({name:xr,message:jr,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 zo(){return{active:!1}}const Yr=(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 zo();default:return e}},Jr=e=>{let t=e(zo(),{type:"RESET"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},re=Jr(Yr),Xr=3*60*1e3,$e="CognitoSignInState",ne={username:`${$e}.username`,challengeName:`${$e}.challengeName`,signInSession:`${$e}.signInSession`,expiry:`${$e}.expiry`},Zr=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return ze({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return ze(t.value),{...t.value};case"SET_CHALLENGE_NAME":return ze({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return ze({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return ea();case"RESET_STATE":return Go(),Ot();default:return e}},Qr=e=>{const t=Number(e),n=Date.now();return t<=n},Z=()=>{ce.dispatch({type:"RESET_STATE"})},Go=()=>{for(const e of Object.values(ne))te.removeItem(e)},Ot=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),ea=()=>{const e=te.getItem(ne.expiry);if(!e||Qr(e))return Go(),Ot();const t=te.getItem(ne.username)??void 0,n=te.getItem(ne.challengeName)??void 0,o=te.getItem(ne.signInSession)??void 0;return{username:t,challengeName:n,signInSession:o}},ta=e=>{let t=e(Ot(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:n=>{t=e(t,n)}}},ce=ta(Zr);function ve(e){ce.dispatch({type:"SET_SIGN_IN_STATE",value:e})}const ze=({challengeName:e,signInSession:t,username:n})=>{n&&te.setItem(ne.username,n),e&&te.setItem(ne.challengeName,e),t&&(te.setItem(ne.signInSession,t),te.setItem(ne.expiry,String(Date.now()+Xr)))},to="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 oe extends K{constructor(t){super(t),this.constructor=oe,Object.setPrototypeOf(this,oe.prototype)}}var A;(function(e){e.PasskeyNotSupported="PasskeyNotSupported",e.PasskeyAlreadyExists="PasskeyAlreadyExists",e.InvalidPasskeyRegistrationOptions="InvalidPasskeyRegistrationOptions",e.InvalidPasskeyAuthenticationOptions="InvalidPasskeyAuthenticationOptions",e.RelyingPartyMismatch="RelyingPartyMismatch",e.PasskeyRegistrationFailed="PasskeyRegistrationFailed",e.PasskeyRetrievalFailed="PasskeyRetrievalFailed",e.PasskeyRegistrationCanceled="PasskeyRegistrationCanceled",e.PasskeyAuthenticationCanceled="PasskeyAuthenticationCanceled",e.PasskeyOperationAborted="PasskeyOperationAborted"})(A||(A={}));const Et="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",no="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",ot={[A.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:to},[A.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:no},[A.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:no},[A.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:to},[A.PasskeyRetrievalFailed]:{message:"Device failed to retrieve passkey.",recoverySuggestion:"Passkeys may not be available on this device. Try an alternative authentication factor like PASSWORD, EMAIL_OTP, or SMS_OTP."},[A.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[A.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:Et},[A.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:Et},[A.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:Et},[A.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},Dt=At(ot,oe),na=e=>{if(e instanceof Error){if(e.name==="AbortError"){const{message:t,recoverySuggestion:n}=ot[A.PasskeyOperationAborted];return new oe({name:A.PasskeyOperationAborted,message:t,recoverySuggestion:n,underlyingError:e})}if(e.name==="SecurityError"){const{message:t,recoverySuggestion:n}=ot[A.RelyingPartyMismatch];return new oe({name:A.RelyingPartyMismatch,message:t,recoverySuggestion:n,underlyingError:e})}}return new oe({name:he.Unknown,message:"An unknown error has occurred.",underlyingError:e})},oa=e=>{if(e instanceof oe)return e;if(e instanceof Error&&e.name==="NotAllowedError"){const{message:t,recoverySuggestion:n}=ot[A.PasskeyAuthenticationCanceled];return new oe({name:A.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:n,underlyingError:e})}return na(e)},sa=()=>wo()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function",Pe=e=>Ue.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0}),oo=e=>Uint8Array.from(Pt.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer,ia=e=>{const t=oo(e.challenge),n=(e.allowCredentials||[]).map(o=>({...o,id:oo(o.id)}));return{...e,challenge:t,allowCredentials:n}},ra=e=>{const t={clientDataJSON:Pe(e.response.clientDataJSON),authenticatorData:Pe(e.response.authenticatorData),signature:Pe(e.response.signature)};e.response.userHandle&&(t.userHandle=Pe(e.response.userHandle));const n={id:e.id,rawId:Pe(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(n.authenticatorAttachment=e.authenticatorAttachment),n};function aa(e){Dt(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,A.PasskeyRetrievalFailed)}const ca=async e=>{try{const t=sa();Dt(t,A.PasskeyNotSupported);const n=ia(e),o=await navigator.credentials.get({publicKey:n});return aa(o),ra(o)}catch(t){throw oa(t)}},da=e=>U(k,F("ConfirmDevice"),B(),{...L,...e}),Xe={convert(e){return new TextEncoder().encode(e)}};function p(e,t){e!=null&&this.fromString(e,t)}function D(){return new p(null,null)}let ae;const ua=0xdeadbeefcafe,so=(ua&16777215)===15715070;function la(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 ha(e,t,n,o,s,i){const r=t&32767,c=t>>15;for(;--i>=0;){let a=this[e]&32767;const d=this[e++]>>15,u=c*a+d*r;a=r*a+((u&32767)<<15)+n[o]+(s&1073741823),s=(a>>>30)+(u>>>15)+c*d+(s>>>30),n[o++]=a&1073741823}return s}function fa(e,t,n,o,s,i){const r=t&16383,c=t>>14;for(;--i>=0;){let a=this[e]&16383;const d=this[e++]>>14,u=c*a+d*r;a=r*a+((u&16383)<<14)+n[o]+s,s=(a>>28)+(u>>14)+c*d,n[o++]=a&268435455}return s}const io=typeof navigator<"u";io&&so&&navigator.appName==="Microsoft Internet Explorer"?(p.prototype.am=ha,ae=30):io&&so&&navigator.appName!=="Netscape"?(p.prototype.am=la,ae=26):(p.prototype.am=fa,ae=28);p.prototype.DB=ae;p.prototype.DM=(1<<ae)-1;p.prototype.DV=1<<ae;const Ft=52;p.prototype.FV=Math.pow(2,Ft);p.prototype.F1=Ft-ae;p.prototype.F2=2*ae-Ft;const pa="0123456789abcdefghijklmnopqrstuvwxyz",dt=[];let Ce,$;Ce=48;for($=0;$<=9;++$)dt[Ce++]=$;Ce=97;for($=10;$<36;++$)dt[Ce++]=$;Ce=65;for($=10;$<36;++$)dt[Ce++]=$;function ro(e){return pa.charAt(e)}function ga(e,t){const n=dt[e.charCodeAt(t)];return n??-1}function Ea(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function ma(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 kt(e){const t=D();return t.fromInt(e),t}function ya(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=ga(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 Ia(){const e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function Sa(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,c=this.DB-r*this.DB%t;if(r-- >0)for(c<this.DB&&(o=this[r]>>c)>0&&(s=!0,i=ro(o));r>=0;)c<t?(o=(this[r]&(1<<c)-1)<<t-c,o|=this[--r]>>(c+=this.DB-t)):(o=this[r]>>(c-=t)&n,c<=0&&(c+=this.DB,--r)),o>0&&(s=!0),s&&(i+=ro(o));return s?i:"0"}function wa(){const e=D();return p.ZERO.subTo(this,e),e}function va(){return this.s<0?this.negate():this}function Ca(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 Lt(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 xa(){return this.t<=0?0:this.DB*(this.t-1)+Lt(this[this.t-1]^this.s&this.DM)}function Ta(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 Ra(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 Aa(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,c;for(c=this.t-1;c>=0;--c)t[c+i+1]=this[c]>>o|r,r=(this[c]&s)<<n;for(c=i-1;c>=0;--c)t[c]=0;t[i]=r,t.t=this.t+i+1,t.s=this.s,t.clamp()}function Pa(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 _a(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 Na(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 ba(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 Ua(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=D());const i=D(),r=this.s,c=e.s,a=this.DB-Lt(o[o.t-1]);a>0?(o.lShiftTo(a,i),s.lShiftTo(a,n)):(o.copyTo(i),s.copyTo(n));const d=i.t,u=i[d-1];if(u===0)return;const h=u*(1<<this.F1)+(d>1?i[d-2]>>this.F2:0),l=this.FV/h,f=(1<<this.F1)/h,g=1<<this.F2;let I=n.t,y=I-d;const w=t===null?D():t;for(i.dlShiftTo(y,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),p.ONE.dlShiftTo(d,w),w.subTo(i,i);i.t<d;)i[i.t++]=0;for(;--y>=0;){let M=n[--I]===u?this.DM:Math.floor(n[I]*l+(n[I-1]+g)*f);if((n[I]+=i.am(0,M,n,y,0,d))<M)for(i.dlShiftTo(y,w),n.subTo(w,n);n[I]<--M;)n.subTo(w,n)}t!==null&&(n.drShiftTo(d,t),r!==c&&p.ZERO.subTo(t,t)),n.t=d,n.clamp(),a>0&&n.rShiftTo(a,n),r<0&&p.ZERO.subTo(n,n)}function Ma(e){const t=D();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(p.ZERO)>0&&e.subTo(t,t),t}function Oa(){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 Da(e){return this.compareTo(e)===0}function Fa(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 ka(e){const t=D();return this.addTo(e,t),t}function La(e){const t=D();return this.subTo(e,t),t}function Ka(e){const t=D();return this.multiplyTo(e,t),t}function Ba(e){const t=D();return this.divRemTo(e,t,null),t}function xe(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 Wa(e){const t=D();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 Va(e){const t=D();return e.copyTo(t),this.reduce(t),t}function Ha(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 qa(e,t){e.squareTo(t),this.reduce(t)}function $a(e,t,n){e.multiplyTo(t,n),this.reduce(n)}xe.prototype.convert=Wa;xe.prototype.revert=Va;xe.prototype.reduce=Ha;xe.prototype.mulTo=$a;xe.prototype.sqrTo=qa;function za(e,t,n){let o=e.bitLength(),s,i=kt(1);const r=new xe(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 c=[];let a=3;const d=s-1,u=(1<<s)-1;if(c[1]=r.convert(this),s>1){const w=D();for(r.sqrTo(c[1],w);a<=u;)c[a]=D(),r.mulTo(w,c[a-2],c[a]),a+=2}let h=e.t-1,l,f=!0,g=D(),I;for(o=Lt(e[h])-1;h>=0;){for(o>=d?l=e[h]>>o-d&u:(l=(e[h]&(1<<o+1)-1)<<d-o,h>0&&(l|=e[h-1]>>this.DB+o-d)),a=s;!(l&1);)l>>=1,--a;if((o-=a)<0&&(o+=this.DB,--h),f)c[l].copyTo(i),f=!1;else{for(;a>1;)r.sqrTo(i,g),r.sqrTo(g,i),a-=2;a>0?r.sqrTo(i,g):(I=i,i=g,g=I),r.mulTo(g,c[l],i)}for(;h>=0&&!(e[h]&1<<o);)r.sqrTo(i,g),I=i,i=g,g=I,--o<0&&(o=this.DB-1,--h)}const y=r.revert(i);return n(null,y),y}p.prototype.copyTo=Ea;p.prototype.fromInt=ma;p.prototype.fromString=ya;p.prototype.clamp=Ia;p.prototype.dlShiftTo=Ta;p.prototype.drShiftTo=Ra;p.prototype.lShiftTo=Aa;p.prototype.rShiftTo=Pa;p.prototype.subTo=_a;p.prototype.multiplyTo=Na;p.prototype.squareTo=ba;p.prototype.divRemTo=Ua;p.prototype.invDigit=Oa;p.prototype.addTo=Fa;p.prototype.toString=Sa;p.prototype.negate=wa;p.prototype.abs=va;p.prototype.compareTo=Ca;p.prototype.bitLength=xa;p.prototype.mod=Ma;p.prototype.equals=Da;p.prototype.add=ka;p.prototype.subtract=La;p.prototype.multiply=Ka;p.prototype.divide=Ba;p.prototype.modPow=za;p.ZERO=kt(0);p.ONE=kt(1);const Ga=async({a:e,g:t,k:n,x:o,B:s,N:i,U:r})=>new Promise((c,a)=>{t.modPow(o,i,(d,u)=>{if(d){a(d);return}s.subtract(n.multiply(u)).modPow(e.add(r.multiply(o)),i,(h,l)=>{if(h){a(h);return}c(l.mod(i))})})}),ja="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",jo={},xt={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),jo[e]=t,xt[t]=e}const me=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 xt)t[n/2]=xt[o];else throw new Error(`Cannot decode unrecognized sequence ${o} as hexadecimal`)}return t},Kt=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=jo[e[n]];return t},Tt=e=>{const t=new et;t.update(e);const n=t.digestSync(),o=Kt(n);return new Array(64-o.length).join("0")+o},Ze=e=>Tt(me(e)),Ya=/^[89a-f]/i,ee=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=Ya.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},Ja=({A:e,B:t})=>{const n=new p(Ze(ee(e)+ee(t)),16);if(n.equals(p.ZERO))throw new Error("U cannot be zero.");return n},Xa=(e,t,n)=>{const o=new et(t);o.update(e);const s=o.digestSync(),i=new et(s);return i.update(n),i.digestSync().slice(0,16)},Bt=e=>{const t=new Ut().random(e).toString();return me(t)},Za=()=>Ue.convert(Bt(40));class Qa{constructor({userPoolName:t,a:n,g:o,A:s,N:i}){this.encoder=Xe,this.userPoolName=t,this.a=n,this.g=o,this.A=s,this.N=i,this.k=new p(Ze(`${ee(i)}${ee(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=Za();const o=`${t}${n}:${this.randomPassword}`,s=Tt(o),i=Kt(Bt(16));return this.saltToHashDevices=ee(new p(i,16)),new Promise((r,c)=>{this.g.modPow(new p(Ze(this.saltToHashDevices+s),16),this.N,(a,d)=>{if(a){c(a);return}this.verifierDevices=ee(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=Ja({A:this.A,B:o}),r=`${this.userPoolName}${t}:${n}`,c=Tt(r),a=new p(Ze(ee(s)+c),16),d=await Ga({a:this.a,g:this.g,k:this.k,x:a,B:o,N:this.N,U:i}),u=this.encoder.convert("Caldera Derived Key"),h=this.encoder.convert(""),l=new Uint8Array(u.byteLength+h.byteLength);return l.set(u,0),l.set(h,u.byteLength),Xa(me(ee(d)),me(ee(i)),l)}}const ec=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)})}),ut=async e=>{const t=new p(ja,16),n=new p("2",16),o=tc(),s=await ec({a:o,g:n,N:t});return new Qa({userPoolName:e,a:o,g:n,A:s,N:t})},tc=()=>{const e=Kt(Bt(128));return new p(e,16)};async function Te({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:n,accessToken:o}){if(!n)return;const s=e.split("_")[1]||"",i=await ut(s),r=n==null?void 0:n.DeviceKey,c=n==null?void 0:n.DeviceGroupKey;try{await i.generateHashDevice(c??"",r??"")}catch{return}const a={Salt:Ue.convert(me(i.getSaltToHashDevices())),PasswordVerifier:Ue.convert(me(i.getVerifierDevices()))},d=i.getRandomPassword();try{return await da({endpointResolver:T({endpointOverride:t})})({region:x(e)},{AccessToken:o,DeviceName:await cr(),DeviceKey:n==null?void 0:n.DeviceKey,DeviceSecretVerifierConfig:a}),{deviceKey:r,deviceGroupKey:c,randomPassword:d}}catch{return}}async function nc(e){var f;const t=(f=v.getConfig().Auth)==null?void 0:f.Cognito;S(t);const{username:n,signInSession:o,signInDetails:s,challengeName:i}=ce.getState();if(i!=="WEB_AUTHN"||!n)throw new m({name:Ee.SignInException,message:"Unable to proceed due to invalid sign in state."});const{CREDENTIAL_REQUEST_OPTIONS:r}=e;Dt(!!r,A.InvalidPasskeyAuthenticationOptions);const c=await ca(JSON.parse(r)),a=ct({endpointResolver:T({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:d,ChallengeParameters:u,AuthenticationResult:h,Session:l}=await a({region:x(t.userPoolId),userAgentValue:O(_.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:n,CREDENTIAL:JSON.stringify(c)},ClientId:t.userPoolClientId,Session:o});if(ve({signInSession:l,username:n,challengeName:d,signInDetails:s}),h)return await Se({...h,username:n,NewDeviceMetadata:await Te({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:h.NewDeviceMetadata,accessToken:h.AccessToken}),signInDetails:s}),ce.dispatch({type:"RESET_STATE"}),await we(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(d==="WEB_AUTHN")throw new m({name:Ee.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:d,challengeParameters:u}}function z({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 oc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],sc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Yo=()=>{const e=new Date,t=sc[e.getUTCDay()],n=oc[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 c=e.getUTCFullYear();return`${t} ${n} ${o} ${s}:${i}:${r} UTC ${c}`},Jo=({userPoolName:e,username:t,challengeParameters:n,dateNow:o,hkdf:s})=>{const i=Xe.convert(e),r=Xe.convert(t),c=ic(n.SECRET_BLOCK),a=Xe.convert(o),d=new Uint8Array(i.byteLength+r.byteLength+c.byteLength+a.byteLength);d.set(i,0),d.set(r,i.byteLength),d.set(c,i.byteLength+r.byteLength),d.set(a,i.byteLength+r.byteLength+c.byteLength);const u=new et(s);u.update(d);const h=u.digestSync();return Ue.convert(h)},ic=e=>{const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),o=Pt.convert(n),s=new Uint8Array(o.length);for(let i=0;i<o.length;++i)s[i]=o.charCodeAt(i);return s};async function Wt({username:e,config:t,clientMetadata:n,session:o,tokenOrchestrator:s}){const{userPoolId:i,userPoolEndpoint:r}=t,c=t.userPoolClientId,a=await(s==null?void 0:s.getDeviceMetadata(e));Wo(a);const d=await ut(a.deviceGroupKey),u={USERNAME:e,SRP_A:d.A.toString(16),DEVICE_KEY:a.deviceKey},h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:c,ChallengeResponses:u,ClientMetadata:n,Session:o},l=ct({endpointResolver:T({endpointOverride:r})}),{ChallengeParameters:f,Session:g}=await l({region:x(i)},h);return rc(e,f,n,g,d,t,s)}async function rc(e,t,n,o,s,{userPoolId:i,userPoolClientId:r,userPoolEndpoint:c},a){const d=await(a==null?void 0:a.getDeviceMetadata(e));Wo(d);const u=new p(t==null?void 0:t.SRP_B,16),h=new p(t==null?void 0:t.SALT,16),{deviceKey:l}=d,{deviceGroupKey:f}=d,g=await s.getPasswordAuthenticationKey({username:d.deviceKey,password:d.randomPassword,serverBValue:u,salt:h}),I=Yo(),y={USERNAME:(t==null?void 0:t.USERNAME)??e,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:I,PASSWORD_CLAIM_SIGNATURE:Jo({username:l,userPoolName:f,challengeParameters:t,dateNow:I,hkdf:g}),DEVICE_KEY:l},w=z({username:e,userPoolId:i,userPoolClientId:r}),M={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r,ChallengeResponses:y,Session:o,ClientMetadata:n,UserContextData:w};return ct({endpointResolver:T({endpointOverride:c})})({region:x(i)},M)}async function Xo(e,t,n,o,s,i,r){const{userPoolId:c,userPoolClientId:a,userPoolEndpoint:d}=i,u=(c==null?void 0:c.split("_")[1])||"",h=new p(t==null?void 0:t.SRP_B,16),l=new p(t==null?void 0:t.SALT,16),f=t==null?void 0:t.USER_ID_FOR_SRP;if(!f)throw new m({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});const g=await s.getPasswordAuthenticationKey({username:f,password:e,serverBValue:h,salt:l}),I=Yo(),y={USERNAME:f,PASSWORD_CLAIM_SECRET_BLOCK:t==null?void 0:t.SECRET_BLOCK,TIMESTAMP:I,PASSWORD_CLAIM_SIGNATURE:Jo({username:f,userPoolName:u,challengeParameters:t,dateNow:I,hkdf:g})},w=await r.getDeviceMetadata(f);w&&w.deviceKey&&(y.DEVICE_KEY=w.deviceKey);const M=z({username:f,userPoolId:c,userPoolClientId:a}),j={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:y,ClientMetadata:n,Session:o,ClientId:a,UserContextData:M},Q=await ct({endpointResolver:T({endpointOverride:d})})({region:x(c)},j);return Q.ChallengeName==="DEVICE_SRP_AUTH"?Wt({username:f,config:i,clientMetadata:n,session:Q.Session,tokenOrchestrator:r}):Q}async function lt(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 Le(e){const{dispatch:t}=ce;t({type:"SET_USERNAME",value:e})}async function Zo({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:i,preferredChallenge:r}){const{userPoolId:c,userPoolClientId:a,userPoolEndpoint:d}=o,u=(c==null?void 0:c.split("_")[1])||"",h=await ut(u),l={USERNAME:e,SRP_A:h.A.toString(16)};i==="USER_AUTH"&&r&&(l.PREFERRED_CHALLENGE=r);const f=z({username:e,userPoolId:c,userPoolClientId:a}),g={AuthFlow:i,AuthParameters:l,ClientMetadata:n,ClientId:a,UserContextData:f},y=await ke({endpointResolver:T({endpointOverride:d})})({region:x(c),userAgentValue:O(_.SignIn)},g),{ChallengeParameters:w,Session:M}=y,j=(w==null?void 0:w.USERNAME)??e;return Le(j),y.ChallengeName==="PASSWORD_VERIFIER"?lt(Xo,[t,w,n,M,h,o,s],j,s):y}const ao="userAttributes.";function ac(e){return"isSignedIn"in e&&"nextStep"in e}async function cc(e,t,n,o,s){var I,y;const{userPoolClientId:i,userPoolId:r,userPoolEndpoint:c}=o,a={USERNAME:e,PASSWORD:t},d=await s.getDeviceMetadata(e);d&&d.deviceKey&&(a.DEVICE_KEY=d.deviceKey);const u=z({username:e,userPoolId:r,userPoolClientId:i}),h={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:a,ClientMetadata:n,ClientId:i,UserContextData:u},f=await ke({endpointResolver:T({endpointOverride:c})})({region:x(r),userAgentValue:O(_.SignIn)},h),g=((I=f.ChallengeParameters)==null?void 0:I.USERNAME)??((y=f.ChallengeParameters)==null?void 0:y.USER_ID_FOR_SRP)??e;return Le(g),f.ChallengeName==="DEVICE_SRP_AUTH"?Wt({username:g,config:o,clientMetadata:n,session:f.Session,tokenOrchestrator:s}):f}async function dc(e,t,n,o,s){return Zo({username:e,password:t,clientMetadata:n,config:o,tokenOrchestrator:s,authFlow:"USER_SRP_AUTH"})}async function uc(e,t,n,o){var g;const{userPoolClientId:s,userPoolId:i,userPoolEndpoint:r}=n,c={USERNAME:e},a=await o.getDeviceMetadata(e);a&&a.deviceKey&&(c.DEVICE_KEY=a.deviceKey);const d=z({username:e,userPoolId:i,userPoolClientId:s}),u={AuthFlow:"CUSTOM_AUTH",AuthParameters:c,ClientMetadata:t,ClientId:s,UserContextData:d},l=await ke({endpointResolver:T({endpointOverride:r})})({region:x(i),userAgentValue:O(_.SignIn)},u),f=((g=l.ChallengeParameters)==null?void 0:g.USERNAME)??e;return Le(f),l.ChallengeName==="DEVICE_SRP_AUTH"?Wt({username:f,config:n,clientMetadata:t,session:l.Session,tokenOrchestrator:o}):l}async function lc(e,t,n,o,s){S(o);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:c}=o,a=(i==null?void 0:i.split("_")[1])||"",d=await ut(a),u={USERNAME:e,SRP_A:d.A.toString(16),CHALLENGE_NAME:"SRP_A"},h=z({username:e,userPoolId:i,userPoolClientId:r}),l={AuthFlow:"CUSTOM_AUTH",AuthParameters:u,ClientMetadata:n,ClientId:r,UserContextData:h},f=ke({endpointResolver:T({endpointOverride:c})}),{ChallengeParameters:g,Session:I}=await f({region:x(i),userAgentValue:O(_.SignIn)},l),y=(g==null?void 0:g.USERNAME)??e;return Le(y),lt(Xo,[t,g,n,I,d,o,s],y,s)}async function Re(e){var i;const{challengeName:t,challengeParameters:n,availableChallenges:o}=e,s=(i=v.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:c}=ce.getState(),a=co(uo(n.MFAS_CAN_SETUP))||[],d=gc(a),u=d.includes("TOTP"),h=d.includes("EMAIL");if(u&&h)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:d}};if(h)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(u){const l=Fr({endpointResolver:T({endpointOverride:s.userPoolEndpoint})}),{Session:f,SecretCode:g}=await l({region:x(s.userPoolId)},{Session:r});return ce.dispatch({type:"SET_SIGN_IN_SESSION",value:f}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:hc(g,c)}}}throw new m({name:Ee.SignInException,message:`Cannot initiate MFA setup from available types: ${a}`})}case"NEW_PASSWORD_REQUIRED":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED",missingAttributes:fc(n.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:co(uo(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 nc(n);return ac(r)?r:Re(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:Ee.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function hc(e,t){return{sharedSecret:e,getSetupUri:(n,o)=>{const s=`otpauth://totp/${n}:${o??t}?secret=${e}&issuer=${n}`;return new Oe(s)}}}function Ke(e){if(e===tt.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===tt.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function fc(e){return e?JSON.parse(e).map(n=>n.includes(ao)?n.replace(ao,""):n):[]}function pc(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function co(e){if(e)return e.map(pc).filter(Boolean)}function uo(e){return e?JSON.parse(e):[]}function gc(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function Ec(){let e;try{e=await Ho()}catch{}if(e&&e.userId&&e.username)throw new m({name:fr,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function Be(e){return ce.getState().username??e}async function mc(e){var c;const t=(c=v.getConfig().Auth)==null?void 0:c.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;C(!!n,E.EmptySignInUsername),C(!o,E.CustomAuthSignInPassword);try{const{ChallengeName:a,ChallengeParameters:d,AuthenticationResult:u,Session:h}=await lt(uc,[n,r,t,H],n,H),l=Be(n);return ve({signInSession:h,username:l,challengeName:a,signInDetails:i}),u?(await Se({username:l,...u,NewDeviceMetadata:await Te({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),Z(),await we(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Re({challengeName:a,challengeParameters:d})}catch(a){Z(),G(a);const d=Ke(a.name);if(d)return d;throw a}}async function yc(e){var c;const{username:t,password:n,options:o}=e,s={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=(c=v.getConfig().Auth)==null?void 0:c.Cognito;S(i);const r=o==null?void 0:o.clientMetadata;C(!!t,E.EmptySignInUsername),C(!!n,E.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:d,AuthenticationResult:u,Session:h}=await lc(t,n,r,i,H),l=Be(t);return ve({signInSession:h,username:l,challengeName:a,signInDetails:s}),u?(await Se({username:l,...u,NewDeviceMetadata:await Te({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),Z(),await we(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Re({challengeName:a,challengeParameters:d})}catch(a){Z(),G(a);const d=Ke(a.name);if(d)return d;throw a}}function se(e=!0){re.dispatch({type:"RESET"})}async function lo(e){var r,c;const{username:t,password:n}=e,o=(r=v.getConfig().Auth)==null?void 0:r.Cognito,s={loginId:t,authFlowType:"USER_SRP_AUTH"};S(o);const i=(c=e.options)==null?void 0:c.clientMetadata;C(!!t,E.EmptySignInUsername),C(!!n,E.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:d,AuthenticationResult:u,Session:h}=await dc(t,n,i,o,H),l=Be(t);return ve({signInSession:h,username:l,challengeName:a,signInDetails:s}),u?(await Se({username:l,...u,NewDeviceMetadata:await Te({userPoolId:o.userPoolId,userPoolEndpoint:o.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),Z(),await we(),se(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Re({challengeName:a,challengeParameters:d})}catch(a){Z(),se(),G(a);const d=Ke(a.name);if(d)return d;throw a}}async function Ic(e){var c;const{username:t,password:n,options:o}=e,s=(c=v.getConfig().Auth)==null?void 0:c.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};S(s);const r=o==null?void 0:o.clientMetadata;C(!!t,E.EmptySignInUsername),C(!!n,E.EmptySignInPassword);try{const{ChallengeName:a,ChallengeParameters:d,AuthenticationResult:u,Session:h}=await lt(cc,[t,n,r,s,H],t,H),l=Be(t);return ve({signInSession:h,username:l,challengeName:a,signInDetails:i}),u?(await Se({...u,username:l,NewDeviceMetadata:await Te({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:i}),Z(),await we(),se(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Re({challengeName:a,challengeParameters:d})}catch(a){Z(),se(),G(a);const d=Ke(a.name);if(d)return d;throw a}}async function Sc({username:e,clientMetadata:t,config:n,tokenOrchestrator:o,preferredChallenge:s,password:i,session:r}){const{userPoolId:c,userPoolClientId:a,userPoolEndpoint:d}=n,u=z({username:e,userPoolId:c,userPoolClientId:a}),h={USERNAME:e};if(s){if(n.passwordless&&(s==="EMAIL_OTP"&&!n.passwordless.emailOtpEnabled||s==="SMS_OTP"&&!n.passwordless.smsOtpEnabled||s==="WEB_AUTHN"&&!n.passwordless.webAuthn)&&C(!1,E.InvalidPreferredChallenge),s==="PASSWORD_SRP")return C(!!i,E.EmptySignInPassword),Zo({username:e,password:i,clientMetadata:t,config:n,tokenOrchestrator:o,authFlow:"USER_AUTH",preferredChallenge:s});s==="PASSWORD"&&(C(!!i,E.EmptySignInPassword),h.PASSWORD=i),h.PREFERRED_CHALLENGE=s}const l={AuthFlow:"USER_AUTH",AuthParameters:h,ClientMetadata:t,ClientId:a,UserContextData:u};r&&(l.Session=r);const g=await ke({endpointResolver:T({endpointOverride:d})})({region:x(c),userAgentValue:O(_.SignIn)},l);return Le(e),g}async function wc(e){var a,d;const{username:t,password:n,options:o}=e,s=(a=v.getConfig().Auth)==null?void 0:a.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};S(s);const r=o==null?void 0:o.clientMetadata,c=(o==null?void 0:o.preferredChallenge)??((d=s==null?void 0:s.passwordless)==null?void 0:d.preferredChallenge);C(!!t,E.EmptySignInUsername);try{const u={username:t,config:s,tokenOrchestrator:H,clientMetadata:r,preferredChallenge:c,password:n},h=re.getState();h.active&&h.username===t&&(u.session=h.session);const l=await Sc(u),f=Be(t);return ve({signInSession:l.Session,username:f,challengeName:l.ChallengeName,signInDetails:i}),l.AuthenticationResult?(await Se({username:f,...l.AuthenticationResult,NewDeviceMetadata:await Te({userPoolId:s.userPoolId,userPoolEndpoint:s.userPoolEndpoint,newDeviceMetadata:l.AuthenticationResult.NewDeviceMetadata,accessToken:l.AuthenticationResult.AccessToken}),signInDetails:i}),Z(),await we(),se(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Re({challengeName:l.ChallengeName,challengeParameters:l.ChallengeParameters,availableChallenges:"AvailableChallenges"in l?l.AvailableChallenges:void 0})}catch(u){Z(),se(),G(u);const h=Ke(u.name);if(h)return h;throw u}}async function rd(e){var n;se(!1);const t=(n=e.options)==null?void 0:n.authFlowType;switch(await Ec(),t){case"USER_SRP_AUTH":return lo(e);case"USER_PASSWORD_AUTH":return Ic(e);case"CUSTOM_WITHOUT_SRP":return mc(e);case"CUSTOM_WITH_SRP":return yc(e);case"USER_AUTH":return wc(e);default:return lo(e)}}const vc=3*60*1e3;function Cc(e){const t=Qe.listen("auth-internal",async({payload:o})=>{switch(o.event){case"confirmSignUp":{const s=o.data;s!=null&&s.isSignUpComplete&&(Qe.dispatch("auth-internal",{event:"autoSignIn"}),t())}}}),n=setTimeout(()=>{t(),clearTimeout(n),se()},vc)}const xc=()=>async e=>{if(e.statusCode>=300){const t=await Ie(e);if(G(t),t.name===Ct.InvalidParameterException&&/'password'/.test(t.message)&&/Member must not be null/.test(t.message)){const n=E.EmptySignUpPassword,{message:o,recoverySuggestion:s}=Ko[n];throw new m({name:n,message:o,recoverySuggestion:s})}throw new m({name:t.name,message:t.message})}return Me(e)},Tc=e=>U(k,F("SignUp"),xc(),{...L,...e});async function ad(e){var Ve;const{username:t,password:n,options:o}=e,s=(Ve=v.getConfig().Auth)==null?void 0:Ve.Cognito,i=(s==null?void 0:s.signUpVerificationMethod)??"code",{clientMetadata:r,validationData:c,autoSignIn:a}=e.options??{};S(s),C(!!t,E.EmptySignUpUsername);const d=typeof a!="boolean"?a:void 0;d==null||d.authFlowType;const{userPoolId:u,userPoolClientId:h,userPoolEndpoint:l}=s,f=Tc({endpointResolver:T({endpointOverride:l})}),g={Username:t,Password:void 0,UserAttributes:(o==null?void 0:o.userAttributes)&&vt(o==null?void 0:o.userAttributes),ClientMetadata:r,ValidationData:c&&vt(c),ClientId:h,UserContextData:z({username:t,userPoolId:u,userPoolClientId:h})};n&&(g.Password=n);const{UserSub:I,CodeDeliveryDetails:y,UserConfirmed:w,Session:M}=await f({region:x(u),userAgentValue:O(_.SignUp)},g);(d||a===!0)&&(re.dispatch({type:"START"}),re.dispatch({type:"SET_USERNAME",value:t}),re.dispatch({type:"SET_SESSION",value:M}));const j={destination:y==null?void 0:y.Destination,deliveryMedium:y==null?void 0:y.DeliveryMedium,attributeName:y==null?void 0:y.AttributeName},We=!!w,Q=re.getState().active;if(We)return Q?{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:I}:{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:I};if(Q){if(i==="link")return{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:j},userId:I};Cc()}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:j},userId:I}}const Rc=e=>U(k,F("ForgotPassword"),B(),{...L,...e});async function cd(e){var h,l;const{username:t}=e;C(!!t,E.EmptyResetPasswordUsername);const n=(h=v.getConfig().Auth)==null?void 0:h.Cognito;S(n);const{userPoolClientId:o,userPoolId:s,userPoolEndpoint:i}=n,r=(l=e.options)==null?void 0:l.clientMetadata,c=z({username:t,userPoolId:s,userPoolClientId:o}),u=(await Rc({endpointResolver:T({endpointOverride:i})})({region:x(s),userAgentValue:O(_.ResetPassword)},{Username:t,ClientMetadata:r,ClientId:o,UserContextData:c})).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 Ac=e=>U(k,F("ConfirmForgotPassword"),B(),{...L,...e});async function dd(e){var h,l;const t=(h=v.getConfig().Auth)==null?void 0:h.Cognito;S(t);const{userPoolClientId:n,userPoolId:o,userPoolEndpoint:s}=t,{username:i,newPassword:r}=e;C(!!i,E.EmptyConfirmResetPasswordUsername),C(!!r,E.EmptyConfirmResetPasswordNewPassword);const c=e.confirmationCode;C(!!c,E.EmptyConfirmResetPasswordConfirmationCode);const a=(l=e.options)==null?void 0:l.clientMetadata,d=z({username:i,userPoolId:o,userPoolClientId:n});await Ac({endpointResolver:T({endpointOverride:s})})({region:x(t.userPoolId),userAgentValue:O(_.ConfirmResetPassword)},{Username:i,ConfirmationCode:c,Password:r,ClientMetadata:a,ClientId:t.userPoolClientId,UserContextData:d})}const Pc=e=>U(k,F("ResendConfirmationCode"),B(),{...L,...e});async function ud(e){var f,g;const{username:t}=e;C(!!t,E.EmptySignUpUsername);const n=(f=v.getConfig().Auth)==null?void 0:f.Cognito;S(n);const{userPoolClientId:o,userPoolId:s,userPoolEndpoint:i}=n,r=(g=e.options)==null?void 0:g.clientMetadata,c=z({username:t,userPoolId:s,userPoolClientId:o}),a=Pc({endpointResolver:T({endpointOverride:i})}),{CodeDeliveryDetails:d}=await a({region:x(n.userPoolId),userAgentValue:O(_.ResendSignUpCode)},{Username:t,ClientMetadata:r,ClientId:n.userPoolClientId,UserContextData:c}),{DeliveryMedium:u,AttributeName:h,Destination:l}={...d};return{destination:l,deliveryMedium:u,attributeName:h||void 0}}const _c=e=>U(k,F("ConfirmSignUp"),B(),{...L,...e});async function ld(e){var l;const{username:t,confirmationCode:n,options:o}=e,s=(l=v.getConfig().Auth)==null?void 0:l.Cognito;S(s);const{userPoolId:i,userPoolClientId:r,userPoolEndpoint:c}=s,a=o==null?void 0:o.clientMetadata;C(!!t,E.EmptyConfirmSignUpUsername),C(!!n,E.EmptyConfirmSignUpCode);const d=z({username:t,userPoolId:i,userPoolClientId:r}),u=_c({endpointResolver:T({endpointOverride:c})}),{Session:h}=await u({region:x(s.userPoolId),userAgentValue:O(_.ConfirmSignUp)},{Username:t,ConfirmationCode:n,ClientMetadata:a,ForceAliasCreation:o==null?void 0:o.forceAliasCreation,ClientId:s.userPoolClientId,UserContextData:d});return new Promise((f,g)=>{try{const I={isSignUpComplete:!0,nextStep:{signUpStep:"DONE"}},y=re.getState();if(!y.active||y.username!==t){f(I),se();return}re.dispatch({type:"SET_SESSION",value:h});const w=Qe.listen("auth-internal",({payload:M})=>{switch(M.event){case"autoSignIn":f({isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"}}),w()}});Qe.dispatch("auth-internal",{event:"confirmSignUp",data:I})}catch(I){g(I)}})}const Nc=e=>U(k,F("GetUser"),B(),{...L,...e}),bc=e=>U(k,F("ChangePassword"),B(),{...L,...e});async function hd(e){var a;const t=(a=v.getConfig().Auth)==null?void 0:a.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{oldPassword:s,newPassword:i}=e;C(!!s,E.EmptyUpdatePassword),C(!!i,E.EmptyUpdatePassword);const{tokens:r}=await Co({forceRefresh:!1});Fe(r),await bc({endpointResolver:T({endpointOverride:n})})({region:x(o),userAgentValue:O(_.UpdatePassword)},{AccessToken:r.accessToken.toString(),PreviousPassword:s,ProposedPassword:i})}const Uc=e=>U(k,F("UpdateUserAttributes"),B(),{...L,...e}),fd=async e=>{var u;const{userAttributes:t,options:n}=e,o=(u=v.getConfig().Auth)==null?void 0:u.Cognito,s=n==null?void 0:n.clientMetadata;S(o);const{userPoolEndpoint:i,userPoolId:r}=o,{tokens:c}=await Co({forceRefresh:!1});Fe(c);const a=Uc({endpointResolver:T({endpointOverride:i})}),{CodeDeliveryDetailsList:d}=await a({region:x(r),userAgentValue:O(_.UpdateUserAttributes)},{AccessToken:c.accessToken.toString(),ClientMetadata:s,UserAttributes:vt(t)});return{...Mc(t),...Oc(d)}};function Mc(e){var n;const t={};return(n=Object.keys(e))==null||n.forEach(o=>{t[o]={isUpdated:!0,nextStep:{updateAttributeStep:"DONE"}}}),t}function Oc(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}function Dc(e,t){if(t){const n=e==null?void 0:e.find(o=>o===t);if(!n)throw Ir;return n}else{const n=(e==null?void 0:e.find(Fc))??(e==null?void 0:e.find(kc)),o=(e==null?void 0:e.find(Kc))??(e==null?void 0:e.find(Lc));if(n)return n;throw o?wr:yr}}const Fc=e=>e.startsWith(String(window.location.origin+(window.location.pathname||"/"))),kc=e=>e.includes(String(window.location.hostname)),Lc=e=>e.startsWith("http://"),Kc=e=>e.startsWith("https://"),Bc=async e=>{window!=null&&window.location&&(window.location.href=e.replace("http://","https://"))},Wc=async e=>{var c;const t=(c=e.getConfig().Auth)==null?void 0:c.Cognito;S(t);const{userPoolEndpoint:n,userPoolId:o}=t,{tokens:s}=await vo(e,{forceRefresh:!1});Fe(s);const i=Nc({endpointResolver:T({endpointOverride:n})}),{UserAttributes:r}=await i({region:x(o),userAgentValue:O(_.FetchUserAttributes)},{AccessToken:s.accessToken.toString()});return hr(r)},pd=()=>Wc(v),Vc=async e=>{await e.clearOAuthData(),H.clearTokens(),await xo(),ge.dispatch("auth",{event:"signedOut"},"Auth",fe)},Hc=async(e,t=!1,n)=>{po(e);const{loginWith:o,userPoolClientId:s}=e,{domain:i,redirectSignOut:r}=o.oauth,c=Dc(r,n),a=`https://${i}/logout?${Object.entries({client_id:s,logout_uri:encodeURIComponent(c)}).map(([d,u])=>`${d}=${u}`).join("&")}`;return Bc(a)},qc=async(e,t,n,o)=>{const{isOAuthSignIn:s}=await t.loadOAuthSignIn(),i=await n.getOAuthMetadata();if(await Vc(t),s||i!=null&&i.oauthSignIn)return Hc(e,!1,o)},$c=e=>U(k,F("RevokeToken"),B(),{...L,...e}),zc=e=>U(k,F("GlobalSignOut"),B(),{...L,...e}),Qo=new V("Auth");async function gd(e){var o,s;const t=(o=v.getConfig().Auth)==null?void 0:o.Cognito;S(t),e!=null&&e.global?await jc(t):await Gc(t);let n;try{po(t),n=!0}catch{n=!1}if(n){const i=new $o(De);i.setAuthConfig(t);const{type:r}=await qc(t,i,H,(s=e==null?void 0:e.oauth)==null?void 0:s.redirectUrl)??{};if(r==="error")throw new m({name:vr,message:"An error occurred when attempting to log out from OAuth provider."})}else H.clearTokens(),await xo(),ge.dispatch("auth",{event:"signedOut"},"Auth",fe)}async function Gc(e){try{const{userPoolEndpoint:t,userPoolId:n,userPoolClientId:o}=e,s=await H.getTokenStore().loadTokens();Bo(s),Yc(s.accessToken)&&await $c({endpointResolver:T({endpointOverride:t})})({region:x(n),userAgentValue:O(_.SignOut)},{ClientId:o,Token:s.refreshToken})}catch{Qo.debug("Client signOut error caught but will proceed with token removal")}}async function jc(e){try{const{userPoolEndpoint:t,userPoolId:n}=e,o=await H.getTokenStore().loadTokens();Fe(o),await zc({endpointResolver:T({endpointOverride:t})})({region:x(n),userAgentValue:O(_.SignOut)},{AccessToken:o.accessToken.toString()})}catch{Qo.debug("Global signOut error caught but will proceed with token removal")}}const Yc=e=>{var t;return!!((t=e==null?void 0:e.payload)!=null&&t.origin_jti)},Jc={identityId:"identityId"},Xc=new V("DefaultIdentityIdStore");class es{setAuthConfig(t){je(t.Cognito),this.authConfig=t,this._authKeys=Zc("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){var t;je((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 Xc.log("Error getting stored IdentityId.",n),null}}async storeIdentityId(t){var n;je((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 Zc=(e,t)=>Mt(Jc)(`com.amplify.${e}`,t),Rt=({endpointOverride:e})=>t=>e?{url:new Oe(e)}:Qi(t);function ts(e){const t=pe(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 Qc({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?ts(e.idToken.toString()):{},i=await ed(s,t);return n.storeIdentityId({id:i,type:e?"primary":"guest"}),i}async function ed(e,t){const n=t==null?void 0:t.identityPoolId,o=wt(n),s=Ji({endpointResolver:Rt({endpointOverride:t.identityPoolEndpoint})});let i;try{i=(await s({region:o},{IdentityPoolId:n,Logins:e})).IdentityId}catch(r){throw G(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 Ge=new V("CognitoCredentialsProvider"),ho=50*60*1e3;class ns{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){Ge.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){Ge.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){const n=t.authenticated,{tokens:o}=t,{authConfig:s}=t;try{je(s==null?void 0:s.Cognito)}catch{return}if(!n&&!s.Cognito.allowGuestAccess)return;const{forceRefresh:i}=t,r=this.hasTokenChanged(o),c=await Qc({tokens:o,authConfig:s.Cognito,identityIdStore:this._identityIdStore});return(i||r)&&this.clearCredentials(),n?(Tr(o),this.credsForOIDCTokens(s.Cognito,o,c)):this.getGuestCredentials(c,s.Cognito)}async getGuestCredentials(t,n){var r,c;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return Ge.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const o=wt(n.identityPoolId),s=An({endpointResolver:Rt({endpointOverride:n.identityPoolEndpoint})});let i;try{i=await s({region:o},{IdentityId:t})}catch(a){throw G(a),new m(a)}if((r=i==null?void 0:i.Credentials)!=null&&r.AccessKeyId&&((c=i==null?void 0:i.Credentials)!=null&&c.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+ho;const a={credentials:{accessKeyId:i.Credentials.AccessKeyId,secretAccessKey:i.Credentials.SecretKey,sessionToken:i.Credentials.SessionToken,expiration:i.Credentials.Expiration},identityId:t};return i.IdentityId&&(a.identityId=i.IdentityId,this._identityIdStore.storeIdentityId({id:i.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...a,isAuthenticatedCreds:!1},a}else throw new m({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,n,o){var a,d,u;if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return Ge.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();const s=n.idToken?ts(n.idToken.toString()):{},i=wt(t.identityPoolId),r=An({endpointResolver:Rt({endpointOverride:t.identityPoolEndpoint})});let c;try{c=await r({region:i},{IdentityId:o,Logins:s})}catch(h){throw G(h),new m(h)}if((a=c==null?void 0:c.Credentials)!=null&&a.AccessKeyId&&((d=c==null?void 0:c.Credentials)!=null&&d.SecretKey)){this._nextCredentialsRefresh=new Date().getTime()+ho;const h={credentials:{accessKeyId:c.Credentials.AccessKeyId,secretAccessKey:c.Credentials.SecretKey,sessionToken:c.Credentials.SessionToken,expiration:c.Credentials.Expiration},identityId:o};return c.IdentityId&&(h.identityId=c.IdentityId,this._identityIdStore.storeIdentityId({id:c.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...h,isAuthenticatedCreds:!0,associatedIdToken:(u=n.idToken)==null?void 0:u.toString()},h}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 td=new ns(new es(De)),Ed={configure(e,t){const n=mo(e),o=new rr({sameSite:"lax"}),s=t!=null&&t.ssr?o:De,i=t!=null&&t.ssr?new ns(new es(o)):td;if(!n.Auth||t!=null&&t.Auth){v.configure(n,t);return}Je.setAuthConfig(n.Auth),Je.setKeyValueStorage(s),v.configure(n,{...t,Auth:{tokenProvider:Je,credentialsProvider:i}})},getConfig(){return v.getConfig()}};export{Ed as D,ge as H,rn as _,sd as a,id as b,qe as c,pd as d,rd as e,Co as f,Ho as g,dd as h,cd as i,ld as j,ad as k,od as l,hd as m,ud as r,gd as s,fd as u};