foundation-sdk 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-auth0.cjs +2 -0
- package/dist/auth-auth0.cjs.map +1 -0
- package/dist/auth-auth0.d.cts +2 -0
- package/dist/auth-auth0.d.ts +2 -0
- package/dist/auth-auth0.js +2 -0
- package/dist/auth-auth0.js.map +1 -0
- package/dist/auth-cognito.cjs +2 -0
- package/dist/auth-cognito.cjs.map +1 -0
- package/dist/auth-cognito.d.cts +2 -0
- package/dist/auth-cognito.d.ts +2 -0
- package/dist/auth-cognito.js +2 -0
- package/dist/auth-cognito.js.map +1 -0
- package/dist/foundation-sdk.browser.auth0.global.js +3 -3
- package/dist/foundation-sdk.browser.auth0.global.js.map +1 -1
- package/dist/foundation-sdk.browser.global.js +4 -12
- package/dist/foundation-sdk.browser.global.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +11 -1
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
"use strict";var FoundationSDK=(()=>{var Vn=Object.defineProperty;var df=Object.getOwnPropertyDescriptor;var uf=Object.getOwnPropertyNames;var lf=Object.prototype.hasOwnProperty;var Bn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var c=(e,t)=>()=>(e&&(t=e(e=0)),t);var Hn=(e,t)=>{for(var o in t)Vn(e,o,{get:t[o],enumerable:!0})},ff=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of uf(t))!lf.call(e,n)&&n!==o&&Vn(e,n,{get:()=>t[n],enumerable:!(r=df(t,n))||r.enumerable});return e};var gf=e=>ff(Vn({},"__esModule",{value:!0}),e);var Vs,Wn,Bs,cr=c(()=>{"use strict";Vs="Logging",Wn="x-amz-user-agent",Bs="NoHubcallbackProvidedException"});var Re,Hs=c(()=>{"use strict";(function(e){e.DEBUG="DEBUG",e.ERROR="ERROR",e.INFO="INFO",e.WARN="WARN",e.VERBOSE="VERBOSE",e.NONE="NONE"})(Re||(Re={}))});var Ws,q,it=c(()=>{"use strict";cr();Hs();Ws={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6},q=class e{constructor(t,o=Re.WARN){this.name=t,this.level=o,this._pluggables=[]}_padding(t){return t<10?"0"+t:""+t}_ts(){let 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,...o){let r=this.level;e.LOG_LEVEL&&(r=e.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(r=window.LOG_LEVEL);let n=Ws[r];if(!(Ws[t]>=n))return;let s=console.log.bind(console);t===Re.ERROR&&console.error&&(s=console.error.bind(console)),t===Re.WARN&&console.warn&&(s=console.warn.bind(console)),e.BIND_ALL_LOG_LEVELS&&(t===Re.INFO&&console.info&&(s=console.info.bind(console)),t===Re.DEBUG&&console.debug&&(s=console.debug.bind(console)));let a=`[${t}] ${this._ts()} ${this.name}`,p="";if(o.length===1&&typeof o[0]=="string")p=`${a} - ${o[0]}`,s(p);else if(o.length===1)p=`${a} ${o[0]}`,s(a,o[0]);else if(typeof o[0]=="string"){let m=o.slice(1);m.length===1&&(m=m[0]),p=`${a} - ${o[0]} ${m}`,s(`${a} - ${o[0]}`,m)}else p=`${a} ${o}`,s(a,o);for(let m of this._pluggables){let d={message:p,timestamp:Date.now()};m.pushLogs([d])}}log(...t){this._log(Re.INFO,...t)}info(...t){this._log(Re.INFO,...t)}warn(...t){this._log(Re.WARN,...t)}error(...t){this._log(Re.ERROR,...t)}debug(...t){this._log(Re.DEBUG,...t)}verbose(...t){this._log(Re.VERBOSE,...t)}addPluggable(t){t&&t.getCategoryName()===Vs&&(this._pluggables.push(t),t.configure(this._config))}listPluggables(){return this._pluggables}};q.LOG_LEVEL=null;q.BIND_ALL_LOG_LEVELS=!1});var te,Rt=c(()=>{"use strict";te=class e extends Error{constructor({message:t,name:o,recoverySuggestion:r,underlyingError:n,metadata:i}){if(super(t),this.name=o,this.underlyingError=n,this.recoverySuggestion=r,i){let{extendedRequestId:s,httpStatusCode:a,requestId:p}=i;this.metadata={extendedRequestId:s,httpStatusCode:a,requestId:p}}this.constructor=e,Object.setPrototypeOf(this,e.prototype)}}});var Me,To=c(()=>{"use strict";(function(e){e.NoEndpointId="NoEndpointId",e.PlatformNotSupported="PlatformNotSupported",e.Unknown="Unknown",e.NetworkError="NetworkError"})(Me||(Me={}))});var je,Ro=c(()=>{"use strict";Rt();je=(e,t=te)=>(o,r,n)=>{let{message:i,recoverySuggestion:s}=e[r];if(!o)throw new t({name:r,message:n?`${i} ${n}`:i,recoverySuggestion:s})}});var fe,_o,pr,Ee,Gt,mr=c(()=>{"use strict";it();cr();Rt();fe=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",_o=new q("Hub"),pr=class{constructor(t){this.listeners=new Map,this.protectedChannels=["core","auth","api","analytics","interactions","pubsub","storage","ui","xr"],this.name=t}_remove(t,o){let r=this.listeners.get(t);if(!r){_o.warn(`No listeners for ${t}`);return}this.listeners.set(t,[...r.filter(({callback:n})=>n!==o)])}dispatch(t,o,r,n){typeof t=="string"&&this.protectedChannels.indexOf(t)>-1&&(n===fe||_o.warn(`WARNING: ${t} is protected and dispatching on it can have unintended consequences`));let i={channel:t,payload:{...o},source:r,patternInfo:[]};try{this._toListeners(i)}catch(s){_o.error(s)}}listen(t,o,r="noname"){let n;if(typeof o!="function")throw new te({name:Bs,message:"No callback supplied to Hub"});n=o;let i=this.listeners.get(t);return i||(i=[],this.listeners.set(t,i)),i.push({name:r,callback:n}),()=>{this._remove(t,n)}}_toListeners(t){let{channel:o,payload:r}=t,n=this.listeners.get(o);n&&n.forEach(i=>{_o.debug(`Dispatching to ${o} with `,r);try{i.callback(t)}catch(s){_o.error(s)}})}},Ee=new pr("__default__"),Gt=new pr("internal-hub")});var qt,Ks,zs,co=c(()=>{"use strict";Rt();qt=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new te({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},Ks=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new te({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},zs=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new te({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})}});var $t,Kn=c(()=>{"use strict";co();$t={convert(e,t){let o=e;return t?.urlSafe&&(o=o.replace(/-/g,"+").replace(/_/g,"/")),zs()(o)}}});var Je,yf,dr,Gs=c(()=>{"use strict";Ro();(function(e){e.AuthTokenConfigException="AuthTokenConfigException",e.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",e.AuthUserPoolException="AuthUserPoolException",e.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",e.OAuthNotConfigureException="OAuthNotConfigureException"})(Je||(Je={}));yf={[Je.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[Je.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[Je.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[Je.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[Je.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},dr=je(yf)});function f(e){let t=!0;e?t=!!e.userPoolId&&!!e.userPoolClientId:t=!1,dr(t,Je.AuthUserPoolException)}function gt(e){let t=!!e?.loginWith?.oauth?.domain&&!!e?.loginWith?.oauth?.redirectSignOut&&!!e?.loginWith?.oauth?.redirectSignIn&&!!e?.loginWith?.oauth?.responseType;dr(t,Je.OAuthNotConfigureException)}function jt(e){let t=!!e?.identityPoolId;dr(t,Je.InvalidIdentityPoolIdException)}function ge(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid token");try{let r=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent($t.convert(r).split("").map(s=>`%${`00${s.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")),i=JSON.parse(n);return{toString:()=>e,payload:i}}catch{throw new Error("Invalid token payload")}}var zn=c(()=>{"use strict";Kn();Gs()});var Gn,qs=c(()=>{"use strict";Gn=e=>{let t=Reflect.ownKeys(e);for(let o of t){let r=e[o];(r&&typeof r=="object"||typeof r=="function")&&Gn(r)}return Object.freeze(e)}});var Sf,If,js,$s,Af,Cf,Js=c(()=>{"use strict";it();Rt();Sf=new q("parseAWSExports"),If={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},js=(e={})=>{if(!Object.prototype.hasOwnProperty.call(e,"aws_project_region"))throw new te({name:"InvalidParameterException",message:"Invalid config parameter.",recoverySuggestion:"Ensure passing the config object imported from `amplifyconfiguration.json`."});let{aws_appsync_apiKey:t,aws_appsync_authenticationType:o,aws_appsync_graphqlEndpoint:r,aws_appsync_region:n,aws_bots_config:i,aws_cognito_identity_pool_id:s,aws_cognito_sign_up_verification_method:a,aws_cognito_mfa_configuration:p,aws_cognito_mfa_types:m,aws_cognito_password_protection_settings:d,aws_cognito_verification_mechanisms:u,aws_cognito_signup_attributes:l,aws_cognito_social_providers:g,aws_cognito_username_attributes:A,aws_mandatory_sign_in:N,aws_mobile_analytics_app_id:D,aws_mobile_analytics_app_region:O,aws_user_files_s3_bucket:oe,aws_user_files_s3_bucket_region:ie,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:Be,aws_user_pools_id:Te,aws_user_pools_web_client_id:$e,geo:ue,oauth:Kt,predictions:ke,aws_cloud_logic_custom:so,Notifications:ao,modelIntrospection:ft}=e,le={};D&&(le.Analytics={Pinpoint:{appId:D,region:O}});let{InAppMessaging:G,Push:he}=ao??{};if(G?.AWSPinpoint||he?.AWSPinpoint){if(G?.AWSPinpoint){let{appId:ne,region:zt}=G.AWSPinpoint;le.Notifications={InAppMessaging:{Pinpoint:{appId:ne,region:zt}}}}if(he?.AWSPinpoint){let{appId:ne,region:zt}=he.AWSPinpoint;le.Notifications={...le.Notifications,PushNotification:{Pinpoint:{appId:ne,region:zt}}}}}if(Array.isArray(i)&&(le.Interactions={LexV1:Object.fromEntries(i.map(ne=>[ne.name,ne]))}),r){let ne=If[o];ne||Sf.debug(`Invalid authentication type ${o}. Falling back to IAM.`),le.API={GraphQL:{endpoint:r,apiKey:t,region:n,defaultAuthMode:ne??"iam"}},ft&&(le.API.GraphQL.modelIntrospection=ft)}let ar=p?{status:p&&p.toLowerCase(),totpEnabled:m?.includes("TOTP")??!1,smsEnabled:m?.includes("SMS")??!1}:void 0,nf=d?{minLength:d.passwordPolicyMinLength,requireLowercase:d.passwordPolicyCharacters?.includes("REQUIRES_LOWERCASE")??!1,requireUppercase:d.passwordPolicyCharacters?.includes("REQUIRES_UPPERCASE")??!1,requireNumbers:d.passwordPolicyCharacters?.includes("REQUIRES_NUMBERS")??!1,requireSpecialCharacters:d.passwordPolicyCharacters?.includes("REQUIRES_SYMBOLS")??!1}:void 0,sf=Array.from(new Set([...u??[],...l??[]])).reduce((ne,zt)=>({...ne,[zt.toLowerCase()]:{required:!0}}),{}),Ds=A?.includes("EMAIL")??!1,ks=A?.includes("PHONE_NUMBER")??!1;(s||Te)&&(le.Auth={Cognito:{identityPoolId:s,allowGuestAccess:N!=="enable",signUpVerificationMethod:a,userAttributes:sf,userPoolClientId:$e,userPoolId:Te,mfa:ar,passwordFormat:nf,loginWith:{username:!(Ds||ks),email:Ds,phone:ks}}});let af=Kt?Object.keys(Kt).length>0:!1,cf=g?g.length>0:!1;if(le.Auth&&af&&(le.Auth.Cognito.loginWith={...le.Auth.Cognito.loginWith,oauth:{...Af(Kt),...cf&&{providers:Cf(g)}}}),oe&&(le.Storage={S3:{bucket:oe,region:ie,dangerouslyConnectToHttpEndpointForTesting:Be}}),ue){let{amazon_location_service:ne}=ue;le.Geo={LocationService:{maps:ne.maps,geofenceCollections:ne.geofenceCollections,searchIndices:ne.search_indices,region:ne.region}}}if(so&&(le.API={...le.API,REST:so.reduce((ne,zt)=>{let{name:pf,endpoint:mf,region:Ms,service:Fs}=zt;return{...ne,[pf]:{endpoint:mf,...Fs?{service:Fs}:void 0,...Ms?{region:Ms}:void 0}}},{})}),ke){let{VoiceId:ne}=ke?.convert?.speechGenerator?.defaults??{};le.Predictions=ne?{...ke,convert:{...ke.convert,speechGenerator:{...ke.convert.speechGenerator,defaults:{voiceId:ne}}}}:ke}return le},$s=e=>e?.split(",")??[],Af=({domain:e,scope:t,redirectSignIn:o,redirectSignOut:r,responseType:n})=>({domain:e,scopes:t,redirectSignIn:$s(o),redirectSignOut:$s(r),responseType:n}),Cf=e=>e.map(t=>{let o=t.toLowerCase();return o.charAt(0).toUpperCase()+o.slice(1)})});var Uo,qn=c(()=>{"use strict";Uo=Symbol("oauth-listener")});function Ys(e,t=0){return(ye[e[t+0]]+ye[e[t+1]]+ye[e[t+2]]+ye[e[t+3]]+"-"+ye[e[t+4]]+ye[e[t+5]]+"-"+ye[e[t+6]]+ye[e[t+7]]+"-"+ye[e[t+8]]+ye[e[t+9]]+"-"+ye[e[t+10]]+ye[e[t+11]]+ye[e[t+12]]+ye[e[t+13]]+ye[e[t+14]]+ye[e[t+15]]).toLowerCase()}var ye,Xs=c(()=>{"use strict";ye=[];for(let e=0;e<256;++e)ye.push((e+256).toString(16).slice(1))});function $n(){return ur>lr.length-16&&((0,Zs.randomFillSync)(lr),ur=0),lr.slice(ur,ur+=16)}var Zs,lr,ur,Qs=c(()=>{"use strict";Zs=Bn("crypto"),lr=new Uint8Array(256),ur=lr.length});var ea,jn,ta=c(()=>{"use strict";ea=Bn("crypto"),jn={randomUUID:ea.randomUUID}});function wf(e,t,o){if(jn.randomUUID&&!t&&!e)return jn.randomUUID();e=e||{};let r=e.random??e.rng?.()??$n();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(o=o||0,o<0||o+16>t.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[o+n]=r[n];return t}return Ys(r)}var Jn,oa=c(()=>{"use strict";ta();Qs();Xs();Jn=wf});var ra=c(()=>{"use strict";oa()});function ia(e){let{version:t}=e;return t?t.startsWith("1"):!1}function xf(e){if(!e)return;let{bucket_name:t,aws_region:o,buckets:r}=e;return{S3:{bucket:t,region:o,buckets:r&&Df(r)}}}function Pf(e){if(!e)return;let{user_pool_id:t,user_pool_client_id:o,identity_pool_id:r,password_policy:n,mfa_configuration:i,mfa_methods:s,unauthenticated_identities_enabled:a,oauth:p,username_attributes:m,standard_required_attributes:d,groups:u}=e,l={Cognito:{userPoolId:t,userPoolClientId:o,groups:u}};return r&&(l.Cognito={...l.Cognito,identityPoolId:r}),n&&(l.Cognito.passwordFormat={requireLowercase:n.require_lowercase,requireNumbers:n.require_numbers,requireUppercase:n.require_uppercase,requireSpecialCharacters:n.require_symbols,minLength:n.min_length??6}),i&&(l.Cognito.mfa={status:Of(i),smsEnabled:s?.includes("SMS"),totpEnabled:s?.includes("TOTP")}),a&&(l.Cognito.allowGuestAccess=a),p&&(l.Cognito.loginWith={oauth:{domain:p.domain,redirectSignIn:p.redirect_sign_in_uri,redirectSignOut:p.redirect_sign_out_uri,responseType:p.response_type==="token"?"token":"code",scopes:p.scopes,providers:bf(p.identity_providers)}}),m&&(l.Cognito.loginWith={...l.Cognito.loginWith,email:m.includes("email"),phone:m.includes("phone_number"),username:m.includes("username")}),d&&(l.Cognito.userAttributes=d.reduce((g,A)=>({...g,[A]:{required:!0}}),{})),l}function vf(e){if(!e?.amazon_pinpoint)return;let{amazon_pinpoint:t}=e;return{Pinpoint:{appId:t.app_id,region:t.aws_region}}}function Tf(e){if(!e)return;let{aws_region:t,geofence_collections:o,maps:r,search_indices:n}=e;return{LocationService:{region:t,searchIndices:n,geofenceCollections:o,maps:r}}}function Rf(e){if(!e)return;let{aws_region:t,default_authorization_type:o,url:r,api_key:n,model_introspection:i}=e;return{GraphQL:{endpoint:r,defaultAuthMode:aa(o),region:t,apiKey:n,modelIntrospection:i}}}function _f(e){if(!e?.events)return;let{url:t,aws_region:o,api_key:r,default_authorization_type:n}=e.events;return{Events:{endpoint:t,defaultAuthMode:aa(n),region:o,apiKey:r}}}function Uf(e){if(!e)return;let{aws_region:t,channels:o,amazon_pinpoint_app_id:r}=e,n=o.includes("IN_APP_MESSAGING"),i=o.includes("APNS")||o.includes("FCM");if(!(n||i))return;let s={};return n&&(s.InAppMessaging={Pinpoint:{appId:r,region:t}}),i&&(s.PushNotification={Pinpoint:{appId:r,region:t}}),s}function sa(e){let t={};if(e.storage&&(t.Storage=xf(e.storage)),e.auth&&(t.Auth=Pf(e.auth)),e.analytics&&(t.Analytics=vf(e.analytics)),e.geo&&(t.Geo=Tf(e.geo)),e.data&&(t.API=Rf(e.data)),e.custom){let o=_f(e.custom);o&&"Events"in o&&(t.API={...t.API,...o})}return e.notifications&&(t.Notifications=Uf(e.notifications)),t}function aa(e){return Nf[e]}function bf(e=[]){return e.reduce((t,o)=>(na[o]!==void 0&&t.push(na[o]),t),[])}function Of(e){return e==="OPTIONAL"?"optional":e==="REQUIRED"?"on":"off"}function Df(e){let t={};return e.forEach(({name:o,bucket_name:r,aws_region:n,paths:i})=>{if(o in t)throw new Error(`Duplicate friendly name found: ${o}. Name must be unique.`);let s=i?Object.entries(i).reduce((a,[p,m])=>(m!==void 0&&(a[p]=m),a),{}):void 0;t[o]={bucketName:r,region:n,paths:s}}),t}var Nf,na,ca=c(()=>{"use strict";Nf={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};na={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"}});var No,Yn=c(()=>{"use strict";Js();ca();No=e=>Object.keys(e).some(t=>t.startsWith("aws_"))?js(e):ia(e)?sa(e):e});function pa(e,t,o,r){function n(i){return i instanceof o?i:new o(function(s){s(i)})}return new(o||(o=Promise))(function(i,s){function a(d){try{m(r.next(d))}catch(u){s(u)}}function p(d){try{m(r.throw(d))}catch(u){s(u)}}function m(d){d.done?i(d.value):n(d.value).then(a,p)}m((r=r.apply(e,t||[])).next())})}function ma(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(m){return function(d){return p([m,d])}}function p(m){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,m[0]&&(o=0)),o;)try{if(r=1,n&&(i=m[0]&2?n.return:m[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,m[1])).done)return i;switch(n=0,i&&(m=[m[0]&2,i.value]),m[0]){case 0:case 1:i=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,n=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!(i=i.length>0&&i[i.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!i||m[1]>i[0]&&m[1]<i[3])){o.label=m[1];break}if(m[0]===6&&o.label<i[1]){o.label=i[1],i=m;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(m);break}i[2]&&o.ops.pop(),o.trys.pop();continue}m=t.call(e,o)}catch(d){m=[6,d],n=0}finally{r=i=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}}var da=c(()=>{"use strict"});var _e,ua,la,fa,ga,Xn=c(()=>{"use strict";_e=64,ua=32,la=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]),fa=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],ga=Math.pow(2,53)-1});var bo,ha=c(()=>{"use strict";Xn();bo=(function(){function e(){this.state=Int32Array.from(fa),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 o=0,r=t.byteLength;if(this.bytesHashed+=r,this.bytesHashed*8>ga)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;r>0;)this.buffer[this.bufferLength++]=t[o++],r--,this.bufferLength===_e&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var t=this.bytesHashed*8,o=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(o.setUint8(this.bufferLength++,128),r%_e>=_e-8){for(var n=this.bufferLength;n<_e;n++)o.setUint8(n,0);this.hashBuffer(),this.bufferLength=0}for(var n=this.bufferLength;n<_e-8;n++)o.setUint8(n,0);o.setUint32(_e-8,Math.floor(t/4294967296),!0),o.setUint32(_e-4,t),this.hashBuffer(),this.finished=!0}for(var i=new Uint8Array(ua),n=0;n<8;n++)i[n*4]=this.state[n]>>>24&255,i[n*4+1]=this.state[n]>>>16&255,i[n*4+2]=this.state[n]>>>8&255,i[n*4+3]=this.state[n]>>>0&255;return i},e.prototype.hashBuffer=function(){for(var t=this,o=t.buffer,r=t.state,n=r[0],i=r[1],s=r[2],a=r[3],p=r[4],m=r[5],d=r[6],u=r[7],l=0;l<_e;l++){if(l<16)this.temp[l]=(o[l*4]&255)<<24|(o[l*4+1]&255)<<16|(o[l*4+2]&255)<<8|o[l*4+3]&255;else{var g=this.temp[l-2],A=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10;g=this.temp[l-15];var N=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3;this.temp[l]=(A+this.temp[l-7]|0)+(N+this.temp[l-16]|0)}var D=(((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&m^~p&d)|0)+(u+(la[l]+this.temp[l]|0)|0)|0,O=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&i^n&s^i&s)|0;u=d,d=m,m=p,p=a+D|0,a=s,s=i,i=n,n=D+O|0}r[0]+=n,r[1]+=i,r[2]+=s,r[3]+=a,r[4]+=p,r[5]+=m,r[6]+=d,r[7]+=u},e})()});var Ea=c(()=>{"use strict"});var Zn,ya,Qn=c(()=>{"use strict";Ea();Zn=Bn("buffer"),ya=(e,t)=>{if(typeof e!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?Zn.Buffer.from(e,t):Zn.Buffer.from(e)}});var ei,ti=c(()=>{"use strict";Qn();ei=e=>{let t=ya(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)}});var Sa=c(()=>{"use strict";ti()});var Ia=c(()=>{"use strict";Qn()});var Aa=c(()=>{"use strict";ti();Sa();Ia()});function fr(e){return e instanceof Uint8Array?e:typeof e=="string"?kf(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}var kf,Ca=c(()=>{"use strict";Aa();kf=typeof Buffer<"u"&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:ei});function oi(e){return typeof e=="string"?e.length===0:e.byteLength===0}var wa=c(()=>{"use strict"});var xa=c(()=>{"use strict"});var Pa=c(()=>{"use strict"});var va=c(()=>{"use strict";Ca();wa();xa();Pa()});function Mf(e){var t=fr(e);if(t.byteLength>_e){var o=new bo;o.update(t),t=o.digest()}var r=new Uint8Array(_e);return r.set(t),r}var ht,Ta=c(()=>{"use strict";da();Xn();ha();va();ht=(function(){function e(t){this.secret=t,this.hash=new bo,this.reset()}return e.prototype.update=function(t){if(!(oi(t)||this.error))try{this.hash.update(fr(t))}catch(o){this.error=o}},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 pa(this,void 0,void 0,function(){return ma(this,function(t){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new bo,this.secret){this.outer=new bo;var t=Mf(this.secret),o=new Uint8Array(_e);o.set(t);for(var r=0;r<_e;r++)t[r]^=54,o[r]^=92;this.hash.update(t),this.outer.update(o);for(var r=0;r<t.byteLength;r++)t[r]=0}},e})()});var se=c(()=>{"use strict";Ta()});var Ff,Lf,_t=c(()=>{"use strict";Ff={},Lf={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),Ff[e]=t,Lf[t]=e}});var X,Oo,ri,ni,ii,I,si,ai,ci,pi,mi,di,ui,li,Do=c(()=>{"use strict";(function(e){e.WebUnknown="0",e.React="1",e.NextJs="2",e.Angular="3",e.VueJs="4",e.Nuxt="5",e.Svelte="6",e.ServerSideUnknown="100",e.ReactSSR="101",e.NextJsSSR="102",e.AngularSSR="103",e.VueJsSSR="104",e.NuxtSSR="105",e.SvelteSSR="106",e.ReactNative="201",e.Expo="202"})(X||(X={}));(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"})(Oo||(Oo={}));(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"})(ri||(ri={}));(function(e){e.Record="1",e.IdentifyUser="2"})(ni||(ni={}));(function(e){e.GraphQl="1",e.Get="2",e.Post="3",e.Put="4",e.Patch="5",e.Del="6",e.Head="7"})(ii||(ii={}));(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"})(I||(I={}));(function(e){e.Subscribe="1",e.GraphQl="2"})(si||(si={}));(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"})(ai||(ai={}));(function(e){e.SyncMessages="1",e.IdentifyUser="2",e.NotifyMessageInteraction="3"})(ci||(ci={}));(function(e){e.None="0"})(pi||(pi={}));(function(e){e.Convert="1",e.Identify="2",e.Interpret="3"})(mi||(mi={}));(function(e){e.Subscribe="1"})(di||(di={}));(function(e){e.InitializePushNotifications="1",e.IdentifyUser="2"})(ui||(ui={}));(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"})(li||(li={}))});var fi,Ra=c(()=>{"use strict";fi="6.15.9"});var Ut,He,gr,po,Nt,Et=c(()=>{"use strict";Ut=()=>typeof global<"u",He=()=>typeof window<"u",gr=()=>typeof document<"u",po=()=>typeof process<"u",Nt=(e,t)=>!!Object.keys(e).find(o=>o.startsWith(t))});function _a(){let e=r=>r.startsWith("_react")||r.startsWith("__react"),t=r=>Object.keys(r).find(e),o=()=>Array.from(document.querySelectorAll("[id]"));return gr()&&o().some(t)}function Ua(){return po()&&typeof process.env<"u"&&!!Object.keys(process.env).find(e=>e.includes("react"))}var Na=c(()=>{"use strict";Et()});function ba(){return He()&&Nt(window,"__VUE")}function Oa(){return Ut()&&Nt(global,"__VUE")}var Da=c(()=>{"use strict";Et()});function ka(){return He()&&Nt(window,"__SVELTE")}function Ma(){return po()&&typeof process.env<"u"&&!!Object.keys(process.env).find(e=>e.includes("svelte"))}var Fa=c(()=>{"use strict";Et()});function La(){return He()&&window.next&&typeof window.next=="object"}function Va(){return Ut()&&(Nt(global,"__next")||Nt(global,"__NEXT"))}var Ba=c(()=>{"use strict";Et()});function Ha(){return He()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function Wa(){return Ut()&&typeof global.__NUXT_PATHS__<"u"}var Ka=c(()=>{"use strict";Et()});function za(){let e=!!(gr()&&document.querySelector("[ng-version]")),t=!!(He()&&typeof window.ng<"u");return e||t}function Ga(){return po()&&typeof process.env=="object"&&process.env.npm_lifecycle_script?.startsWith("ng ")||!1}var qa=c(()=>{"use strict";Et()});function $a(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}var ja=c(()=>{"use strict"});function Ja(){return Ut()&&typeof global.expo<"u"}var Ya=c(()=>{"use strict";Et()});function Xa(){return He()}var Za=c(()=>{"use strict";Et()});function Qa(){return Vf.find(e=>e.detectionMethod())?.platform||X.ServerSideUnknown}var Vf,ec=c(()=>{"use strict";Do();Na();Da();Fa();Ba();Ka();qa();ja();Ya();Za();Vf=[{platform:X.Expo,detectionMethod:Ja},{platform:X.ReactNative,detectionMethod:$a},{platform:X.NextJs,detectionMethod:La},{platform:X.Nuxt,detectionMethod:Ha},{platform:X.Angular,detectionMethod:za},{platform:X.React,detectionMethod:_a},{platform:X.VueJs,detectionMethod:ba},{platform:X.Svelte,detectionMethod:ka},{platform:X.WebUnknown,detectionMethod:Xa},{platform:X.NextJsSSR,detectionMethod:Va},{platform:X.NuxtSSR,detectionMethod:Wa},{platform:X.ReactSSR,detectionMethod:Ua},{platform:X.VueJsSSR,detectionMethod:Oa},{platform:X.AngularSSR,detectionMethod:Ga},{platform:X.SvelteSSR,detectionMethod:Ma}]});function Kf(){ko=void 0}function tc(e,t){ko===e&&!Er&&setTimeout(()=>{Kf(),Er=!0,setTimeout(yr,Wf)},t)}var ko,hr,Er,Bf,Hf,Wf,yr,oc,rc=c(()=>{"use strict";Do();ec();hr=[],Er=!1,Bf=10,Hf=10,Wf=1e3,yr=()=>{if(!ko){if(ko=Qa(),Er)for(;hr.length;)hr.pop()?.();else hr.forEach(e=>{e()});tc(X.ServerSideUnknown,Bf),tc(X.WebUnknown,Hf)}return ko},oc=e=>{Er||hr.push(e)}});var zf,nc,ic=c(()=>{"use strict";zf={},nc=(e,t)=>zf[e]?.[t]?.additionalDetails});var sc,ac,gi,Gf,cc,yt,Sr=c(()=>{"use strict";Do();Ra();rc();ic();sc="aws-amplify",ac=e=>e.replace(/\+.*/,""),gi=class{constructor(){this.userAgent=`${sc}/${ac(fi)}`}get framework(){return yr()}get isReactNative(){return this.framework===X.ReactNative||this.framework===X.Expo}observeFrameworkChanges(t){oc(t)}},Gf=new gi,cc=({category:e,action:t}={})=>{let o=[[sc,ac(fi)]];if(e&&o.push([e,t]),o.push(["framework",yr()]),e&&t){let r=nc(e,t);r&&r.forEach(n=>{o.push(n)})}return o},yt=e=>cc(e).map(([r,n])=>r&&n?`${r}/${n}`:r).join(" ")});var St,pc=c(()=>{"use strict";St=()=>typeof window<"u"&&typeof window.document<"u"});var mc,Ir,dc,uc=c(()=>{"use strict";it();mc=new q("Auth"),Ir=class{configure(t,o){this.authConfig=t,this.authOptions=o,t&&t.Cognito?.userPoolEndpoint&&mc.warn(dc("Amazon Cognito User Pool")),t&&t.Cognito?.identityPoolEndpoint&&mc.warn(dc("Amazon Cognito Identity Pool"))}async fetchAuthSession(t={}){let o,r,n=await this.getTokens(t);return n?(r=n.accessToken?.payload?.sub,o=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,tokens:n,authenticated:!0,forceRefresh:t.forceRefresh})):o=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,authenticated:!1,forceRefresh:t.forceRefresh}),{tokens:n,credentials:o?.credentials,identityId:o?.identityId,userSub:r}}async clearCredentials(){await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId()}async getTokens(t){return await this.authOptions?.tokenProvider?.getTokens(t)??void 0}},dc=e=>`You are using a custom Amazon ${e} endpoint, ensure the endpoint is correct.`});var Ar,h,Cr=c(()=>{"use strict";mr();qs();qn();Yn();se();_t();uc();Ar=class{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new Ir}configure(t,o){let r=No(t);this.resourcesConfig=r,o&&(this.libraryOptions=o),this.resourcesConfig=Gn(this.resourcesConfig),this.Auth.configure(this.resourcesConfig.Auth,this.libraryOptions.Auth),Ee.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}[Uo](t){this.resourcesConfig.Auth?.Cognito.loginWith?.oauth?t(this.resourcesConfig.Auth?.Cognito):this.oAuthListener=t}notifyOAuthListener(){!this.resourcesConfig.Auth?.Cognito.loginWith?.oauth||!this.oAuthListener||(this.oAuthListener(this.resourcesConfig.Auth?.Cognito),this.oAuthListener=void 0)}},h=new Ar});var Mo,hi=c(()=>{"use strict";Mo=(e,t)=>e.Auth.fetchAuthSession(t)});var W,lc=c(()=>{"use strict";Cr();hi();W=e=>Mo(h,e)});function Fo(){return h.Auth.clearCredentials()}var fc=c(()=>{"use strict";Cr()});var Jt,qf,wr=c(()=>{"use strict";Jt=e=>{let{headers:t,statusCode:o}=e;return{...qf(e)?e.$metadata:{},httpStatusCode:o,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"]}},qf=e=>typeof e?.$metadata=="object"});var we,st,Lo=c(()=>{"use strict";wr();we=async e=>{if(!e||e.statusCode<300)return;let t=await st(e),r=(s=>{let[a]=s.toString().split(/[,:]+/);return a.includes("#")?a.split("#")[1]:a})(e.headers["x-amzn-errortype"]??t.code??t.__type??"UnknownError"),n=t.message??t.Message??"Unknown error",i=new Error(n);return Object.assign(i,{name:r,$metadata:Jt(e)})},st=async e=>{if(!e.body)throw new Error("Missing response payload");let t=await e.body.json();return Object.assign(t,{$metadata:Jt(e)})}});var v,xr=c(()=>{"use strict";v=(e,t,o,r)=>async(n,i)=>{let s={...r,...n},a=await s.endpointResolver(s,i),p=await t(i,a),m=await e(p,{...s});return o(m)}});function gc(e=3e5){return r=>{let n=2**r*100+100*Math.random();return n>e?!1:n}}var hc=c(()=>{"use strict"});var Ei,Ec,yi=c(()=>{"use strict";Ei="amz-sdk-invocation-id",Ec="amz-sdk-request"});var Vo,Si=c(()=>{"use strict";hc();Vo=e=>{let o=gc(3e5)(e);return o===!1?3e5:o}});var jf,yc,Sc=c(()=>{"use strict";jf=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],yc=e=>!!e&&jf.includes(e)});var Bo,Jf,Yf,Xf,Zf,Qf,Ii=c(()=>{"use strict";To();Sc();Bo=e=>async(t,o)=>{let r=o??await e(t)??void 0,n=r?.code||r?.name,i=t?.statusCode;return{retryable:Zf(o)||Xf(i,n)||yc(n)||Qf(i,n)}},Jf=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],Yf=["TimeoutError","RequestTimeout","RequestTimeoutException"],Xf=(e,t)=>e===429||!!t&&Jf.includes(t),Zf=e=>[Me.NetworkError,"ERR_NETWORK"].includes(e?.name),Qf=(e,t)=>!!e&&[500,502,503,504].includes(e)||!!t&&Yf.includes(t)});var Ai,Pr,vr=c(()=>{"use strict";Si();Ii();se();_t();Lo();Ai="cognito-identity",Pr={service:Ai,retryDecider:Bo(we),computeDelay:Vo,cache:"no-store"}});var Cc,eg,Ic,wc=c(()=>{"use strict";Cc=({maxAttempts:e=3,retryDecider:t,computeDelay:o,abortSignal:r})=>{if(e<1)throw new Error("maxAttempts must be greater than 0");return(n,i)=>async function(a){let p,m=i.attemptsCount??0,d,u=()=>{if(d)return Ic(d,m),d;throw Ic(p,m),p};for(;!r?.aborted&&m<e;){try{d=await n(a),p=void 0}catch(A){p=A,d=void 0}m=(i.attemptsCount??0)>m?i.attemptsCount??0:m+1,i.attemptsCount=m;let{isCredentialsExpiredError:l,retryable:g}=await t(d,p,i);if(g){if(i.isCredentialsExpired=!!l,!r?.aborted&&m<e){let A=o(m);await eg(A,r)}continue}else return u()}if(r?.aborted)throw new Error("Request aborted.");return u()}},eg=(e,t)=>{if(t?.aborted)return Promise.resolve();let o,r,n=new Promise(i=>{r=i,o=setTimeout(i,e)});return t?.addEventListener("abort",function i(s){clearTimeout(o),t?.removeEventListener("abort",i),r()}),n},Ic=(e,t)=>{Object.prototype.toString.call(e)==="[object Object]"&&(e.$metadata={...e.$metadata??{},attempts:t})}});var xc,Pc=c(()=>{"use strict";ra();xc=Jn});var vc,Tc=c(()=>{"use strict";Pc();se();_t();yi();vc=()=>e=>async function(o){return o.headers[Ei]||(o.headers[Ei]=xc()),e(o)}});var Rc,_c=c(()=>{"use strict";yi();Rc=({maxAttempts:e=3})=>(t,o)=>async function(n){let i=o.attemptsCount??0;return n.headers[Ec]=`attempt=${i+1}; max=${e}`,t(n)}});var Uc,Nc=c(()=>{"use strict";Uc=({userAgentHeader:e="x-amz-user-agent",userAgentValue:t=""})=>o=>async function(n){if(t.trim().length===0)return await o(n);{let i=e.toLowerCase();return n.headers[i]=n.headers[i]?`${n.headers[i]} ${t}`:t,await o(n)}}});var Yt,Tr=c(()=>{"use strict";Yt=(e,t)=>(o,r)=>{let n={},i=s=>e(s,r);for(let s=t.length-1;s>=0;s--){let a=t[s];i=a(r)(i,n)}return i(o)}});var Rr,bc=c(()=>{"use strict";Rr=e=>{let t;return()=>(t||(t=e()),t)}});var tg,Oc,Dc=c(()=>{"use strict";Rt();To();bc();tg=e=>!["HEAD","GET"].includes(e.toUpperCase()),Oc=async({url:e,method:t,headers:o,body:r},{abortSignal:n,cache:i,withCrossDomainCredentials:s})=>{let a;try{a=await fetch(e,{method:t,headers:o,body:tg(t)?r:void 0,signal:n,cache:i,credentials:s?"include":"same-origin"})}catch(u){throw u instanceof TypeError?new te({name:Me.NetworkError,message:"A network error has occurred.",underlyingError:u}):u}let p={};a.headers?.forEach((u,l)=>{p[l.toLowerCase()]=u});let m={statusCode:a.status,headers:p,body:null},d=Object.assign(a.body??{},{text:Rr(()=>a.text()),blob:Rr(()=>a.blob()),json:Rr(()=>a.json())});return{...m,body:d}}});var Ho,Ci=c(()=>{"use strict";wc();Tc();_c();Nc();Tr();Dc();Ho=Yt(Oc,[Uc,vc,Cc,Rc])});var kc,Mc=c(()=>{"use strict";kc=()=>e=>async function(o){return o.headers["cache-control"]="no-store",e(o)}});var _r,wi=c(()=>{"use strict";Ci();se();_t();Tr();Mc();_r=Yt(Ho,[kc])});var Ur,og,rg,xi=c(()=>{"use strict";Ur=e=>(t,o)=>{let r=og(e),n=JSON.stringify(t);return rg(o,r,n)},og=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),rg=({url:e},t,o)=>({headers:t,url:e,body:o,method:"POST"})});var Nr,ng,ig,Fc=c(()=>{"use strict";se();_t();Sr();wr();Lo();xr();vr();wi();xi();Nr=e=>v(_r,Ur("GetCredentialsForIdentity"),ng,{...Pr,...e,userAgentValue:yt()}),ng=async e=>{if(e.statusCode>=300)throw await we(e);let t=await st(e);return{IdentityId:t.IdentityId,Credentials:ig(t.Credentials),$metadata:Jt(e)}},ig=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)})});var Pi,sg,Lc=c(()=>{"use strict";se();_t();Sr();wr();Lo();xr();vr();wi();xi();Pi=e=>v(_r,Ur("GetId"),sg,{...Pr,...e,userAgentValue:yt()}),sg=async e=>{if(e.statusCode>=300)throw await we(e);return{IdentityId:(await st(e)).IdentityId,$metadata:Jt(e)}}});var vi,Vc,Bc=c(()=>{"use strict";vi={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},Vc={partitions:[vi,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]}});var Wo,Ti=c(()=>{"use strict";Bc();Wo=e=>{let{partitions:t}=Vc;for(let{regions:o,outputs:r,regionRegex:n}of t){let i=new RegExp(n);if(o.includes(e)||i.test(e))return r.dnsSuffix}return vi.outputs.dnsSuffix}});var xe,Ri=c(()=>{"use strict";xe=URL});var _i,Hc=c(()=>{"use strict";Ti();Ri();se();_t();vr();_i=({region:e})=>({url:new xe(`https://${Ai}.${e}.${Wo(e)}`)})});var It,Ui=c(()=>{"use strict";To();Rt();It=class extends te{constructor(){super({name:Me.PlatformNotSupported,message:"Function not supported on current platform"})}}});var at,Ko=c(()=>{"use strict";Ui();at=class{constructor(t){this.storage=t}async setItem(t,o){if(!this.storage)throw new It;this.storage.setItem(t,o)}async getItem(t){if(!this.storage)throw new It;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new It;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new It;this.storage.clear()}}});var Xt,Ni=c(()=>{"use strict";Xt=class{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,o){this.storage.set(t,o)}getItem(t){return this.storage.get(t)??null}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}}});var Wc,br,Or,zo=c(()=>{"use strict";it();Ni();Wc=new q("CoreStorageUtils"),br=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{Wc.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new Xt},Or=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return Wc.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new Xt}}});var Dr,Kc=c(()=>{"use strict";Ko();zo();Dr=class extends at{constructor(){super(br())}}});var kr,zc=c(()=>{"use strict";Ko();zo();kr=class extends at{constructor(){super(Or())}}});var Mr,Gc=c(()=>{"use strict";Ui();Mr=class{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new It;return this._storage}setItem(t,o){this.storage.setItem(t,o)}getItem(t){return this.storage.getItem(t)}removeItem(t){this.storage.removeItem(t)}clear(){this.storage.clear()}}});var Fr,qc=c(()=>{"use strict";Gc();zo();Fr=class extends Mr{constructor(){super(Or())}}});function Lr(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)e[r]=o[r]}return e}function bi(e,t){function o(n,i,s){if(!(typeof document>"u")){s=Lr({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),n=encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var p in s)s[p]&&(a+="; "+p,s[p]!==!0&&(a+="="+s[p].split(";")[0]));return document.cookie=n+"="+e.write(i,n)+a}}function r(n){if(!(typeof document>"u"||arguments.length&&!n)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var p=i[a].split("="),m=p.slice(1).join("=");try{var d=decodeURIComponent(p[0]);if(s[d]=e.read(m,d),n===d)break}catch{}}return n?s[n]:s}}return Object.create({set:o,get:r,remove:function(n,i){o(n,"",Lr({},i,{expires:-1}))},withAttributes:function(n){return bi(this.converter,Lr({},this.attributes,n))},withConverter:function(n){return bi(Lr({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var ag,Go,$c=c(()=>{"use strict";ag={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)}};Go=bi(ag,{path:"/"})});var qo,jc=c(()=>{"use strict";$c();qo=class{constructor(t={}){let{path:o,domain:r,expires:n,sameSite:i,secure:s}=t;if(this.domain=r,this.path=o||"/",this.expires=Object.prototype.hasOwnProperty.call(t,"expires")?n:365,this.secure=Object.prototype.hasOwnProperty.call(t,"secure")?s:!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,o){Go.set(t,o,this.getData())}async getItem(t){return Go.get(t)??null}async removeItem(t){Go.remove(t,this.getData())}async clear(){let t=Go.get(),o=Object.keys(t).map(r=>this.removeItem(r));await Promise.all(o)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}}});var Ye,cg,Xe,pg,Jc=c(()=>{"use strict";Kc();Ni();Ko();zc();qc();Ye=new Dr,cg=new kr,Xe=new Fr,pg=new at(new Xt)});var bt,At,Vr=c(()=>{"use strict";bt={keyPrefix:"aws-amplify-cache",capacityInBytes:1048576,itemMaxSize:21e4,defaultTTL:2592e5,defaultPriority:5,warningThreshold:.8},At="CurSize"});function Oi(e){let t=0;t=e.length;for(let o=e.length;o>=0;o-=1){let r=e.charCodeAt(o);r>127&&r<=2047?t+=1:r>2047&&r<=65535&&(t+=2),r>=56320&&r<=57343&&(o-=1)}return t}function Ot(){return new Date().getTime()}var Zt,Di=c(()=>{"use strict";Vr();Zt=e=>`${e}${At}`});var Dt,mg,ki,Yc=c(()=>{"use strict";Ro();(function(e){e.NoCacheItem="NoCacheItem",e.NullNextNode="NullNextNode",e.NullPreviousNode="NullPreviousNode"})(Dt||(Dt={}));mg={[Dt.NoCacheItem]:{message:"Item not found in the cache storage."},[Dt.NullNextNode]:{message:"Next node is null."},[Dt.NullPreviousNode]:{message:"Previous node is null."}},ki=je(mg)});var re,Br,Xc=c(()=>{"use strict";it();Vr();Di();Yc();re=new q("StorageCache"),Br=class{constructor({config:t,keyValueStorage:o}){this.config={...bt,...t},this.keyValueStorage=o,this.sanitizeConfig()}getModuleName(){return"Cache"}configure(t){return t&&(t.keyPrefix&&re.warn("keyPrefix can not be re-configured on an existing Cache instance."),this.config={...this.config,...t}),this.sanitizeConfig(),this.config}async getCurrentCacheSize(){let t=await this.getStorage().getItem(Zt(this.config.keyPrefix));return t||(await this.getStorage().setItem(Zt(this.config.keyPrefix),"0"),t="0"),Number(t)}async setItem(t,o,r){if(re.debug(`Set item: key is ${t}, value is ${o} with options: ${r}`),!t||t===At){re.warn(`Invalid key: should not be empty or reserved key: '${At}'`);return}if(typeof o>"u"){re.warn("The value of item should not be undefined!");return}let n={priority:r?.priority!==void 0?r.priority:this.config.defaultPriority,expires:r?.expires!==void 0?r.expires:this.config.defaultTTL+Ot()};if(n.priority<1||n.priority>5){re.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");return}let i=`${this.config.keyPrefix}${t}`,s=this.fillCacheItem(i,o,n);if(s.byteSize>this.config.itemMaxSize){re.warn(`Item with key: ${t} you are trying to put into is too big!`);return}try{let a=await this.getStorage().getItem(i);if(a&&await this.removeCacheItem(i,JSON.parse(a).byteSize),await this.isCacheFull(s.byteSize)){let p=await this.clearInvalidAndGetRemainingKeys();if(await this.isCacheFull(s.byteSize)){let m=await this.sizeToPop(s.byteSize);await this.popOutItems(p,m)}}return this.setCacheItem(i,s)}catch(a){re.warn(`setItem failed! ${a}`)}}async getItem(t,o){re.debug(`Get item: key is ${t} with options ${o}`);let r;if(!t||t===At)return re.warn(`Invalid key: should not be empty or reserved key: '${At}'`),null;let n=`${this.config.keyPrefix}${t}`;try{if(r=await this.getStorage().getItem(n),r!=null)if(await this.isExpired(n))await this.removeCacheItem(n,JSON.parse(r).byteSize);else return(await this.updateVisitedTime(JSON.parse(r),n)).data;if(o?.callback){let i=o.callback();return i!==null&&await this.setItem(t,i,o),i}return null}catch(i){return re.warn(`getItem failed! ${i}`),null}}async removeItem(t){if(re.debug(`Remove item: key is ${t}`),!t||t===At){re.warn(`Invalid key: should not be empty or reserved key: '${At}'`);return}let o=`${this.config.keyPrefix}${t}`;try{let r=await this.getStorage().getItem(o);r&&await this.removeCacheItem(o,JSON.parse(r).byteSize)}catch(r){re.warn(`removeItem failed! ${r}`)}}async getAllKeys(){try{return await this.getAllCacheKeys()}catch(t){return re.warn(`getAllkeys failed! ${t}`),[]}}getStorage(){return this.keyValueStorage}async isExpired(t){let o=await this.getStorage().getItem(t);ki(o!==null,Dt.NoCacheItem,`Key: ${t}`);let r=JSON.parse(o);return Ot()>=r.expires}async removeCacheItem(t,o){let r=await this.getStorage().getItem(t);ki(r!==null,Dt.NoCacheItem,`Key: ${t}`);let n=o??JSON.parse(r).byteSize;await this.decreaseCurrentSizeInBytes(n);try{await this.getStorage().removeItem(t)}catch(i){await this.increaseCurrentSizeInBytes(n),re.error(`Failed to remove item: ${i}`)}}fillCacheItem(t,o,r){let n={key:t,data:o,timestamp:Ot(),visitedTime:Ot(),priority:r.priority??0,expires:r.expires??0,type:typeof o,byteSize:0};return n.byteSize=Oi(JSON.stringify(n)),n.byteSize=Oi(JSON.stringify(n)),n}sanitizeConfig(){this.config.itemMaxSize>this.config.capacityInBytes&&(re.error("Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default."),this.config.itemMaxSize=bt.itemMaxSize),(this.config.defaultPriority>5||this.config.defaultPriority<1)&&(re.error("Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default."),this.config.defaultPriority=bt.defaultPriority),(Number(this.config.warningThreshold)>1||Number(this.config.warningThreshold)<0)&&(re.error("Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default."),this.config.warningThreshold=bt.warningThreshold);let t=5*1024*1024;this.config.capacityInBytes>t&&(re.error("Cache Capacity should be less than 5MB. Setting back to default. Setting back to default."),this.config.capacityInBytes=bt.capacityInBytes)}async increaseCurrentSizeInBytes(t){let o=await this.getCurrentCacheSize();await this.getStorage().setItem(Zt(this.config.keyPrefix),(o+t).toString())}async decreaseCurrentSizeInBytes(t){let o=await this.getCurrentCacheSize();await this.getStorage().setItem(Zt(this.config.keyPrefix),(o-t).toString())}async updateVisitedTime(t,o){return t.visitedTime=Ot(),await this.getStorage().setItem(o,JSON.stringify(t)),t}async setCacheItem(t,o){await this.increaseCurrentSizeInBytes(o.byteSize);try{await this.getStorage().setItem(t,JSON.stringify(o))}catch(r){await this.decreaseCurrentSizeInBytes(o.byteSize),re.error(`Failed to set item ${r}`)}}async sizeToPop(t){let r=await this.getCurrentCacheSize()+t-this.config.capacityInBytes,n=(1-this.config.warningThreshold)*this.config.capacityInBytes;return r>n?r:n}async isCacheFull(t){let o=await this.getCurrentCacheSize();return t+o>this.config.capacityInBytes}async popOutItems(t,o){let r=[],n=o;for(let i of t){let s=await this.getStorage().getItem(i);if(s!=null){let a=JSON.parse(s);r.push(a)}}r.sort((i,s)=>i.priority>s.priority?-1:i.priority<s.priority?1:i.visitedTime<s.visitedTime?-1:1);for(let i of r)if(await this.removeCacheItem(i.key,i.byteSize),n-=i.byteSize,n<=0)return}async clearInvalidAndGetRemainingKeys(){let t=[],o=await this.getAllCacheKeys({omitSizeKey:!0});for(let r of o)await this.isExpired(r)?await this.removeCacheItem(r):t.push(r);return t}async clear(){re.debug("Clear Cache");try{let t=await this.getAllKeys();for(let o of t){let r=`${this.config.keyPrefix}${o}`;await this.getStorage().removeItem(r)}}catch(t){re.warn(`clear failed! ${t}`)}}}});var dg,Hr,Zc=c(()=>{"use strict";it();Ko();zo();Vr();Xc();Di();dg=new q("StorageCache"),Hr=class e extends Br{constructor(t){let o=br();super({config:t,keyValueStorage:new at(o)}),this.storage=o,this.getItem=this.getItem.bind(this),this.setItem=this.setItem.bind(this),this.removeItem=this.removeItem.bind(this)}async getAllCacheKeys(t){let{omitSizeKey:o}=t??{},r=[];for(let n=0;n<this.storage.length;n++){let i=this.storage.key(n);o&&i===Zt(this.config.keyPrefix)||i?.startsWith(this.config.keyPrefix)&&r.push(i.substring(this.config.keyPrefix.length))}return r}createInstance(t){return(!t.keyPrefix||t.keyPrefix===bt.keyPrefix)&&(dg.error("invalid keyPrefix, setting keyPrefix with timeStamp"),t.keyPrefix=Ot.toString()),new e(t)}}});var ug,Qc=c(()=>{"use strict";Zc();ug=new Hr});var lg,ep,tp=c(()=>{"use strict";it();lg=new q("I18n"),ep=class{constructor(){this._options=null,this._lang=null,this._dict={}}setDefaultLanguage(){!this._lang&&typeof window<"u"&&window&&window.navigator&&(this._lang=window.navigator.language),lg.debug(this._lang)}setLanguage(t){this._lang=t}get(t,o=void 0){if(this.setDefaultLanguage(),!this._lang)return typeof o<"u"?o:t;let r=this._lang,n=this.getByLanguage(t,r);return n||(r.indexOf("-")>0&&(n=this.getByLanguage(t,r.split("-")[0])),n)?n:typeof o<"u"?o:t}getByLanguage(t,o,r=null){if(!o)return r;let n=this._dict[o];return n?n[t]:r}putVocabulariesForLanguage(t,o){let r=this._dict[t];r||(r=this._dict[t]={}),this._dict[t]={...r,...o}}putVocabularies(t){Object.keys(t).forEach(o=>{this.putVocabulariesForLanguage(o,t[o])})}}});var kt,fg,$o,op=c(()=>{"use strict";Ro();(function(e){e.NotConfigured="NotConfigured"})(kt||(kt={}));fg={[kt.NotConfigured]:{message:"i18n is not configured."}},$o=je(fg)});var rp,Wr,Ze,Kr,np=c(()=>{"use strict";it();tp();op();rp=new q("I18n"),Wr={language:null},Ze=null,Kr=class e{static configure(t){return rp.debug("configure I18n"),t&&(Wr=Object.assign({},Wr,t.I18n||t),e.createInstance()),Wr}static getModuleName(){return"I18n"}static createInstance(){rp.debug("create I18n instance"),!Ze&&(Ze=new ep)}static setLanguage(t){e.checkConfig(),$o(!!Ze,kt.NotConfigured),Ze.setLanguage(t)}static get(t,o){return e.checkConfig()?($o(!!Ze,kt.NotConfigured),Ze.get(t,o)):typeof o>"u"?t:o}static putVocabulariesForLanguage(t,o){e.checkConfig(),$o(!!Ze,kt.NotConfigured),Ze.putVocabulariesForLanguage(t,o)}static putVocabularies(t){e.checkConfig(),$o(!!Ze,kt.NotConfigured),Ze.putVocabularies(t)}static checkConfig(){return Ze||e.createInstance(),!0}};Kr.createInstance()});var U=c(()=>{"use strict";mr();zn();Cr();lc();fc();Fc();Lc();Hc();Jc();Qc();np();it();jc()});var Mi,ip=c(()=>{"use strict";co();Mi=e=>{let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=[],r=new Uint8Array(e);qt().getRandomValues(r);for(let n of r)o.push(t[n%t.length]);return o.join("")}});function Fi(e){return(e.match(/.{2}/g)||[]).map(o=>String.fromCharCode(parseInt(o,16))).join("")}var sp=c(()=>{"use strict"});function Li(e){return e.split("").map(t=>t.charCodeAt(0).toString(16).padStart(2,"0")).join("")}var ap=c(()=>{"use strict"});var Vi,cp=c(()=>{"use strict";Vi=e=>{let t;return async(...o)=>t||(t=new Promise((r,n)=>{e(...o).then(i=>{r(i)}).catch(i=>{n(i)}).finally(()=>{t=void 0})}),t)}});function zr({expiresAt:e,clockDrift:t,tolerance:o=5e3}){return Date.now()+t+o>e}var pp=c(()=>{"use strict"});var Bi,mp=c(()=>{"use strict";Bi=async()=>{let{userAgentData:e}=navigator;if(!e)return navigator.userAgent;let{platform:t="",platformVersion:o="",model:r="",architecture:n="",fullVersionList:i=[]}=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),s=i.map(p=>`${p.brand}/${p.version}`).join(";");return[t,o,n,r,t,s].filter(p=>p).join(" ")||navigator.userAgent}});function dp(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}var up=c(()=>{"use strict"});var We,lp=c(()=>{"use strict";co();up();We={convert(e,t={urlSafe:!1,skipPadding:!1}){let o=typeof e=="string"?e:dp(e),r=Ks()(o);return t.urlSafe&&(r=r.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(r=r.replace(/=/g,"")),r}}});function fp(){return qt().getRandomValues(new Uint32Array(1))[0]}var gp=c(()=>{"use strict";co()});function gg(e){let{words:t}=e,{sigBytes:o}=e,r=[];for(let n=0;n<o;n++){let i=t[n>>>2]>>>24-n%4*8&255;r.push((i>>>4).toString(16)),r.push((i&15).toString(16))}return r.join("")}var jo,hp=c(()=>{"use strict";gp();jo=class e{constructor(t,o){this.words=[];let r=t;r=this.words=r||[],o!==void 0?this.sigBytes=o:this.sigBytes=r.length*4}random(t){let o=[];for(let r=0;r<t;r+=4)o.push(fp());return new e(o,t)}toString(){return gg(this)}}});var C=c(()=>{"use strict";ip();pc();sp();ap();cp();pp();qn();Ri();Yn();mp();zn();Sr();Do();Rt();Ro();To();cr();hi();mr();Kn();lp();co();hp()});var P,me=c(()=>{"use strict";(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"})(P||(P={}))});var Gr,de,Ue,Mt=c(()=>{"use strict";me();Gr={[P.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[P.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[P.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[P.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[P.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[P.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[P.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[P.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[P.EmptySignInPassword]:{message:"password is required to signIn"},[P.EmptySignInUsername]:{message:"username is required to signIn"},[P.EmptySignUpPassword]:{message:"password is required to signUp"},[P.EmptySignUpUsername]:{message:"username is required to signUp"},[P.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[P.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"},[P.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[P.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[P.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"}};(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"})(de||(de={}));(function(e){e.SignInException="SignInException",e.OAuthSignInError="OAuthSignInException"})(Ue||(Ue={}))});var S,$=c(()=>{"use strict";C();S=class e extends te{constructor(t){super(t),this.constructor=e,Object.setPrototypeOf(this,e.prototype)}}});function k(e,t){let{message:o,recoverySuggestion:r}=Gr[t];if(!e)throw new S({name:t,message:o,recoverySuggestion:r})}var Se=c(()=>{"use strict";Mt();$()});function E(e){let t=e?.split("_")[0];if(!e||e.indexOf("_")<0||!t||typeof t!="string")throw new S({name:"InvalidUserPoolId",message:"Invalid user pool id provided."});return t}function Jo(e){if(!e||!e.includes(":"))throw new S({name:"InvalidIdentityPoolIdException",message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."});return e.split(":")[0]}var F=c(()=>{"use strict";$()});function Yo(e){return Object.entries(e).map(([t,o])=>({Name:t,Value:o}))}function Ep(e){let t={};return e?.forEach(o=>{o.Name&&(t[o.Name]=o.Value)}),t}var qr=c(()=>{"use strict"});var yp,Sp,Ip,Ap,Cp,wp,xp,Pp,vp,Tp,Rp,_p,Up,Np,Xo,bp,Op,Dp,$r,kp,Mp,Fp,Lp,Vp,Bp,jr=c(()=>{"use strict";(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(yp||(yp={}));(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"})(Sp||(Sp={}));(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"})(Ip||(Ip={}));(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"})(Ap||(Ap={}));(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"})(Cp||(Cp={}));(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"})(wp||(wp={}));(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"})(xp||(xp={}));(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"})(Pp||(Pp={}));(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"})(vp||(vp={}));(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"})(Tp||(Tp={}));(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"})(Rp||(Rp={}));(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"})(_p||(_p={}));(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"})(Up||(Up={}));(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"})(Np||(Np={}));(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"})(Xo||(Xo={}));(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"})(bp||(bp={}));(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"})(Op||(Op={}));(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"})(Dp||(Dp={}));(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"})($r||($r={}));(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"})(kp||(kp={}));(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"})(Mp||(Mp={}));(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"})(Fp||(Fp={}));(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"})(Lp||(Lp={}));(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"})(Vp||(Vp={}));Bp="SetUpTOTPException"});var mo,Hp,Wp,Jr,hg,Eg,yg,Kp,Kw,zp,Sg,Gp,qp,$p,jp,Ft=c(()=>{"use strict";$();mo="UserUnAuthenticatedException",Hp="UserAlreadyAuthenticatedException",Wp="DeviceMetadataNotFoundException",Jr="AutoSignInException",hg="InvalidRedirectException",Eg="InvalidAppSchemeException",yg="InvalidPreferredRedirectUrlException",Kp=new S({name:hg,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."}),Kw=new S({name:Eg,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."}),zp=new S({name:yg,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."}),Sg="InvalidOriginException",Gp=new S({name:Sg,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."}),qp="OAuthSignOutException",$p="TokenRefreshException",jp="UnexpectedSignInInterruptionException"});function M(e){if(!e||!e.accessToken)throw new S({name:mo,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function Jp(e){if(!e||!e.idToken)throw new S({name:mo,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function Yr(e){if(wg(e))throw Ig;if(!Cg(e))throw Ag}function Qt(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new S({name:Wp,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."})}function Xp(e){return e?.accessToken||e?.idToken}function Cg(e){return Xp(e)&&e?.refreshToken}function wg(e){return Xp(e)&&!e?.refreshToken}var Ig,Ag,Yp,ee=c(()=>{"use strict";$();Ft();Ig=new S({name:$p,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow.
|
|
1
|
+
"use strict";var FoundationSDK=(()=>{var cr=Object.defineProperty;var Ua=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Da=Object.prototype.hasOwnProperty;var dr=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ma=(e,t)=>{for(var o in t)cr(e,o,{get:t[o],enumerable:!0})},ka=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Oa(t))!Da.call(e,n)&&n!==o&&cr(e,n,{get:()=>t[n],enumerable:!(r=Ua(t,n))||r.enumerable});return e};var Fa=e=>ka(cr({},"__esModule",{value:!0}),e);var Ou={};Ma(Ou,{createFoundation:()=>va});var yn="Logging",ur="x-amz-user-agent",En="NoHubcallbackProvidedException";var se;(function(e){e.DEBUG="DEBUG",e.ERROR="ERROR",e.INFO="INFO",e.WARN="WARN",e.VERBOSE="VERBOSE",e.NONE="NONE"})(se||(se={}));var Sn={VERBOSE:1,DEBUG:2,INFO:3,WARN:4,ERROR:5,NONE:6},C=class e{constructor(t,o=se.WARN){this.name=t,this.level=o,this._pluggables=[]}_padding(t){return t<10?"0"+t:""+t}_ts(){let 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,...o){let r=this.level;e.LOG_LEVEL&&(r=e.LOG_LEVEL),typeof window<"u"&&window.LOG_LEVEL&&(r=window.LOG_LEVEL);let n=Sn[r];if(!(Sn[t]>=n))return;let s=console.log.bind(console);t===se.ERROR&&console.error&&(s=console.error.bind(console)),t===se.WARN&&console.warn&&(s=console.warn.bind(console)),e.BIND_ALL_LOG_LEVELS&&(t===se.INFO&&console.info&&(s=console.info.bind(console)),t===se.DEBUG&&console.debug&&(s=console.debug.bind(console)));let a=`[${t}] ${this._ts()} ${this.name}`,c="";if(o.length===1&&typeof o[0]=="string")c=`${a} - ${o[0]}`,s(c);else if(o.length===1)c=`${a} ${o[0]}`,s(a,o[0]);else if(typeof o[0]=="string"){let d=o.slice(1);d.length===1&&(d=d[0]),c=`${a} - ${o[0]} ${d}`,s(`${a} - ${o[0]}`,d)}else c=`${a} ${o}`,s(a,o);for(let d of this._pluggables){let u={message:c,timestamp:Date.now()};d.pushLogs([u])}}log(...t){this._log(se.INFO,...t)}info(...t){this._log(se.INFO,...t)}warn(...t){this._log(se.WARN,...t)}error(...t){this._log(se.ERROR,...t)}debug(...t){this._log(se.DEBUG,...t)}verbose(...t){this._log(se.VERBOSE,...t)}addPluggable(t){t&&t.getCategoryName()===yn&&(this._pluggables.push(t),t.configure(this._config))}listPluggables(){return this._pluggables}};C.LOG_LEVEL=null;C.BIND_ALL_LOG_LEVELS=!1;var U=class e extends Error{constructor({message:t,name:o,recoverySuggestion:r,underlyingError:n,metadata:i}){if(super(t),this.name=o,this.underlyingError=n,this.recoverySuggestion=r,i){let{extendedRequestId:s,httpStatusCode:a,requestId:c}=i;this.metadata={extendedRequestId:s,httpStatusCode:a,requestId:c}}this.constructor=e,Object.setPrototypeOf(this,e.prototype)}};var ue;(function(e){e.NoEndpointId="NoEndpointId",e.PlatformNotSupported="PlatformNotSupported",e.Unknown="Unknown",e.NetworkError="NetworkError"})(ue||(ue={}));var Se=(e,t=U)=>(o,r,n)=>{let{message:i,recoverySuggestion:s}=e[r];if(!o)throw new t({name:r,message:n?`${i} ${n}`:i,recoverySuggestion:s})};var j=typeof Symbol<"u"?Symbol("amplify_default"):"@@amplify_default",Dt=new C("Hub"),no=class{constructor(t){this.listeners=new Map,this.protectedChannels=["core","auth","api","analytics","interactions","pubsub","storage","ui","xr"],this.name=t}_remove(t,o){let r=this.listeners.get(t);if(!r){Dt.warn(`No listeners for ${t}`);return}this.listeners.set(t,[...r.filter(({callback:n})=>n!==o)])}dispatch(t,o,r,n){typeof t=="string"&&this.protectedChannels.indexOf(t)>-1&&(n===j||Dt.warn(`WARNING: ${t} is protected and dispatching on it can have unintended consequences`));let i={channel:t,payload:{...o},source:r,patternInfo:[]};try{this._toListeners(i)}catch(s){Dt.error(s)}}listen(t,o,r="noname"){let n;if(typeof o!="function")throw new U({name:En,message:"No callback supplied to Hub"});n=o;let i=this.listeners.get(t);return i||(i=[],this.listeners.set(t,i)),i.push({name:r,callback:n}),()=>{this._remove(t,n)}}_toListeners(t){let{channel:o,payload:r}=t,n=this.listeners.get(o);n&&n.forEach(i=>{Dt.debug(`Dispatching to ${o} with `,r);try{i.callback(t)}catch(s){Dt.error(s)}})}},Z=new no("__default__"),io=new no("internal-hub");var st=()=>{if(typeof window=="object"&&typeof window.crypto=="object")return window.crypto;if(typeof crypto=="object")return crypto;throw new U({name:"MissingPolyfill",message:"Cannot resolve the `crypto` function from the environment."})},In=()=>{if(typeof window<"u"&&typeof window.btoa=="function")return window.btoa;if(typeof btoa=="function")return btoa;throw new U({name:"Base64EncoderError",message:"Cannot resolve the `btoa` function from the environment."})},wn=()=>{if(typeof window<"u"&&typeof window.atob=="function")return window.atob;if(typeof atob=="function")return atob;throw new U({name:"Base64EncoderError",message:"Cannot resolve the `atob` function from the environment."})};var at={convert(e,t){let o=e;return t?.urlSafe&&(o=o.replace(/-/g,"+").replace(/_/g,"/")),wn()(o)}};var Ie;(function(e){e.AuthTokenConfigException="AuthTokenConfigException",e.AuthUserPoolAndIdentityPoolException="AuthUserPoolAndIdentityPoolException",e.AuthUserPoolException="AuthUserPoolException",e.InvalidIdentityPoolIdException="InvalidIdentityPoolIdException",e.OAuthNotConfigureException="OAuthNotConfigureException"})(Ie||(Ie={}));var La={[Ie.AuthTokenConfigException]:{message:"Auth Token Provider not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app."},[Ie.AuthUserPoolAndIdentityPoolException]:{message:"Auth UserPool or IdentityPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with UserPoolId and IdentityPoolId."},[Ie.AuthUserPoolException]:{message:"Auth UserPool not configured.",recoverySuggestion:"Make sure to call Amplify.configure in your app with userPoolId and userPoolClientId."},[Ie.InvalidIdentityPoolIdException]:{message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."},[Ie.OAuthNotConfigureException]:{message:"oauth param not configured.",recoverySuggestion:"Make sure to call Amplify.configure with oauth parameter in your app."}},so=Se(La);function E(e){let t=!0;e?t=!!e.userPoolId&&!!e.userPoolClientId:t=!1,so(t,Ie.AuthUserPoolException)}function Le(e){let t=!!e?.loginWith?.oauth?.domain&&!!e?.loginWith?.oauth?.redirectSignOut&&!!e?.loginWith?.oauth?.redirectSignIn&&!!e?.loginWith?.oauth?.responseType;so(t,Ie.OAuthNotConfigureException)}function ct(e){let t=!!e?.identityPoolId;so(t,Ie.InvalidIdentityPoolIdException)}function Q(e){let t=e.split(".");if(t.length!==3)throw new Error("Invalid token");try{let r=t[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(at.convert(r).split("").map(s=>`%${`00${s.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")),i=JSON.parse(n);return{toString:()=>e,payload:i}}catch{throw new Error("Invalid token payload")}}var pr=e=>{let t=Reflect.ownKeys(e);for(let o of t){let r=e[o];(r&&typeof r=="object"||typeof r=="function")&&pr(r)}return Object.freeze(e)};var Ba=new C("parseAWSExports"),Ha={API_KEY:"apiKey",AWS_IAM:"iam",AMAZON_COGNITO_USER_POOLS:"userPool",OPENID_CONNECT:"oidc",NONE:"none",AWS_LAMBDA:"lambda",LAMBDA:"lambda"},xn=(e={})=>{if(!Object.prototype.hasOwnProperty.call(e,"aws_project_region"))throw new U({name:"InvalidParameterException",message:"Invalid config parameter.",recoverySuggestion:"Ensure passing the config object imported from `amplifyconfiguration.json`."});let{aws_appsync_apiKey:t,aws_appsync_authenticationType:o,aws_appsync_graphqlEndpoint:r,aws_appsync_region:n,aws_bots_config:i,aws_cognito_identity_pool_id:s,aws_cognito_sign_up_verification_method:a,aws_cognito_mfa_configuration:c,aws_cognito_mfa_types:d,aws_cognito_password_protection_settings:u,aws_cognito_verification_mechanisms:p,aws_cognito_signup_attributes:l,aws_cognito_social_providers:m,aws_cognito_username_attributes:h,aws_mandatory_sign_in:I,aws_mobile_analytics_app_id:A,aws_mobile_analytics_app_region:S,aws_user_files_s3_bucket:M,aws_user_files_s3_bucket_region:H,aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing:le,aws_user_pools_id:ie,aws_user_pools_web_client_id:Ee,geo:F,oauth:nt,predictions:de,aws_cloud_logic_custom:yt,Notifications:Et,modelIntrospection:Fe}=e,$={};A&&($.Analytics={Pinpoint:{appId:A,region:S}});let{InAppMessaging:x,Push:X}=Et??{};if(x?.AWSPinpoint||X?.AWSPinpoint){if(x?.AWSPinpoint){let{appId:L,region:it}=x.AWSPinpoint;$.Notifications={InAppMessaging:{Pinpoint:{appId:L,region:it}}}}if(X?.AWSPinpoint){let{appId:L,region:it}=X.AWSPinpoint;$.Notifications={...$.Notifications,PushNotification:{Pinpoint:{appId:L,region:it}}}}}if(Array.isArray(i)&&($.Interactions={LexV1:Object.fromEntries(i.map(L=>[L.name,L]))}),r){let L=Ha[o];L||Ba.debug(`Invalid authentication type ${o}. Falling back to IAM.`),$.API={GraphQL:{endpoint:r,apiKey:t,region:n,defaultAuthMode:L??"iam"}},Fe&&($.API.GraphQL.modelIntrospection=Fe)}let ro=c?{status:c&&c.toLowerCase(),totpEnabled:d?.includes("TOTP")??!1,smsEnabled:d?.includes("SMS")??!1}:void 0,Pa=u?{minLength:u.passwordPolicyMinLength,requireLowercase:u.passwordPolicyCharacters?.includes("REQUIRES_LOWERCASE")??!1,requireUppercase:u.passwordPolicyCharacters?.includes("REQUIRES_UPPERCASE")??!1,requireNumbers:u.passwordPolicyCharacters?.includes("REQUIRES_NUMBERS")??!1,requireSpecialCharacters:u.passwordPolicyCharacters?.includes("REQUIRES_SYMBOLS")??!1}:void 0,Ta=Array.from(new Set([...p??[],...l??[]])).reduce((L,it)=>({...L,[it.toLowerCase()]:{required:!0}}),{}),mn=h?.includes("EMAIL")??!1,fn=h?.includes("PHONE_NUMBER")??!1;(s||ie)&&($.Auth={Cognito:{identityPoolId:s,allowGuestAccess:I!=="enable",signUpVerificationMethod:a,userAttributes:Ta,userPoolClientId:Ee,userPoolId:ie,mfa:ro,passwordFormat:Pa,loginWith:{username:!(mn||fn),email:mn,phone:fn}}});let Ra=nt?Object.keys(nt).length>0:!1,_a=m?m.length>0:!1;if($.Auth&&Ra&&($.Auth.Cognito.loginWith={...$.Auth.Cognito.loginWith,oauth:{...Ka(nt),..._a&&{providers:Wa(m)}}}),M&&($.Storage={S3:{bucket:M,region:H,dangerouslyConnectToHttpEndpointForTesting:le}}),F){let{amazon_location_service:L}=F;$.Geo={LocationService:{maps:L.maps,geofenceCollections:L.geofenceCollections,searchIndices:L.search_indices,region:L.region}}}if(yt&&($.API={...$.API,REST:yt.reduce((L,it)=>{let{name:Na,endpoint:ba,region:gn,service:hn}=it;return{...L,[Na]:{endpoint:ba,...hn?{service:hn}:void 0,...gn?{region:gn}:void 0}}},{})}),de){let{VoiceId:L}=de?.convert?.speechGenerator?.defaults??{};$.Predictions=L?{...de,convert:{...de.convert,speechGenerator:{...de.convert.speechGenerator,defaults:{voiceId:L}}}}:de}return $},An=e=>e?.split(",")??[],Ka=({domain:e,scope:t,redirectSignIn:o,redirectSignOut:r,responseType:n})=>({domain:e,scopes:t,redirectSignIn:An(o),redirectSignOut:An(r),responseType:n}),Wa=e=>e.map(t=>{let o=t.toLowerCase();return o.charAt(0).toUpperCase()+o.slice(1)});var Mt=Symbol("oauth-listener");var ee=[];for(let e=0;e<256;++e)ee.push((e+256).toString(16).slice(1));function Cn(e,t=0){return(ee[e[t+0]]+ee[e[t+1]]+ee[e[t+2]]+ee[e[t+3]]+"-"+ee[e[t+4]]+ee[e[t+5]]+"-"+ee[e[t+6]]+ee[e[t+7]]+"-"+ee[e[t+8]]+ee[e[t+9]]+"-"+ee[e[t+10]]+ee[e[t+11]]+ee[e[t+12]]+ee[e[t+13]]+ee[e[t+14]]+ee[e[t+15]]).toLowerCase()}var vn=dr("crypto"),co=new Uint8Array(256),ao=co.length;function lr(){return ao>co.length-16&&((0,vn.randomFillSync)(co),ao=0),co.slice(ao,ao+=16)}var Pn=dr("crypto"),mr={randomUUID:Pn.randomUUID};function Va(e,t,o){if(mr.randomUUID&&!t&&!e)return mr.randomUUID();e=e||{};let r=e.random??e.rng?.()??lr();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(o=o||0,o<0||o+16>t.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[o+n]=r[n];return t}return Cn(r)}var fr=Va;function Rn(e){let{version:t}=e;return t?t.startsWith("1"):!1}function za(e){if(!e)return;let{bucket_name:t,aws_region:o,buckets:r}=e;return{S3:{bucket:t,region:o,buckets:r&&ec(r)}}}function qa(e){if(!e)return;let{user_pool_id:t,user_pool_client_id:o,identity_pool_id:r,password_policy:n,mfa_configuration:i,mfa_methods:s,unauthenticated_identities_enabled:a,oauth:c,username_attributes:d,standard_required_attributes:u,groups:p,passwordless:l}=e,m={Cognito:{userPoolId:t,userPoolClientId:o,groups:p}};return r&&(m.Cognito={...m.Cognito,identityPoolId:r}),n&&(m.Cognito.passwordFormat={requireLowercase:n.require_lowercase,requireNumbers:n.require_numbers,requireUppercase:n.require_uppercase,requireSpecialCharacters:n.require_symbols,minLength:n.min_length??6}),i&&(m.Cognito.mfa={status:Qa(i),smsEnabled:s?.includes("SMS"),totpEnabled:s?.includes("TOTP")}),a&&(m.Cognito.allowGuestAccess=a),c&&(m.Cognito.loginWith={oauth:{domain:c.domain,redirectSignIn:c.redirect_sign_in_uri,redirectSignOut:c.redirect_sign_out_uri,responseType:c.response_type==="token"?"token":"code",scopes:c.scopes,providers:Za(c.identity_providers)}}),d&&(m.Cognito.loginWith={...m.Cognito.loginWith,email:d.includes("email"),phone:d.includes("phone_number"),username:d.includes("username")}),u&&(m.Cognito.userAttributes=u.reduce((h,I)=>({...h,[I]:{required:!0}}),{})),l&&(m.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}),m}function $a(e){if(!e?.amazon_pinpoint)return;let{amazon_pinpoint:t}=e;return{Pinpoint:{appId:t.app_id,region:t.aws_region}}}function ja(e){if(!e)return;let{aws_region:t,geofence_collections:o,maps:r,search_indices:n}=e;return{LocationService:{region:t,searchIndices:n,geofenceCollections:o,maps:r}}}function Ga(e){if(!e)return;let{aws_region:t,default_authorization_type:o,url:r,api_key:n,model_introspection:i}=e;return{GraphQL:{endpoint:r,defaultAuthMode:Nn(o),region:t,apiKey:n,modelIntrospection:i}}}function Ya(e){if(!e?.events)return;let{url:t,aws_region:o,api_key:r,default_authorization_type:n}=e.events;return{Events:{endpoint:t,defaultAuthMode:Nn(n),region:o,apiKey:r}}}function Ja(e){if(!e)return;let{aws_region:t,channels:o,amazon_pinpoint_app_id:r}=e,n=o.includes("IN_APP_MESSAGING"),i=o.includes("APNS")||o.includes("FCM");if(!(n||i))return;let s={};return n&&(s.InAppMessaging={Pinpoint:{appId:r,region:t}}),i&&(s.PushNotification={Pinpoint:{appId:r,region:t}}),s}function _n(e){let t={};if(e.storage&&(t.Storage=za(e.storage)),e.auth&&(t.Auth=qa(e.auth)),e.analytics&&(t.Analytics=$a(e.analytics)),e.geo&&(t.Geo=ja(e.geo)),e.data&&(t.API=Ga(e.data)),e.custom){let o=Ya(e.custom);o&&"Events"in o&&(t.API={...t.API,...o})}return e.notifications&&(t.Notifications=Ja(e.notifications)),t}var Xa={AMAZON_COGNITO_USER_POOLS:"userPool",API_KEY:"apiKey",AWS_IAM:"iam",AWS_LAMBDA:"lambda",OPENID_CONNECT:"oidc"};function Nn(e){return Xa[e]}var Tn={GOOGLE:"Google",LOGIN_WITH_AMAZON:"Amazon",FACEBOOK:"Facebook",SIGN_IN_WITH_APPLE:"Apple"};function Za(e=[]){return e.reduce((t,o)=>(Tn[o]!==void 0&&t.push(Tn[o]),t),[])}function Qa(e){return e==="OPTIONAL"?"optional":e==="REQUIRED"?"on":"off"}function ec(e){let t={};return e.forEach(({name:o,bucket_name:r,aws_region:n,paths:i})=>{if(o in t)throw new Error(`Duplicate friendly name found: ${o}. Name must be unique.`);let s=i?Object.entries(i).reduce((a,[c,d])=>(d!==void 0&&(a[c]=d),a),{}):void 0;t[o]={bucketName:r,region:n,paths:s}}),t}var kt=e=>Object.keys(e).some(t=>t.startsWith("aws_"))?xn(e):Rn(e)?_n(e):e;function bn(e,t,o,r){function n(i){return i instanceof o?i:new o(function(s){s(i)})}return new(o||(o=Promise))(function(i,s){function a(u){try{d(r.next(u))}catch(p){s(p)}}function c(u){try{d(r.throw(u))}catch(p){s(p)}}function d(u){u.done?i(u.value):n(u.value).then(a,c)}d((r=r.apply(e,t||[])).next())})}function Un(e,t){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,n,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(d){return function(u){return c([d,u])}}function c(d){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,d[0]&&(o=0)),o;)try{if(r=1,n&&(i=d[0]&2?n.return:d[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,d[1])).done)return i;switch(n=0,i&&(d=[d[0]&2,i.value]),d[0]){case 0:case 1:i=d;break;case 4:return o.label++,{value:d[1],done:!1};case 5:o.label++,n=d[1],d=[0];continue;case 7:d=o.ops.pop(),o.trys.pop();continue;default:if(i=o.trys,!(i=i.length>0&&i[i.length-1])&&(d[0]===6||d[0]===2)){o=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){o.label=d[1];break}if(d[0]===6&&o.label<i[1]){o.label=i[1],i=d;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(d);break}i[2]&&o.ops.pop(),o.trys.pop();continue}d=t.call(e,o)}catch(u){d=[6,u],n=0}finally{r=i=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}var ae=64,On=32,Dn=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]),Mn=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],kn=Math.pow(2,53)-1;var Ft=(function(){function e(){this.state=Int32Array.from(Mn),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 o=0,r=t.byteLength;if(this.bytesHashed+=r,this.bytesHashed*8>kn)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;r>0;)this.buffer[this.bufferLength++]=t[o++],r--,this.bufferLength===ae&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var t=this.bytesHashed*8,o=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(o.setUint8(this.bufferLength++,128),r%ae>=ae-8){for(var n=this.bufferLength;n<ae;n++)o.setUint8(n,0);this.hashBuffer(),this.bufferLength=0}for(var n=this.bufferLength;n<ae-8;n++)o.setUint8(n,0);o.setUint32(ae-8,Math.floor(t/4294967296),!0),o.setUint32(ae-4,t),this.hashBuffer(),this.finished=!0}for(var i=new Uint8Array(On),n=0;n<8;n++)i[n*4]=this.state[n]>>>24&255,i[n*4+1]=this.state[n]>>>16&255,i[n*4+2]=this.state[n]>>>8&255,i[n*4+3]=this.state[n]>>>0&255;return i},e.prototype.hashBuffer=function(){for(var t=this,o=t.buffer,r=t.state,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],d=r[5],u=r[6],p=r[7],l=0;l<ae;l++){if(l<16)this.temp[l]=(o[l*4]&255)<<24|(o[l*4+1]&255)<<16|(o[l*4+2]&255)<<8|o[l*4+3]&255;else{var m=this.temp[l-2],h=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10;m=this.temp[l-15];var I=(m>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;this.temp[l]=(h+this.temp[l-7]|0)+(I+this.temp[l-16]|0)}var A=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&d^~c&u)|0)+(p+(Dn[l]+this.temp[l]|0)|0)|0,S=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&i^n&s^i&s)|0;p=u,u=d,d=c,c=a+A|0,a=s,s=i,i=n,n=A+S|0}r[0]+=n,r[1]+=i,r[2]+=s,r[3]+=a,r[4]+=c,r[5]+=d,r[6]+=u,r[7]+=p},e})();var gr=dr("buffer");var Fn=(e,t)=>{if(typeof e!="string")throw new TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?gr.Buffer.from(e,t):gr.Buffer.from(e)};var hr=e=>{let t=Fn(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)};var tc=typeof Buffer<"u"&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:hr;function uo(e){return e instanceof Uint8Array?e:typeof e=="string"?tc(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}function yr(e){return typeof e=="string"?e.length===0:e.byteLength===0}var Be=(function(){function e(t){this.secret=t,this.hash=new Ft,this.reset()}return e.prototype.update=function(t){if(!(yr(t)||this.error))try{this.hash.update(uo(t))}catch(o){this.error=o}},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 bn(this,void 0,void 0,function(){return Un(this,function(t){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new Ft,this.secret){this.outer=new Ft;var t=oc(this.secret),o=new Uint8Array(ae);o.set(t);for(var r=0;r<ae;r++)t[r]^=54,o[r]^=92;this.hash.update(t),this.outer.update(o);for(var r=0;r<t.byteLength;r++)t[r]=0}},e})();function oc(e){var t=uo(e);if(t.byteLength>ae){var o=new Ft;o.update(t),t=o.digest()}var r=new Uint8Array(ae);return r.set(t),r}var rc={},nc={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),rc[e]=t,nc[t]=e}var T;(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"})(T||(T={}));var Lt;(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"})(Lt||(Lt={}));var Er;(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"})(Er||(Er={}));var Sr;(function(e){e.Record="1",e.IdentifyUser="2"})(Sr||(Sr={}));var Ir;(function(e){e.GraphQl="1",e.Get="2",e.Post="3",e.Put="4",e.Patch="5",e.Del="6",e.Head="7"})(Ir||(Ir={}));var R;(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"})(R||(R={}));var wr;(function(e){e.Subscribe="1",e.GraphQl="2"})(wr||(wr={}));var Ar;(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"})(Ar||(Ar={}));var xr;(function(e){e.SyncMessages="1",e.IdentifyUser="2",e.NotifyMessageInteraction="3"})(xr||(xr={}));var Cr;(function(e){e.None="0"})(Cr||(Cr={}));var vr;(function(e){e.Convert="1",e.Identify="2",e.Interpret="3"})(vr||(vr={}));var Pr;(function(e){e.Subscribe="1"})(Pr||(Pr={}));var Tr;(function(e){e.InitializePushNotifications="1",e.IdentifyUser="2"})(Tr||(Tr={}));var Rr;(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"})(Rr||(Rr={}));var _r="6.16.2";var $e=()=>typeof global<"u";var me=()=>typeof window<"u",po=()=>typeof document<"u",St=()=>typeof process<"u",je=(e,t)=>!!Object.keys(e).find(o=>o.startsWith(t));function Ln(){let e=r=>r.startsWith("_react")||r.startsWith("__react"),t=r=>Object.keys(r).find(e),o=()=>Array.from(document.querySelectorAll("[id]"));return po()&&o().some(t)}function Bn(){return St()&&typeof process.env<"u"&&!!Object.keys(process.env).find(e=>e.includes("react"))}function Hn(){return me()&&je(window,"__VUE")}function Kn(){return $e()&&je(global,"__VUE")}function Wn(){return me()&&je(window,"__SVELTE")}function Vn(){return St()&&typeof process.env<"u"&&!!Object.keys(process.env).find(e=>e.includes("svelte"))}function zn(){return me()&&window.next&&typeof window.next=="object"}function qn(){return $e()&&(je(global,"__next")||je(global,"__NEXT"))}function $n(){return me()&&(window.__NUXT__!==void 0||window.$nuxt!==void 0)}function jn(){return $e()&&typeof global.__NUXT_PATHS__<"u"}function Gn(){let e=!!(po()&&document.querySelector("[ng-version]")),t=!!(me()&&typeof window.ng<"u");return e||t}function Yn(){return St()&&typeof process.env=="object"&&process.env.npm_lifecycle_script?.startsWith("ng ")||!1}function Jn(){return typeof navigator<"u"&&typeof navigator.product<"u"&&navigator.product==="ReactNative"}function Xn(){return $e()&&typeof global.expo<"u"}function Zn(){return me()}var ic=[{platform:T.Expo,detectionMethod:Xn},{platform:T.ReactNative,detectionMethod:Jn},{platform:T.NextJs,detectionMethod:zn},{platform:T.Nuxt,detectionMethod:$n},{platform:T.Angular,detectionMethod:Gn},{platform:T.React,detectionMethod:Ln},{platform:T.VueJs,detectionMethod:Hn},{platform:T.Svelte,detectionMethod:Wn},{platform:T.WebUnknown,detectionMethod:Zn},{platform:T.NextJsSSR,detectionMethod:qn},{platform:T.NuxtSSR,detectionMethod:jn},{platform:T.ReactSSR,detectionMethod:Bn},{platform:T.VueJsSSR,detectionMethod:Kn},{platform:T.AngularSSR,detectionMethod:Yn},{platform:T.SvelteSSR,detectionMethod:Vn}];function Qn(){return ic.find(e=>e.detectionMethod())?.platform||T.ServerSideUnknown}var Bt,lo=[],mo=!1,sc=10,ac=10,cc=1e3,fo=()=>{if(!Bt){if(Bt=Qn(),mo)for(;lo.length;)lo.pop()?.();else lo.forEach(e=>{e()});ei(T.ServerSideUnknown,sc),ei(T.WebUnknown,ac)}return Bt},ti=e=>{mo||lo.push(e)};function dc(){Bt=void 0}function ei(e,t){Bt===e&&!mo&&setTimeout(()=>{dc(),mo=!0,setTimeout(fo,cc)},t)}var uc={};var oi=(e,t)=>uc[e]?.[t]?.additionalDetails;var ri="aws-amplify",ni=e=>e.replace(/\+.*/,""),Nr=class{constructor(){this.userAgent=`${ri}/${ni(_r)}`}get framework(){return fo()}get isReactNative(){return this.framework===T.ReactNative||this.framework===T.Expo}observeFrameworkChanges(t){ti(t)}},pc=new Nr,ii=({category:e,action:t}={})=>{let o=[[ri,ni(_r)]];if(e&&o.push([e,t]),o.push(["framework",fo()]),e&&t){let r=oi(e,t);r&&r.forEach(n=>{o.push(n)})}return o},He=e=>ii(e).map(([r,n])=>r&&n?`${r}/${n}`:r).join(" ");var Ke=()=>typeof window<"u"&&typeof window.document<"u";var si=new C("Auth"),go=class{configure(t,o){this.authConfig=t,this.authOptions=o,t&&t.Cognito?.userPoolEndpoint&&si.warn(ai("Amazon Cognito User Pool")),t&&t.Cognito?.identityPoolEndpoint&&si.warn(ai("Amazon Cognito Identity Pool"))}async fetchAuthSession(t={}){let o,r,n=await this.getTokens(t);return n?(r=n.accessToken?.payload?.sub,o=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,tokens:n,authenticated:!0,forceRefresh:t.forceRefresh})):o=await this.authOptions?.credentialsProvider?.getCredentialsAndIdentityId({authConfig:this.authConfig,authenticated:!1,forceRefresh:t.forceRefresh}),{tokens:n,credentials:o?.credentials,identityId:o?.identityId,userSub:r}}async clearCredentials(){await this.authOptions?.credentialsProvider?.clearCredentialsAndIdentityId()}async getTokens(t){return await this.authOptions?.tokenProvider?.getTokens(t)??void 0}},ai=e=>`You are using a custom Amazon ${e} endpoint, ensure the endpoint is correct.`;var ho=class{constructor(){this.oAuthListener=void 0,this.isConfigured=!1,this.resourcesConfig={},this.libraryOptions={},this.Auth=new go}configure(t,o){let r=kt(t);this.resourcesConfig=r,o&&(this.libraryOptions=o),this.resourcesConfig=pr(this.resourcesConfig),this.Auth.configure(this.resourcesConfig.Auth,this.libraryOptions.Auth),(this.resourcesConfig.Analytics?.Pinpoint||this.resourcesConfig.Notifications?.InAppMessaging?.Pinpoint||this.resourcesConfig.Notifications?.PushNotification?.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."),Z.dispatch("core",{event:"configure",data:this.resourcesConfig},"Configure",j),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}[Mt](t){this.resourcesConfig.Auth?.Cognito.loginWith?.oauth?t(this.resourcesConfig.Auth?.Cognito):this.oAuthListener=t}notifyOAuthListener(){!this.resourcesConfig.Auth?.Cognito.loginWith?.oauth||!this.oAuthListener||(this.oAuthListener(this.resourcesConfig.Auth?.Cognito),this.oAuthListener=void 0)}},w=new ho;var ci=(e,t)=>e.Auth.fetchAuthSession(t);var yo=e=>ci(w,e);function Ht(){return w.Auth.clearCredentials()}var dt=e=>{let{headers:t,statusCode:o}=e;return{...lc(e)?e.$metadata:{},httpStatusCode:o,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"]}},lc=e=>typeof e?.$metadata=="object";var pe=async e=>{if(!e||e.statusCode<300)return;let t=await Re(e),r=(s=>{let[a]=s.toString().split(/[,:]+/);return a.includes("#")?a.split("#")[1]:a})(e.headers["x-amzn-errortype"]??t.code??t.__type??"UnknownError"),n=t.message??t.Message??"Unknown error",i=new Error(n);return Object.assign(i,{name:r,$metadata:dt(e)})},Re=async e=>{if(!e.body)throw new Error("Missing response payload");let t=await e.body.json();return Object.assign(t,{$metadata:dt(e)})};var b=(e,t,o,r)=>async(n,i)=>{let s={...r,...n},a=await s.endpointResolver(s,i),c=await t(i,a),d=await e(c,{...s});return o(d)};function di(e=3e5){return r=>{let n=2**r*100+100*Math.random();return n>e?!1:n}}var br="amz-sdk-invocation-id",ui="amz-sdk-request";var Kt=e=>{let o=di(3e5)(e);return o===!1?3e5:o};var fc=["AuthFailure","InvalidSignatureException","RequestExpired","RequestInTheFuture","RequestTimeTooSkewed","SignatureDoesNotMatch","BadRequestException"],pi=e=>!!e&&fc.includes(e);var Wt=e=>async(t,o)=>{let r=o??await e(t)??void 0,n=r?.code||r?.name,i=t?.statusCode;return{retryable:Ec(o)||yc(i,n)||pi(n)||Sc(i,n)}},gc=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException"],hc=["TimeoutError","RequestTimeout","RequestTimeoutException"],yc=(e,t)=>e===429||!!t&&gc.includes(t),Ec=e=>[ue.NetworkError,"ERR_NETWORK"].includes(e?.name),Sc=(e,t)=>!!e&&[500,502,503,504].includes(e)||!!t&&hc.includes(t);var Ur="cognito-identity",Eo={service:Ur,retryDecider:Wt(pe),computeDelay:Kt,cache:"no-store"};var fi=({maxAttempts:e=3,retryDecider:t,computeDelay:o,abortSignal:r})=>{if(e<1)throw new Error("maxAttempts must be greater than 0");return(n,i)=>async function(a){let c,d=i.attemptsCount??0,u,p=()=>{if(u)return li(u,d),u;throw li(c,d),c};for(;!r?.aborted&&d<e;){try{u=await n(a),c=void 0}catch(h){c=h,u=void 0}d=(i.attemptsCount??0)>d?i.attemptsCount??0:d+1,i.attemptsCount=d;let{isCredentialsExpiredError:l,retryable:m}=await t(u,c,i);if(m){if(i.isCredentialsExpired=!!l,!r?.aborted&&d<e){let h=o(d);await Ic(h,r)}continue}else return p()}if(r?.aborted)throw new Error("Request aborted.");return p()}},Ic=(e,t)=>{if(t?.aborted)return Promise.resolve();let o,r,n=new Promise(i=>{r=i,o=setTimeout(i,e)});return t?.addEventListener("abort",function i(s){clearTimeout(o),t?.removeEventListener("abort",i),r()}),n},li=(e,t)=>{Object.prototype.toString.call(e)==="[object Object]"&&(e.$metadata={...e.$metadata??{},attempts:t})};var gi=fr;var hi=()=>e=>async function(o){return o.headers[br]||(o.headers[br]=gi()),e(o)};var yi=({maxAttempts:e=3})=>(t,o)=>async function(n){let i=o.attemptsCount??0;return n.headers[ui]=`attempt=${i+1}; max=${e}`,t(n)};var Ei=({userAgentHeader:e="x-amz-user-agent",userAgentValue:t=""})=>o=>async function(n){if(t.trim().length===0)return await o(n);{let i=e.toLowerCase();return n.headers[i]=n.headers[i]?`${n.headers[i]} ${t}`:t,await o(n)}};var ut=(e,t)=>(o,r)=>{let n={},i=s=>e(s,r);for(let s=t.length-1;s>=0;s--){let a=t[s];i=a(r)(i,n)}return i(o)};var So=e=>{let t;return()=>(t||(t=e()),t)};var wc=e=>!["HEAD","GET"].includes(e.toUpperCase()),Si=async({url:e,method:t,headers:o,body:r},{abortSignal:n,cache:i,withCrossDomainCredentials:s})=>{let a;try{a=await fetch(e,{method:t,headers:o,body:wc(t)?r:void 0,signal:n,cache:i,credentials:s?"include":"same-origin"})}catch(p){throw p instanceof TypeError?new U({name:ue.NetworkError,message:"A network error has occurred.",underlyingError:p}):p}let c={};a.headers?.forEach((p,l)=>{c[l.toLowerCase()]=p});let d={statusCode:a.status,headers:c,body:null},u=Object.assign(a.body??{},{text:So(()=>a.text()),blob:So(()=>a.blob()),json:So(()=>a.json())});return{...d,body:u}};var Vt=ut(Si,[Ei,hi,fi,yi]);var Ii=()=>e=>async function(o){return o.headers["cache-control"]="no-store",e(o)};var Io=ut(Vt,[Ii]);var wo=e=>(t,o)=>{let r=Ac(e),n=JSON.stringify(t);return xc(o,r,n)},Ac=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityService.${e}`}),xc=({url:e},t,o)=>({headers:t,url:e,body:o,method:"POST"});var Ao=e=>b(Io,wo("GetCredentialsForIdentity"),Cc,{...Eo,...e,userAgentValue:He()}),Cc=async e=>{if(e.statusCode>=300)throw await pe(e);let t=await Re(e);return{IdentityId:t.IdentityId,Credentials:vc(t.Credentials),$metadata:dt(e)}},vc=({Expiration:e,...t}={})=>({...t,Expiration:e&&new Date(e*1e3)});var Or=e=>b(Io,wo("GetId"),Pc,{...Eo,...e,userAgentValue:He()}),Pc=async e=>{if(e.statusCode>=300)throw await pe(e);return{IdentityId:(await Re(e)).IdentityId,$metadata:dt(e)}};var Dr={id:"aws",outputs:{dnsSuffix:"amazonaws.com"},regionRegex:"^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$",regions:["aws-global"]},wi={partitions:[Dr,{id:"aws-cn",outputs:{dnsSuffix:"amazonaws.com.cn"},regionRegex:"^cn\\-\\w+\\-\\d+$",regions:["aws-cn-global"]}]};var zt=e=>{let{partitions:t}=wi;for(let{regions:o,outputs:r,regionRegex:n}of t){let i=new RegExp(n);if(o.includes(e)||i.test(e))return r.dnsSuffix}return Dr.outputs.dnsSuffix};var te=URL;var Mr=({region:e})=>({url:new te(`https://${Ur}.${e}.${zt(e)}`)});var We=class extends U{constructor(){super({name:ue.PlatformNotSupported,message:"Function not supported on current platform"})}};var _e=class{constructor(t){this.storage=t}async setItem(t,o){if(!this.storage)throw new We;this.storage.setItem(t,o)}async getItem(t){if(!this.storage)throw new We;return this.storage.getItem(t)}async removeItem(t){if(!this.storage)throw new We;this.storage.removeItem(t)}async clear(){if(!this.storage)throw new We;this.storage.clear()}};var pt=class{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,o){this.storage.set(t,o)}getItem(t){return this.storage.get(t)??null}removeItem(t){this.storage.delete(t)}clear(){this.storage.clear()}};var Ai=new C("CoreStorageUtils"),xo=()=>{try{if(typeof window<"u"&&window.localStorage)return window.localStorage}catch{Ai.info("localStorage not found. InMemoryStorage is used as a fallback.")}return new pt},Co=()=>{try{if(typeof window<"u"&&window.sessionStorage)return window.sessionStorage.getItem("test"),window.sessionStorage;throw new Error("sessionStorage is not defined")}catch{return Ai.info("sessionStorage not found. InMemoryStorage is used as a fallback."),new pt}};var vo=class extends _e{constructor(){super(xo())}};var Po=class extends _e{constructor(){super(Co())}};var To=class{constructor(t){this._storage=t}get storage(){if(!this._storage)throw new We;return this._storage}setItem(t,o){this.storage.setItem(t,o)}getItem(t){return this.storage.getItem(t)}removeItem(t){this.storage.removeItem(t)}clear(){this.storage.clear()}};var Ro=class extends To{constructor(){super(Co())}};function _o(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)e[r]=o[r]}return e}var Tc={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 kr(e,t){function o(n,i,s){if(!(typeof document>"u")){s=_o({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),n=encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=n+"="+e.write(i,n)+a}}function r(n){if(!(typeof document>"u"||arguments.length&&!n)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var c=i[a].split("="),d=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(s[u]=e.read(d,u),n===u)break}catch{}}return n?s[n]:s}}return Object.create({set:o,get:r,remove:function(n,i){o(n,"",_o({},i,{expires:-1}))},withAttributes:function(n){return kr(this.converter,_o({},this.attributes,n))},withConverter:function(n){return kr(_o({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var qt=kr(Tc,{path:"/"});var $t=class{constructor(t={}){let{path:o,domain:r,expires:n,sameSite:i,secure:s}=t;if(this.domain=r,this.path=o||"/",this.expires=Object.prototype.hasOwnProperty.call(t,"expires")?n:365,this.secure=Object.prototype.hasOwnProperty.call(t,"secure")?s:!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,o){qt.set(t,o,this.getData())}async getItem(t){return qt.get(t)??null}async removeItem(t){qt.remove(t,this.getData())}async clear(){let t=qt.get(),o=Object.keys(t).map(r=>this.removeItem(r));await Promise.all(o)}getData(){return{path:this.path,expires:this.expires,domain:this.domain,secure:this.secure,...this.sameSite&&{sameSite:this.sameSite}}}};var we=new vo,Rc=new Po,Ae=new Ro,_c=new _e(new pt);var Ge={keyPrefix:"aws-amplify-cache",capacityInBytes:1048576,itemMaxSize:21e4,defaultTTL:2592e5,defaultPriority:5,warningThreshold:.8},Ve="CurSize";function Fr(e){let t=0;t=e.length;for(let o=e.length;o>=0;o-=1){let r=e.charCodeAt(o);r>127&&r<=2047?t+=1:r>2047&&r<=65535&&(t+=2),r>=56320&&r<=57343&&(o-=1)}return t}function Ye(){return new Date().getTime()}var lt=e=>`${e}${Ve}`;var Je;(function(e){e.NoCacheItem="NoCacheItem",e.NullNextNode="NullNextNode",e.NullPreviousNode="NullPreviousNode"})(Je||(Je={}));var Nc={[Je.NoCacheItem]:{message:"Item not found in the cache storage."},[Je.NullNextNode]:{message:"Next node is null."},[Je.NullPreviousNode]:{message:"Previous node is null."}},Lr=Se(Nc);var k=new C("StorageCache"),No=class{constructor({config:t,keyValueStorage:o}){this.config={...Ge,...t},this.keyValueStorage=o,this.sanitizeConfig()}getModuleName(){return"Cache"}configure(t){return t&&(t.keyPrefix&&k.warn("keyPrefix can not be re-configured on an existing Cache instance."),this.config={...this.config,...t}),this.sanitizeConfig(),this.config}async getCurrentCacheSize(){let t=await this.getStorage().getItem(lt(this.config.keyPrefix));return t||(await this.getStorage().setItem(lt(this.config.keyPrefix),"0"),t="0"),Number(t)}async setItem(t,o,r){if(k.debug(`Set item: key is ${t}, value is ${o} with options: ${r}`),!t||t===Ve){k.warn(`Invalid key: should not be empty or reserved key: '${Ve}'`);return}if(typeof o>"u"){k.warn("The value of item should not be undefined!");return}let n={priority:r?.priority!==void 0?r.priority:this.config.defaultPriority,expires:r?.expires!==void 0?r.expires:this.config.defaultTTL+Ye()};if(n.priority<1||n.priority>5){k.warn("Invalid parameter: priority due to out or range. It should be within 1 and 5.");return}let i=`${this.config.keyPrefix}${t}`,s=this.fillCacheItem(i,o,n);if(s.byteSize>this.config.itemMaxSize){k.warn(`Item with key: ${t} you are trying to put into is too big!`);return}try{let a=await this.getStorage().getItem(i);if(a&&await this.removeCacheItem(i,JSON.parse(a).byteSize),await this.isCacheFull(s.byteSize)){let c=await this.clearInvalidAndGetRemainingKeys();if(await this.isCacheFull(s.byteSize)){let d=await this.sizeToPop(s.byteSize);await this.popOutItems(c,d)}}return this.setCacheItem(i,s)}catch(a){k.warn(`setItem failed! ${a}`)}}async getItem(t,o){k.debug(`Get item: key is ${t} with options ${o}`);let r;if(!t||t===Ve)return k.warn(`Invalid key: should not be empty or reserved key: '${Ve}'`),null;let n=`${this.config.keyPrefix}${t}`;try{if(r=await this.getStorage().getItem(n),r!=null)if(await this.isExpired(n))await this.removeCacheItem(n,JSON.parse(r).byteSize);else return(await this.updateVisitedTime(JSON.parse(r),n)).data;if(o?.callback){let i=o.callback();return i!==null&&await this.setItem(t,i,o),i}return null}catch(i){return k.warn(`getItem failed! ${i}`),null}}async removeItem(t){if(k.debug(`Remove item: key is ${t}`),!t||t===Ve){k.warn(`Invalid key: should not be empty or reserved key: '${Ve}'`);return}let o=`${this.config.keyPrefix}${t}`;try{let r=await this.getStorage().getItem(o);r&&await this.removeCacheItem(o,JSON.parse(r).byteSize)}catch(r){k.warn(`removeItem failed! ${r}`)}}async getAllKeys(){try{return await this.getAllCacheKeys()}catch(t){return k.warn(`getAllkeys failed! ${t}`),[]}}getStorage(){return this.keyValueStorage}async isExpired(t){let o=await this.getStorage().getItem(t);Lr(o!==null,Je.NoCacheItem,`Key: ${t}`);let r=JSON.parse(o);return Ye()>=r.expires}async removeCacheItem(t,o){let r=await this.getStorage().getItem(t);Lr(r!==null,Je.NoCacheItem,`Key: ${t}`);let n=o??JSON.parse(r).byteSize;await this.decreaseCurrentSizeInBytes(n);try{await this.getStorage().removeItem(t)}catch(i){await this.increaseCurrentSizeInBytes(n),k.error(`Failed to remove item: ${i}`)}}fillCacheItem(t,o,r){let n={key:t,data:o,timestamp:Ye(),visitedTime:Ye(),priority:r.priority??0,expires:r.expires??0,type:typeof o,byteSize:0};return n.byteSize=Fr(JSON.stringify(n)),n.byteSize=Fr(JSON.stringify(n)),n}sanitizeConfig(){this.config.itemMaxSize>this.config.capacityInBytes&&(k.error("Invalid parameter: itemMaxSize. It should be smaller than capacityInBytes. Setting back to default."),this.config.itemMaxSize=Ge.itemMaxSize),(this.config.defaultPriority>5||this.config.defaultPriority<1)&&(k.error("Invalid parameter: defaultPriority. It should be between 1 and 5. Setting back to default."),this.config.defaultPriority=Ge.defaultPriority),(Number(this.config.warningThreshold)>1||Number(this.config.warningThreshold)<0)&&(k.error("Invalid parameter: warningThreshold. It should be between 0 and 1. Setting back to default."),this.config.warningThreshold=Ge.warningThreshold);let t=5*1024*1024;this.config.capacityInBytes>t&&(k.error("Cache Capacity should be less than 5MB. Setting back to default. Setting back to default."),this.config.capacityInBytes=Ge.capacityInBytes)}async increaseCurrentSizeInBytes(t){let o=await this.getCurrentCacheSize();await this.getStorage().setItem(lt(this.config.keyPrefix),(o+t).toString())}async decreaseCurrentSizeInBytes(t){let o=await this.getCurrentCacheSize();await this.getStorage().setItem(lt(this.config.keyPrefix),(o-t).toString())}async updateVisitedTime(t,o){return t.visitedTime=Ye(),await this.getStorage().setItem(o,JSON.stringify(t)),t}async setCacheItem(t,o){await this.increaseCurrentSizeInBytes(o.byteSize);try{await this.getStorage().setItem(t,JSON.stringify(o))}catch(r){await this.decreaseCurrentSizeInBytes(o.byteSize),k.error(`Failed to set item ${r}`)}}async sizeToPop(t){let r=await this.getCurrentCacheSize()+t-this.config.capacityInBytes,n=(1-this.config.warningThreshold)*this.config.capacityInBytes;return r>n?r:n}async isCacheFull(t){let o=await this.getCurrentCacheSize();return t+o>this.config.capacityInBytes}async popOutItems(t,o){let r=[],n=o;for(let i of t){let s=await this.getStorage().getItem(i);if(s!=null){let a=JSON.parse(s);r.push(a)}}r.sort((i,s)=>i.priority>s.priority?-1:i.priority<s.priority?1:i.visitedTime<s.visitedTime?-1:1);for(let i of r)if(await this.removeCacheItem(i.key,i.byteSize),n-=i.byteSize,n<=0)return}async clearInvalidAndGetRemainingKeys(){let t=[],o=await this.getAllCacheKeys({omitSizeKey:!0});for(let r of o)await this.isExpired(r)?await this.removeCacheItem(r):t.push(r);return t}async clear(){k.debug("Clear Cache");try{let t=await this.getAllKeys();for(let o of t){let r=`${this.config.keyPrefix}${o}`;await this.getStorage().removeItem(r)}}catch(t){k.warn(`clear failed! ${t}`)}}};var bc=new C("StorageCache"),bo=class e extends No{constructor(t){let o=xo();super({config:t,keyValueStorage:new _e(o)}),this.storage=o,this.getItem=this.getItem.bind(this),this.setItem=this.setItem.bind(this),this.removeItem=this.removeItem.bind(this)}async getAllCacheKeys(t){let{omitSizeKey:o}=t??{},r=[];for(let n=0;n<this.storage.length;n++){let i=this.storage.key(n);o&&i===lt(this.config.keyPrefix)||i?.startsWith(this.config.keyPrefix)&&r.push(i.substring(this.config.keyPrefix.length))}return r}createInstance(t){return(!t.keyPrefix||t.keyPrefix===Ge.keyPrefix)&&(bc.error("invalid keyPrefix, setting keyPrefix with timeStamp"),t.keyPrefix=Ye.toString()),new e(t)}};var Uc=new bo;var Oc=new C("I18n"),xi=class{constructor(){this._options=null,this._lang=null,this._dict={}}setDefaultLanguage(){!this._lang&&typeof window<"u"&&window&&window.navigator&&(this._lang=window.navigator.language),Oc.debug(this._lang)}setLanguage(t){this._lang=t}get(t,o=void 0){if(this.setDefaultLanguage(),!this._lang)return typeof o<"u"?o:t;let r=this._lang,n=this.getByLanguage(t,r);return n||(r.indexOf("-")>0&&(n=this.getByLanguage(t,r.split("-")[0])),n)?n:typeof o<"u"?o:t}getByLanguage(t,o,r=null){if(!o)return r;let n=this._dict[o];return n?n[t]:r}putVocabulariesForLanguage(t,o){let r=this._dict[t];r||(r=this._dict[t]={}),this._dict[t]={...r,...o}}putVocabularies(t){Object.keys(t).forEach(o=>{this.putVocabulariesForLanguage(o,t[o])})}};var Xe;(function(e){e.NotConfigured="NotConfigured"})(Xe||(Xe={}));var Dc={[Xe.NotConfigured]:{message:"i18n is not configured."}},jt=Se(Dc);var Ci=new C("I18n"),Uo={language:null},xe=null,Oo=class e{static configure(t){return Ci.debug("configure I18n"),t&&(Uo=Object.assign({},Uo,t.I18n||t),e.createInstance()),Uo}static getModuleName(){return"I18n"}static createInstance(){Ci.debug("create I18n instance"),!xe&&(xe=new xi)}static setLanguage(t){e.checkConfig(),jt(!!xe,Xe.NotConfigured),xe.setLanguage(t)}static get(t,o){return e.checkConfig()?(jt(!!xe,Xe.NotConfigured),xe.get(t,o)):typeof o>"u"?t:o}static putVocabulariesForLanguage(t,o){e.checkConfig(),jt(!!xe,Xe.NotConfigured),xe.putVocabulariesForLanguage(t,o)}static putVocabularies(t){e.checkConfig(),jt(!!xe,Xe.NotConfigured),xe.putVocabularies(t)}static checkConfig(){return xe||e.createInstance(),!0}};Oo.createInstance();var Br=e=>{let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=[],r=new Uint8Array(e);st().getRandomValues(r);for(let n of r)o.push(t[n%t.length]);return o.join("")};function Hr(e){return(e.match(/.{2}/g)||[]).map(o=>String.fromCharCode(parseInt(o,16))).join("")}function Kr(e){return e.split("").map(t=>t.charCodeAt(0).toString(16).padStart(2,"0")).join("")}var Wr=e=>{let t;return async(...o)=>t||(t=new Promise((r,n)=>{e(...o).then(i=>{r(i)}).catch(i=>{n(i)}).finally(()=>{t=void 0})}),t)};function Do({expiresAt:e,clockDrift:t,tolerance:o=5e3}){return Date.now()+t+o>e}var Vr=async()=>{let{userAgentData:e}=navigator;if(!e)return navigator.userAgent;let{platform:t="",platformVersion:o="",model:r="",architecture:n="",fullVersionList:i=[]}=await e.getHighEntropyValues(["platform","platformVersion","architecture","model","fullVersionList"]),s=i.map(c=>`${c.brand}/${c.version}`).join(";");return[t,o,n,r,t,s].filter(c=>c).join(" ")||navigator.userAgent};function vi(e){return Array.from(e,t=>String.fromCodePoint(t)).join("")}var fe={convert(e,t={urlSafe:!1,skipPadding:!1}){let o=typeof e=="string"?e:vi(e),r=In()(o);return t.urlSafe&&(r=r.replace(/\+/g,"-").replace(/\//g,"_")),t.skipPadding&&(r=r.replace(/=/g,"")),r}};function Pi(){return st().getRandomValues(new Uint32Array(1))[0]}function Mc(e){let{words:t}=e,{sigBytes:o}=e,r=[];for(let n=0;n<o;n++){let i=t[n>>>2]>>>24-n%4*8&255;r.push((i>>>4).toString(16)),r.push((i&15).toString(16))}return r.join("")}var Gt=class e{constructor(t,o){this.words=[];let r=t;r=this.words=r||[],o!==void 0?this.sigBytes=o:this.sigBytes=r.length*4}random(t){let o=[];for(let r=0;r<t;r+=4)o.push(Pi());return new e(o,t)}toString(){return Mc(this)}};var y;(function(e){e.EmptySignInUsername="EmptySignInUsername",e.EmptySignInPassword="EmptySignInPassword",e.CustomAuthSignInPassword="CustomAuthSignInPassword",e.EmptySignUpUsername="EmptySignUpUsername",e.EmptySignUpPassword="EmptySignUpPassword",e.EmptyConfirmSignUpUsername="EmptyConfirmSignUpUsername",e.EmptyConfirmSignUpCode="EmptyConfirmSignUpCode",e.EmptyResendSignUpCodeUsername="EmptyresendSignUpCodeUsername",e.EmptyChallengeResponse="EmptyChallengeResponse",e.EmptyConfirmResetPasswordUsername="EmptyConfirmResetPasswordUsername",e.EmptyConfirmResetPasswordNewPassword="EmptyConfirmResetPasswordNewPassword",e.EmptyConfirmResetPasswordConfirmationCode="EmptyConfirmResetPasswordConfirmationCode",e.EmptyResetPasswordUsername="EmptyResetPasswordUsername",e.EmptyVerifyTOTPSetupCode="EmptyVerifyTOTPSetupCode",e.EmptyConfirmUserAttributeCode="EmptyConfirmUserAttributeCode",e.IncorrectMFAMethod="IncorrectMFAMethod",e.EmptyUpdatePassword="EmptyUpdatePassword",e.InvalidPreferredChallenge="InvalidPreferredChallenge"})(y||(y={}));var Mo={[y.EmptyChallengeResponse]:{message:"challengeResponse is required to confirmSignIn"},[y.EmptyConfirmResetPasswordUsername]:{message:"username is required to confirmResetPassword"},[y.EmptyConfirmSignUpCode]:{message:"code is required to confirmSignUp"},[y.EmptyConfirmSignUpUsername]:{message:"username is required to confirmSignUp"},[y.EmptyConfirmResetPasswordConfirmationCode]:{message:"confirmationCode is required to confirmResetPassword"},[y.EmptyConfirmResetPasswordNewPassword]:{message:"newPassword is required to confirmResetPassword"},[y.EmptyResendSignUpCodeUsername]:{message:"username is required to confirmSignUp"},[y.EmptyResetPasswordUsername]:{message:"username is required to resetPassword"},[y.EmptySignInPassword]:{message:"password is required to signIn"},[y.EmptySignInUsername]:{message:"username is required to signIn"},[y.EmptySignUpPassword]:{message:"password is required to signUp"},[y.EmptySignUpUsername]:{message:"username is required to signUp"},[y.CustomAuthSignInPassword]:{message:"A password is not needed when signing in with CUSTOM_WITHOUT_SRP",recoverySuggestion:"Do not include a password in your signIn call."},[y.IncorrectMFAMethod]:{message:"Incorrect MFA method was chosen. It should be either SMS, TOTP, or EMAIL",recoverySuggestion:"Try to pass SMS, TOTP, or EMAIL as the challengeResponse"},[y.EmptyVerifyTOTPSetupCode]:{message:"code is required to verifyTotpSetup"},[y.EmptyUpdatePassword]:{message:"oldPassword and newPassword are required to changePassword"},[y.EmptyConfirmUserAttributeCode]:{message:"confirmation code is required to confirmUserAttribute"},[y.InvalidPreferredChallenge]:{message:"The preferred challenge is not enabled in your backend configuration",recoverySuggestion:"Ensure the authentication method is enabled in your Amplify backend configuration"}},q;(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"})(q||(q={}));var Ne;(function(e){e.SignInException="SignInException",e.OAuthSignInError="OAuthSignInException"})(Ne||(Ne={}));var g=class e extends U{constructor(t){super(t),this.constructor=e,Object.setPrototypeOf(this,e.prototype)}};function _(e,t){let{message:o,recoverySuggestion:r}=Mo[t];if(!e)throw new g({name:t,message:o,recoverySuggestion:r})}function v(e){let t=e?.split("_")[0];if(!e||e.indexOf("_")<0||!t||typeof t!="string")throw new g({name:"InvalidUserPoolId",message:"Invalid user pool id provided."});return t}function Yt(e){if(!e||!e.includes(":"))throw new g({name:"InvalidIdentityPoolIdException",message:"Invalid identity pool id provided.",recoverySuggestion:"Make sure a valid identityPoolId is given in the config."});return e.split(":")[0]}function zr(e){return Object.entries(e).map(([t,o])=>({Name:t,Value:o}))}var Ti;(function(e){e.ConcurrentModificationException="ConcurrentModificationException",e.ForbiddenException="ForbiddenException",e.InternalErrorException="InternalErrorException",e.InvalidParameterException="InvalidParameterException",e.NotAuthorizedException="NotAuthorizedException",e.ResourceNotFoundException="ResourceNotFoundException",e.SoftwareTokenMFANotFoundException="SoftwareTokenMFANotFoundException"})(Ti||(Ti={}));var Ri;(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"})(Ri||(Ri={}));var _i;(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"})(_i||(_i={}));var Ni;(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"})(Ni||(Ni={}));var bi;(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"})(bi||(bi={}));var Ui;(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"})(Ui||(Ui={}));var Oi;(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"})(Oi||(Oi={}));var Di;(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"})(Di||(Di={}));var Mi;(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"})(Mi||(Mi={}));var ki;(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"})(ki||(ki={}));var Fi;(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"})(Fi||(Fi={}));var Li;(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"})(Li||(Li={}));var Bi;(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"})(Bi||(Bi={}));var Hi;(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"})(Hi||(Hi={}));var Jt;(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"})(Jt||(Jt={}));var Ki;(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"})(Ki||(Ki={}));var Wi;(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"})(Wi||(Wi={}));var Vi;(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"})(Vi||(Vi={}));var ko;(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"})(ko||(ko={}));var zi;(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"})(zi||(zi={}));var qi;(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"})(qi||(qi={}));var $i;(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"})($i||($i={}));var ji;(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"})(ji||(ji={}));var Gi;(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"})(Gi||(Gi={}));var It="UserUnAuthenticatedException",Yi="UserAlreadyAuthenticatedException",Ji="DeviceMetadataNotFoundException",Fo="AutoSignInException",kc="InvalidRedirectException",Fc="InvalidAppSchemeException",Lc="InvalidPreferredRedirectUrlException",Xi=new g({name:kc,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."}),Qh=new g({name:Fc,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."}),Zi=new g({name:Lc,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."}),Bc="InvalidOriginException",Qi=new g({name:Bc,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."}),es="OAuthSignOutException",ts="TokenRefreshException",os="UnexpectedSignInInterruptionException";function Lo(e){if(!e||!e.accessToken)throw new g({name:It,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}function rs(e){if(!e||!e.idToken)throw new g({name:It,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."})}var Hc=new g({name:ts,message:`Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow.
|
|
2
2
|
Please change your oauth configuration to use 'code grant' flow.`,recoverySuggestion:`Please logout and change your Amplify configuration to use "code grant" flow.
|
|
3
|
-
E.g { responseType: 'code' }`}),Ag=new S({name:mo,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});Yp={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"}});function xg(e){return e?.signInDetails}var Zp,Qp=c(()=>{"use strict";C();ee();Zp=async e=>{let t=e.getConfig().Auth?.Cognito;f(t);let o=await e.Auth.getTokens({forceRefresh:!1});M(o);let{"cognito:username":r,sub:n}=o.idToken?.payload??{},i={username:r,userId:n},s=xg(o);return s&&(i.signInDetails=s),i}});var uo,Xr=c(()=>{"use strict";U();Qp();uo=async()=>Zp(h)});var w,B=c(()=>{"use strict";C();w=(e,t)=>yt({category:Oo.Auth,action:e,...t})});var K=c(()=>{"use strict";xr();Tr()});var T,Pg,vg,j=c(()=>{"use strict";T=e=>(t,o)=>{let r=Pg(e),n=JSON.stringify(t);return vg(o,r,n)},Pg=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}),vg=({url:e},t,o)=>({headers:t,url:e,body:o,method:"POST"})});var eo=c(()=>{"use strict";Ti();Ci();Si();Ii();Lo()});function Q(e){if(!e||e.name==="Error"||e instanceof TypeError)throw new S({name:Me.Unknown,message:"An unknown error has occurred.",underlyingError:e})}var Fe=c(()=>{"use strict";C();$()});var b,Z=c(()=>{"use strict";eo();Fe();$();b=()=>async e=>{if(e.statusCode>=300){let t=await we(e);throw Q(t),new S({name:t.name,message:t.message,metadata:t.$metadata})}return st(e)}});var Tg,R,J=c(()=>{"use strict";K();eo();Tg=()=>(e,t)=>async function(r){return r.headers["cache-control"]="no-store",e(r)},R=Yt(Ho,[Tg])});var Zr,Hi=c(()=>{"use strict";Zr="cognito-idp"});var _,Y=c(()=>{"use strict";eo();C();Hi();_={service:Zr,retryDecider:Bo(we),computeDelay:Vo,get userAgentValue(){return yt()},cache:"no-store"}});var Lt,Qr=c(()=>{"use strict";K();j();Z();J();Y();Lt=e=>v(R,T("InitiateAuth"),b(),{..._,...e})});var ae,Vt=c(()=>{"use strict";K();J();j();Z();Y();ae=e=>v(R,T("RespondToAuthChallenge"),b(),{..._,...e})});var en,Wi=c(()=>{"use strict";K();J();j();Z();Y();en=e=>v(R,T("VerifySoftwareToken"),b(),{..._,...e})});var tn,Ki=c(()=>{"use strict";K();J();j();Z();Y();tn=e=>v(R,T("AssociateSoftwareToken"),b(),{..._,...e})});var em,tm=c(()=>{"use strict";eo();C();Hi();em=({region:e})=>({url:new xe(`https://${Zr}.${e}.${Wo(e)}`)})});var y,V=c(()=>{"use strict";C();tm();y=({endpointOverride:e})=>t=>e?{url:new xe(e)}:em(t)});var om,rm=c(()=>{"use strict";K();j();Z();J();Y();om=e=>v(R,T("GetTokensFromRefreshToken"),b(),{..._,...e})});var Rg,nm,im=c(()=>{"use strict";C();F();ee();$();V();rm();Rg=async({tokens:e,authConfig:t,username:o,clientMetadata:r})=>{f(t?.Cognito);let{userPoolId:n,userPoolClientId:i,userPoolEndpoint:s}=t.Cognito,a=E(n);Yr(e);let p=om({endpointResolver:y({endpointOverride:s})}),{AuthenticationResult:m}=await p({region:a},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:e.deviceMetadata?.deviceKey,ClientMetadata:r}),d=ge(m?.AccessToken??""),u=m?.IdToken?ge(m.IdToken):void 0,{iat:l}=d.payload;if(!l)throw new S({name:"iatNotFoundException",message:"iat not found in access token"});let g=l*1e3-new Date().getTime();return{accessToken:d,idToken:u,clockDrift:g,refreshToken:m?.RefreshToken??e.refreshToken,username:o}},nm=Vi(Rg)});var sm,am=c(()=>{"use strict";sm={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"}});var Zo,_g,cm,pm=c(()=>{"use strict";C();(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(Zo||(Zo={}));_g={[Zo.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},cm=je(_g)});var zi,mm=c(()=>{"use strict";zi="CognitoIdentityServiceProvider"});function Qo(e){let t=Object.values({...e});return(o,r)=>t.reduce((n,i)=>({...n,[i]:`${o}.${r}.${i}`}),{})}var on,Ug,rn=c(()=>{"use strict";C();$();am();pm();mm();on=class{getKeyValueStorage(){if(!this.keyValueStorage)throw new S({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{let t=await this.getAuthKeys(),o=await this.getKeyValueStorage().getItem(t.accessToken);if(!o)throw new S({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});let r=ge(o),n=await this.getKeyValueStorage().getItem(t.idToken),i=n?ge(n):void 0,s=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",p=Number.parseInt(a),m=await this.getKeyValueStorage().getItem(t.signInDetails),d={accessToken:r,idToken:i,refreshToken:s,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:p,username:await this.getLastAuthUser()};return m&&(d.signInDetails=JSON.parse(m)),d}catch{return null}}async storeTokens(t){cm(t!==void 0,Zo.InvalidAuthTokens);let o=t.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),o);let r=await this.getAuthKeys();await this.getKeyValueStorage().setItem(r.accessToken,t.accessToken.toString()),t.idToken?await this.getKeyValueStorage().setItem(r.idToken,t.idToken.toString()):await this.getKeyValueStorage().removeItem(r.idToken),t.refreshToken?await this.getKeyValueStorage().setItem(r.refreshToken,t.refreshToken):await this.getKeyValueStorage().removeItem(r.refreshToken),t.deviceMetadata&&(t.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(r.deviceKey,t.deviceMetadata.deviceKey),t.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(r.deviceGroupKey,t.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(r.randomPasswordKey,t.deviceMetadata.randomPassword)),t.signInDetails?await this.getKeyValueStorage().setItem(r.signInDetails,JSON.stringify(t.signInDetails)):await this.getKeyValueStorage().removeItem(r.signInDetails),await this.getKeyValueStorage().setItem(r.clockDrift,`${t.clockDrift}`)}async clearTokens(){let 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){let o=await this.getAuthKeys(t),r=await this.getKeyValueStorage().getItem(o.deviceKey),n=await this.getKeyValueStorage().getItem(o.deviceGroupKey),i=await this.getKeyValueStorage().getItem(o.randomPasswordKey);return i&&n&&r?{deviceKey:r,deviceGroupKey:n,randomPassword:i}:null}async clearDeviceMetadata(t){let o=await this.getAuthKeys(t);await Promise.all([this.getKeyValueStorage().removeItem(o.deviceKey),this.getKeyValueStorage().removeItem(o.deviceGroupKey),this.getKeyValueStorage().removeItem(o.randomPasswordKey)])}async getAuthKeys(t){f(this.authConfig?.Cognito);let o=t??await this.getLastAuthUser();return Ug(zi,`${this.authConfig.Cognito.userPoolClientId}.${o}`)}getLastAuthUserKey(){f(this.authConfig?.Cognito);let t=this.authConfig.Cognito.userPoolClientId;return`${zi}.${t}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(t){let{oauthMetadata:o}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(o,JSON.stringify(t))}async getOAuthMetadata(){let{oauthMetadata:t}=await this.getAuthKeys(),o=await this.getKeyValueStorage().getItem(t);return o&&JSON.parse(o)}},Ug=(e,t)=>Qo(sm)(`${e}`,t)});var dm,ct,lo,pt,Gi=c(()=>{"use strict";C();rn();ee();dm="amplify-signin-with-hostedUI",ct="CognitoIdentityServiceProvider",lo=class{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(t.inflightOAuth),this.keyValueStorage.removeItem(t.oauthPKCE),this.keyValueStorage.removeItem(t.oauthState)])}async clearOAuthData(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(dm),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){f(this.cognitoConfig);let o=pt(ct,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(o.oauthState,t)}loadPKCE(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){f(this.cognitoConfig);let o=pt(ct,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(o.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){f(this.cognitoConfig);let o=pt(ct,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.inflightOAuth,`${t}`)}async loadOAuthSignIn(){f(this.cognitoConfig);let t=pt(ct,this.cognitoConfig.userPoolClientId),o=await this.keyValueStorage.getItem(dm),[r,n]=(await this.keyValueStorage.getItem(t.oauthSignIn))?.split(",")??[];return{isOAuthSignIn:r==="true"||o==="true",preferPrivateSession:n==="true"}}async storeOAuthSignIn(t,o=!1){f(this.cognitoConfig);let r=pt(ct,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(r.oauthSignIn,`${t},${o}`)}},pt=(e,t)=>Qo(Yp)(e,t)});var ce,to=c(()=>{"use strict";U();Gi();ce=new lo(Ye)});var qi,um,nn,sn=c(()=>{"use strict";qi=[],um=e=>{qi.push(e)},nn=()=>{for(;qi.length;)qi.pop()?.()}});var an,lm=c(()=>{"use strict";U();C();Fe();$();to();sn();an=class{constructor(){this.waitForInflightOAuth=St()?async()=>{if(await ce.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,o)=>{um(t)}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){ce.setAuthConfig(t.Cognito),this.authConfig=t}setTokenRefresher(t){this.tokenRefresher=t}setAuthTokenStore(t){this.tokenStore=t}getTokenStore(){if(!this.tokenStore)throw new S({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new S({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}setClientMetadataProvider(t){this.clientMetadataProvider=t}async getTokens(t){let o;try{f(this.authConfig?.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,o=await this.getTokenStore().loadTokens();let r=await this.getTokenStore().getLastAuthUser();if(o===null)return null;let n=!!o?.idToken&&zr({expiresAt:(o.idToken?.payload?.exp??0)*1e3,clockDrift:o.clockDrift??0}),i=zr({expiresAt:(o.accessToken?.payload?.exp??0)*1e3,clockDrift:o.clockDrift??0});return(t?.forceRefresh||n||i)&&(o=await this.refreshTokens({tokens:o,username:r,clientMetadata:t?.clientMetadata??await this.clientMetadataProvider?.()}),o===null)?null:{accessToken:o?.accessToken,idToken:o?.idToken,signInDetails:o?.signInDetails}}async refreshTokens({tokens:t,username:o,clientMetadata:r}){try{let{signInDetails:n}=t,i=await this.getTokenRefresher()({tokens:t,authConfig:this.authConfig,username:o,clientMetadata:r});return i.signInDetails=n,await this.setTokens({tokens:i}),Ee.dispatch("auth",{event:"tokenRefresh"},"Auth",fe),i}catch(n){return this.handleErrors(n)}}handleErrors(t){if(Q(t),this.isAuthenticationError(t)&&this.clearTokens(),Ee.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(r=>t?.name?.startsWith?.(r))}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()}}});var cn,fm=c(()=>{"use strict";U();im();rn();lm();cn=class{constructor(){this.authTokenStore=new on,this.authTokenStore.setKeyValueStorage(Ye),this.tokenOrchestrator=new an,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(nm)}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)}}});var oo,H,Pe=c(()=>{"use strict";fm();oo=new cn,{tokenOrchestrator:H}=oo});async function Ie(e){if(e.AccessToken){let t=ge(e.AccessToken),o=(t.payload.iat||0)*1e3,r=new Date().getTime(),n=o>0?o-r:0,i,s,a;e.RefreshToken&&(s=e.RefreshToken),e.IdToken&&(i=ge(e.IdToken)),e?.NewDeviceMetadata&&(a=e.NewDeviceMetadata);let p={accessToken:t,idToken:i,refreshToken:s,clockDrift:n,deviceMetadata:a,username:e.username};e?.signInDetails&&(p.signInDetails=e.signInDetails),await H.setTokens({tokens:p})}else throw new te({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}var Ct=c(()=>{"use strict";C();Pe()});var Ng,Ce,wt=c(()=>{"use strict";U();C();Xr();Ft();$();Ng="Unable to get user session following successful sign-in.",Ce=async()=>{try{Ee.dispatch("auth",{event:"signedIn",data:await uo()},"Auth",fe)}catch(e){throw e.name===mo?new S({name:jp,message:Ng,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 gm(){return{active:!1}}var bg,Og,Ke,er=c(()=>{"use strict";bg=(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 gm();default:return e}},Og=e=>{let t=e(gm(),{type:"RESET"});return{getState:()=>t,dispatch:o=>{t=e(t,o)}}},Ke=Og(bg)});function be(e){Ne.dispatch({type:"SET_SIGN_IN_STATE",value:e})}var Dg,pn,xt,kg,Mg,Ae,hm,$i,Fg,Lg,Ne,mn,mt=c(()=>{"use strict";U();Dg=180*1e3,pn="CognitoSignInState",xt={username:`${pn}.username`,challengeName:`${pn}.challengeName`,signInSession:`${pn}.signInSession`,expiry:`${pn}.expiry`},kg=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return mn({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return mn(t.value),{...t.value};case"SET_CHALLENGE_NAME":return mn({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return mn({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return Fg();case"RESET_STATE":return hm(),$i();default:return e}},Mg=e=>{let t=Number(e),o=Date.now();return t<=o},Ae=()=>{Ne.dispatch({type:"RESET_STATE"})},hm=()=>{for(let e of Object.values(xt))Xe.removeItem(e)},$i=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),Fg=()=>{let e=Xe.getItem(xt.expiry);if(!e||Mg(e))return hm(),$i();let t=Xe.getItem(xt.username)??void 0,o=Xe.getItem(xt.challengeName)??void 0,r=Xe.getItem(xt.signInSession)??void 0;return{username:t,challengeName:o,signInSession:r}},Lg=e=>{let t=e($i(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:o=>{t=e(t,o)}}},Ne=Lg(kg);mn=({challengeName:e,signInSession:t,username:o})=>{o&&Xe.setItem(xt.username,o),e&&Xe.setItem(xt.challengeName,e),t&&(Xe.setItem(xt.signInSession,t),Xe.setItem(xt.expiry,String(Date.now()+Dg)))}});var ji,Em=c(()=>{"use strict";ji="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported."});var Oe,L,Ji,ym,Pt,Qe,vt=c(()=>{"use strict";C();Em();Oe=class e extends te{constructor(t){super(t),this.constructor=e,Object.setPrototypeOf(this,e.prototype)}};(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"})(L||(L={}));Ji="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",ym="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",Pt={[L.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:ji},[L.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:ym},[L.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:ym},[L.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:ji},[L.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."},[L.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[L.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:Ji},[L.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:Ji},[L.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:Ji},[L.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},Qe=je(Pt,Oe)});var dn,Yi=c(()=>{"use strict";C();vt();dn=e=>{if(e instanceof Error){if(e.name==="AbortError"){let{message:t,recoverySuggestion:o}=Pt[L.PasskeyOperationAborted];return new Oe({name:L.PasskeyOperationAborted,message:t,recoverySuggestion:o,underlyingError:e})}if(e.name==="SecurityError"){let{message:t,recoverySuggestion:o}=Pt[L.RelyingPartyMismatch];return new Oe({name:L.RelyingPartyMismatch,message:t,recoverySuggestion:o,underlyingError:e})}}return new Oe({name:Me.Unknown,message:"An unknown error has occurred.",underlyingError:e})}});var Sm,Im=c(()=>{"use strict";Yi();vt();Sm=e=>{if(e instanceof Oe)return e;if(e instanceof Error&&e.name==="NotAllowedError"){let{message:t,recoverySuggestion:o}=Pt[L.PasskeyAuthenticationCanceled];return new Oe({name:L.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:o,underlyingError:e})}return dn(e)}});var un,Xi=c(()=>{"use strict";C();un=()=>St()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function"});var et,Am=c(()=>{"use strict";C();et=e=>We.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0})});var fo,Cm=c(()=>{"use strict";C();fo=e=>Uint8Array.from($t.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer});var wm,xm,Pm,vm,Zi=c(()=>{"use strict";Am();Cm();wm=e=>{let t=fo(e.user.id),o=fo(e.challenge),r=(e.excludeCredentials||[]).map(n=>({...n,id:fo(n.id)}));return{...e,excludeCredentials:r,challenge:o,user:{...e.user,id:t}}},xm=e=>{let t={clientDataJSON:et(e.response.clientDataJSON),attestationObject:et(e.response.attestationObject),transports:e.response.getTransports(),publicKeyAlgorithm:e.response.getPublicKeyAlgorithm(),authenticatorData:et(e.response.getAuthenticatorData())},o=e.response.getPublicKey();o&&(t.publicKey=et(o));let r={type:e.type,id:e.id,rawId:et(e.rawId),clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(r.authenticatorAttachment=e.authenticatorAttachment),r},Pm=e=>{let t=fo(e.challenge),o=(e.allowCredentials||[]).map(r=>({...r,id:fo(r.id)}));return{...e,challenge:t,allowCredentials:o}},vm=e=>{let t={clientDataJSON:et(e.response.clientDataJSON),authenticatorData:et(e.response.authenticatorData),signature:et(e.response.signature)};e.response.userHandle&&(t.userHandle=et(e.response.userHandle));let o={id:e.id,rawId:et(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(o.authenticatorAttachment=e.authenticatorAttachment),o}});function Tm(e){Qe([!!e,!!e?.challenge,!!e?.user,!!e?.rp,!!e?.pubKeyCredParams].every(Boolean),L.InvalidPasskeyRegistrationOptions)}var Rm=c(()=>{"use strict";vt()});function _m(e){Qe(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAttestationResponse,L.PasskeyRegistrationFailed)}function Um(e){Qe(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,L.PasskeyRetrievalFailed)}var Qi=c(()=>{"use strict";vt()});var Nm,bm=c(()=>{"use strict";Im();vt();Xi();Zi();Qi();Nm=async e=>{try{let t=un();Qe(t,L.PasskeyNotSupported);let o=Pm(e),r=await navigator.credentials.get({publicKey:o});return Um(r),vm(r)}catch(t){throw Sm(t)}}});var Om,Dm=c(()=>{"use strict";K();J();j();Z();Y();Om=e=>v(R,T("ConfirmDevice"),b(),{..._,...e})});var go,es=c(()=>{"use strict";go={convert(e){return new TextEncoder().encode(e)}}});function x(e,t){e!=null&&this.fromString(e,t)}function ve(){return new x(null,null)}function Bg(e,t,o,r,n,i){for(;--i>=0;){let s=t*this[e++]+o[r]+n;n=Math.floor(s/67108864),o[r++]=s&67108863}return n}function Hg(e,t,o,r,n,i){let s=t&32767,a=t>>15;for(;--i>=0;){let p=this[e]&32767,m=this[e++]>>15,d=a*p+m*s;p=s*p+((d&32767)<<15)+o[r]+(n&1073741823),n=(p>>>30)+(d>>>15)+a*m+(n>>>30),o[r++]=p&1073741823}return n}function Wg(e,t,o,r,n,i){let s=t&16383,a=t>>14;for(;--i>=0;){let p=this[e]&16383,m=this[e++]>>14,d=a*p+m*s;p=s*p+((d&16383)<<14)+o[r]+n,n=(p>>28)+(d>>14)+a*m,o[r++]=p&268435455}return n}function Fm(e){return Kg.charAt(e)}function zg(e,t){let o=ln[e.charCodeAt(t)];return o??-1}function Gg(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function qg(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 os(e){let t=ve();return t.fromInt(e),t}function $g(e,t){let o;if(t===16)o=4;else if(t===8)o=3;else if(t===2)o=1;else if(t===32)o=5;else if(t===4)o=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let r=e.length,n=!1,i=0;for(;--r>=0;){let s=zg(e,r);if(s<0){e.charAt(r)==="-"&&(n=!0);continue}n=!1,i===0?this[this.t++]=s:i+o>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,i+=o,i>=this.DB&&(i-=this.DB)}this.clamp(),n&&x.ZERO.subTo(this,this)}function jg(){let e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function Jg(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");let o=(1<<t)-1,r,n=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(n=!0,i=Fm(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&o,a<=0&&(a+=this.DB,--s)),r>0&&(n=!0),n&&(i+=Fm(r));return n?i:"0"}function Yg(){let e=ve();return x.ZERO.subTo(this,e),e}function Xg(){return this.s<0?this.negate():this}function Zg(e){let t=this.s-e.s;if(t!=0)return t;let o=this.t;if(t=o-e.t,t!=0)return this.s<0?-t:t;for(;--o>=0;)if((t=this[o]-e[o])!=0)return t;return 0}function rs(e){let t=1,o;return(o=e>>>16)!==0&&(e=o,t+=16),(o=e>>8)!==0&&(e=o,t+=8),(o=e>>4)!==0&&(e=o,t+=4),(o=e>>2)!==0&&(e=o,t+=2),(o=e>>1)!==0&&(e=o,t+=1),t}function Qg(){return this.t<=0?0:this.DB*(this.t-1)+rs(this[this.t-1]^this.s&this.DM)}function eh(e,t){let o;for(o=this.t-1;o>=0;--o)t[o+e]=this[o];for(o=e-1;o>=0;--o)t[o]=0;t.t=this.t+e,t.s=this.s}function th(e,t){for(let o=e;o<this.t;++o)t[o-e]=this[o];t.t=Math.max(this.t-e,0),t.s=this.s}function oh(e,t){let o=e%this.DB,r=this.DB-o,n=(1<<r)-1,i=Math.floor(e/this.DB),s=this.s<<o&this.DM,a;for(a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>r|s,s=(this[a]&n)<<o;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}function rh(e,t){t.s=this.s;let o=Math.floor(e/this.DB);if(o>=this.t){t.t=0;return}let r=e%this.DB,n=this.DB-r,i=(1<<r)-1;t[0]=this[o]>>r;for(let s=o+1;s<this.t;++s)t[s-o-1]|=(this[s]&i)<<n,t[s-o]=this[s]>>r;r>0&&(t[this.t-o-1]|=(this.s&i)<<n),t.t=this.t-o,t.clamp()}function nh(e,t){let o=0,r=0,n=Math.min(e.t,this.t);for(;o<n;)r+=this[o]-e[o],t[o++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;o<this.t;)r+=this[o],t[o++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;o<e.t;)r-=e[o],t[o++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[o++]=this.DV+r:r>0&&(t[o++]=r),t.t=o,t.clamp()}function ih(e,t){let o=this.abs(),r=e.abs(),n=o.t;for(t.t=n+r.t;--n>=0;)t[n]=0;for(n=0;n<r.t;++n)t[n+o.t]=o.am(0,r[n],t,n,0,o.t);t.s=0,t.clamp(),this.s!==e.s&&x.ZERO.subTo(t,t)}function sh(e){let t=this.abs(),o=e.t=2*t.t;for(;--o>=0;)e[o]=0;for(o=0;o<t.t-1;++o){let r=t.am(o,t[o],e,2*o,0,1);(e[o+t.t]+=t.am(o+1,2*t[o],e,2*o+1,r,t.t-o-1))>=t.DV&&(e[o+t.t]-=t.DV,e[o+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(o,t[o],e,2*o,0,1)),e.s=0,e.clamp()}function ah(e,t,o){let r=e.abs();if(r.t<=0)return;let n=this.abs();if(n.t<r.t){t?.fromInt(0),o!=null&&this.copyTo(o);return}o===null&&(o=ve());let i=ve(),s=this.s,a=e.s,p=this.DB-rs(r[r.t-1]);p>0?(r.lShiftTo(p,i),n.lShiftTo(p,o)):(r.copyTo(i),n.copyTo(o));let m=i.t,d=i[m-1];if(d===0)return;let u=d*(1<<this.F1)+(m>1?i[m-2]>>this.F2:0),l=this.FV/u,g=(1<<this.F1)/u,A=1<<this.F2,N=o.t,D=N-m,O=t===null?ve():t;for(i.dlShiftTo(D,O),o.compareTo(O)>=0&&(o[o.t++]=1,o.subTo(O,o)),x.ONE.dlShiftTo(m,O),O.subTo(i,i);i.t<m;)i[i.t++]=0;for(;--D>=0;){let oe=o[--N]===d?this.DM:Math.floor(o[N]*l+(o[N-1]+A)*g);if((o[N]+=i.am(0,oe,o,D,0,m))<oe)for(i.dlShiftTo(D,O),o.subTo(O,o);o[N]<--oe;)o.subTo(O,o)}t!==null&&(o.drShiftTo(m,t),s!==a&&x.ZERO.subTo(t,t)),o.t=m,o.clamp(),p>0&&o.rShiftTo(p,o),s<0&&x.ZERO.subTo(o,o)}function ch(e){let t=ve();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(x.ZERO)>0&&e.subTo(t,t),t}function ph(){if(this.t<1)return 0;let e=this[0];if((e&1)===0)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 mh(e){return this.compareTo(e)===0}function dh(e,t){let o=0,r=0,n=Math.min(e.t,this.t);for(;o<n;)r+=this[o]+e[o],t[o++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;o<this.t;)r+=this[o],t[o++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;o<e.t;)r+=e[o],t[o++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[o++]=r:r<-1&&(t[o++]=this.DV+r),t.t=o,t.clamp()}function uh(e){let t=ve();return this.addTo(e,t),t}function lh(e){let t=ve();return this.subTo(e,t),t}function fh(e){let t=ve();return this.multiplyTo(e,t),t}function gh(e){let t=ve();return this.divRemTo(e,t,null),t}function Eo(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 hh(e){let t=ve();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(x.ZERO)>0&&this.m.subTo(t,t),t}function Eh(e){let t=ve();return e.copyTo(t),this.reduce(t),t}function yh(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(let t=0;t<this.m.t;++t){let o=e[t]&32767,r=o*this.mpl+((o*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(o=t+this.m.t,e[o]+=this.m.am(0,r,e,t,0,this.m.t);e[o]>=e.DV;)e[o]-=e.DV,e[++o]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Sh(e,t){e.squareTo(t),this.reduce(t)}function Ih(e,t,o){e.multiplyTo(t,o),this.reduce(o)}function Ah(e,t,o){let r=e.bitLength(),n,i=os(1),s=new Eo(t);if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6;let a=[],p=3,m=n-1,d=(1<<n)-1;if(a[1]=s.convert(this),n>1){let O=ve();for(s.sqrTo(a[1],O);p<=d;)a[p]=ve(),s.mulTo(O,a[p-2],a[p]),p+=2}let u=e.t-1,l,g=!0,A=ve(),N;for(r=rs(e[u])-1;u>=0;){for(r>=m?l=e[u]>>r-m&d:(l=(e[u]&(1<<r+1)-1)<<m-r,u>0&&(l|=e[u-1]>>this.DB+r-m)),p=n;(l&1)===0;)l>>=1,--p;if((r-=p)<0&&(r+=this.DB,--u),g)a[l].copyTo(i),g=!1;else{for(;p>1;)s.sqrTo(i,A),s.sqrTo(A,i),p-=2;p>0?s.sqrTo(i,A):(N=i,i=A,A=N),s.mulTo(A,a[l],i)}for(;u>=0&&(e[u]&1<<r)===0;)s.sqrTo(i,A),N=i,i=A,A=N,--r<0&&(r=this.DB-1,--u)}let D=s.revert(i);return o(null,D),D}var Bt,Vg,km,Mm,ts,Kg,ln,ho,ze,Ht=c(()=>{"use strict";Vg=0xdeadbeefcafe,km=(Vg&16777215)===15715070;Mm=typeof navigator<"u";Mm&&km&&navigator.appName==="Microsoft Internet Explorer"?(x.prototype.am=Hg,Bt=30):Mm&&km&&navigator.appName!=="Netscape"?(x.prototype.am=Bg,Bt=26):(x.prototype.am=Wg,Bt=28);x.prototype.DB=Bt;x.prototype.DM=(1<<Bt)-1;x.prototype.DV=1<<Bt;ts=52;x.prototype.FV=Math.pow(2,ts);x.prototype.F1=ts-Bt;x.prototype.F2=2*Bt-ts;Kg="0123456789abcdefghijklmnopqrstuvwxyz",ln=[];ho=48;for(ze=0;ze<=9;++ze)ln[ho++]=ze;ho=97;for(ze=10;ze<36;++ze)ln[ho++]=ze;ho=65;for(ze=10;ze<36;++ze)ln[ho++]=ze;Eo.prototype.convert=hh;Eo.prototype.revert=Eh;Eo.prototype.reduce=yh;Eo.prototype.mulTo=Ih;Eo.prototype.sqrTo=Sh;x.prototype.copyTo=Gg;x.prototype.fromInt=qg;x.prototype.fromString=$g;x.prototype.clamp=jg;x.prototype.dlShiftTo=eh;x.prototype.drShiftTo=th;x.prototype.lShiftTo=oh;x.prototype.rShiftTo=rh;x.prototype.subTo=nh;x.prototype.multiplyTo=ih;x.prototype.squareTo=sh;x.prototype.divRemTo=ah;x.prototype.invDigit=ph;x.prototype.addTo=dh;x.prototype.toString=Jg;x.prototype.negate=Yg;x.prototype.abs=Xg;x.prototype.compareTo=Zg;x.prototype.bitLength=Qg;x.prototype.mod=ch;x.prototype.equals=mh;x.prototype.add=uh;x.prototype.subtract=lh;x.prototype.multiply=fh;x.prototype.divide=gh;x.prototype.modPow=Ah;x.ZERO=os(0);x.ONE=os(1)});var Lm,Vm=c(()=>{"use strict";Lm=async({a:e,g:t,k:o,x:r,B:n,N:i,U:s})=>new Promise((a,p)=>{t.modPow(r,i,(m,d)=>{if(m){p(m);return}n.subtract(o.multiply(d)).modPow(e.add(s.multiply(r)),i,(u,l)=>{if(u){p(u);return}a(l.mod(i))})})})});var Bm,ns,fn,gn=c(()=>{"use strict";Bm="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",ns={},fn={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),ns[e]=t,fn[t]=e}});var dt,tr=c(()=>{"use strict";gn();dt=e=>{if(e.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let t=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2){let r=e.slice(o,o+2).toLowerCase();if(r in fn)t[o/2]=fn[r];else throw new Error(`Cannot decode unrecognized sequence ${r} as hexadecimal`)}return t}});var yo,hn=c(()=>{"use strict";gn();yo=e=>{let t="";for(let o=0;o<e.byteLength;o++)t+=ns[e[o]];return t}});var or,is=c(()=>{"use strict";se();hn();or=e=>{let t=new ht;t.update(e);let o=t.digestSync(),r=yo(o);return new Array(64-r.length).join("0")+r}});var So,ss=c(()=>{"use strict";tr();is();So=e=>or(dt(e))});var Ch,tt,as=c(()=>{"use strict";Ht();Ch=/^[89a-f]/i,tt=e=>{if(!(e instanceof x))throw new Error("Not a BigInteger");let t=e.compareTo(x.ZERO)<0,o=e.abs().toString(16);if(o=o.length%2!==0?`0${o}`:o,o=Ch.test(o)?`00${o}`:o,t){let r=o.split("").map(i=>{let s=~parseInt(i,16)&15;return"0123456789ABCDEF".charAt(s)}).join("");o=new x(r,16).add(x.ONE).toString(16),o.toUpperCase().startsWith("FF8")&&(o=o.substring(2))}return o}});var Hm,Wm=c(()=>{"use strict";Ht();ss();as();Hm=({A:e,B:t})=>{let o=new x(So(tt(e)+tt(t)),16);if(o.equals(x.ZERO))throw new Error("U cannot be zero.");return o}});var Km,zm=c(()=>{"use strict";se();Km=(e,t,o)=>{let r=new ht(t);r.update(e);let n=r.digestSync(),i=new ht(n);return i.update(o),i.digestSync().slice(0,16)}});var Io,En=c(()=>{"use strict";C();tr();Io=e=>{let t=new jo().random(e).toString();return dt(t)}});var Gm,qm=c(()=>{"use strict";C();En();Gm=()=>We.convert(Io(40))});var yn,$m=c(()=>{"use strict";$();es();Ht();Vm();Wm();tr();is();ss();hn();zm();as();En();qm();yn=class{constructor({userPoolName:t,a:o,g:r,A:n,N:i}){this.encoder=go,this.userPoolName=t,this.a=o,this.g=r,this.A=n,this.N=i,this.k=new x(So(`${tt(i)}${tt(r)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new S({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new S({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new S({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(t,o){this.randomPassword=Gm();let r=`${t}${o}:${this.randomPassword}`,n=or(r),i=yo(Io(16));return this.saltToHashDevices=tt(new x(i,16)),new Promise((s,a)=>{this.g.modPow(new x(So(this.saltToHashDevices+n),16),this.N,(p,m)=>{if(p){a(p);return}this.verifierDevices=tt(m),s()})})}async getPasswordAuthenticationKey({username:t,password:o,serverBValue:r,salt:n}){if(r.mod(this.N).equals(x.ZERO))throw new Error("B cannot be zero.");let i=Hm({A:this.A,B:r}),s=`${this.userPoolName}${t}:${o}`,a=or(s),p=new x(So(tt(n)+a),16),m=await Lm({a:this.a,g:this.g,k:this.k,x:p,B:r,N:this.N,U:i}),d=this.encoder.convert("Caldera Derived Key"),u=this.encoder.convert(""),l=new Uint8Array(d.byteLength+u.byteLength);return l.set(d,0),l.set(u,d.byteLength),Km(dt(tt(m)),dt(tt(i)),l)}}});var jm,Jm=c(()=>{"use strict";Ht();jm=async({a:e,g:t,N:o})=>new Promise((r,n)=>{t.modPow(e,o,(i,s)=>{if(i){n(i);return}if(s.mod(o).equals(x.ZERO)){n(new Error("Illegal parameter. A mod N cannot be 0."));return}r(s)})})});var ut,wh,Ao=c(()=>{"use strict";$m();Ht();Jm();gn();se();hn();En();ut=async e=>{let t=new x(Bm,16),o=new x("2",16),r=wh(),n=await jm({a:r,g:o,N:t});return new yn({userPoolName:e,a:r,g:o,A:n,N:t})},wh=()=>{let e=yo(Io(128));return new x(e,16)}});async function De({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:o,accessToken:r}){if(!o)return;let n=e.split("_")[1]||"",i=await ut(n),s=o?.DeviceKey,a=o?.DeviceGroupKey;try{await i.generateHashDevice(a??"",s??"")}catch{return}let p={Salt:We.convert(dt(i.getSaltToHashDevices())),PasswordVerifier:We.convert(dt(i.getVerifierDevices()))},m=i.getRandomPassword();try{return await Om({endpointResolver:y({endpointOverride:t})})({region:E(e)},{AccessToken:r,DeviceName:await Bi(),DeviceKey:o?.DeviceKey,DeviceSecretVerifierConfig:p}),{deviceKey:s,deviceGroupKey:a,randomPassword:m}}catch{return}}var Wt=c(()=>{"use strict";C();Dm();V();F();Ao();tr();se()});async function Ym(e){let t=h.getConfig().Auth?.Cognito;f(t);let{username:o,signInSession:r,signInDetails:n,challengeName:i}=Ne.getState();if(i!=="WEB_AUTHN"||!o)throw new S({name:Ue.SignInException,message:"Unable to proceed due to invalid sign in state."});let{CREDENTIAL_REQUEST_OPTIONS:s}=e;Qe(!!s,L.InvalidPasskeyAuthenticationOptions);let a=await Nm(JSON.parse(s)),p=ae({endpointResolver:y({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:m,ChallengeParameters:d,AuthenticationResult:u,Session:l}=await p({region:E(t.userPoolId),userAgentValue:w(I.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:o,CREDENTIAL:JSON.stringify(a)},ClientId:t.userPoolClientId,Session:r});if(be({signInSession:l,username:o,challengeName:m,signInDetails:n}),u)return await Ie({...u,username:o,NewDeviceMetadata:await De({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:n}),Ne.dispatch({type:"RESET_STATE"}),await Ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(m==="WEB_AUTHN")throw new S({name:Ue.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:m,challengeParameters:d}}var Xm=c(()=>{"use strict";U();C();Mt();$();Vt();F();V();Ct();wt();mt();B();vt();bm();Wt()});function z({username:e,userPoolId:t,userPoolClientId:o}){if(typeof window>"u")return;let r=window.AmazonCognitoAdvancedSecurityData;if(typeof r>"u")return;let n=r.getData(e,t,o);return n?{EncodedData:n}:{}}var Le=c(()=>{"use strict"});var xh,Ph,Sn,cs=c(()=>{"use strict";xh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ph=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Sn=()=>{let e=new Date,t=Ph[e.getUTCDay()],o=xh[e.getUTCMonth()],r=e.getUTCDate(),n=e.getUTCHours();n<10&&(n=`0${n}`);let i=e.getUTCMinutes();i<10&&(i=`0${i}`);let s=e.getUTCSeconds();s<10&&(s=`0${s}`);let a=e.getUTCFullYear();return`${t} ${o} ${r} ${n}:${i}:${s} UTC ${a}`}});var In,vh,ps=c(()=>{"use strict";se();C();es();In=({userPoolName:e,username:t,challengeParameters:o,dateNow:r,hkdf:n})=>{let i=go.convert(e),s=go.convert(t),a=vh(o.SECRET_BLOCK),p=go.convert(r),m=new Uint8Array(i.byteLength+s.byteLength+a.byteLength+p.byteLength);m.set(i,0),m.set(s,i.byteLength),m.set(a,i.byteLength+s.byteLength),m.set(p,i.byteLength+s.byteLength+a.byteLength);let d=new ht(n);d.update(m);let u=d.digestSync();return We.convert(u)},vh=e=>{let t="=".repeat((4-e.length%4)%4),o=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=$t.convert(o),n=new Uint8Array(r.length);for(let i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n}});async function ro({username:e,config:t,clientMetadata:o,session:r,tokenOrchestrator:n}){let{userPoolId:i,userPoolEndpoint:s}=t,a=t.userPoolClientId,p=await n?.getDeviceMetadata(e);Qt(p);let m=await ut(p.deviceGroupKey),d={USERNAME:e,SRP_A:m.A.toString(16),DEVICE_KEY:p.deviceKey},u={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:d,ClientMetadata:o,Session:r},l=ae({endpointResolver:y({endpointOverride:s})}),{ChallengeParameters:g,Session:A}=await l({region:E(i)},u);return Th(e,g,o,A,m,t,n)}async function Th(e,t,o,r,n,{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a},p){let m=await p?.getDeviceMetadata(e);Qt(m);let d=new x(t?.SRP_B,16),u=new x(t?.SALT,16),{deviceKey:l}=m,{deviceGroupKey:g}=m,A=await n.getPasswordAuthenticationKey({username:m.deviceKey,password:m.randomPassword,serverBValue:d,salt:u}),N=Sn(),D={USERNAME:t?.USERNAME??e,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:N,PASSWORD_CLAIM_SIGNATURE:In({username:l,userPoolName:g,challengeParameters:t,dateNow:N,hkdf:A}),DEVICE_KEY:l},O=z({username:e,userPoolId:i,userPoolClientId:s}),oe={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:s,ChallengeResponses:D,Session:r,ClientMetadata:o,UserContextData:O};return ae({endpointResolver:y({endpointOverride:a})})({region:E(i)},oe)}var ms=c(()=>{"use strict";Vt();V();F();ee();Ao();cs();ps();Ht();Le()});async function Co(e,t,o,r,n,i,s){let{userPoolId:a,userPoolClientId:p,userPoolEndpoint:m}=i,d=a?.split("_")[1]||"",u=new x(t?.SRP_B,16),l=new x(t?.SALT,16),g=t?.USER_ID_FOR_SRP;if(!g)throw new S({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});let A=await n.getPasswordAuthenticationKey({username:g,password:e,serverBValue:u,salt:l}),N=Sn(),D={USERNAME:g,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:N,PASSWORD_CLAIM_SIGNATURE:In({username:g,userPoolName:d,challengeParameters:t,dateNow:N,hkdf:A})},O=await s.getDeviceMetadata(g);O&&O.deviceKey&&(D.DEVICE_KEY=O.deviceKey);let oe=z({username:g,userPoolId:a,userPoolClientId:p}),ie={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:D,ClientMetadata:o,Session:r,ClientId:p,UserContextData:oe},Te=await ae({endpointResolver:y({endpointOverride:m})})({region:E(a)},ie);return Te.ChallengeName==="DEVICE_SRP_AUTH"?ro({username:g,config:i,clientMetadata:o,session:Te.Session,tokenOrchestrator:s}):Te}var An=c(()=>{"use strict";$();Vt();V();F();Ht();se();cs();ps();Le();ms()});async function ot(e,t,o,r){try{return await e(...t)}catch(n){if(n instanceof S&&n.name==="ResourceNotFoundException"&&n.message.includes("Device does not exist."))return await r.clearDeviceMetadata(o),e(...t);throw n}}var wo=c(()=>{"use strict";$()});function Ge(e){let{dispatch:t}=Ne;t({type:"SET_USERNAME",value:e})}var xo=c(()=>{"use strict";mt()});async function Cn({username:e,password:t,clientMetadata:o,config:r,tokenOrchestrator:n,authFlow:i,preferredChallenge:s}){let{userPoolId:a,userPoolClientId:p,userPoolEndpoint:m}=r,d=a?.split("_")[1]||"",u=await ut(d),l={USERNAME:e,SRP_A:u.A.toString(16)};i==="USER_AUTH"&&s&&(l.PREFERRED_CHALLENGE=s);let g=z({username:e,userPoolId:a,userPoolClientId:p}),A={AuthFlow:i,AuthParameters:l,ClientMetadata:o,ClientId:p,UserContextData:g},D=await Lt({endpointResolver:y({endpointOverride:m})})({region:E(a),userAgentValue:w(I.SignIn)},A),{ChallengeParameters:O,Session:oe}=D,ie=O?.USERNAME??e;return Ge(ie),D.ChallengeName==="PASSWORD_VERIFIER"?ot(Co,[t,O,o,oe,u,r,n],ie,n):D}var ds=c(()=>{"use strict";C();Le();Ao();se();Qr();V();F();B();An();wo();xo()});async function Zm({username:e,session:t,selectedChallenge:o,config:r,clientMetadata:n}){return ae({endpointResolver:y({endpointOverride:r.userPoolEndpoint})})({region:E(r.userPoolId),userAgentValue:w(I.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:{USERNAME:e,ANSWER:o},ClientId:r.userPoolClientId,Session:t,ClientMetadata:n})}var Qm=c(()=>{"use strict";C();Vt();V();F();B()});async function ed(e,t,o,r,n){let{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a}=r,p={ANSWER:"PASSWORD",USERNAME:e,PASSWORD:t},m=z({username:e,userPoolId:i,userPoolClientId:s}),u=await ae({endpointResolver:y({endpointOverride:a})})({region:E(i),userAgentValue:w(I.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:p,ClientId:s,ClientMetadata:o,Session:n,UserContextData:m}),l=u.ChallengeParameters?.USERNAME??e;return Ge(l),u}var td=c(()=>{"use strict";C();Vt();V();F();B();Le();xo()});async function od(e,t,o,r,n,i){let{userPoolId:s,userPoolClientId:a,userPoolEndpoint:p}=r,m=s.split("_")[1]||"",d=await ut(m),u={ANSWER:"PASSWORD_SRP",USERNAME:e,SRP_A:d.A.toString(16)},l=z({username:e,userPoolId:s,userPoolClientId:a}),A=await ae({endpointResolver:y({endpointOverride:p})})({region:E(s),userAgentValue:w(I.ConfirmSignIn)},{ChallengeName:"SELECT_CHALLENGE",ChallengeResponses:u,ClientId:a,ClientMetadata:o,Session:n,UserContextData:l}),N=A.ChallengeParameters?.USERNAME??e;return Ge(N),A.ChallengeName==="PASSWORD_VERIFIER"?ot(Co,[t,A.ChallengeParameters,o,A.Session,d,r,i],N,i):A}var rd=c(()=>{"use strict";C();Vt();V();F();B();Ao();se();Le();xo();wo();An()});function Rh(e){return"isSignedIn"in e&&"nextStep"in e}async function _h({challengeResponse:e,clientMetadata:t,session:o,username:r,config:n,tokenOrchestrator:i}){let{userPoolId:s,userPoolClientId:a,userPoolEndpoint:p}=n,m={USERNAME:r,ANSWER:e},d=await i?.getDeviceMetadata(r);d&&d.deviceKey&&(m.DEVICE_KEY=d.deviceKey);let u=z({username:r,userPoolId:s,userPoolClientId:a}),l={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:m,Session:o,ClientMetadata:t,ClientId:a,UserContextData:u},A=await ae({endpointResolver:y({endpointOverride:p})})({region:E(s),userAgentValue:w(I.ConfirmSignIn)},l);return A.ChallengeName==="DEVICE_SRP_AUTH"?ro({username:r,config:n,clientMetadata:t,session:A.Session,tokenOrchestrator:i}):A}async function Uh({challengeResponse:e,username:t,clientMetadata:o,session:r,deviceName:n,config:i}){let{userPoolId:s,userPoolClientId:a,userPoolEndpoint:p}=i;if(e==="EMAIL")return{ChallengeName:"MFA_SETUP",Session:r,ChallengeParameters:{MFAS_CAN_SETUP:'["EMAIL_OTP"]'},$metadata:{}};if(e==="TOTP")return{ChallengeName:"MFA_SETUP",Session:r,ChallengeParameters:{MFAS_CAN_SETUP:'["SOFTWARE_TOKEN_MFA"]'},$metadata:{}};let m={USERNAME:t};if(/^\d+$/.test(e)){let l=en({endpointResolver:y({endpointOverride:p})}),{Session:g}=await l({region:E(s),userAgentValue:w(I.ConfirmSignIn)},{UserCode:e,Session:r,FriendlyDeviceName:n});Ne.dispatch({type:"SET_SIGN_IN_SESSION",value:g});let A={ChallengeName:"MFA_SETUP",ChallengeResponses:m,Session:g,ClientMetadata:o,ClientId:a};return ae({endpointResolver:y({endpointOverride:p})})({region:E(s),userAgentValue:w(I.ConfirmSignIn)},A)}if(e.includes("@")){m.EMAIL=e;let l={ChallengeName:"MFA_SETUP",ChallengeResponses:m,Session:r,ClientMetadata:o,ClientId:a};return ae({endpointResolver:y({endpointOverride:p})})({region:E(s),userAgentValue:w(I.ConfirmSignIn)},l)}throw new S({name:Ue.SignInException,message:`Cannot proceed with MFA setup using challengeResponse: ${e}`,recoverySuggestion:'Try passing "EMAIL", "TOTP", a valid email, or OTP code as the challengeResponse.'})}async function Nh({challengeResponse:e,username:t,clientMetadata:o,session:r,config:n}){let{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a}=n;k(e==="TOTP"||e==="SMS"||e==="EMAIL",P.IncorrectMFAMethod);let p={USERNAME:t,ANSWER:kh(e)},m=z({username:t,userPoolId:i,userPoolClientId:s}),d={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:p,Session:r,ClientMetadata:o,ClientId:s,UserContextData:m};return ae({endpointResolver:y({endpointOverride:a})})({region:E(i),userAgentValue:w(I.ConfirmSignIn)},d)}async function bh({challengeResponse:e,clientMetadata:t,session:o,username:r,requiredAttributes:n,config:i}){let{userPoolId:s,userPoolClientId:a,userPoolEndpoint:p}=i,m={...Dh(n),NEW_PASSWORD:e,USERNAME:r},d=z({username:r,userPoolId:s,userPoolClientId:a}),u={ChallengeName:"NEW_PASSWORD_REQUIRED",ChallengeResponses:m,ClientMetadata:t,Session:o,ClientId:a,UserContextData:d};return ae({endpointResolver:y({endpointOverride:p})})({region:E(s),userAgentValue:w(I.ConfirmSignIn)},u)}async function id(e,t,o,r,n){let{userPoolClientId:i,userPoolId:s,userPoolEndpoint:a}=r,p={USERNAME:e,PASSWORD:t},m=await n.getDeviceMetadata(e);m&&m.deviceKey&&(p.DEVICE_KEY=m.deviceKey);let d=z({username:e,userPoolId:s,userPoolClientId:i}),u={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:p,ClientMetadata:o,ClientId:i,UserContextData:d},g=await Lt({endpointResolver:y({endpointOverride:a})})({region:E(s),userAgentValue:w(I.SignIn)},u),A=g.ChallengeParameters?.USERNAME??g.ChallengeParameters?.USER_ID_FOR_SRP??e;return Ge(A),g.ChallengeName==="DEVICE_SRP_AUTH"?ro({username:A,config:r,clientMetadata:o,session:g.Session,tokenOrchestrator:n}):g}async function sd(e,t,o,r,n){return Cn({username:e,password:t,clientMetadata:o,config:r,tokenOrchestrator:n,authFlow:"USER_SRP_AUTH"})}async function ad(e,t,o,r){let{userPoolClientId:n,userPoolId:i,userPoolEndpoint:s}=o,a={USERNAME:e},p=await r.getDeviceMetadata(e);p&&p.deviceKey&&(a.DEVICE_KEY=p.deviceKey);let m=z({username:e,userPoolId:i,userPoolClientId:n}),d={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:t,ClientId:n,UserContextData:m},l=await Lt({endpointResolver:y({endpointOverride:s})})({region:E(i),userAgentValue:w(I.SignIn)},d),g=l.ChallengeParameters?.USERNAME??e;return Ge(g),l.ChallengeName==="DEVICE_SRP_AUTH"?ro({username:g,config:o,clientMetadata:t,session:l.Session,tokenOrchestrator:r}):l}async function cd(e,t,o,r,n){f(r);let{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a}=r,p=i?.split("_")[1]||"",m=await ut(p),d={USERNAME:e,SRP_A:m.A.toString(16),CHALLENGE_NAME:"SRP_A"},u=z({username:e,userPoolId:i,userPoolClientId:s}),l={AuthFlow:"CUSTOM_AUTH",AuthParameters:d,ClientMetadata:o,ClientId:s,UserContextData:u},g=Lt({endpointResolver:y({endpointOverride:a})}),{ChallengeParameters:A,Session:N}=await g({region:E(i),userAgentValue:w(I.SignIn)},l),D=A?.USERNAME??e;return Ge(D),ot(Co,[t,A,o,N,m,r,n],D,n)}async function Ve(e){let{challengeName:t,challengeParameters:o,availableChallenges:r}=e,n=h.getConfig().Auth?.Cognito;switch(f(n),t){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:o}};case"MFA_SETUP":{let{signInSession:i,username:s}=Ne.getState(),a=wn(nd(o.MFAS_CAN_SETUP))||[],p=Mh(a),m=p.includes("TOTP"),d=p.includes("EMAIL");if(m&&d)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:p}};if(d)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(m){let u=tn({endpointResolver:y({endpointOverride:n.userPoolEndpoint})}),{Session:l,SecretCode:g}=await u({region:E(n.userPoolId)},{Session:i});return Ne.dispatch({type:"SET_SIGN_IN_SESSION",value:l}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:ls(g,s)}}}throw new S({name:Ue.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:Oh(o.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:wn(nd(o.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:o.CODE_DELIVERY_DELIVERY_MEDIUM,destination:o.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:o.CODE_DELIVERY_DELIVERY_MEDIUM,destination:o.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{let i=await Ym(o);return Rh(i)?i:Ve(i)}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:r}}}throw new S({name:Ue.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function ls(e,t){return{sharedSecret:e,getSetupUri:(o,r)=>{let n=`otpauth://totp/${o}:${r??t}?secret=${e}&issuer=${o}`;return new xe(n)}}}function qe(e){if(e===Xo.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===Xo.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function Oh(e){return e?JSON.parse(e).map(o=>o.includes(us)?o.replace(us,""):o):[]}function Dh(e){if(!e)return{};let t={};return Object.entries(e).forEach(([o,r])=>{r&&(t[`${us}${o}`]=r)}),t}async function pd(e,t,o,r,n,i,s,a){let p=a?.userAttributes,m=a?.friendlyDeviceName;switch(t){case"WEB_AUTHN":case"SELECT_CHALLENGE":return r==="PASSWORD_SRP"||r==="PASSWORD"?{ChallengeName:r,Session:o,$metadata:{}}:Zm({username:e,session:o,selectedChallenge:r,config:n,clientMetadata:s});case"SELECT_MFA_TYPE":return Nh({challengeResponse:r,clientMetadata:s,session:o,username:e,config:n});case"MFA_SETUP":return Uh({challengeResponse:r,clientMetadata:s,session:o,username:e,deviceName:m,config:n});case"NEW_PASSWORD_REQUIRED":return bh({challengeResponse:r,clientMetadata:s,session:o,username:e,requiredAttributes:p,config:n});case"CUSTOM_CHALLENGE":return ot(_h,[{challengeResponse:r,clientMetadata:s,session:o,username:e,config:n,tokenOrchestrator:i}],e,i);case"SMS_MFA":case"SOFTWARE_TOKEN_MFA":case"SMS_OTP":case"EMAIL_OTP":return Fh({challengeName:t,challengeResponse:r,clientMetadata:s,session:o,username:e,config:n,tokenOrchestrator:i});case"PASSWORD":return ed(e,r,s,n,o);case"PASSWORD_SRP":return od(e,r,s,n,o,i)}throw new S({name:Ue.SignInException,message:`An error occurred during the sign in process.
|
|
4
|
-
${t} challengeName returned by the underlying service was not addressed.`})}function kh(e){let t="SMS_MFA";return e==="TOTP"&&(t="SOFTWARE_TOKEN_MFA"),e==="EMAIL"&&(t="EMAIL_OTP"),t}function fs(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function wn(e){if(e)return e.map(fs).filter(Boolean)}function nd(e){return e?JSON.parse(e):[]}function Mh(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function xn(){let e;try{e=await uo()}catch{}if(e&&e.userId&&e.username)throw new S({name:Hp,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function lt(e){return Ne.getState().username??e}async function Fh({challengeName:e,challengeResponse:t,clientMetadata:o,session:r,username:n,config:i,tokenOrchestrator:s}){let{userPoolId:a,userPoolClientId:p,userPoolEndpoint:m}=i,d={USERNAME:n};e==="EMAIL_OTP"&&(d.EMAIL_OTP_CODE=t),e==="SMS_MFA"&&(d.SMS_MFA_CODE=t),e==="SMS_OTP"&&(d.SMS_OTP_CODE=t),e==="SOFTWARE_TOKEN_MFA"&&(d.SOFTWARE_TOKEN_MFA_CODE=t);let u=await s?.getDeviceMetadata(n);u&&u.deviceKey&&(d.DEVICE_KEY=u.deviceKey);let l=z({username:n,userPoolId:a,userPoolClientId:p}),g={ChallengeName:e,ChallengeResponses:d,Session:r,ClientMetadata:o,ClientId:p,UserContextData:l},N=await ae({endpointResolver:y({endpointOverride:m})})({region:E(a),userAgentValue:w(I.ConfirmSignIn)},g);return N.ChallengeName==="DEVICE_SRP_AUTH"?ro({username:n,config:i,clientMetadata:o,session:N.Session,tokenOrchestrator:s}):N}var us,rt=c(()=>{"use strict";U();C();$();jr();Mt();me();Se();Ft();Xr();B();Qr();Vt();Wi();Ki();V();F();Xm();ds();Qm();td();rd();mt();Ao();se();Le();An();ms();wo();xo();us="userAttributes."});async function md(e){let t=h.getConfig().Auth?.Cognito;f(t);let{username:o,password:r,options:n}=e,i={loginId:o,authFlowType:"CUSTOM_WITHOUT_SRP"},s=n?.clientMetadata;k(!!o,P.EmptySignInUsername),k(!r,P.CustomAuthSignInPassword);try{let{ChallengeName:a,ChallengeParameters:p,AuthenticationResult:m,Session:d}=await ot(ad,[o,s,t,H],o,H),u=lt(o);return be({signInSession:d,username:u,challengeName:a,signInDetails:i}),m?(await Ie({username:u,...m,NewDeviceMetadata:await De({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:m.NewDeviceMetadata,accessToken:m.AccessToken}),signInDetails:i}),Ae(),await Ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:a,challengeParameters:p})}catch(a){Ae(),Q(a);let p=qe(a.name);if(p)return p;throw a}}var dd=c(()=>{"use strict";U();C();me();Se();Fe();rt();mt();Ct();Pe();wt();wo();Wt()});async function ud(e){let{username:t,password:o,options:r}=e,n={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=h.getConfig().Auth?.Cognito;f(i);let s=r?.clientMetadata;k(!!t,P.EmptySignInUsername),k(!!o,P.EmptySignInPassword);try{let{ChallengeName:a,ChallengeParameters:p,AuthenticationResult:m,Session:d}=await cd(t,o,s,i,H),u=lt(t);return be({signInSession:d,username:u,challengeName:a,signInDetails:n}),m?(await Ie({username:u,...m,NewDeviceMetadata:await De({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:m.NewDeviceMetadata,accessToken:m.AccessToken}),signInDetails:n}),Ae(),await Ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:a,challengeParameters:p})}catch(a){Ae(),Q(a);let p=qe(a.name);if(p)return p;throw a}}var ld=c(()=>{"use strict";U();C();me();Se();Fe();rt();mt();Ct();Pe();wt();Wt()});function rr(e){Pn=e}function pe(e=!0){e&&(Pn=fd),Ke.dispatch({type:"RESET"})}var fd,Pn,Tt=c(()=>{"use strict";er();$();Ft();fd=async()=>{throw new S({name:Jr,message:"The autoSignIn flow has not started, or has been cancelled/completed.",recoverySuggestion:"Please try to use the signIn API or log out before starting a new autoSignIn flow."})},Pn=fd});async function gs(e){let{username:t,password:o}=e,r=h.getConfig().Auth?.Cognito,n={loginId:t,authFlowType:"USER_SRP_AUTH"};f(r);let i=e.options?.clientMetadata;k(!!t,P.EmptySignInUsername),k(!!o,P.EmptySignInPassword);try{let{ChallengeName:s,ChallengeParameters:a,AuthenticationResult:p,Session:m}=await sd(t,o,i,r,H),d=lt(t);return be({signInSession:m,username:d,challengeName:s,signInDetails:n}),p?(await Ie({username:d,...p,NewDeviceMetadata:await De({userPoolId:r.userPoolId,userPoolEndpoint:r.userPoolEndpoint,newDeviceMetadata:p.NewDeviceMetadata,accessToken:p.AccessToken}),signInDetails:n}),Ae(),await Ce(),pe(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:s,challengeParameters:a})}catch(s){Ae(),pe(),Q(s);let a=qe(s.name);if(a)return a;throw s}}var gd=c(()=>{"use strict";U();C();me();Se();Fe();rt();mt();Ct();Pe();wt();Wt();Tt()});async function hd(e){let{username:t,password:o,options:r}=e,n=h.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};f(n);let s=r?.clientMetadata;k(!!t,P.EmptySignInUsername),k(!!o,P.EmptySignInPassword);try{let{ChallengeName:a,ChallengeParameters:p,AuthenticationResult:m,Session:d}=await ot(id,[t,o,s,n,H],t,H),u=lt(t);return be({signInSession:d,username:u,challengeName:a,signInDetails:i}),m?(await Ie({...m,username:u,NewDeviceMetadata:await De({userPoolId:n.userPoolId,userPoolEndpoint:n.userPoolEndpoint,newDeviceMetadata:m.NewDeviceMetadata,accessToken:m.AccessToken}),signInDetails:i}),Ae(),await Ce(),pe(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:a,challengeParameters:p})}catch(a){Ae(),pe(),Q(a);let p=qe(a.name);if(p)return p;throw a}}var Ed=c(()=>{"use strict";U();C();me();Fe();Se();rt();mt();Ct();Pe();wt();wo();Wt();Tt()});async function yd({username:e,clientMetadata:t,config:o,tokenOrchestrator:r,preferredChallenge:n,password:i,session:s}){let{userPoolId:a,userPoolClientId:p,userPoolEndpoint:m}=o,d=z({username:e,userPoolId:a,userPoolClientId:p}),u={USERNAME:e};if(n){if(n==="PASSWORD_SRP")return k(!!i,P.EmptySignInPassword),Cn({username:e,password:i,clientMetadata:t,config:o,tokenOrchestrator:r,authFlow:"USER_AUTH",preferredChallenge:n});n==="PASSWORD"&&(k(!!i,P.EmptySignInPassword),u.PASSWORD=i),u.PREFERRED_CHALLENGE=n}let l={AuthFlow:"USER_AUTH",AuthParameters:u,ClientMetadata:t,ClientId:p,UserContextData:d};s&&(l.Session=s);let A=await Lt({endpointResolver:y({endpointOverride:m})})({region:E(a),userAgentValue:w(I.SignIn)},l);return Ge(e),A}var Sd=c(()=>{"use strict";C();Le();Qr();me();V();F();B();ds();Se();xo()});async function vn(e){let{username:t,password:o,options:r}=e,n=h.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};f(n);let s=r?.clientMetadata,a=r?.preferredChallenge;k(!!t,P.EmptySignInUsername);try{let p={username:t,config:n,tokenOrchestrator:H,clientMetadata:s,preferredChallenge:a,password:o},m=Ke.getState();m.active&&m.username===t&&(p.session=m.session);let d=await yd(p),u=lt(t);return be({signInSession:d.Session,username:u,challengeName:d.ChallengeName,signInDetails:i}),d.AuthenticationResult?(await Ie({username:u,...d.AuthenticationResult,NewDeviceMetadata:await De({userPoolId:n.userPoolId,userPoolEndpoint:n.userPoolEndpoint,newDeviceMetadata:d.AuthenticationResult.NewDeviceMetadata,accessToken:d.AuthenticationResult.AccessToken}),signInDetails:i}),Ae(),await Ce(),pe(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:d.ChallengeName,challengeParameters:d.ChallengeParameters,availableChallenges:"AvailableChallenges"in d?d.AvailableChallenges:void 0})}catch(p){Ae(),pe(),Q(p);let m=qe(p.name);if(m)return m;throw p}}var hs=c(()=>{"use strict";U();C();me();Se();Fe();rt();er();mt();Ct();wt();Pe();Sd();Wt();Tt()});async function nr(e){pe(!1);let t=e.options?.authFlowType;switch(await xn(),t){case"USER_SRP_AUTH":return gs(e);case"USER_PASSWORD_AUTH":return hd(e);case"CUSTOM_WITHOUT_SRP":return md(e);case"CUSTOM_WITH_SRP":return ud(e);case"USER_AUTH":return vn(e);default:return gs(e)}}var Es=c(()=>{"use strict";rt();dd();ld();gd();Ed();hs();Tt()});function Ad(e){let t=Gt.listen("auth-internal",async({payload:r})=>{r.event==="confirmSignUp"&&r.data?.isSignUpComplete&&(Gt.dispatch("auth-internal",{event:"autoSignIn"}),rr(xd(e)),t())}),o=setTimeout(()=>{t(),clearTimeout(o),pe()},Id)}function Cd(e,t){let o;return r=>{o||e(...r),clearTimeout(o),o=setTimeout(()=>{o=void 0},t)}}function Lh(e,t,o){let r=Date.now(),n=setInterval(async()=>{if(Date.now()-r>Id)clearInterval(n),o(new S({name:Jr,message:"The account was not confirmed on time.",recoverySuggestion:"Try to verify your account by clicking the link sent your email or phone and then login manually."})),pe();else try{let a=await nr(e);a.nextStep.signInStep!=="CONFIRM_SIGN_UP"&&(t(a),clearInterval(n),pe())}catch(a){clearInterval(n),o(a),pe()}},5e3)}function wd(e){return async()=>new Promise((t,o)=>{Vh([e,t,o])})}async function Hh(e,t,o){try{let r=e?.options?.authFlowType==="USER_AUTH"?await vn(e):await nr(e);t(r),pe()}catch(r){o(r),pe()}}function xd(e){return async()=>new Promise((t,o)=>{Bh([e,t,o])})}var Id,Vh,Bh,Pd,vd=c(()=>{"use strict";C();Es();$();Tt();Ft();hs();Id=180*1e3;Vh=Cd(Lh,300),Bh=Cd(Hh,300);Pd=xd});var Wh,Td,Rd=c(()=>{"use strict";K();eo();Mt();$();me();Fe();jr();j();J();Y();Wh=()=>async e=>{if(e.statusCode>=300){let t=await we(e);if(Q(t),t.name===$r.InvalidParameterException&&/'password'/.test(t.message)&&/Member must not be null/.test(t.message)){let o=P.EmptySignUpPassword,{message:r,recoverySuggestion:n}=Gr[o];throw new S({name:o,message:r,recoverySuggestion:n})}throw new S({name:t.name,message:t.message})}return st(e)},Td=e=>v(R,T("SignUp"),Wh(),{..._,...e})});async function _d(e){let{username:t,password:o,options:r}=e,n=h.getConfig().Auth?.Cognito,i=n?.signUpVerificationMethod??"code",{clientMetadata:s,validationData:a,autoSignIn:p}=e.options??{};f(n),k(!!t,P.EmptySignUpUsername);let m=typeof p!="boolean"?p:void 0,d={username:t,options:m};m?.authFlowType!=="CUSTOM_WITHOUT_SRP"&&(d.password=o);let{userPoolId:u,userPoolClientId:l,userPoolEndpoint:g}=n,A=Td({endpointResolver:y({endpointOverride:g})}),N={Username:t,Password:void 0,UserAttributes:r?.userAttributes&&Yo(r?.userAttributes),ClientMetadata:s,ValidationData:a&&Yo(a),ClientId:l,UserContextData:z({username:t,userPoolId:u,userPoolClientId:l})};o&&(N.Password=o);let{UserSub:D,CodeDeliveryDetails:O,UserConfirmed:oe,Session:ie}=await A({region:E(u),userAgentValue:w(I.SignUp)},N);(m||p===!0)&&(Ke.dispatch({type:"START"}),Ke.dispatch({type:"SET_USERNAME",value:t}),Ke.dispatch({type:"SET_SESSION",value:ie}));let Be={destination:O?.Destination,deliveryMedium:O?.DeliveryMedium,attributeName:O?.AttributeName},Te=!!oe,$e=Ke.getState().active;if(Te)return $e?(rr(Pd(d)),{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:D}):{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:D};if($e){if(i==="link")return rr(wd(d)),{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:Be},userId:D};Ad(d)}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:Be},userId:D}}var Ud=c(()=>{"use strict";U();C();Se();me();F();qr();vd();Le();B();Rd();V();er();Tt()});var Nd,bd=c(()=>{"use strict";K();J();j();Z();Y();Nd=e=>v(R,T("ForgotPassword"),b(),{..._,...e})});async function Od(e){let{username:t}=e;k(!!t,P.EmptyResetPasswordUsername);let o=h.getConfig().Auth?.Cognito;f(o);let{userPoolClientId:r,userPoolId:n,userPoolEndpoint:i}=o,s=e.options?.clientMetadata,a=z({username:t,userPoolId:n,userPoolClientId:r}),d=(await Nd({endpointResolver:y({endpointOverride:i})})({region:E(n),userAgentValue:w(I.ResetPassword)},{Username:t,ClientMetadata:s,ClientId:r,UserContextData:a})).CodeDeliveryDetails;return{isPasswordReset:!1,nextStep:{resetPasswordStep:"CONFIRM_RESET_PASSWORD_WITH_CODE",codeDeliveryDetails:{deliveryMedium:d?.DeliveryMedium,destination:d?.Destination,attributeName:d?.AttributeName}}}}var Dd=c(()=>{"use strict";U();C();me();Se();F();B();Le();bd();V()});var kd,Md=c(()=>{"use strict";K();J();j();Z();Y();kd=e=>v(R,T("ConfirmForgotPassword"),b(),{..._,...e})});async function Fd(e){let t=h.getConfig().Auth?.Cognito;f(t);let{userPoolClientId:o,userPoolId:r,userPoolEndpoint:n}=t,{username:i,newPassword:s}=e;k(!!i,P.EmptyConfirmResetPasswordUsername),k(!!s,P.EmptyConfirmResetPasswordNewPassword);let a=e.confirmationCode;k(!!a,P.EmptyConfirmResetPasswordConfirmationCode);let p=e.options?.clientMetadata,m=z({username:i,userPoolId:r,userPoolClientId:o});await kd({endpointResolver:y({endpointOverride:n})})({region:E(t.userPoolId),userAgentValue:w(I.ConfirmResetPassword)},{Username:i,ConfirmationCode:a,Password:s,ClientMetadata:p,ClientId:t.userPoolClientId,UserContextData:m})}var Ld=c(()=>{"use strict";U();C();me();Se();B();Le();Md();V();F()});var Vd,Bd=c(()=>{"use strict";K();J();j();Z();Y();Vd=e=>v(R,T("ResendConfirmationCode"),b(),{..._,...e})});async function Hd(e){let{username:t}=e;k(!!t,P.EmptySignUpUsername);let o=h.getConfig().Auth?.Cognito;f(o);let{userPoolClientId:r,userPoolId:n,userPoolEndpoint:i}=o,s=e.options?.clientMetadata,a=z({username:t,userPoolId:n,userPoolClientId:r}),p=Vd({endpointResolver:y({endpointOverride:i})}),{CodeDeliveryDetails:m}=await p({region:E(o.userPoolId),userAgentValue:w(I.ResendSignUpCode)},{Username:t,ClientMetadata:s,ClientId:o.userPoolClientId,UserContextData:a}),{DeliveryMedium:d,AttributeName:u,Destination:l}={...m};return{destination:l,deliveryMedium:d,attributeName:u||void 0}}var Wd=c(()=>{"use strict";U();C();Se();me();F();B();Le();Bd();V()});var Kd,zd=c(()=>{"use strict";K();Y();J();j();Z();Kd=e=>v(R,T("ConfirmSignUp"),b(),{..._,...e})});async function Gd(e){let{username:t,confirmationCode:o,options:r}=e,n=h.getConfig().Auth?.Cognito;f(n);let{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a}=n,p=r?.clientMetadata;k(!!t,P.EmptyConfirmSignUpUsername),k(!!o,P.EmptyConfirmSignUpCode);let m=z({username:t,userPoolId:i,userPoolClientId:s}),d=Kd({endpointResolver:y({endpointOverride:a})}),{Session:u}=await d({region:E(n.userPoolId),userAgentValue:w(I.ConfirmSignUp)},{Username:t,ConfirmationCode:o,ClientMetadata:p,ForceAliasCreation:r?.forceAliasCreation,ClientId:n.userPoolClientId,UserContextData:m});return new Promise((l,g)=>{try{let A={isSignUpComplete:!0,nextStep:{signUpStep:"DONE"}},N=Ke.getState();if(!N.active||N.username!==t){l(A),pe();return}Ke.dispatch({type:"SET_SESSION",value:u});let D=Gt.listen("auth-internal",({payload:O})=>{O.event==="autoSignIn"&&(l({isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"}}),D())});Gt.dispatch("auth-internal",{event:"confirmSignUp",data:A})}catch(A){g(A)}})}var qd=c(()=>{"use strict";U();C();Se();me();F();B();Le();zd();V();er();Tt()});async function $d(e){let{challengeResponse:t,options:o}=e,{username:r,challengeName:n,signInSession:i,signInDetails:s}=Ne.getState(),a=h.getConfig().Auth?.Cognito;f(a);let p=o?.clientMetadata;if(k(!!t,P.EmptyChallengeResponse),!r||!n||!i)throw new S({name:Ue.SignInException,message:`
|
|
5
|
-
An error occurred during the sign in process.
|
|
6
|
-
|
|
7
|
-
This most likely occurred due to:
|
|
8
|
-
1. signIn was not called before confirmSignIn.
|
|
9
|
-
2. signIn threw an exception.
|
|
10
|
-
3. page was refreshed during the sign in flow and session has expired.
|
|
11
|
-
`,recoverySuggestion:"Make sure a successful call to signIn is made before calling confirmSignInand that the session has not expired."});try{let{Session:m,ChallengeName:d,AuthenticationResult:u,ChallengeParameters:l}=await pd(r,n,i,t,a,H,p,o);return be({signInSession:m,username:r,challengeName:d,signInDetails:s}),u?(await Ie({username:r,...u,NewDeviceMetadata:await De({userPoolId:a.userPoolId,userPoolEndpoint:a.userPoolEndpoint,newDeviceMetadata:u.NewDeviceMetadata,accessToken:u.AccessToken}),signInDetails:s}),Ae(),await Ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Ve({challengeName:d,challengeParameters:l})}catch(m){Q(m);let d=qe(m.name);if(d)return d;throw m}}var jd=c(()=>{"use strict";U();C();mt();$();rt();Fe();Se();me();Mt();Ct();Pe();wt();Wt()});var Jd,Yd=c(()=>{"use strict";K();J();j();Z();Y();Jd=e=>v(R,T("SetUserMFAPreference"),b(),{..._,...e})});async function Xd(e){let{sms:t,totp:o,email:r}=e,n=h.getConfig().Auth?.Cognito;f(n);let{userPoolEndpoint:i,userPoolId:s}=n,{tokens:a}=await W({forceRefresh:!1});M(a),await Jd({endpointResolver:y({endpointOverride:i})})({region:E(s),userAgentValue:w(I.UpdateMFAPreference)},{AccessToken:a.accessToken.toString(),SMSMfaSettings:ys(t),SoftwareTokenMfaSettings:ys(o),EmailMfaSettings:ys(r)})}function ys(e){if(e==="DISABLED")return{Enabled:!1};if(e==="PREFERRED")return{Enabled:!0,PreferredMfa:!0};if(e==="ENABLED")return{Enabled:!0};if(e==="NOT_PREFERRED")return{Enabled:!0,PreferredMfa:!1}}var Zd=c(()=>{"use strict";U();C();F();ee();B();Yd();V()});var Tn,Ss=c(()=>{"use strict";K();J();j();Z();Y();Tn=e=>v(R,T("GetUser"),b(),{..._,...e})});async function Qd(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W({forceRefresh:!1});M(r);let n=Tn({endpointResolver:y({endpointOverride:t})}),{PreferredMfaSetting:i,UserMFASettingList:s}=await n({region:E(o),userAgentValue:w(I.FetchMFAPreference)},{AccessToken:r.accessToken.toString()});return{preferred:fs(i),enabled:wn(s)}}var eu=c(()=>{"use strict";U();C();rt();F();ee();B();Ss();V()});async function tu(e){let t=h.getConfig().Auth?.Cognito;f(t);let{userPoolEndpoint:o,userPoolId:r}=t,{code:n,options:i}=e;k(!!n,P.EmptyVerifyTOTPSetupCode);let{tokens:s}=await W({forceRefresh:!1});M(s),await en({endpointResolver:y({endpointOverride:o})})({region:E(r),userAgentValue:w(I.VerifyTOTPSetup)},{AccessToken:s.accessToken.toString(),UserCode:n,FriendlyDeviceName:i?.friendlyDeviceName})}var ou=c(()=>{"use strict";U();C();me();Se();F();ee();B();Wi();V()});var ru,nu=c(()=>{"use strict";K();J();j();Z();Y();ru=e=>v(R,T("ChangePassword"),b(),{..._,...e})});async function iu(e){let t=h.getConfig().Auth?.Cognito;f(t);let{userPoolEndpoint:o,userPoolId:r}=t,{oldPassword:n,newPassword:i}=e;k(!!n,P.EmptyUpdatePassword),k(!!i,P.EmptyUpdatePassword);let{tokens:s}=await W({forceRefresh:!1});M(s),await ru({endpointResolver:y({endpointOverride:o})})({region:E(r),userAgentValue:w(I.UpdatePassword)},{AccessToken:s.accessToken.toString(),PreviousPassword:n,ProposedPassword:i})}var su=c(()=>{"use strict";U();C();me();Se();F();ee();B();nu();V()});async function au(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W({forceRefresh:!1});M(r);let n=r.idToken?.payload["cognito:username"]??"",i=tn({endpointResolver:y({endpointOverride:t})}),{SecretCode:s}=await i({region:E(o),userAgentValue:w(I.SetUpTOTP)},{AccessToken:r.accessToken.toString()});if(!s)throw new S({name:Bp,message:"Failed to set up TOTP."});return ls(s,JSON.stringify(n))}var cu=c(()=>{"use strict";U();C();$();jr();rt();F();ee();B();Ki();V()});var pu,mu=c(()=>{"use strict";K();J();j();Z();Y();pu=e=>v(R,T("UpdateUserAttributes"),b(),{..._,...e})});function Kh(e){let t={};return Object.keys(e)?.forEach(o=>{t[o]={isUpdated:!0,nextStep:{updateAttributeStep:"DONE"}}}),t}function zh(e){let t={};return e?.forEach(o=>{let{AttributeName:r,DeliveryMedium:n,Destination:i}=o;r&&(t[r]={isUpdated:!1,nextStep:{updateAttributeStep:"CONFIRM_ATTRIBUTE_WITH_CODE",codeDeliveryDetails:{attributeName:r,deliveryMedium:n,destination:i}}})}),t}var Rn,Is=c(()=>{"use strict";U();C();ee();F();qr();B();mu();V();Rn=async e=>{let{userAttributes:t,options:o}=e,r=h.getConfig().Auth?.Cognito,n=o?.clientMetadata;f(r);let{userPoolEndpoint:i,userPoolId:s}=r,{tokens:a}=await W({forceRefresh:!1});M(a);let p=pu({endpointResolver:y({endpointOverride:i})}),{CodeDeliveryDetailsList:m}=await p({region:E(s),userAgentValue:w(I.UpdateUserAttributes)},{AccessToken:a.accessToken.toString(),ClientMetadata:n,UserAttributes:Yo(t)});return{...Kh(t),...zh(m)}}});var du,uu=c(()=>{"use strict";Is();du=async e=>{let{userAttribute:{attributeKey:t,value:o},options:r}=e,n=await Rn({userAttributes:{[t]:o},options:r});return Object.values(n)[0]}});var lu,fu=c(()=>{"use strict";K();J();j();Z();Y();lu=e=>v(R,T("VerifyUserAttribute"),b(),{..._,...e})});async function gu(e){let t=h.getConfig().Auth?.Cognito;f(t);let{userPoolEndpoint:o,userPoolId:r}=t,{confirmationCode:n,userAttributeKey:i}=e;k(!!n,P.EmptyConfirmUserAttributeCode);let{tokens:s}=await W({forceRefresh:!1});M(s),await lu({endpointResolver:y({endpointOverride:o})})({region:E(r),userAgentValue:w(I.ConfirmUserAttribute)},{AccessToken:s.accessToken.toString(),AttributeName:i,Code:n})}var hu=c(()=>{"use strict";U();C();me();Se();F();ee();B();fu();V()});var Ok,Eu,yu=c(()=>{"use strict";U();Mt();Ok=new q("AuthError"),Eu={oauthSignInError:{message:de.OAUTH_ERROR,log:"Make sure Cognito Hosted UI has been configured correctly"},noConfig:{message:de.DEFAULT_MSG,log:`
|
|
3
|
+
E.g { responseType: 'code' }`}),Kc=new g({name:It,message:"User needs to be authenticated to call this API.",recoverySuggestion:"Sign in before calling this API again."});function Bo(e){if(Vc(e))throw Hc;if(!Wc(e))throw Kc}function qr(e){if(!e||!e.deviceKey||!e.deviceGroupKey||!e.randomPassword)throw new g({name:Ji,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."})}var ns={inflightOAuth:"inflightOAuth",oauthSignIn:"oauthSignIn",oauthPKCE:"oauthPKCE",oauthState:"oauthState"};function is(e){return e?.accessToken||e?.idToken}function Wc(e){return is(e)&&e?.refreshToken}function Vc(e){return is(e)&&!e?.refreshToken}var ss=async e=>{let t=e.getConfig().Auth?.Cognito;E(t);let o=await e.Auth.getTokens({forceRefresh:!1});Lo(o);let{"cognito:username":r,sub:n}=o.idToken?.payload??{},i={username:r,userId:n},s=zc(o);return s&&(i.signInDetails=s),i};function zc(e){return e?.signInDetails}var Ze=async()=>ss(w);var O=(e,t)=>He({category:Lt.Auth,action:e,...t});var K=e=>(t,o)=>{let r=qc(e),n=JSON.stringify(t);return $c(o,r,n)},qc=e=>({"content-type":"application/x-amz-json-1.1","x-amz-target":`AWSCognitoIdentityProviderService.${e}`}),$c=({url:e},t,o)=>({headers:t,url:e,body:o,method:"POST"});function B(e){if(!e||e.name==="Error"||e instanceof TypeError)throw new g({name:ue.Unknown,message:"An unknown error has occurred.",underlyingError:e})}var G=()=>async e=>{if(e.statusCode>=300){let t=await pe(e);throw B(t),new g({name:t.name,message:t.message,metadata:t.$metadata})}return Re(e)};var jc=()=>(e,t)=>async function(r){return r.headers["cache-control"]="no-store",e(r)},W=ut(Vt,[jc]);var Ho="cognito-idp";var V={service:Ho,retryDecider:Wt(pe),computeDelay:Kt,get userAgentValue(){return He()},cache:"no-store"};var Qe=e=>b(W,K("InitiateAuth"),G(),{...V,...e});var mt=e=>b(W,K("RespondToAuthChallenge"),G(),{...V,...e});var as=e=>b(W,K("AssociateSoftwareToken"),G(),{...V,...e});var cs=({region:e})=>({url:new te(`https://${Ho}.${e}.${zt(e)}`)});var P=({endpointOverride:e})=>t=>e?{url:new te(e)}:cs(t);var ds=e=>b(W,K("GetTokensFromRefreshToken"),G(),{...V,...e});var Gc=async({tokens:e,authConfig:t,username:o,clientMetadata:r})=>{E(t?.Cognito);let{userPoolId:n,userPoolClientId:i,userPoolEndpoint:s}=t.Cognito,a=v(n);Bo(e);let c=ds({endpointResolver:P({endpointOverride:s})}),{AuthenticationResult:d}=await c({region:a},{ClientId:i,RefreshToken:e.refreshToken,DeviceKey:e.deviceMetadata?.deviceKey,ClientMetadata:r}),u=Q(d?.AccessToken??""),p=d?.IdToken?Q(d.IdToken):void 0,{iat:l}=u.payload;if(!l)throw new g({name:"iatNotFoundException",message:"iat not found in access token"});let m=l*1e3-new Date().getTime();return{accessToken:u,idToken:p,clockDrift:m,refreshToken:d?.RefreshToken??e.refreshToken,username:o}},us=Wr(Gc);var ps={accessToken:"accessToken",idToken:"idToken",oidcProvider:"oidcProvider",clockDrift:"clockDrift",refreshToken:"refreshToken",deviceKey:"deviceKey",randomPasswordKey:"randomPasswordKey",deviceGroupKey:"deviceGroupKey",signInDetails:"signInDetails",oauthMetadata:"oauthMetadata"};var Xt;(function(e){e.InvalidAuthTokens="InvalidAuthTokens"})(Xt||(Xt={}));var Yc={[Xt.InvalidAuthTokens]:{message:"Invalid tokens.",recoverySuggestion:"Make sure the tokens are valid."}},ls=Se(Yc);var $r="CognitoIdentityServiceProvider";var Ko=class{getKeyValueStorage(){if(!this.keyValueStorage)throw new g({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{let t=await this.getAuthKeys(),o=await this.getKeyValueStorage().getItem(t.accessToken);if(!o)throw new g({name:"NoSessionFoundException",message:"Auth session was not found. Make sure to call signIn."});let r=Q(o),n=await this.getKeyValueStorage().getItem(t.idToken),i=n?Q(n):void 0,s=await this.getKeyValueStorage().getItem(t.refreshToken)??void 0,a=await this.getKeyValueStorage().getItem(t.clockDrift)??"0",c=Number.parseInt(a),d=await this.getKeyValueStorage().getItem(t.signInDetails),u={accessToken:r,idToken:i,refreshToken:s,deviceMetadata:await this.getDeviceMetadata()??void 0,clockDrift:c,username:await this.getLastAuthUser()};return d&&(u.signInDetails=JSON.parse(d)),u}catch{return null}}async storeTokens(t){ls(t!==void 0,Xt.InvalidAuthTokens);let o=t.username;await this.getKeyValueStorage().setItem(this.getLastAuthUserKey(),o);let r=await this.getAuthKeys();await this.getKeyValueStorage().setItem(r.accessToken,t.accessToken.toString()),t.idToken?await this.getKeyValueStorage().setItem(r.idToken,t.idToken.toString()):await this.getKeyValueStorage().removeItem(r.idToken),t.refreshToken?await this.getKeyValueStorage().setItem(r.refreshToken,t.refreshToken):await this.getKeyValueStorage().removeItem(r.refreshToken),t.deviceMetadata&&(t.deviceMetadata.deviceKey&&await this.getKeyValueStorage().setItem(r.deviceKey,t.deviceMetadata.deviceKey),t.deviceMetadata.deviceGroupKey&&await this.getKeyValueStorage().setItem(r.deviceGroupKey,t.deviceMetadata.deviceGroupKey),await this.getKeyValueStorage().setItem(r.randomPasswordKey,t.deviceMetadata.randomPassword)),t.signInDetails?await this.getKeyValueStorage().setItem(r.signInDetails,JSON.stringify(t.signInDetails)):await this.getKeyValueStorage().removeItem(r.signInDetails),await this.getKeyValueStorage().setItem(r.clockDrift,`${t.clockDrift}`)}async clearTokens(){let 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){let o=await this.getAuthKeys(t),r=await this.getKeyValueStorage().getItem(o.deviceKey),n=await this.getKeyValueStorage().getItem(o.deviceGroupKey),i=await this.getKeyValueStorage().getItem(o.randomPasswordKey);return i&&n&&r?{deviceKey:r,deviceGroupKey:n,randomPassword:i}:null}async clearDeviceMetadata(t){let o=await this.getAuthKeys(t);await Promise.all([this.getKeyValueStorage().removeItem(o.deviceKey),this.getKeyValueStorage().removeItem(o.deviceGroupKey),this.getKeyValueStorage().removeItem(o.randomPasswordKey)])}async getAuthKeys(t){E(this.authConfig?.Cognito);let o=t??await this.getLastAuthUser();return Jc($r,`${this.authConfig.Cognito.userPoolClientId}.${o}`)}getLastAuthUserKey(){E(this.authConfig?.Cognito);let t=this.authConfig.Cognito.userPoolClientId;return`${$r}.${t}.LastAuthUser`}async getLastAuthUser(){return await this.getKeyValueStorage().getItem(this.getLastAuthUserKey())??"username"}async setOAuthMetadata(t){let{oauthMetadata:o}=await this.getAuthKeys();await this.getKeyValueStorage().setItem(o,JSON.stringify(t))}async getOAuthMetadata(){let{oauthMetadata:t}=await this.getAuthKeys(),o=await this.getKeyValueStorage().getItem(t);return o&&JSON.parse(o)}},Jc=(e,t)=>Zt(ps)(`${e}`,t);function Zt(e){let t=Object.values({...e});return(o,r)=>t.reduce((n,i)=>({...n,[i]:`${o}.${r}.${i}`}),{})}var ms="amplify-signin-with-hostedUI",be="CognitoIdentityServiceProvider",wt=class{constructor(t){this.keyValueStorage=t}async clearOAuthInflightData(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId);await Promise.all([this.keyValueStorage.removeItem(t.inflightOAuth),this.keyValueStorage.removeItem(t.oauthPKCE),this.keyValueStorage.removeItem(t.oauthState)])}async clearOAuthData(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId);return await this.clearOAuthInflightData(),await this.keyValueStorage.removeItem(ms),this.keyValueStorage.removeItem(t.oauthSignIn)}loadOAuthState(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthState)}storeOAuthState(t){E(this.cognitoConfig);let o=Ue(be,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(o.oauthState,t)}loadPKCE(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.getItem(t.oauthPKCE)}storePKCE(t){E(this.cognitoConfig);let o=Ue(be,this.cognitoConfig.userPoolClientId);return this.keyValueStorage.setItem(o.oauthPKCE,t)}setAuthConfig(t){this.cognitoConfig=t}async loadOAuthInFlight(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId);return await this.keyValueStorage.getItem(t.inflightOAuth)==="true"}async storeOAuthInFlight(t){E(this.cognitoConfig);let o=Ue(be,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(o.inflightOAuth,`${t}`)}async loadOAuthSignIn(){E(this.cognitoConfig);let t=Ue(be,this.cognitoConfig.userPoolClientId),o=await this.keyValueStorage.getItem(ms),[r,n]=(await this.keyValueStorage.getItem(t.oauthSignIn))?.split(",")??[];return{isOAuthSignIn:r==="true"||o==="true",preferPrivateSession:n==="true"}}async storeOAuthSignIn(t,o=!1){E(this.cognitoConfig);let r=Ue(be,this.cognitoConfig.userPoolClientId);await this.keyValueStorage.setItem(r.oauthSignIn,`${t},${o}`)}},Ue=(e,t)=>Zt(ns)(e,t);var z=new wt(we);var jr=[],fs=e=>{jr.push(e)},Wo=()=>{for(;jr.length;)jr.pop()?.()};var Vo=class{constructor(){this.waitForInflightOAuth=Ke()?async()=>{if(await z.loadOAuthInFlight())return this.inflightPromise?this.inflightPromise:(this.inflightPromise=new Promise((t,o)=>{fs(t)}),this.inflightPromise)}:async()=>{}}setAuthConfig(t){z.setAuthConfig(t.Cognito),this.authConfig=t}setTokenRefresher(t){this.tokenRefresher=t}setAuthTokenStore(t){this.tokenStore=t}getTokenStore(){if(!this.tokenStore)throw new g({name:"EmptyTokenStoreException",message:"TokenStore not set"});return this.tokenStore}getTokenRefresher(){if(!this.tokenRefresher)throw new g({name:"EmptyTokenRefresherException",message:"TokenRefresher not set"});return this.tokenRefresher}setClientMetadataProvider(t){this.clientMetadataProvider=t}async getTokens(t){let o;try{E(this.authConfig?.Cognito)}catch{return null}await this.waitForInflightOAuth(),this.inflightPromise=void 0,o=await this.getTokenStore().loadTokens();let r=await this.getTokenStore().getLastAuthUser();if(o===null)return null;let n=!!o?.idToken&&Do({expiresAt:(o.idToken?.payload?.exp??0)*1e3,clockDrift:o.clockDrift??0}),i=Do({expiresAt:(o.accessToken?.payload?.exp??0)*1e3,clockDrift:o.clockDrift??0});return(t?.forceRefresh||n||i)&&(o=await this.refreshTokens({tokens:o,username:r,clientMetadata:t?.clientMetadata??await this.clientMetadataProvider?.()}),o===null)?null:{accessToken:o?.accessToken,idToken:o?.idToken,signInDetails:o?.signInDetails}}async refreshTokens({tokens:t,username:o,clientMetadata:r}){try{let{signInDetails:n}=t,i=await this.getTokenRefresher()({tokens:t,authConfig:this.authConfig,username:o,clientMetadata:r});return i.signInDetails=n,await this.setTokens({tokens:i}),Z.dispatch("auth",{event:"tokenRefresh"},"Auth",j),i}catch(n){return this.handleErrors(n)}}handleErrors(t){if(B(t),this.isAuthenticationError(t)&&this.clearTokens(),Z.dispatch("auth",{event:"tokenRefresh_failure",data:{error:t}},"Auth",j),t.name.startsWith("NotAuthorizedException"))return null;throw t}isAuthenticationError(t){return["NotAuthorizedException","TokenRevokedException","UserNotFoundException","PasswordResetRequiredException","UserNotConfirmedException","RefreshTokenReuseException"].some(r=>t?.name?.startsWith?.(r))}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()}};var zo=class{constructor(){this.authTokenStore=new Ko,this.authTokenStore.setKeyValueStorage(we),this.tokenOrchestrator=new Vo,this.tokenOrchestrator.setAuthTokenStore(this.authTokenStore),this.tokenOrchestrator.setTokenRefresher(us)}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)}};var ft=new zo,{tokenOrchestrator:D}=ft;async function oe(e){if(e.AccessToken){let t=Q(e.AccessToken),o=(t.payload.iat||0)*1e3,r=new Date().getTime(),n=o>0?o-r:0,i,s,a;e.RefreshToken&&(s=e.RefreshToken),e.IdToken&&(i=Q(e.IdToken)),e?.NewDeviceMetadata&&(a=e.NewDeviceMetadata);let c={accessToken:t,idToken:i,refreshToken:s,clockDrift:n,deviceMetadata:a,username:e.username};e?.signInDetails&&(c.signInDetails=e.signInDetails),await D.setTokens({tokens:c})}else throw new U({message:"Invalid tokens",name:"InvalidTokens",recoverySuggestion:"Check Cognito UserPool settings"})}var Xc="Unable to get user session following successful sign-in.",ce=async()=>{try{Z.dispatch("auth",{event:"signedIn",data:await Ze()},"Auth",j)}catch(e){throw e.name===It?new g({name:os,message:Xc,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 gs(){return{active:!1}}var Zc=(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 gs();default:return e}},Qc=e=>{let t=e(gs(),{type:"RESET"});return{getState:()=>t,dispatch:o=>{t=e(t,o)}}},ze=Qc(Zc);var ed=180*1e3,qo="CognitoSignInState",qe={username:`${qo}.username`,challengeName:`${qo}.challengeName`,signInSession:`${qo}.signInSession`,expiry:`${qo}.expiry`},td=(e,t)=>{switch(t.type){case"SET_SIGN_IN_SESSION":return $o({signInSession:t.value}),{...e,signInSession:t.value};case"SET_SIGN_IN_STATE":return $o(t.value),{...t.value};case"SET_CHALLENGE_NAME":return $o({challengeName:t.value}),{...e,challengeName:t.value};case"SET_USERNAME":return $o({username:t.value}),{...e,username:t.value};case"SET_INITIAL_STATE":return rd();case"RESET_STATE":return hs(),Gr();default:return e}},od=e=>{let t=Number(e),o=Date.now();return t<=o},re=()=>{Ce.dispatch({type:"RESET_STATE"})},hs=()=>{for(let e of Object.values(qe))Ae.removeItem(e)},Gr=()=>({username:void 0,challengeName:void 0,signInSession:void 0}),rd=()=>{let e=Ae.getItem(qe.expiry);if(!e||od(e))return hs(),Gr();let t=Ae.getItem(qe.username)??void 0,o=Ae.getItem(qe.challengeName)??void 0,r=Ae.getItem(qe.signInSession)??void 0;return{username:t,challengeName:o,signInSession:r}},nd=e=>{let t=e(Gr(),{type:"SET_INITIAL_STATE"});return{getState:()=>t,dispatch:o=>{t=e(t,o)}}},Ce=nd(td);function ge(e){Ce.dispatch({type:"SET_SIGN_IN_STATE",value:e})}var $o=({challengeName:e,signInSession:t,username:o})=>{o&&Ae.setItem(qe.username,o),e&&Ae.setItem(qe.challengeName,e),t&&(Ae.setItem(qe.signInSession,t),Ae.setItem(qe.expiry,String(Date.now()+ed)))};var Yr="Passkeys may not be supported on this device. Ensure your application is running in a secure context (HTTPS) and Web Authentication API is supported.";var Oe=class e extends U{constructor(t){super(t),this.constructor=e,Object.setPrototypeOf(this,e.prototype)}},N;(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"})(N||(N={}));var Jr="User may have canceled the ceremony or another interruption has occurred. Check underlying error for details.",ys="Ensure your user pool is configured to support the WEB_AUTHN as an authentication factor.",At={[N.PasskeyNotSupported]:{message:"Passkeys may not be supported on this device.",recoverySuggestion:Yr},[N.InvalidPasskeyRegistrationOptions]:{message:"Invalid passkey registration options.",recoverySuggestion:ys},[N.InvalidPasskeyAuthenticationOptions]:{message:"Invalid passkey authentication options.",recoverySuggestion:ys},[N.PasskeyRegistrationFailed]:{message:"Device failed to create passkey.",recoverySuggestion:Yr},[N.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."},[N.PasskeyAlreadyExists]:{message:"Passkey already exists in authenticator.",recoverySuggestion:"Proceed with existing passkey or try again after deleting the credential."},[N.PasskeyRegistrationCanceled]:{message:"Passkey registration ceremony has been canceled.",recoverySuggestion:Jr},[N.PasskeyAuthenticationCanceled]:{message:"Passkey authentication ceremony has been canceled.",recoverySuggestion:Jr},[N.PasskeyOperationAborted]:{message:"Passkey operation has been aborted.",recoverySuggestion:Jr},[N.RelyingPartyMismatch]:{message:"Relying party does not match current domain.",recoverySuggestion:"Ensure relying party identifier matches current domain."}},xt=Se(At,Oe);var Es=e=>{if(e instanceof Error){if(e.name==="AbortError"){let{message:t,recoverySuggestion:o}=At[N.PasskeyOperationAborted];return new Oe({name:N.PasskeyOperationAborted,message:t,recoverySuggestion:o,underlyingError:e})}if(e.name==="SecurityError"){let{message:t,recoverySuggestion:o}=At[N.RelyingPartyMismatch];return new Oe({name:N.RelyingPartyMismatch,message:t,recoverySuggestion:o,underlyingError:e})}}return new Oe({name:ue.Unknown,message:"An unknown error has occurred.",underlyingError:e})};var Ss=e=>{if(e instanceof Oe)return e;if(e instanceof Error&&e.name==="NotAllowedError"){let{message:t,recoverySuggestion:o}=At[N.PasskeyAuthenticationCanceled];return new Oe({name:N.PasskeyAuthenticationCanceled,message:t,recoverySuggestion:o,underlyingError:e})}return Es(e)};var Is=()=>Ke()&&window.isSecureContext&&"credentials"in navigator&&typeof window.PublicKeyCredential=="function";var Ct=e=>fe.convert(new Uint8Array(e),{urlSafe:!0,skipPadding:!0});var Xr=e=>Uint8Array.from(at.convert(e,{urlSafe:!0}),t=>t.charCodeAt(0)).buffer;var ws=e=>{let t=Xr(e.challenge),o=(e.allowCredentials||[]).map(r=>({...r,id:Xr(r.id)}));return{...e,challenge:t,allowCredentials:o}},As=e=>{let t={clientDataJSON:Ct(e.response.clientDataJSON),authenticatorData:Ct(e.response.authenticatorData),signature:Ct(e.response.signature)};e.response.userHandle&&(t.userHandle=Ct(e.response.userHandle));let o={id:e.id,rawId:Ct(e.rawId),type:e.type,clientExtensionResults:e.getClientExtensionResults(),response:t};return e.authenticatorAttachment&&(o.authenticatorAttachment=e.authenticatorAttachment),o};function xs(e){xt(e&&e instanceof PublicKeyCredential&&e.response instanceof AuthenticatorAssertionResponse,N.PasskeyRetrievalFailed)}var Cs=async e=>{try{let t=Is();xt(t,N.PasskeyNotSupported);let o=ws(e),r=await navigator.credentials.get({publicKey:o});return xs(r),As(r)}catch(t){throw Ss(t)}};var vs=e=>b(W,K("ConfirmDevice"),G(),{...V,...e});var vt={convert(e){return new TextEncoder().encode(e)}};function f(e,t){e!=null&&this.fromString(e,t)}function ne(){return new f(null,null)}var et,id=0xdeadbeefcafe,Ps=(id&16777215)===15715070;function sd(e,t,o,r,n,i){for(;--i>=0;){let s=t*this[e++]+o[r]+n;n=Math.floor(s/67108864),o[r++]=s&67108863}return n}function ad(e,t,o,r,n,i){let s=t&32767,a=t>>15;for(;--i>=0;){let c=this[e]&32767,d=this[e++]>>15,u=a*c+d*s;c=s*c+((u&32767)<<15)+o[r]+(n&1073741823),n=(c>>>30)+(u>>>15)+a*d+(n>>>30),o[r++]=c&1073741823}return n}function cd(e,t,o,r,n,i){let s=t&16383,a=t>>14;for(;--i>=0;){let c=this[e]&16383,d=this[e++]>>14,u=a*c+d*s;c=s*c+((u&16383)<<14)+o[r]+n,n=(c>>28)+(u>>14)+a*d,o[r++]=c&268435455}return n}var Ts=typeof navigator<"u";Ts&&Ps&&navigator.appName==="Microsoft Internet Explorer"?(f.prototype.am=ad,et=30):Ts&&Ps&&navigator.appName!=="Netscape"?(f.prototype.am=sd,et=26):(f.prototype.am=cd,et=28);f.prototype.DB=et;f.prototype.DM=(1<<et)-1;f.prototype.DV=1<<et;var Zr=52;f.prototype.FV=Math.pow(2,Zr);f.prototype.F1=Zr-et;f.prototype.F2=2*et-Zr;var dd="0123456789abcdefghijklmnopqrstuvwxyz",jo=[],Pt,he;Pt=48;for(he=0;he<=9;++he)jo[Pt++]=he;Pt=97;for(he=10;he<36;++he)jo[Pt++]=he;Pt=65;for(he=10;he<36;++he)jo[Pt++]=he;function Rs(e){return dd.charAt(e)}function ud(e,t){let o=jo[e.charCodeAt(t)];return o??-1}function pd(e){for(let t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function ld(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 Qr(e){let t=ne();return t.fromInt(e),t}function md(e,t){let o;if(t===16)o=4;else if(t===8)o=3;else if(t===2)o=1;else if(t===32)o=5;else if(t===4)o=2;else throw new Error("Only radix 2, 4, 8, 16, 32 are supported");this.t=0,this.s=0;let r=e.length,n=!1,i=0;for(;--r>=0;){let s=ud(e,r);if(s<0){e.charAt(r)==="-"&&(n=!0);continue}n=!1,i===0?this[this.t++]=s:i+o>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,i+=o,i>=this.DB&&(i-=this.DB)}this.clamp(),n&&f.ZERO.subTo(this,this)}function fd(){let e=this.s&this.DM;for(;this.t>0&&this[this.t-1]==e;)--this.t}function gd(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");let o=(1<<t)-1,r,n=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(n=!0,i=Rs(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&o,a<=0&&(a+=this.DB,--s)),r>0&&(n=!0),n&&(i+=Rs(r));return n?i:"0"}function hd(){let e=ne();return f.ZERO.subTo(this,e),e}function yd(){return this.s<0?this.negate():this}function Ed(e){let t=this.s-e.s;if(t!=0)return t;let o=this.t;if(t=o-e.t,t!=0)return this.s<0?-t:t;for(;--o>=0;)if((t=this[o]-e[o])!=0)return t;return 0}function en(e){let t=1,o;return(o=e>>>16)!==0&&(e=o,t+=16),(o=e>>8)!==0&&(e=o,t+=8),(o=e>>4)!==0&&(e=o,t+=4),(o=e>>2)!==0&&(e=o,t+=2),(o=e>>1)!==0&&(e=o,t+=1),t}function Sd(){return this.t<=0?0:this.DB*(this.t-1)+en(this[this.t-1]^this.s&this.DM)}function Id(e,t){let o;for(o=this.t-1;o>=0;--o)t[o+e]=this[o];for(o=e-1;o>=0;--o)t[o]=0;t.t=this.t+e,t.s=this.s}function wd(e,t){for(let o=e;o<this.t;++o)t[o-e]=this[o];t.t=Math.max(this.t-e,0),t.s=this.s}function Ad(e,t){let o=e%this.DB,r=this.DB-o,n=(1<<r)-1,i=Math.floor(e/this.DB),s=this.s<<o&this.DM,a;for(a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>r|s,s=(this[a]&n)<<o;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}function xd(e,t){t.s=this.s;let o=Math.floor(e/this.DB);if(o>=this.t){t.t=0;return}let r=e%this.DB,n=this.DB-r,i=(1<<r)-1;t[0]=this[o]>>r;for(let s=o+1;s<this.t;++s)t[s-o-1]|=(this[s]&i)<<n,t[s-o]=this[s]>>r;r>0&&(t[this.t-o-1]|=(this.s&i)<<n),t.t=this.t-o,t.clamp()}function Cd(e,t){let o=0,r=0,n=Math.min(e.t,this.t);for(;o<n;)r+=this[o]-e[o],t[o++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;o<this.t;)r+=this[o],t[o++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;o<e.t;)r-=e[o],t[o++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[o++]=this.DV+r:r>0&&(t[o++]=r),t.t=o,t.clamp()}function vd(e,t){let o=this.abs(),r=e.abs(),n=o.t;for(t.t=n+r.t;--n>=0;)t[n]=0;for(n=0;n<r.t;++n)t[n+o.t]=o.am(0,r[n],t,n,0,o.t);t.s=0,t.clamp(),this.s!==e.s&&f.ZERO.subTo(t,t)}function Pd(e){let t=this.abs(),o=e.t=2*t.t;for(;--o>=0;)e[o]=0;for(o=0;o<t.t-1;++o){let r=t.am(o,t[o],e,2*o,0,1);(e[o+t.t]+=t.am(o+1,2*t[o],e,2*o+1,r,t.t-o-1))>=t.DV&&(e[o+t.t]-=t.DV,e[o+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(o,t[o],e,2*o,0,1)),e.s=0,e.clamp()}function Td(e,t,o){let r=e.abs();if(r.t<=0)return;let n=this.abs();if(n.t<r.t){t?.fromInt(0),o!=null&&this.copyTo(o);return}o===null&&(o=ne());let i=ne(),s=this.s,a=e.s,c=this.DB-en(r[r.t-1]);c>0?(r.lShiftTo(c,i),n.lShiftTo(c,o)):(r.copyTo(i),n.copyTo(o));let d=i.t,u=i[d-1];if(u===0)return;let p=u*(1<<this.F1)+(d>1?i[d-2]>>this.F2:0),l=this.FV/p,m=(1<<this.F1)/p,h=1<<this.F2,I=o.t,A=I-d,S=t===null?ne():t;for(i.dlShiftTo(A,S),o.compareTo(S)>=0&&(o[o.t++]=1,o.subTo(S,o)),f.ONE.dlShiftTo(d,S),S.subTo(i,i);i.t<d;)i[i.t++]=0;for(;--A>=0;){let M=o[--I]===u?this.DM:Math.floor(o[I]*l+(o[I-1]+h)*m);if((o[I]+=i.am(0,M,o,A,0,d))<M)for(i.dlShiftTo(A,S),o.subTo(S,o);o[I]<--M;)o.subTo(S,o)}t!==null&&(o.drShiftTo(d,t),s!==a&&f.ZERO.subTo(t,t)),o.t=d,o.clamp(),c>0&&o.rShiftTo(c,o),s<0&&f.ZERO.subTo(o,o)}function Rd(e){let t=ne();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(f.ZERO)>0&&e.subTo(t,t),t}function _d(){if(this.t<1)return 0;let e=this[0];if((e&1)===0)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 Nd(e){return this.compareTo(e)===0}function bd(e,t){let o=0,r=0,n=Math.min(e.t,this.t);for(;o<n;)r+=this[o]+e[o],t[o++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;o<this.t;)r+=this[o],t[o++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;o<e.t;)r+=e[o],t[o++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[o++]=r:r<-1&&(t[o++]=this.DV+r),t.t=o,t.clamp()}function Ud(e){let t=ne();return this.addTo(e,t),t}function Od(e){let t=ne();return this.subTo(e,t),t}function Dd(e){let t=ne();return this.multiplyTo(e,t),t}function Md(e){let t=ne();return this.divRemTo(e,t,null),t}function Tt(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 kd(e){let t=ne();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(f.ZERO)>0&&this.m.subTo(t,t),t}function Fd(e){let t=ne();return e.copyTo(t),this.reduce(t),t}function Ld(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(let t=0;t<this.m.t;++t){let o=e[t]&32767,r=o*this.mpl+((o*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(o=t+this.m.t,e[o]+=this.m.am(0,r,e,t,0,this.m.t);e[o]>=e.DV;)e[o]-=e.DV,e[++o]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Bd(e,t){e.squareTo(t),this.reduce(t)}function Hd(e,t,o){e.multiplyTo(t,o),this.reduce(o)}Tt.prototype.convert=kd;Tt.prototype.revert=Fd;Tt.prototype.reduce=Ld;Tt.prototype.mulTo=Hd;Tt.prototype.sqrTo=Bd;function Kd(e,t,o){let r=e.bitLength(),n,i=Qr(1),s=new Tt(t);if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6;let a=[],c=3,d=n-1,u=(1<<n)-1;if(a[1]=s.convert(this),n>1){let S=ne();for(s.sqrTo(a[1],S);c<=u;)a[c]=ne(),s.mulTo(S,a[c-2],a[c]),c+=2}let p=e.t-1,l,m=!0,h=ne(),I;for(r=en(e[p])-1;p>=0;){for(r>=d?l=e[p]>>r-d&u:(l=(e[p]&(1<<r+1)-1)<<d-r,p>0&&(l|=e[p-1]>>this.DB+r-d)),c=n;(l&1)===0;)l>>=1,--c;if((r-=c)<0&&(r+=this.DB,--p),m)a[l].copyTo(i),m=!1;else{for(;c>1;)s.sqrTo(i,h),s.sqrTo(h,i),c-=2;c>0?s.sqrTo(i,h):(I=i,i=h,h=I),s.mulTo(h,a[l],i)}for(;p>=0&&(e[p]&1<<r)===0;)s.sqrTo(i,h),I=i,i=h,h=I,--r<0&&(r=this.DB-1,--p)}let A=s.revert(i);return o(null,A),A}f.prototype.copyTo=pd;f.prototype.fromInt=ld;f.prototype.fromString=md;f.prototype.clamp=fd;f.prototype.dlShiftTo=Id;f.prototype.drShiftTo=wd;f.prototype.lShiftTo=Ad;f.prototype.rShiftTo=xd;f.prototype.subTo=Cd;f.prototype.multiplyTo=vd;f.prototype.squareTo=Pd;f.prototype.divRemTo=Td;f.prototype.invDigit=_d;f.prototype.addTo=bd;f.prototype.toString=gd;f.prototype.negate=hd;f.prototype.abs=yd;f.prototype.compareTo=Ed;f.prototype.bitLength=Sd;f.prototype.mod=Rd;f.prototype.equals=Nd;f.prototype.add=Ud;f.prototype.subtract=Od;f.prototype.multiply=Dd;f.prototype.divide=Md;f.prototype.modPow=Kd;f.ZERO=Qr(0);f.ONE=Qr(1);var _s=async({a:e,g:t,k:o,x:r,B:n,N:i,U:s})=>new Promise((a,c)=>{t.modPow(r,i,(d,u)=>{if(d){c(d);return}n.subtract(o.multiply(u)).modPow(e.add(s.multiply(r)),i,(p,l)=>{if(p){c(p);return}a(l.mod(i))})})});var Ns="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",tn={},Go={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),tn[e]=t,Go[t]=e}var De=e=>{if(e.length%2!==0)throw new Error("Hex encoded strings must have an even number length");let t=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2){let r=e.slice(o,o+2).toLowerCase();if(r in Go)t[o/2]=Go[r];else throw new Error(`Cannot decode unrecognized sequence ${r} as hexadecimal`)}return t};var Rt=e=>{let t="";for(let o=0;o<e.byteLength;o++)t+=tn[e[o]];return t};var Qt=e=>{let t=new Be;t.update(e);let o=t.digestSync(),r=Rt(o);return new Array(64-r.length).join("0")+r};var _t=e=>Qt(De(e));var Wd=/^[89a-f]/i,ve=e=>{if(!(e instanceof f))throw new Error("Not a BigInteger");let t=e.compareTo(f.ZERO)<0,o=e.abs().toString(16);if(o=o.length%2!==0?`0${o}`:o,o=Wd.test(o)?`00${o}`:o,t){let r=o.split("").map(i=>{let s=~parseInt(i,16)&15;return"0123456789ABCDEF".charAt(s)}).join("");o=new f(r,16).add(f.ONE).toString(16),o.toUpperCase().startsWith("FF8")&&(o=o.substring(2))}return o};var bs=({A:e,B:t})=>{let o=new f(_t(ve(e)+ve(t)),16);if(o.equals(f.ZERO))throw new Error("U cannot be zero.");return o};var Us=(e,t,o)=>{let r=new Be(t);r.update(e);let n=r.digestSync(),i=new Be(n);return i.update(o),i.digestSync().slice(0,16)};var Nt=e=>{let t=new Gt().random(e).toString();return De(t)};var Os=()=>fe.convert(Nt(40));var Yo=class{constructor({userPoolName:t,a:o,g:r,A:n,N:i}){this.encoder=vt,this.userPoolName=t,this.a=o,this.g=r,this.A=n,this.N=i,this.k=new f(_t(`${ve(i)}${ve(r)}`),16)}getRandomPassword(){if(!this.randomPassword)throw new g({name:"EmptyBigIntegerRandomPassword",message:"random password is empty"});return this.randomPassword}getSaltToHashDevices(){if(!this.saltToHashDevices)throw new g({name:"EmptyBigIntegersaltToHashDevices",message:"saltToHashDevices is empty"});return this.saltToHashDevices}getVerifierDevices(){if(!this.verifierDevices)throw new g({name:"EmptyBigIntegerVerifierDevices",message:"verifyDevices is empty"});return this.verifierDevices}async generateHashDevice(t,o){this.randomPassword=Os();let r=`${t}${o}:${this.randomPassword}`,n=Qt(r),i=Rt(Nt(16));return this.saltToHashDevices=ve(new f(i,16)),new Promise((s,a)=>{this.g.modPow(new f(_t(this.saltToHashDevices+n),16),this.N,(c,d)=>{if(c){a(c);return}this.verifierDevices=ve(d),s()})})}async getPasswordAuthenticationKey({username:t,password:o,serverBValue:r,salt:n}){if(r.mod(this.N).equals(f.ZERO))throw new Error("B cannot be zero.");let i=bs({A:this.A,B:r}),s=`${this.userPoolName}${t}:${o}`,a=Qt(s),c=new f(_t(ve(n)+a),16),d=await _s({a:this.a,g:this.g,k:this.k,x:c,B:r,N:this.N,U:i}),u=this.encoder.convert("Caldera Derived Key"),p=this.encoder.convert(""),l=new Uint8Array(u.byteLength+p.byteLength);return l.set(u,0),l.set(p,u.byteLength),Us(De(ve(d)),De(ve(i)),l)}};var Ds=async({a:e,g:t,N:o})=>new Promise((r,n)=>{t.modPow(e,o,(i,s)=>{if(i){n(i);return}if(s.mod(o).equals(f.ZERO)){n(new Error("Illegal parameter. A mod N cannot be 0."));return}r(s)})});var tt=async e=>{let t=new f(Ns,16),o=new f("2",16),r=Vd(),n=await Ds({a:r,g:o,N:t});return new Yo({userPoolName:e,a:r,g:o,A:n,N:t})},Vd=()=>{let e=Rt(Nt(128));return new f(e,16)};async function ye({userPoolId:e,userPoolEndpoint:t,newDeviceMetadata:o,accessToken:r}){if(!o)return;let n=e.split("_")[1]||"",i=await tt(n),s=o?.DeviceKey,a=o?.DeviceGroupKey;try{await i.generateHashDevice(a??"",s??"")}catch{return}let c={Salt:fe.convert(De(i.getSaltToHashDevices())),PasswordVerifier:fe.convert(De(i.getVerifierDevices()))},d=i.getRandomPassword();try{return await vs({endpointResolver:P({endpointOverride:t})})({region:v(e)},{AccessToken:r,DeviceName:await Vr(),DeviceKey:o?.DeviceKey,DeviceSecretVerifierConfig:c}),{deviceKey:s,deviceGroupKey:a,randomPassword:d}}catch{return}}async function Ms(e){let t=w.getConfig().Auth?.Cognito;E(t);let{username:o,signInSession:r,signInDetails:n,challengeName:i}=Ce.getState();if(i!=="WEB_AUTHN"||!o)throw new g({name:Ne.SignInException,message:"Unable to proceed due to invalid sign in state."});let{CREDENTIAL_REQUEST_OPTIONS:s}=e;xt(!!s,N.InvalidPasskeyAuthenticationOptions);let a=await Cs(JSON.parse(s)),c=mt({endpointResolver:P({endpointOverride:t.userPoolEndpoint})}),{ChallengeName:d,ChallengeParameters:u,AuthenticationResult:p,Session:l}=await c({region:v(t.userPoolId),userAgentValue:O(R.ConfirmSignIn)},{ChallengeName:"WEB_AUTHN",ChallengeResponses:{USERNAME:o,CREDENTIAL:JSON.stringify(a)},ClientId:t.userPoolClientId,Session:r});if(ge({signInSession:l,username:o,challengeName:d,signInDetails:n}),p)return await oe({...p,username:o,NewDeviceMetadata:await ye({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:p.NewDeviceMetadata,accessToken:p.AccessToken}),signInDetails:n}),Ce.dispatch({type:"RESET_STATE"}),await ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}};if(d==="WEB_AUTHN")throw new g({name:Ne.SignInException,message:"Sequential WEB_AUTHN challenges returned from underlying service cannot be handled."});return{challengeName:d,challengeParameters:u}}function Y({username:e,userPoolId:t,userPoolClientId:o}){if(typeof window>"u")return;let r=window.AmazonCognitoAdvancedSecurityData;if(typeof r>"u")return;let n=r.getData(e,t,o);return n?{EncodedData:n}:{}}var zd=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],qd=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Jo=()=>{let e=new Date,t=qd[e.getUTCDay()],o=zd[e.getUTCMonth()],r=e.getUTCDate(),n=e.getUTCHours();n<10&&(n=`0${n}`);let i=e.getUTCMinutes();i<10&&(i=`0${i}`);let s=e.getUTCSeconds();s<10&&(s=`0${s}`);let a=e.getUTCFullYear();return`${t} ${o} ${r} ${n}:${i}:${s} UTC ${a}`};var Xo=({userPoolName:e,username:t,challengeParameters:o,dateNow:r,hkdf:n})=>{let i=vt.convert(e),s=vt.convert(t),a=$d(o.SECRET_BLOCK),c=vt.convert(r),d=new Uint8Array(i.byteLength+s.byteLength+a.byteLength+c.byteLength);d.set(i,0),d.set(s,i.byteLength),d.set(a,i.byteLength+s.byteLength),d.set(c,i.byteLength+s.byteLength+a.byteLength);let u=new Be(n);u.update(d);let p=u.digestSync();return fe.convert(p)},$d=e=>{let t="=".repeat((4-e.length%4)%4),o=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=at.convert(o),n=new Uint8Array(r.length);for(let i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n};async function eo({username:e,config:t,clientMetadata:o,session:r,tokenOrchestrator:n}){let{userPoolId:i,userPoolEndpoint:s}=t,a=t.userPoolClientId,c=await n?.getDeviceMetadata(e);qr(c);let d=await tt(c.deviceGroupKey),u={USERNAME:e,SRP_A:d.A.toString(16),DEVICE_KEY:c.deviceKey},p={ChallengeName:"DEVICE_SRP_AUTH",ClientId:a,ChallengeResponses:u,ClientMetadata:o,Session:r},l=mt({endpointResolver:P({endpointOverride:s})}),{ChallengeParameters:m,Session:h}=await l({region:v(i)},p);return jd(e,m,o,h,d,t,n)}async function jd(e,t,o,r,n,{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a},c){let d=await c?.getDeviceMetadata(e);qr(d);let u=new f(t?.SRP_B,16),p=new f(t?.SALT,16),{deviceKey:l}=d,{deviceGroupKey:m}=d,h=await n.getPasswordAuthenticationKey({username:d.deviceKey,password:d.randomPassword,serverBValue:u,salt:p}),I=Jo(),A={USERNAME:t?.USERNAME??e,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:I,PASSWORD_CLAIM_SIGNATURE:Xo({username:l,userPoolName:m,challengeParameters:t,dateNow:I,hkdf:h}),DEVICE_KEY:l},S=Y({username:e,userPoolId:i,userPoolClientId:s}),M={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:s,ChallengeResponses:A,Session:r,ClientMetadata:o,UserContextData:S};return mt({endpointResolver:P({endpointOverride:a})})({region:v(i)},M)}async function Zo(e,t,o,r,n,i,s){let{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=i,u=a?.split("_")[1]||"",p=new f(t?.SRP_B,16),l=new f(t?.SALT,16),m=t?.USER_ID_FOR_SRP;if(!m)throw new g({name:"EmptyUserIdForSRPException",message:"USER_ID_FOR_SRP was not found in challengeParameters"});let h=await n.getPasswordAuthenticationKey({username:m,password:e,serverBValue:p,salt:l}),I=Jo(),A={USERNAME:m,PASSWORD_CLAIM_SECRET_BLOCK:t?.SECRET_BLOCK,TIMESTAMP:I,PASSWORD_CLAIM_SIGNATURE:Xo({username:m,userPoolName:u,challengeParameters:t,dateNow:I,hkdf:h})},S=await s.getDeviceMetadata(m);S&&S.deviceKey&&(A.DEVICE_KEY=S.deviceKey);let M=Y({username:m,userPoolId:a,userPoolClientId:c}),H={ChallengeName:"PASSWORD_VERIFIER",ChallengeResponses:A,ClientMetadata:o,Session:r,ClientId:c,UserContextData:M},ie=await mt({endpointResolver:P({endpointOverride:d})})({region:v(a)},H);return ie.ChallengeName==="DEVICE_SRP_AUTH"?eo({username:m,config:i,clientMetadata:o,session:ie.Session,tokenOrchestrator:s}):ie}async function ot(e,t,o,r){try{return await e(...t)}catch(n){if(n instanceof g&&n.name==="ResourceNotFoundException"&&n.message.includes("Device does not exist."))return await r.clearDeviceMetadata(o),e(...t);throw n}}function rt(e){let{dispatch:t}=Ce;t({type:"SET_USERNAME",value:e})}async function Qo({username:e,password:t,clientMetadata:o,config:r,tokenOrchestrator:n,authFlow:i,preferredChallenge:s}){let{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=r,u=a?.split("_")[1]||"",p=await tt(u),l={USERNAME:e,SRP_A:p.A.toString(16)};i==="USER_AUTH"&&s&&(l.PREFERRED_CHALLENGE=s);let m=Y({username:e,userPoolId:a,userPoolClientId:c}),h={AuthFlow:i,AuthParameters:l,ClientMetadata:o,ClientId:c,UserContextData:m},A=await Qe({endpointResolver:P({endpointOverride:d})})({region:v(a),userAgentValue:O(R.SignIn)},h),{ChallengeParameters:S,Session:M}=A,H=S?.USERNAME??e;return rt(H),A.ChallengeName==="PASSWORD_VERIFIER"?ot(Zo,[t,S,o,M,p,r,n],H,n):A}var ks="userAttributes.";function Gd(e){return"isSignedIn"in e&&"nextStep"in e}async function Bs(e,t,o,r,n){let{userPoolClientId:i,userPoolId:s,userPoolEndpoint:a}=r,c={USERNAME:e,PASSWORD:t},d=await n.getDeviceMetadata(e);d&&d.deviceKey&&(c.DEVICE_KEY=d.deviceKey);let u=Y({username:e,userPoolId:s,userPoolClientId:i}),p={AuthFlow:"USER_PASSWORD_AUTH",AuthParameters:c,ClientMetadata:o,ClientId:i,UserContextData:u},m=await Qe({endpointResolver:P({endpointOverride:a})})({region:v(s),userAgentValue:O(R.SignIn)},p),h=m.ChallengeParameters?.USERNAME??m.ChallengeParameters?.USER_ID_FOR_SRP??e;return rt(h),m.ChallengeName==="DEVICE_SRP_AUTH"?eo({username:h,config:r,clientMetadata:o,session:m.Session,tokenOrchestrator:n}):m}async function Hs(e,t,o,r,n){return Qo({username:e,password:t,clientMetadata:o,config:r,tokenOrchestrator:n,authFlow:"USER_SRP_AUTH"})}async function Ks(e,t,o,r){let{userPoolClientId:n,userPoolId:i,userPoolEndpoint:s}=o,a={USERNAME:e},c=await r.getDeviceMetadata(e);c&&c.deviceKey&&(a.DEVICE_KEY=c.deviceKey);let d=Y({username:e,userPoolId:i,userPoolClientId:n}),u={AuthFlow:"CUSTOM_AUTH",AuthParameters:a,ClientMetadata:t,ClientId:n,UserContextData:d},l=await Qe({endpointResolver:P({endpointOverride:s})})({region:v(i),userAgentValue:O(R.SignIn)},u),m=l.ChallengeParameters?.USERNAME??e;return rt(m),l.ChallengeName==="DEVICE_SRP_AUTH"?eo({username:m,config:o,clientMetadata:t,session:l.Session,tokenOrchestrator:r}):l}async function Ws(e,t,o,r,n){E(r);let{userPoolId:i,userPoolClientId:s,userPoolEndpoint:a}=r,c=i?.split("_")[1]||"",d=await tt(c),u={USERNAME:e,SRP_A:d.A.toString(16),CHALLENGE_NAME:"SRP_A"},p=Y({username:e,userPoolId:i,userPoolClientId:s}),l={AuthFlow:"CUSTOM_AUTH",AuthParameters:u,ClientMetadata:o,ClientId:s,UserContextData:p},m=Qe({endpointResolver:P({endpointOverride:a})}),{ChallengeParameters:h,Session:I}=await m({region:v(i),userAgentValue:O(R.SignIn)},l),A=h?.USERNAME??e;return rt(A),ot(Zo,[t,h,o,I,d,r,n],A,n)}async function Pe(e){let{challengeName:t,challengeParameters:o,availableChallenges:r}=e,n=w.getConfig().Auth?.Cognito;switch(E(n),t){case"CUSTOM_CHALLENGE":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_CUSTOM_CHALLENGE",additionalInfo:o}};case"MFA_SETUP":{let{signInSession:i,username:s}=Ce.getState(),a=Fs(Ls(o.MFAS_CAN_SETUP))||[],c=Zd(a),d=c.includes("TOTP"),u=c.includes("EMAIL");if(d&&u)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION",allowedMFATypes:c}};if(u)return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_EMAIL_SETUP"}};if(d){let p=as({endpointResolver:P({endpointOverride:n.userPoolEndpoint})}),{Session:l,SecretCode:m}=await p({region:v(n.userPoolId)},{Session:i});return Ce.dispatch({type:"SET_SIGN_IN_SESSION",value:l}),{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_TOTP_SETUP",totpSetupDetails:Yd(m,s)}}}throw new g({name:Ne.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:Jd(o.requiredAttributes)}};case"SELECT_MFA_TYPE":return{isSignedIn:!1,nextStep:{signInStep:"CONTINUE_SIGN_IN_WITH_MFA_SELECTION",allowedMFATypes:Fs(Ls(o.MFAS_CAN_CHOOSE))}};case"SMS_OTP":case"SMS_MFA":return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_IN_WITH_SMS_CODE",codeDeliveryDetails:{deliveryMedium:o.CODE_DELIVERY_DELIVERY_MEDIUM,destination:o.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:o.CODE_DELIVERY_DELIVERY_MEDIUM,destination:o.CODE_DELIVERY_DESTINATION}}};case"WEB_AUTHN":{let i=await Ms(o);return Gd(i)?i:Pe(i)}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:r}}}throw new g({name:Ne.SignInException,message:`An error occurred during the sign in process. ${t} challengeName returned by the underlying service was not addressed.`})}function Yd(e,t){return{sharedSecret:e,getSetupUri:(o,r)=>{let n=`otpauth://totp/${o}:${r??t}?secret=${e}&issuer=${o}`;return new te(n)}}}function Me(e){if(e===Jt.PasswordResetRequiredException)return{isSignedIn:!1,nextStep:{signInStep:"RESET_PASSWORD"}};if(e===Jt.UserNotConfirmedException)return{isSignedIn:!1,nextStep:{signInStep:"CONFIRM_SIGN_UP"}}}function Jd(e){return e?JSON.parse(e).map(o=>o.includes(ks)?o.replace(ks,""):o):[]}function Xd(e){if(e==="SMS_MFA")return"SMS";if(e==="SOFTWARE_TOKEN_MFA")return"TOTP";if(e==="EMAIL_OTP")return"EMAIL"}function Fs(e){if(e)return e.map(Xd).filter(Boolean)}function Ls(e){return e?JSON.parse(e):[]}function Zd(e){return e.filter(t=>t==="EMAIL"||t==="TOTP")}async function er(){let e;try{e=await Ze()}catch{}if(e&&e.userId&&e.username)throw new g({name:Yi,message:"There is already a signed in user.",recoverySuggestion:"Call signOut before calling signIn again."})}function ke(e){return Ce.getState().username??e}async function Vs(e){let t=w.getConfig().Auth?.Cognito;E(t);let{username:o,password:r,options:n}=e,i={loginId:o,authFlowType:"CUSTOM_WITHOUT_SRP"},s=n?.clientMetadata;_(!!o,y.EmptySignInUsername),_(!r,y.CustomAuthSignInPassword);try{let{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:u}=await ot(Ks,[o,s,t,D],o,D),p=ke(o);return ge({signInSession:u,username:p,challengeName:a,signInDetails:i}),d?(await oe({username:p,...d,NewDeviceMetadata:await ye({userPoolId:t.userPoolId,userPoolEndpoint:t.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:i}),re(),await ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Pe({challengeName:a,challengeParameters:c})}catch(a){re(),B(a);let c=Me(a.name);if(c)return c;throw a}}async function zs(e){let{username:t,password:o,options:r}=e,n={loginId:t,authFlowType:"CUSTOM_WITH_SRP"},i=w.getConfig().Auth?.Cognito;E(i);let s=r?.clientMetadata;_(!!t,y.EmptySignInUsername),_(!!o,y.EmptySignInPassword);try{let{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:u}=await Ws(t,o,s,i,D),p=ke(t);return ge({signInSession:u,username:p,challengeName:a,signInDetails:n}),d?(await oe({username:p,...d,NewDeviceMetadata:await ye({userPoolId:i.userPoolId,userPoolEndpoint:i.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:n}),re(),await ce(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Pe({challengeName:a,challengeParameters:c})}catch(a){re(),B(a);let c=Me(a.name);if(c)return c;throw a}}var qs=async()=>{throw new g({name:Fo,message:"The autoSignIn flow has not started, or has been cancelled/completed.",recoverySuggestion:"Please try to use the signIn API or log out before starting a new autoSignIn flow."})},$s=qs;function to(e){$s=e}function J(e=!0){e&&($s=qs),ze.dispatch({type:"RESET"})}async function on(e){let{username:t,password:o}=e,r=w.getConfig().Auth?.Cognito,n={loginId:t,authFlowType:"USER_SRP_AUTH"};E(r);let i=e.options?.clientMetadata;_(!!t,y.EmptySignInUsername),_(!!o,y.EmptySignInPassword);try{let{ChallengeName:s,ChallengeParameters:a,AuthenticationResult:c,Session:d}=await Hs(t,o,i,r,D),u=ke(t);return ge({signInSession:d,username:u,challengeName:s,signInDetails:n}),c?(await oe({username:u,...c,NewDeviceMetadata:await ye({userPoolId:r.userPoolId,userPoolEndpoint:r.userPoolEndpoint,newDeviceMetadata:c.NewDeviceMetadata,accessToken:c.AccessToken}),signInDetails:n}),re(),await ce(),J(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Pe({challengeName:s,challengeParameters:a})}catch(s){re(),J(),B(s);let a=Me(s.name);if(a)return a;throw s}}async function js(e){let{username:t,password:o,options:r}=e,n=w.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_PASSWORD_AUTH"};E(n);let s=r?.clientMetadata;_(!!t,y.EmptySignInUsername),_(!!o,y.EmptySignInPassword);try{let{ChallengeName:a,ChallengeParameters:c,AuthenticationResult:d,Session:u}=await ot(Bs,[t,o,s,n,D],t,D),p=ke(t);return ge({signInSession:u,username:p,challengeName:a,signInDetails:i}),d?(await oe({...d,username:p,NewDeviceMetadata:await ye({userPoolId:n.userPoolId,userPoolEndpoint:n.userPoolEndpoint,newDeviceMetadata:d.NewDeviceMetadata,accessToken:d.AccessToken}),signInDetails:i}),re(),await ce(),J(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Pe({challengeName:a,challengeParameters:c})}catch(a){re(),J(),B(a);let c=Me(a.name);if(c)return c;throw a}}async function Gs({username:e,clientMetadata:t,config:o,tokenOrchestrator:r,preferredChallenge:n,password:i,session:s}){let{userPoolId:a,userPoolClientId:c,userPoolEndpoint:d}=o,u=Y({username:e,userPoolId:a,userPoolClientId:c}),p={USERNAME:e};if(n){if(o.passwordless&&(n==="EMAIL_OTP"&&!o.passwordless.emailOtpEnabled||n==="SMS_OTP"&&!o.passwordless.smsOtpEnabled||n==="WEB_AUTHN"&&!o.passwordless.webAuthn)&&_(!1,y.InvalidPreferredChallenge),n==="PASSWORD_SRP")return _(!!i,y.EmptySignInPassword),Qo({username:e,password:i,clientMetadata:t,config:o,tokenOrchestrator:r,authFlow:"USER_AUTH",preferredChallenge:n});n==="PASSWORD"&&(_(!!i,y.EmptySignInPassword),p.PASSWORD=i),p.PREFERRED_CHALLENGE=n}let l={AuthFlow:"USER_AUTH",AuthParameters:p,ClientMetadata:t,ClientId:c,UserContextData:u};s&&(l.Session=s);let h=await Qe({endpointResolver:P({endpointOverride:d})})({region:v(a),userAgentValue:O(R.SignIn)},l);return rt(e),h}async function tr(e){let{username:t,password:o,options:r}=e,n=w.getConfig().Auth?.Cognito,i={loginId:t,authFlowType:"USER_AUTH"};E(n);let s=r?.clientMetadata,a=r?.preferredChallenge??n?.passwordless?.preferredChallenge;_(!!t,y.EmptySignInUsername);try{let c={username:t,config:n,tokenOrchestrator:D,clientMetadata:s,preferredChallenge:a,password:o},d=ze.getState();d.active&&d.username===t&&(c.session=d.session);let u=await Gs(c),p=ke(t);return ge({signInSession:u.Session,username:p,challengeName:u.ChallengeName,signInDetails:i}),u.AuthenticationResult?(await oe({username:p,...u.AuthenticationResult,NewDeviceMetadata:await ye({userPoolId:n.userPoolId,userPoolEndpoint:n.userPoolEndpoint,newDeviceMetadata:u.AuthenticationResult.NewDeviceMetadata,accessToken:u.AuthenticationResult.AccessToken}),signInDetails:i}),re(),await ce(),J(),{isSignedIn:!0,nextStep:{signInStep:"DONE"}}):Pe({challengeName:u.ChallengeName,challengeParameters:u.ChallengeParameters,availableChallenges:"AvailableChallenges"in u?u.AvailableChallenges:void 0})}catch(c){re(),J(),B(c);let d=Me(c.name);if(d)return d;throw c}}async function bt(e){J(!1);let t=e.options?.authFlowType;switch(await er(),t){case"USER_SRP_AUTH":return on(e);case"USER_PASSWORD_AUTH":return js(e);case"CUSTOM_WITHOUT_SRP":return Vs(e);case"CUSTOM_WITH_SRP":return zs(e);case"USER_AUTH":return tr(e);default:return on(e)}}var Ys=180*1e3;function Js(e){let t=io.listen("auth-internal",async({payload:r})=>{r.event==="confirmSignUp"&&r.data?.isSignUpComplete&&(io.dispatch("auth-internal",{event:"autoSignIn"}),to(Qs(e)),t())}),o=setTimeout(()=>{t(),clearTimeout(o),J()},Ys)}function Xs(e,t){let o;return r=>{o||e(...r),clearTimeout(o),o=setTimeout(()=>{o=void 0},t)}}function Qd(e,t,o){let r=Date.now(),n=setInterval(async()=>{if(Date.now()-r>Ys)clearInterval(n),o(new g({name:Fo,message:"The account was not confirmed on time.",recoverySuggestion:"Try to verify your account by clicking the link sent your email or phone and then login manually."})),J();else try{let a=await bt(e);a.nextStep.signInStep!=="CONFIRM_SIGN_UP"&&(t(a),clearInterval(n),J())}catch(a){clearInterval(n),o(a),J()}},5e3)}var eu=Xs(Qd,300),tu=Xs(ou,300);function Zs(e){return async()=>new Promise((t,o)=>{eu([e,t,o])})}async function ou(e,t,o){try{let r=e?.options?.authFlowType==="USER_AUTH"?await tr(e):await bt(e);t(r),J()}catch(r){o(r),J()}}function Qs(e){return async()=>new Promise((t,o)=>{tu([e,t,o])})}var ea=Qs;var ru=()=>async e=>{if(e.statusCode>=300){let t=await pe(e);if(B(t),t.name===ko.InvalidParameterException&&/'password'/.test(t.message)&&/Member must not be null/.test(t.message)){let o=y.EmptySignUpPassword,{message:r,recoverySuggestion:n}=Mo[o];throw new g({name:o,message:r,recoverySuggestion:n})}throw new g({name:t.name,message:t.message})}return Re(e)},ta=e=>b(W,K("SignUp"),ru(),{...V,...e});async function rn(e){let{username:t,password:o,options:r}=e,n=w.getConfig().Auth?.Cognito,i=n?.signUpVerificationMethod??"code",{clientMetadata:s,validationData:a,autoSignIn:c}=e.options??{};E(n),_(!!t,y.EmptySignUpUsername);let d=typeof c!="boolean"?c:void 0,u={username:t,options:d};d?.authFlowType!=="CUSTOM_WITHOUT_SRP"&&(u.password=o);let{userPoolId:p,userPoolClientId:l,userPoolEndpoint:m}=n,h=ta({endpointResolver:P({endpointOverride:m})}),I={Username:t,Password:void 0,UserAttributes:r?.userAttributes&&zr(r?.userAttributes),ClientMetadata:s,ValidationData:a&&zr(a),ClientId:l,UserContextData:Y({username:t,userPoolId:p,userPoolClientId:l})};o&&(I.Password=o);let{UserSub:A,CodeDeliveryDetails:S,UserConfirmed:M,Session:H}=await h({region:v(p),userAgentValue:O(R.SignUp)},I);(d||c===!0)&&(ze.dispatch({type:"START"}),ze.dispatch({type:"SET_USERNAME",value:t}),ze.dispatch({type:"SET_SESSION",value:H}));let le={destination:S?.Destination,deliveryMedium:S?.DeliveryMedium,attributeName:S?.AttributeName},ie=!!M,Ee=ze.getState().active;if(ie)return Ee?(to(ea(u)),{isSignUpComplete:!0,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN"},userId:A}):{isSignUpComplete:!0,nextStep:{signUpStep:"DONE"},userId:A};if(Ee){if(i==="link")return to(Zs(u)),{isSignUpComplete:!1,nextStep:{signUpStep:"COMPLETE_AUTO_SIGN_IN",codeDeliveryDetails:le},userId:A};Js(u)}return{isSignUpComplete:!1,nextStep:{signUpStep:"CONFIRM_SIGN_UP",codeDeliveryDetails:le},userId:A}}var oa=e=>b(W,K("ForgotPassword"),G(),{...V,...e});async function nn(e){let{username:t}=e;_(!!t,y.EmptyResetPasswordUsername);let o=w.getConfig().Auth?.Cognito;E(o);let{userPoolClientId:r,userPoolId:n,userPoolEndpoint:i}=o,s=e.options?.clientMetadata,a=Y({username:t,userPoolId:n,userPoolClientId:r}),u=(await oa({endpointResolver:P({endpointOverride:i})})({region:v(n),userAgentValue:O(R.ResetPassword)},{Username:t,ClientMetadata:s,ClientId:r,UserContextData:a})).CodeDeliveryDetails;return{isPasswordReset:!1,nextStep:{resetPasswordStep:"CONFIRM_RESET_PASSWORD_WITH_CODE",codeDeliveryDetails:{deliveryMedium:u?.DeliveryMedium,destination:u?.Destination,attributeName:u?.AttributeName}}}}var ra=e=>b(W,K("ConfirmForgotPassword"),G(),{...V,...e});async function sn(e){let t=w.getConfig().Auth?.Cognito;E(t);let{userPoolClientId:o,userPoolId:r,userPoolEndpoint:n}=t,{username:i,newPassword:s}=e;_(!!i,y.EmptyConfirmResetPasswordUsername),_(!!s,y.EmptyConfirmResetPasswordNewPassword);let a=e.confirmationCode;_(!!a,y.EmptyConfirmResetPasswordConfirmationCode);let c=e.options?.clientMetadata,d=Y({username:i,userPoolId:r,userPoolClientId:o});await ra({endpointResolver:P({endpointOverride:n})})({region:v(t.userPoolId),userAgentValue:O(R.ConfirmResetPassword)},{Username:i,ConfirmationCode:a,Password:s,ClientMetadata:c,ClientId:t.userPoolClientId,UserContextData:d})}var yv=new C("AuthError");var na={oauthSignInError:{message:q.OAUTH_ERROR,log:"Make sure Cognito Hosted UI has been configured correctly"},noConfig:{message:q.DEFAULT_MSG,log:`
|
|
12
4
|
Error: Amplify has not been configured correctly.
|
|
13
5
|
This error is typically caused by one of the following scenarios:
|
|
14
6
|
|
|
@@ -17,7 +9,7 @@
|
|
|
17
9
|
|
|
18
10
|
2. There might be multiple conflicting versions of amplify packages in your node_modules.
|
|
19
11
|
Refer to our docs site for help upgrading Amplify packages (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js)
|
|
20
|
-
`},missingAuthConfig:{message:
|
|
12
|
+
`},missingAuthConfig:{message:q.DEFAULT_MSG,log:`
|
|
21
13
|
Error: Amplify has not been configured correctly.
|
|
22
14
|
The configuration object is missing required auth properties.
|
|
23
15
|
This error is typically caused by one of the following scenarios:
|
|
@@ -26,7 +18,7 @@
|
|
|
26
18
|
See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information
|
|
27
19
|
|
|
28
20
|
2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js) for help upgrading Amplify packages.
|
|
29
|
-
`},emptyUsername:{message:de.EMPTY_USERNAME},invalidUsername:{message:de.INVALID_USERNAME},emptyPassword:{message:de.EMPTY_PASSWORD},emptyCode:{message:de.EMPTY_CODE},signUpError:{message:de.SIGN_UP_ERROR,log:"The first parameter should either be non-null string or object"},noMFA:{message:de.NO_MFA},invalidMFA:{message:de.INVALID_MFA},emptyChallengeResponse:{message:de.EMPTY_CHALLENGE},noUserSession:{message:de.NO_USER_SESSION},deviceConfig:{message:de.DEVICE_CONFIG},networkError:{message:de.NETWORK_ERROR},autoSignInError:{message:de.AUTOSIGNIN_ERROR},default:{message:de.DEFAULT_MSG}}});var nt,_n=c(()=>{"use strict";yu();Mt();$();nt=(e,t)=>new S({message:e??"An error has occurred during the oauth process.",name:Ue.OAuthSignInError,recoverySuggestion:t??Eu.oauthSignInError.log})});var Un,Su=c(()=>{"use strict";(function(e){e.NoConfig="noConfig",e.MissingAuthConfig="missingAuthConfig",e.EmptyUsername="emptyUsername",e.InvalidUsername="invalidUsername",e.EmptyPassword="emptyPassword",e.EmptyCode="emptyCode",e.SignUpError="signUpError",e.NoMFA="noMFA",e.InvalidMFA="invalidMFA",e.EmptyChallengeResponse="emptyChallengeResponse",e.NoUserSession="noUserSession",e.Default="default",e.DeviceConfig="deviceConfig",e.NetworkError="networkError",e.AutoSignInError="autoSignInError",e.OAuthSignInError="oauthSignInError"})(Un||(Un={}))});var Gh,qh,$h,As,Iu=c(()=>{"use strict";$();Su();to();Gh="`signInWithRedirect` has been canceled.",qh="An error occurred while validating the state.",$h="Try to initiate an OAuth flow from Amplify",As=async e=>{let t=await ce.loadOAuthState(),o=e===t?t:void 0;if(!o)throw new S({name:Un.OAuthSignInError,message:e===null?Gh:qh,recoverySuggestion:e===null?void 0:$h});return o}});var Nn,jh,Jh,Au,Yh,Xh,Zh,Cs=c(()=>{"use strict";C();U();Ct();wt();to();sn();Pe();_n();Iu();Nn=async({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,responseType:n,domain:i,preferPrivateSession:s})=>{let a=new xe(e),p=a.searchParams.get("error"),m=a.searchParams.get("error_description");if(p)throw nt(m??p);return n==="code"?jh({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,domain:i,preferPrivateSession:s}):Jh({currentUrl:e,redirectUri:r,preferPrivateSession:s})},jh=async({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,domain:n,preferPrivateSession:i})=>{let s=new xe(e),a=s.searchParams.get("code"),p=s.searchParams.get("state");if(!a||!p)throw nt("User cancelled OAuth flow.");let m=await As(p),d="https://"+n+"/oauth2/token",u=await ce.loadPKCE(),l={grant_type:"authorization_code",code:a,client_id:o,redirect_uri:r,...u?{code_verifier:u}:{}},g=Object.entries(l).map(([$e,ue])=>`${encodeURIComponent($e)}=${encodeURIComponent(ue)}`).join("&"),{access_token:A,refresh_token:N,id_token:D,error:O,error_message:oe,token_type:ie,expires_in:Be}=await(await fetch(d,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",[Wn]:t},body:g})).json();if(O)throw nt(oe??O);let Te=(A&&ge(A).payload.username)??"username";return await Ie({username:Te,AccessToken:A,IdToken:D,RefreshToken:N}),Au({redirectUri:r,state:m,preferPrivateSession:i})},Jh=async({currentUrl:e,redirectUri:t,preferPrivateSession:o})=>{let r=new xe(e),{id_token:n,access_token:i,state:s,token_type:a,expires_in:p,error_description:m,error:d}=(r.hash??"#").substring(1).split("&").map(g=>g.split("=")).reduce((g,[A,N])=>({...g,[A]:N}),{id_token:void 0,access_token:void 0,state:void 0,token_type:void 0,expires_in:void 0,error_description:void 0,error:void 0});if(d)throw nt(m??d);if(!i)throw nt("No access token returned from OAuth flow.");let u=await As(s),l=(i&&ge(i).payload.username)??"username";return await Ie({username:l,AccessToken:i,IdToken:n}),Au({redirectUri:t,state:u,preferPrivateSession:o})},Au=async({redirectUri:e,state:t,preferPrivateSession:o})=>{await H.setOAuthMetadata({oauthSignIn:!0}),await ce.clearOAuthData(),await ce.storeOAuthSignIn(!0,o),nn(),Zh(e),Yh(t)&&Ee.dispatch("auth",{event:"customOAuthState",data:Fi(Xh(t))},"Auth",fe),Ee.dispatch("auth",{event:"signInWithRedirect"},"Auth",fe),await Ce()},Yh=e=>/-/.test(e),Xh=e=>e.split("-").splice(1).join("-"),Zh=e=>{typeof window<"u"&&typeof window.history<"u"&&window.history.replaceState(window.history.state,"",e)}});function Po(e,t){if(t){let o=e?.find(r=>r===t);if(!o)throw zp;return o}else{let o=e?.find(Qh)??e?.find(eE),r=e?.find(oE)??e?.find(tE);if(o)return o;throw r?Gp:Kp}}var Qh,eE,tE,oE,bn=c(()=>{"use strict";Ft();Qh=e=>e.startsWith(String(window.location.origin+(window.location.pathname||"/"))),eE=e=>e.includes(String(window.location.hostname)),tE=e=>e.startsWith("http://"),oE=e=>e.startsWith("https://")});var vo,On=c(()=>{"use strict";U();C();to();sn();vo=async e=>{nn(),await ce.clearOAuthInflightData(),Ee.dispatch("auth",{event:"signInWithRedirect_failure",data:{error:e}},"Auth",fe)}});var Cu,wu=c(()=>{"use strict";C();B();to();Cs();bn();On();Cu=async e=>{try{f(e),gt(e),ce.setAuthConfig(e)}catch{return}if(await ce.loadOAuthInFlight())try{let t=window.location.href,{loginWith:o,userPoolClientId:r}=e,{domain:n,redirectSignIn:i,responseType:s}=o.oauth,a=Po(i);await Nn({currentUrl:t,clientId:r,domain:n,redirectUri:a,responseType:s,userAgentValue:w(I.SignInWithRedirect)})}catch(t){await vo(t)}}});var xu=c(()=>{"use strict";U();C();wu();St()&&h[Uo](Cu)});var Pu,vu=c(()=>{"use strict";Pu={Google:"Google",Facebook:"Facebook",Amazon:"LoginWithAmazon",Apple:"SignInWithApple"}});var Dn,ws=c(()=>{"use strict";Dn=async e=>{window?.location&&(window.location.href=e.replace("http://","https://"))}});function rE(e){let t=new ht;return t.update(e),nE(We.convert(t.digestSync(),{urlSafe:!0}))}function nE(e){return e.replace(/=/g,"")}var Tu,Ru,_u=c(()=>{"use strict";se();C();Tu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",Ru=e=>{let t=new Uint8Array(e);qt().getRandomValues(t);let o="",r;for(let n of t)o+=Tu.charAt(n%Tu.length);return{value:o,method:"S256",toCodeChallenge(){return r||(r=rE(o),r)}}}});var Uu,Nu=c(()=>{"use strict";C();Uu=()=>Mi(32)});var bu,Ou=c(()=>{"use strict";_n();On();bu=e=>{async function t(o){if(o.persisted&&await e.loadOAuthInFlight()){let n=nt("User cancelled OAuth flow.");await vo(n)}window.removeEventListener("pageshow",t)}window.addEventListener("pageshow",t)}});async function xs(e){let t=h.getConfig().Auth?.Cognito;f(t),gt(t),ce.setAuthConfig(t),e?.options?.prompt||await xn();let o="COGNITO",r;return typeof e?.provider=="string"?o=Pu[e.provider]:e?.provider?.custom?o=e.provider.custom:e?.provider?.idpIdentifier&&({idpIdentifier:r}=e.provider),iE({oauthConfig:t.loginWith.oauth,clientId:t.userPoolClientId,provider:o,idpIdentifier:r,customState:e?.customState,preferPrivateSession:e?.options?.preferPrivateSession,options:{loginHint:e?.options?.loginHint,lang:e?.options?.lang,nonce:e?.options?.nonce,prompt:e?.options?.prompt},authSessionOpener:e?.options?.authSessionOpener})}var iE,Ps=c(()=>{"use strict";U();C();xu();vu();B();ws();rt();_u();Nu();to();bn();On();Cs();_n();Ou();iE=async({oauthConfig:e,provider:t,idpIdentifier:o,clientId:r,customState:n,preferPrivateSession:i,options:s,authSessionOpener:a})=>{let{domain:p,redirectSignIn:m,responseType:d,scopes:u}=e,{loginHint:l,lang:g,nonce:A,prompt:N}=s??{},D=Uu(),O=a||Dn,oe=n?`${D}-${Li(n)}`:D,{value:ie,method:Be,toCodeChallenge:Te}=Ru(128),$e=Po(e.redirectSignIn);St()&&ce.storeOAuthInFlight(!0),ce.storeOAuthState(oe),ce.storePKCE(ie);let ue=new URLSearchParams([["redirect_uri",$e],["response_type",d],["client_id",r]]);o?ue.append("idp_identifier",o):ue.append("identity_provider",t),ue.append("scope",u.join(" ")),l&&ue.append("login_hint",l),g&&ue.append("lang",g),A&&ue.append("nonce",A),N&&ue.append("prompt",N.toLowerCase()),ue.append("state",oe),d==="code"&&(ue.append("code_challenge",Te()),ue.append("code_challenge_method",Be));let Kt=`https://${p}/oauth2/authorize?${ue.toString()}`;bu(ce);let{type:ke,error:so,url:ao}=await O(Kt,m,i)??{};try{if(ke==="error")throw nt(String(so));if(ke==="canceled")throw nt(String(ke));ke==="success"&&ao&&await Nn({currentUrl:ao,clientId:r,domain:p,redirectUri:$e,responseType:d,userAgentValue:w(I.SignInWithRedirect),preferPrivateSession:i})}catch(ft){throw await vo(ft),ft}}});var Du,ku=c(()=>{"use strict";C();F();ee();qr();B();Ss();V();Du=async e=>{let t=e.getConfig().Auth?.Cognito;f(t);let{userPoolEndpoint:o,userPoolId:r}=t,{tokens:n}=await Mo(e,{forceRefresh:!1});M(n);let i=Tn({endpointResolver:y({endpointOverride:o})}),{UserAttributes:s}=await i({region:E(r),userAgentValue:w(I.FetchUserAttributes)},{AccessToken:n.accessToken.toString()});return Ep(s)}});var Mu,Fu=c(()=>{"use strict";U();ku();Mu=()=>Du(h)});var Lu,Vu=c(()=>{"use strict";U();C();Pe();Lu=async e=>{await e.clearOAuthData(),H.clearTokens(),await Fo(),Ee.dispatch("auth",{event:"signedOut"},"Auth",fe)}});var Bu,Hu=c(()=>{"use strict";C();ws();bn();Bu=async(e,t=!1,o)=>{gt(e);let{loginWith:r,userPoolClientId:n}=e,{domain:i,redirectSignOut:s}=r.oauth,a=Po(s,o),p=`https://${i}/logout?${Object.entries({client_id:n,logout_uri:encodeURIComponent(a)}).map(([m,d])=>`${m}=${d}`).join("&")}`;return Dn(p)}});var Wu,Ku=c(()=>{"use strict";Vu();Hu();Wu=async(e,t,o,r)=>{let{isOAuthSignIn:n}=await t.loadOAuthSignIn(),i=await o.getOAuthMetadata();if(await Lu(t),n||i?.oauthSignIn)return Bu(e,!1,r)}});var zu,Gu=c(()=>{"use strict";K();J();j();Z();Y();zu=e=>v(R,T("RevokeToken"),b(),{..._,...e})});var qu,$u=c(()=>{"use strict";K();J();j();Z();Y();qu=e=>v(R,T("GlobalSignOut"),b(),{..._,...e})});async function kn(e){let t=h.getConfig().Auth?.Cognito;f(t),e?.global?await aE(t):await sE(t);let o;try{gt(t),o=!0}catch{o=!1}if(o){let r=new lo(Ye);r.setAuthConfig(t);let{type:n}=await Wu(t,r,H,e?.oauth?.redirectUrl)??{};if(n==="error")throw new S({name:qp,message:"An error occurred when attempting to log out from OAuth provider."})}else H.clearTokens(),await Fo(),Ee.dispatch("auth",{event:"signedOut"},"Auth",fe)}async function sE(e){try{let{userPoolEndpoint:t,userPoolId:o,userPoolClientId:r}=e,n=await H.getTokenStore().loadTokens();Yr(n),cE(n.accessToken)&&await zu({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.SignOut)},{ClientId:r,Token:n.refreshToken})}catch{ju.debug("Client signOut error caught but will proceed with token removal")}}async function aE(e){try{let{userPoolEndpoint:t,userPoolId:o}=e,r=await H.getTokenStore().loadTokens();M(r),await qu({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.SignOut)},{AccessToken:r.accessToken.toString()})}catch{ju.debug("Global signOut error caught but will proceed with token removal")}}var ju,cE,vs=c(()=>{"use strict";U();C();B();$();Gi();Pe();F();ee();se();Ku();Ft();Gu();$u();V();ju=new q("Auth");cE=e=>!!e?.payload?.origin_jti});var Ju,Yu=c(()=>{"use strict";K();J();j();Z();Y();Ju=e=>v(R,T("GetUserAttributeVerificationCode"),b(),{..._,...e})});var Xu,Zu=c(()=>{"use strict";U();C();ee();F();B();Yu();V();Xu=async e=>{let{userAttributeKey:t,options:o}=e,r=h.getConfig().Auth?.Cognito,n=o?.clientMetadata;f(r);let{userPoolEndpoint:i,userPoolId:s}=r,{tokens:a}=await W({forceRefresh:!1});M(a);let p=Ju({endpointResolver:y({endpointOverride:i})}),{CodeDeliveryDetails:m}=await p({region:E(s),userAgentValue:w(I.SendUserAttributeVerificationCode)},{AccessToken:a.accessToken.toString(),ClientMetadata:n,AttributeName:t}),{DeliveryMedium:d,AttributeName:u,Destination:l}={...m};return{destination:l,deliveryMedium:d,attributeName:u}}});var Qu,el=c(()=>{"use strict";K();J();j();Z();Y();Qu=e=>v(R,T("DeleteUserAttributes"),b(),{..._,...e})});async function tl(e){let t=h.getConfig().Auth?.Cognito;f(t);let{userAttributeKeys:o}=e,{userPoolEndpoint:r,userPoolId:n}=t,{tokens:i}=await W({forceRefresh:!1});M(i),await Qu({endpointResolver:y({endpointOverride:r})})({region:E(n),userAgentValue:w(I.DeleteUserAttributes)},{AccessToken:i.accessToken.toString(),UserAttributeNames:o})}var ol=c(()=>{"use strict";U();C();F();ee();B();el();V()});var Mn,Ts=c(()=>{"use strict";eo();Fe();$();Mn=()=>async e=>{if(e.statusCode>=300){let t=await we(e);throw Q(t),new S({name:t.name,message:t.message})}else return}});var rl,nl=c(()=>{"use strict";K();J();j();Ts();Y();rl=e=>v(R,T("DeleteUser"),Mn(),{..._,...e})});async function il(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W();M(r),await rl({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.DeleteUser)},{AccessToken:r.accessToken.toString()}),await H.clearDeviceMetadata(),await kn()}var sl=c(()=>{"use strict";U();C();F();ee();Pe();B();nl();V();vs()});var al,cl=c(()=>{"use strict";K();J();j();Z();Y();al=e=>v(R,T("UpdateDeviceStatus"),b(),{..._,...e})});async function pl(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W();M(r);let n=await H?.getDeviceMetadata();Qt(n),await al({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.RememberDevice)},{AccessToken:r.accessToken.toString(),DeviceKey:n.deviceKey,DeviceRememberedStatus:"remembered"})}var ml=c(()=>{"use strict";U();C();ee();F();Pe();B();cl();V()});var dl,ul=c(()=>{"use strict";K();J();j();Ts();Y();dl=e=>v(R,T("ForgetDevice"),Mn(),{..._,...e})});async function ll(e){let{device:{id:t}={id:void 0}}=e??{},o=h.getConfig().Auth?.Cognito;f(o);let{userPoolEndpoint:r,userPoolId:n}=o,{tokens:i}=await W();M(i);let s=await H.getDeviceMetadata(),a=s?.deviceKey;t||Qt(s),await dl({endpointResolver:y({endpointOverride:r})})({region:E(n),userAgentValue:w(I.ForgetDevice)},{AccessToken:i.accessToken.toString(),DeviceKey:t??a}),(!t||t===a)&&await H.clearDeviceMetadata()}var fl=c(()=>{"use strict";U();C();ee();F();Pe();B();ul();V()});var gl,hl=c(()=>{"use strict";K();J();j();Z();Y();gl=e=>v(R,T("ListDevices"),b(),{..._,...e})});async function El(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W();M(r);let i=await gl({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.FetchDevices)},{AccessToken:r.accessToken.toString(),Limit:pE});return mE(i.Devices??[])}var pE,mE,yl=c(()=>{"use strict";U();C();ee();F();B();hl();V();pE=60;mE=async e=>e.map(({DeviceKey:t="",DeviceAttributes:o=[],DeviceCreateDate:r,DeviceLastModifiedDate:n,DeviceLastAuthenticatedDate:i})=>{let s,a=o.reduce((m,{Name:d,Value:u})=>(d&&u&&(d==="device_name"&&(s=u),m[d]=u),m),{});return{id:t,name:s,attributes:a,createDate:r?new Date(r*1e3):void 0,lastModifiedDate:n?new Date(n*1e3):void 0,lastAuthenticatedDate:i?new Date(i*1e3):void 0}})});var Sl,Il=c(()=>{"use strict";Sl={identityId:"identityId"}});var dE,no,uE,Rs=c(()=>{"use strict";U();C();rn();Il();dE=new q("DefaultIdentityIdStore"),no=class{setAuthConfig(t){jt(t.Cognito),this.authConfig=t,this._authKeys=uE("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){jt(this.authConfig?.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{let t=await this.keyValueStorage.getItem(this._authKeys.identityId);return t?(this._hasGuestIdentityId=!0,{id:t,type:"guest"}):null}}catch(t){return dE.log("Error getting stored IdentityId.",t),null}}async storeIdentityId(t){jt(this.authConfig?.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)}},uE=(e,t)=>Qo(Sl)(`com.amplify.${e}`,t)});var ir,_s=c(()=>{"use strict";U();C();ir=({endpointOverride:e})=>t=>e?{url:new xe(e)}:_i(t)});function Fn(e){let t=ge(e).payload.iss,o={};if(!t)throw new S({name:"InvalidIdTokenException",message:"Invalid Idtoken."});let r=t.replace(/(^\w+:|^)\/\//,"");return o[r]=e,o}var Us=c(()=>{"use strict";C();$()});async function Al({tokens:e,authConfig:t,identityIdStore:o}){o.setAuthConfig({Cognito:t});let r=await o.loadIdentityId();if(r)return r.id;let n=e?.idToken?Fn(e.idToken.toString()):{},i=await lE(n,t);return o.storeIdentityId({id:i,type:e?"primary":"guest"}),i}async function lE(e,t){let o=t?.identityPoolId,r=Jo(o),n=Pi({endpointResolver:ir({endpointOverride:t.identityPoolEndpoint})}),i;try{i=(await n({region:r},{IdentityPoolId:o,Logins:e})).IdentityId}catch(s){throw Q(s),new S(s)}if(!i)throw new S({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return i}var Cl=c(()=>{"use strict";U();$();Fe();F();_s();Us()});var Ln,wl,io,Ns=c(()=>{"use strict";U();C();$();Fe();F();ee();_s();Cl();Us();Ln=new q("CognitoCredentialsProvider"),wl=3e3*1e3,io=class{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){Ln.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){Ln.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){let o=t.authenticated,{tokens:r}=t,{authConfig:n}=t;try{jt(n?.Cognito)}catch{return}if(!o&&!n.Cognito.allowGuestAccess)return;let{forceRefresh:i}=t,s=this.hasTokenChanged(r),a=await Al({tokens:r,authConfig:n.Cognito,identityIdStore:this._identityIdStore});return(i||s)&&this.clearCredentials(),o?(Jp(r),this.credsForOIDCTokens(n.Cognito,r,a)):this.getGuestCredentials(a,n.Cognito)}async getGuestCredentials(t,o){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return Ln.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();let r=Jo(o.identityPoolId),n=Nr({endpointResolver:ir({endpointOverride:o.identityPoolEndpoint})}),i;try{i=await n({region:r},{IdentityId:t})}catch(s){throw Q(s),new S(s)}if(i?.Credentials?.AccessKeyId&&i?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+wl;let s={credentials:{accessKeyId:i.Credentials.AccessKeyId,secretAccessKey:i.Credentials.SecretKey,sessionToken:i.Credentials.SessionToken,expiration:i.Credentials.Expiration},identityId:t};return i.IdentityId&&(s.identityId=i.IdentityId,this._identityIdStore.storeIdentityId({id:i.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...s,isAuthenticatedCreds:!1},s}else throw new S({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,o,r){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return Ln.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();let n=o.idToken?Fn(o.idToken.toString()):{},i=Jo(t.identityPoolId),s=Nr({endpointResolver:ir({endpointOverride:t.identityPoolEndpoint})}),a;try{a=await s({region:i},{IdentityId:r,Logins:n})}catch(p){throw Q(p),new S(p)}if(a?.Credentials?.AccessKeyId&&a?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+wl;let p={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:r};return a.IdentityId&&(p.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...p,isAuthenticatedCreds:!0,associatedIdToken:o.idToken?.toString()},p}else throw new S({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){return!!t&&!!this._credentialsAndIdentityId?.associatedIdToken&&t.idToken?.toString()!==this._credentialsAndIdentityId.associatedIdToken}}});var xl,Pl=c(()=>{"use strict";Yi();vt();xl=e=>{if(e instanceof Oe)return e;if(e instanceof Error){if(e.name==="InvalidStateError"){let{message:t,recoverySuggestion:o}=Pt[L.PasskeyAlreadyExists];return new Oe({name:L.PasskeyAlreadyExists,message:t,recoverySuggestion:o,underlyingError:e})}if(e.name==="NotAllowedError"){let{message:t,recoverySuggestion:o}=Pt[L.PasskeyRegistrationCanceled];return new Oe({name:L.PasskeyRegistrationCanceled,message:t,recoverySuggestion:o,underlyingError:e})}}return dn(e)}});var vl,Tl=c(()=>{"use strict";Qi();Zi();vt();Pl();Xi();vl=async e=>{try{let t=un();Qe(t,L.PasskeyNotSupported);let o=wm(e),r=await navigator.credentials.create({publicKey:o});return _m(r),xm(r)}catch(t){throw xl(t)}}});var Rl,_l=c(()=>{"use strict";K();J();j();Z();Y();Rl=e=>v(R,T("StartWebAuthnRegistration"),b(),{..._,...e})});var Ul,Nl=c(()=>{"use strict";K();J();j();Z();Y();Ul=e=>v(R,T("CompleteWebAuthnRegistration"),b(),{..._,...e})});async function bl(){let e=h.getConfig().Auth?.Cognito;f(e);let{userPoolEndpoint:t,userPoolId:o}=e,{tokens:r}=await W();M(r);let n=Rl({endpointResolver:y({endpointOverride:t})}),{CredentialCreationOptions:i}=await n({region:E(o),userAgentValue:w(I.StartWebAuthnRegistration)},{AccessToken:r.accessToken.toString()});Tm(i);let s=await vl(i);await Ul({endpointResolver:y({endpointOverride:t})})({region:E(o),userAgentValue:w(I.CompleteWebAuthnRegistration)},{AccessToken:r.accessToken.toString(),Credential:s})}var Ol=c(()=>{"use strict";U();C();ee();V();F();B();Tl();Rm();_l();Nl()});var Dl,kl=c(()=>{"use strict";K();J();j();Z();Y();Dl=e=>v(R,T("ListWebAuthnCredentials"),b(),{..._,...e})});async function Ml(e,t){let o=e.getConfig().Auth?.Cognito;f(o);let{userPoolEndpoint:r,userPoolId:n}=o,{tokens:i}=await e.Auth.fetchAuthSession();M(i);let s=Dl({endpointResolver:y({endpointOverride:r})}),{Credentials:a=[],NextToken:p}=await s({region:E(n),userAgentValue:w(I.ListWebAuthnCredentials)},{AccessToken:i.accessToken.toString(),MaxResults:t?.pageSize,NextToken:t?.nextToken});return{credentials:a.map(d=>({credentialId:d.CredentialId,friendlyCredentialName:d.FriendlyCredentialName,relyingPartyId:d.RelyingPartyId,authenticatorAttachment:d.AuthenticatorAttachment,authenticatorTransports:d.AuthenticatorTransports,createdAt:d.CreatedAt?new Date(d.CreatedAt*1e3):void 0})),nextToken:p}}var Fl=c(()=>{"use strict";C();ee();V();F();B();kl()});async function Ll(e){return Ml(h,e)}var Vl=c(()=>{"use strict";U();Fl()});var Bl,Hl=c(()=>{"use strict";K();J();j();Z();Y();Bl=e=>v(R,T("DeleteWebAuthnCredential"),b(),{..._,...e})});async function Wl(e,t){let o=e.getConfig().Auth?.Cognito;f(o);let{userPoolEndpoint:r,userPoolId:n}=o,{tokens:i}=await e.Auth.fetchAuthSession();M(i),await Bl({endpointResolver:y({endpointOverride:r})})({region:E(n),userAgentValue:w(I.DeleteWebAuthnCredential)},{AccessToken:i.accessToken.toString(),CredentialId:t.credentialId})}var Kl=c(()=>{"use strict";C();ee();V();F();B();Hl()});async function zl(e){return Wl(h,e)}var Gl=c(()=>{"use strict";U();Kl()});var ql=c(()=>{"use strict";Ud();Dd();Ld();Es();Wd();qd();jd();Zd();eu();ou();su();cu();Is();uu();Xr();hu();Ps();Fu();vs();Zu();ol();sl();ml();fl();yl();Tt();U();$();se();Ol();Vl();Gl()});var $l={};Hn($l,{AuthError:()=>S,associateWebAuthnCredential:()=>bl,autoSignIn:()=>Pn,confirmResetPassword:()=>Fd,confirmSignIn:()=>$d,confirmSignUp:()=>Gd,confirmUserAttribute:()=>gu,decodeJWT:()=>ge,deleteUser:()=>il,deleteUserAttributes:()=>tl,deleteWebAuthnCredential:()=>zl,fetchAuthSession:()=>W,fetchDevices:()=>El,fetchMFAPreference:()=>Qd,fetchUserAttributes:()=>Mu,forgetDevice:()=>ll,getCurrentUser:()=>uo,listWebAuthnCredentials:()=>Ll,rememberDevice:()=>pl,resendSignUpCode:()=>Hd,resetPassword:()=>Od,sendUserAttributeVerificationCode:()=>Xu,setUpTOTP:()=>au,signIn:()=>nr,signInWithRedirect:()=>xs,signOut:()=>kn,signUp:()=>_d,updateMFAPreference:()=>Xd,updatePassword:()=>iu,updateUserAttribute:()=>du,updateUserAttributes:()=>Rn,verifyTOTPSetup:()=>tu});var jl=c(()=>{"use strict";ql()});var bs,Jl=c(()=>{"use strict";U();Rs();Ns();bs=new io(new no(Ye))});var Yl=c(()=>{"use strict";Ps();Jl();Pe();Ns();Rs()});var Xl,Zl=c(()=>{"use strict";U();C();Yl();Xl={configure(e,t){let o=No(e),r=new qo({sameSite:"lax"}),n=t?.ssr?r:Ye,i=t?.ssr?new io(new no(r)):bs;if(!o.Auth){h.configure(o,t);return}if(t?.Auth){h.configure(o,t);return}if(!h.libraryOptions.Auth){oo.setAuthConfig(o.Auth),oo.setKeyValueStorage(n),h.configure(o,{...t,Auth:{tokenProvider:oo,credentialsProvider:i}});return}if(t){let s=h.libraryOptions.Auth;t.ssr!==void 0&&(oo.setKeyValueStorage(n),s.credentialsProvider=i),h.configure(o,{Auth:s,...t});return}h.configure(o)},getConfig(){return h.getConfig()}}});var Ql={};Hn(Ql,{Amplify:()=>Xl});var ef=c(()=>{"use strict";Zl()});var CE={};Hn(CE,{createFoundation:()=>rf});function hf(e){return e?.response!==void 0?e.response:e?.data!==void 0?e.data:e}function Ef(e,t){let o=t?.error;if(o){let n=o.message||"Unknown error",i=o.details;if(i?.length){let s=i.map(a=>a.field?`${a.field}: ${a.message}`:a.message).join(", ");n=n?`${n} ${s}`:s}return Object.assign(new Error(n),{code:o.code,type:o.code,details:i,status:e})}let r=t?.data?.message||t?.message;return r?Object.assign(new Error(r),{status:e}):Object.assign(new Error(`HTTP ${e}`),{status:e})}function Ls(e){function t(n){return{"X-Foundation-Mvp-Application-Id":e.appId,"X-Foundation-Mvp-Tenant-Id":e.tenantId,"X-Foundation-Mvp-Application-Version":e.version,"Content-Type":"application/json",Authorization:`Bearer ${n}`}}async function o(n,i,s,a={}){let p=await e.getToken(),m=t(p),d=`${n}${i}`;if(a.params){let A=new URLSearchParams;for(let[D,O]of Object.entries(a.params))O!=null&&A.set(D,String(O));let N=A.toString();N&&(d+=`?${N}`)}let u={method:s,headers:m};a.body!==void 0&&(u.body=JSON.stringify(a.body));let l=await fetch(d,u);if(!l.ok){let A={};try{A=await l.json()}catch{}throw Ef(l.status,A)}if(l.status===204)return null;let g=await l.json();return hf(g)}async function r(n,i={}){return fetch(n,i)}return{request:o,rawFetch:r,headers:t}}async function fE(){return import("@auth0/auth0-spa-js")}async function sr(){return Promise.resolve().then(()=>(jl(),$l))}async function gE(){return Promise.resolve().then(()=>(ef(),Ql))}async function tf(e){switch(e.provider){case"auth0":{if(!e.auth0)throw new Error("Auth0 config required");let{createAuth0Client:t}=await fE(),o=await t({domain:e.auth0.domain,clientId:e.auth0.clientId,authorizationParams:{audience:e.auth0.audience,scope:e.auth0.scope||"openid profile email",redirect_uri:window.location.origin},useRefreshTokens:!0,cacheLocation:"localstorage"}),r=e.auth0.domain,n=e.auth0.clientId;return{login:i=>o.loginWithRedirect(i),logout:i=>o.logout({logoutParams:{returnTo:window.location.origin},...i}),getUser:async()=>{let i=await o.getUser();if(i)return{id:i.sub||"",email:i.email||"",name:i.name,picture:i.picture}},getTokenSilently:i=>o.getTokenSilently(i),isAuthenticated:()=>o.isAuthenticated(),async signIn(i,s){let a=await fetch(`https://${r}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"password",client_id:n,username:i,password:s,audience:e.auth0.audience,scope:e.auth0.scope||"openid profile email"})});if(!a.ok){let p=await a.json().catch(()=>({}));throw new Error(p.error_description||p.message||"Sign in failed")}},async signUp(i,s,a){let p=await fetch(`https://${r}/dbconnections/signup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,email:i,password:s,connection:"Username-Password-Authentication",...a})});if(!p.ok){let m=await p.json().catch(()=>({}));throw new Error(m.description||m.message||"Sign up failed")}},async forgotPassword(i){let s=await fetch(`https://${r}/dbconnections/change_password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,email:i,connection:"Username-Password-Authentication"})});if(!s.ok){let a=await s.json().catch(()=>({}));throw new Error(a.error_description||a.message||"Password reset request failed")}},async resetPassword(i,s){throw new Error("Auth0 password reset is completed via the email link, not a code")}}}case"cognito":{if(!e.cognito)throw new Error("Cognito config required");let{fetchAuthSession:t,signInWithRedirect:o,signOut:r,getCurrentUser:n}=await sr(),{Amplify:i}=await gE();return i.configure({Auth:{Cognito:{userPoolId:e.cognito.userPoolId,userPoolClientId:e.cognito.clientId,loginWith:{oauth:{domain:e.cognito.domain.replace("https://",""),scopes:(e.cognito.scope||"openid profile email").split(" "),redirectSignIn:[window.location.origin],redirectSignOut:[window.location.origin],responseType:"code"}}}}}),{login:async()=>{await o()},logout:async()=>{await r()},getUser:async()=>{try{let s=await n();return{id:s.userId,email:s.signInDetails?.loginId||"",name:s.username}}catch{return}},getTokenSilently:async()=>{let a=(await t()).tokens?.accessToken?.toString();if(!a)throw new Error("No token available");return a},isAuthenticated:async()=>{try{return await n(),!0}catch{return!1}},async signIn(s,a){let{signIn:p}=await sr();await p({username:s,password:a})},async signUp(s,a,p){let{signUp:m}=await sr();await m({username:s,password:a,options:{userAttributes:{email:s,...p}}})},async forgotPassword(s){let{resetPassword:a}=await sr();await a({username:s})},async resetPassword(s,a){let{confirmResetPassword:p}=await sr();await p({username:"",confirmationCode:s,newPassword:a})}}}case"none":return{login:async()=>{},logout:async()=>{},getUser:async()=>{},getTokenSilently:async()=>"none",isAuthenticated:async()=>!0};default:throw new Error(`Unknown auth provider: ${e.provider}`)}}function of(e){let t=null,o=[];function r(){o.forEach(n=>{try{n(t)}catch{}})}return{get user(){return t},get isAuthenticated(){return!!t},async getToken(){return e.getTokenSilently()},async login(n){await e.login(n);let i=await e.getUser();t=i?{id:i.id,email:i.email,name:i.name,picture:i.picture}:null,r()},async logout(n){await e.logout(n),t=null,r()},async signIn(n,i){if(!e.signIn)throw new Error("signIn not supported by this auth provider");await e.signIn(n,i);let s=await e.getUser();t=s?{id:s.id,email:s.email,name:s.name,picture:s.picture}:null,r()},async signUp(n,i,s){if(!e.signUp)throw new Error("signUp not supported by this auth provider");await e.signUp(n,i,s)},async forgotPassword(n){if(!e.forgotPassword)throw new Error("forgotPassword not supported by this auth provider");await e.forgotPassword(n)},async resetPassword(n,i){if(!e.resetPassword)throw new Error("resetPassword not supported by this auth provider");await e.resetPassword(n,i)},onChange(n){return o.length>=100?(console.warn("[Foundation SDK] Auth listener limit reached."),()=>{}):(o.push(n),()=>{let i=o.indexOf(n);i>-1&&o.splice(i,1)})},async _initUser(){if(await e.isAuthenticated()){let i=await e.getUser();t=i?{id:i.id,email:i.email,name:i.name,picture:i.picture}:null}}}}function Os(e){if(!e)throw new Error("Token parsing failed: Missing auth token");try{let[t,o]=e.split("?"),r=t.split(".");if(r.length!==3)throw new Error("Invalid JWT format");let n=atob(r[1]),i=JSON.parse(n);o&&new URLSearchParams(o).forEach((d,u)=>{i[u]=d});let s=i["BaseApplication/apiBaseUrl"];if(!s)throw new Error("Token missing apiBaseUrl");let a=i["BaseApplication/websocketBaseUrl"]||"",p=i["BaseApplication/accountBaseUrl"]||s;return{sub:i.sub||"",apiBaseUrl:s,accountBaseUrl:p,websocketBaseUrl:a,userId:i["BaseApplication/userId"]||"",namespace:i["BaseApplication/namespace"]}}catch(t){if(t instanceof Error&&t.message.startsWith("Token"))throw t;let o=t instanceof Error?t.message:"Failed to parse token";throw new Error(`Token parsing failed: ${o}`)}}async function rf(e){let t=e.configUrl,o=e.appId,r=e.tenantId;try{let G=await fetch("/foundation-env.json");if(G.ok){let he=await G.json();he.configUrl&&(t=he.configUrl,o=he.applicationId||o,r=he.applicationTenant||r)}}catch{}if(!t)throw new Error("No configUrl provided and /foundation-env.json not found");let n={Accept:"application/json","Cache-Control":"no-cache"};o&&(n["X-Foundation-Mvp-Application-Id"]=o),r&&(n["X-Foundation-Mvp-Tenant-Id"]=r);let i=await fetch(t,{headers:n});if(!i.ok)throw new Error(`Failed to fetch config: ${i.statusText}`);let s=await i.json(),a=s.data??s,p=a.auth||{provider:"none"},m=e.auth||await tf(p),u=of(m);await u._initUser();let l,g;if(e.baseUrl)l=e.baseUrl,g=e.baseUrl;else if(p.apiUrls?.apiBaseUrl)l=p.apiUrls.apiBaseUrl,g=p.apiUrls.accountBaseUrl||l;else{let G=await m.getTokenSilently(),he=Os(G);l=he.apiBaseUrl,g=he.accountBaseUrl}let A=o||a.app?.id||a.tenant?.identifier||"",N=r||a.tenant?.identifier||"",D=a.app?.version||a.core?.version||"0.0.0",O=Ls({appId:A,tenantId:N,version:D,getToken:()=>m.getTokenSilently()}),oe={};try{oe=await O.request(l,"/api/v1/config/init","GET")||{}}catch(G){console.warn("[Foundation SDK] Backend config fetch failed:",G)}let ie={...a,...oe},Be="";try{let G=await m.getTokenSilently();G&&G!=="none"&&(Be=Os(G).namespace||"")}catch{}let Te={get app(){let G=ie.app||{};return{id:G.id||A,name:G.name||"",version:G.version||D,environment:G.environment||"",...G}},get features(){return ie.features||{}},get plans(){return ie.plans||[]},get theme(){let G=ie.theme||{};return{colors:G.colors||{},dark:G.dark||{},defaultColorScheme:G.defaultColorScheme}},get connectors(){return ie.connectors||{}},get resources(){return ie.resources||{}},get auth(){let{provider:G,...he}=p;return{provider:G,...he}},get raw(){return ie}},$e=hE(O,l),ue=EE(O,l,Be),Kt=yE(O,g),ke=SE(O,l,g,Be),so=IE(O,l),ao=AE(),ft=[];return{get ready(){return Promise.resolve()},get isReady(){return!0},auth:u,db:$e,files:ue,integration:ke,account:Kt,config:Te,openapi:so,log:ao,on(G,he){return G==="entity.changed"?(ft.push(he),()=>{let ar=ft.indexOf(he);ar>-1&&ft.splice(ar,1)}):()=>{}}}}function hE(e,t){return{async list(o,r={}){let{filters:n,limit:i,cursor:s,orderBy:a,orderDir:p}=r,m={...n};return i&&(m.limit=i),s&&(m.next=s),a&&(m.orderBy=a),p&&(m.orderDir=p),e.request(t,`/api/v1/core/${o}`,"GET",{params:m})},async get(o,r){return e.request(t,`/api/v1/core/${o}`,"GET",{params:{id:r}})},async create(o,r){return e.request(t,`/api/v1/core/${o}`,"POST",{body:r})},async update(o,r,n){return e.request(t,`/api/v1/core/${o}`,"PUT",{body:{id:r,...n}})},async save(o,r){try{return await e.request(t,`/api/v1/core/${o}`,"PUT",{body:r})}catch{return e.request(t,`/api/v1/core/${o}`,"POST",{body:r})}},async delete(o,r){await e.request(t,`/api/v1/core/${o}`,"DELETE",{body:{id:r}})}}}function EE(e,t,o){return{async initiate(r){return e.request(t,"/api/v1/core/upload","POST",{body:{...r,__namespace:o}})},async upload(r){let n;r.file instanceof ArrayBuffer?n=r.file:n=await r.file.arrayBuffer();let i=await e.request(t,"/api/v1/core/upload","POST",{body:{name:r.name,contentType:r.contentType,contentLength:n.byteLength,sha256:r.sha256,__namespace:o}});if(!i.signedUrl||!i.signedData)throw new Error("Missing signedUrl or signedData in response");let s=new FormData;Object.entries(i.signedData).forEach(([p,m])=>{s.append(p,m)}),s.append("file",new Blob([n],{type:r.contentType}),r.name);let a=await fetch(i.signedUrl,{method:"POST",body:s});if(a.status!==204)throw new Error(`S3 upload failed: ${a.status}`);return{id:i.id,name:i.name,status:"uploaded",s3UploadComplete:!0}},async get(r){return e.request(t,"/api/v1/core/files","GET",{params:{id:r,__namespace:o}})},async delete(r){await e.request(t,`/api/v1/core/files/${r}`,"DELETE")},async list(r={}){let n={__namespace:o};r.limit&&(n.limit=r.limit),r.cursor&&(n.cursor=r.cursor);let i=await e.request(t,"/api/v1/core/files","GET",{params:n});return{items:i?.items||[],nextCursor:i?.next}}}}function yE(e,t){return{async get(){return e.request(t,"/api/v1/accounts/account","GET")},async update(o){await e.request(t,"/api/v1/accounts/account","PUT",{body:{user:o}})},async usage(){return e.request(t,"/api/v1/accounts/account/usage","GET")},async resendVerification(){await e.request(t,"/api/v1/accounts/account/resend-verification","POST")}}}function SE(e,t,o,r){let n={async list(){return e.request(t,"/api/v1/config/connectors","GET")},async connections(){return e.request(t,"/api/v1/core/integrations","GET",{params:{query:"default",__namespace:r}})},async all(){let[i,s]=await Promise.all([n.list(),n.connections()]),a=Array.isArray(i)?i:i?.items||[],p=Array.isArray(s)?s:s?.items||[],m=new Map;for(let d of p){let u=d.source||d.id;m.has(u)||m.set(u,[]),m.get(u).push(d)}return a.map(d=>{let u=m.get(d.id)||[];return{...d,connections:u,connected:u.some(l=>l.connected),connectionCount:u.filter(l=>l.connected).length}})},async status(i){let s=await n.connections(),p=(Array.isArray(s)?s:s?.items||[]).filter(m=>m.source===i&&m.connected);return{connected:p.length>0,connections:p}},async connect(i){return e.request(o,`/api/v1/accounts/integrations/${i}/initialize`,"POST",{body:{__namespace:r}})},async disconnect(i,s){await e.request(o,`/api/v1/accounts/integrations/${i}/remove`,"POST",{body:{configurationId:s}})}};return n}function IE(e,t){return{async get(){return e.request(t,"/api/v1/config/openapi","GET")}}}function AE(){return{info:(e,t)=>console.log(`[Foundation] ${e}`,t??""),warn:(e,t)=>console.warn(`[Foundation] ${e}`,t??""),error:(e,t)=>console.error(`[Foundation] ${e}`,t??""),event:(e,t)=>console.log(`[Foundation Event] ${e}`,t??"")}}return gf(CE);})();
|
|
21
|
+
`},emptyUsername:{message:q.EMPTY_USERNAME},invalidUsername:{message:q.INVALID_USERNAME},emptyPassword:{message:q.EMPTY_PASSWORD},emptyCode:{message:q.EMPTY_CODE},signUpError:{message:q.SIGN_UP_ERROR,log:"The first parameter should either be non-null string or object"},noMFA:{message:q.NO_MFA},invalidMFA:{message:q.INVALID_MFA},emptyChallengeResponse:{message:q.EMPTY_CHALLENGE},noUserSession:{message:q.NO_USER_SESSION},deviceConfig:{message:q.DEVICE_CONFIG},networkError:{message:q.NETWORK_ERROR},autoSignInError:{message:q.AUTOSIGNIN_ERROR},default:{message:q.DEFAULT_MSG}};var Te=(e,t)=>new g({message:e??"An error has occurred during the oauth process.",name:Ne.OAuthSignInError,recoverySuggestion:t??na.oauthSignInError.log});var or;(function(e){e.NoConfig="noConfig",e.MissingAuthConfig="missingAuthConfig",e.EmptyUsername="emptyUsername",e.InvalidUsername="invalidUsername",e.EmptyPassword="emptyPassword",e.EmptyCode="emptyCode",e.SignUpError="signUpError",e.NoMFA="noMFA",e.InvalidMFA="invalidMFA",e.EmptyChallengeResponse="emptyChallengeResponse",e.NoUserSession="noUserSession",e.Default="default",e.DeviceConfig="deviceConfig",e.NetworkError="networkError",e.AutoSignInError="autoSignInError",e.OAuthSignInError="oauthSignInError"})(or||(or={}));var nu="`signInWithRedirect` has been canceled.",iu="An error occurred while validating the state.",su="Try to initiate an OAuth flow from Amplify",an=async e=>{let t=await z.loadOAuthState(),o=e===t?t:void 0;if(!o)throw new g({name:or.OAuthSignInError,message:e===null?nu:iu,recoverySuggestion:e===null?void 0:su});return o};var rr=async({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,responseType:n,domain:i,preferPrivateSession:s})=>{let a=new te(e),c=a.searchParams.get("error"),d=a.searchParams.get("error_description");if(c)throw Te(d??c);return n==="code"?au({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,domain:i,preferPrivateSession:s}):cu({currentUrl:e,redirectUri:r,preferPrivateSession:s})},au=async({currentUrl:e,userAgentValue:t,clientId:o,redirectUri:r,domain:n,preferPrivateSession:i})=>{let s=new te(e),a=s.searchParams.get("code"),c=s.searchParams.get("state");if(!a||!c)throw Te("User cancelled OAuth flow.");let d=await an(c),u="https://"+n+"/oauth2/token",p=await z.loadPKCE(),l={grant_type:"authorization_code",code:a,client_id:o,redirect_uri:r,...p?{code_verifier:p}:{}},m=Object.entries(l).map(([Ee,F])=>`${encodeURIComponent(Ee)}=${encodeURIComponent(F)}`).join("&"),{access_token:h,refresh_token:I,id_token:A,error:S,error_message:M,token_type:H,expires_in:le}=await(await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",[ur]:t},body:m})).json();if(S)throw Te(M??S);let ie=(h&&Q(h).payload.username)??"username";return await oe({username:ie,AccessToken:h,IdToken:A,RefreshToken:I}),ia({redirectUri:r,state:d,preferPrivateSession:i})},cu=async({currentUrl:e,redirectUri:t,preferPrivateSession:o})=>{let r=new te(e),{id_token:n,access_token:i,state:s,token_type:a,expires_in:c,error_description:d,error:u}=(r.hash??"#").substring(1).split("&").map(m=>m.split("=")).reduce((m,[h,I])=>({...m,[h]:I}),{id_token:void 0,access_token:void 0,state:void 0,token_type:void 0,expires_in:void 0,error_description:void 0,error:void 0});if(u)throw Te(d??u);if(!i)throw Te("No access token returned from OAuth flow.");let p=await an(s),l=(i&&Q(i).payload.username)??"username";return await oe({username:l,AccessToken:i,IdToken:n}),ia({redirectUri:t,state:p,preferPrivateSession:o})},ia=async({redirectUri:e,state:t,preferPrivateSession:o})=>{await D.setOAuthMetadata({oauthSignIn:!0}),await z.clearOAuthData(),await z.storeOAuthSignIn(!0,o),Wo(),pu(e),du(t)&&Z.dispatch("auth",{event:"customOAuthState",data:Hr(uu(t))},"Auth",j),Z.dispatch("auth",{event:"signInWithRedirect"},"Auth",j),await ce()},du=e=>/-/.test(e),uu=e=>e.split("-").splice(1).join("-"),pu=e=>{typeof window<"u"&&typeof window.history<"u"&&window.history.replaceState(window.history.state,"",e)};function Ut(e,t){if(t){let o=e?.find(r=>r===t);if(!o)throw Zi;return o}else{let o=e?.find(lu)??e?.find(mu),r=e?.find(gu)??e?.find(fu);if(o)return o;throw r?Qi:Xi}}var lu=e=>e.startsWith(String(window.location.origin+(window.location.pathname||"/"))),mu=e=>e.includes(String(window.location.hostname)),fu=e=>e.startsWith("http://"),gu=e=>e.startsWith("https://");var Ot=async e=>{Wo(),await z.clearOAuthInflightData(),Z.dispatch("auth",{event:"signInWithRedirect_failure",data:{error:e}},"Auth",j)};var sa=async e=>{try{E(e),Le(e),z.setAuthConfig(e)}catch{return}if(await z.loadOAuthInFlight())try{let t=window.location.href,{loginWith:o,userPoolClientId:r}=e,{domain:n,redirectSignIn:i,responseType:s}=o.oauth,a=Ut(i);await rr({currentUrl:t,clientId:r,domain:n,redirectUri:a,responseType:s,userAgentValue:O(R.SignInWithRedirect)})}catch(t){await Ot(t)}};Ke()&&w[Mt](sa);var aa={Google:"Google",Facebook:"Facebook",Amazon:"LoginWithAmazon",Apple:"SignInWithApple"};var nr=async e=>{window?.location&&(window.location.href=e.replace("http://","https://"))};var ca="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",da=e=>{let t=new Uint8Array(e);st().getRandomValues(t);let o="",r;for(let n of t)o+=ca.charAt(n%ca.length);return{value:o,method:"S256",toCodeChallenge(){return r||(r=hu(o),r)}}};function hu(e){let t=new Be;return t.update(e),yu(fe.convert(t.digestSync(),{urlSafe:!0}))}function yu(e){return e.replace(/=/g,"")}var ua=()=>Br(32);var pa=e=>{async function t(o){if(o.persisted&&await e.loadOAuthInFlight()){let n=Te("User cancelled OAuth flow.");await Ot(n)}window.removeEventListener("pageshow",t)}window.addEventListener("pageshow",t)};async function ir(e){let t=w.getConfig().Auth?.Cognito;E(t),Le(t),z.setAuthConfig(t),e?.options?.prompt||await er();let o="COGNITO",r;return typeof e?.provider=="string"?o=aa[e.provider]:e?.provider?.custom?o=e.provider.custom:e?.provider?.idpIdentifier&&({idpIdentifier:r}=e.provider),Eu({oauthConfig:t.loginWith.oauth,clientId:t.userPoolClientId,provider:o,idpIdentifier:r,customState:e?.customState,preferPrivateSession:e?.options?.preferPrivateSession,options:{loginHint:e?.options?.loginHint,lang:e?.options?.lang,nonce:e?.options?.nonce,prompt:e?.options?.prompt},authSessionOpener:e?.options?.authSessionOpener})}var Eu=async({oauthConfig:e,provider:t,idpIdentifier:o,clientId:r,customState:n,preferPrivateSession:i,options:s,authSessionOpener:a})=>{let{domain:c,redirectSignIn:d,responseType:u,scopes:p}=e,{loginHint:l,lang:m,nonce:h,prompt:I}=s??{},A=ua(),S=a||nr,M=n?`${A}-${Kr(n)}`:A,{value:H,method:le,toCodeChallenge:ie}=da(128),Ee=Ut(e.redirectSignIn);Ke()&&z.storeOAuthInFlight(!0),z.storeOAuthState(M),z.storePKCE(H);let F=new URLSearchParams;F.append("redirect_uri",Ee),F.append("response_type",u),F.append("client_id",r),o?F.append("idp_identifier",o):F.append("identity_provider",t),F.append("scope",p.join(" ")),l&&F.append("login_hint",l),m&&F.append("lang",m),h&&F.append("nonce",h),I&&F.append("prompt",I.toLowerCase()),F.append("state",M),u==="code"&&(F.append("code_challenge",ie()),F.append("code_challenge_method",le));let nt=`https://${c}/oauth2/authorize?${F.toString()}`;pa(z);let{type:de,error:yt,url:Et}=await S(nt,d,i)??{};try{if(de==="error")throw Te(String(yt));if(de==="canceled")throw Te(String(de));de==="success"&&Et&&await rr({currentUrl:Et,clientId:r,domain:c,redirectUri:Ee,responseType:u,userAgentValue:O(R.SignInWithRedirect),preferPrivateSession:i})}catch(Fe){throw await Ot(Fe),Fe}};var la=async e=>{await e.clearOAuthData(),D.clearTokens(),await Ht(),Z.dispatch("auth",{event:"signedOut"},"Auth",j)};var ma=async(e,t=!1,o)=>{Le(e);let{loginWith:r,userPoolClientId:n}=e,{domain:i,redirectSignOut:s}=r.oauth,a=Ut(s,o),c=`https://${i}/logout?${Object.entries({client_id:n,logout_uri:encodeURIComponent(a)}).map(([d,u])=>`${d}=${u}`).join("&")}`;return nr(c)};var fa=async(e,t,o,r)=>{let{isOAuthSignIn:n}=await t.loadOAuthSignIn(),i=await o.getOAuthMetadata();if(await la(t),n||i?.oauthSignIn)return ma(e,!1,r)};var ga=e=>b(W,K("RevokeToken"),G(),{...V,...e});var ha=e=>b(W,K("GlobalSignOut"),G(),{...V,...e});var ya=new C("Auth");async function cn(e){let t=w.getConfig().Auth?.Cognito;E(t),e?.global?await Iu(t):await Su(t);let o;try{Le(t),o=!0}catch{o=!1}if(o){let r=new wt(we);r.setAuthConfig(t);let{type:n}=await fa(t,r,D,e?.oauth?.redirectUrl)??{};if(n==="error")throw new g({name:es,message:"An error occurred when attempting to log out from OAuth provider."})}else D.clearTokens(),await Ht(),Z.dispatch("auth",{event:"signedOut"},"Auth",j)}async function Su(e){try{let{userPoolEndpoint:t,userPoolId:o,userPoolClientId:r}=e,n=await D.getTokenStore().loadTokens();Bo(n),wu(n.accessToken)&&await ga({endpointResolver:P({endpointOverride:t})})({region:v(o),userAgentValue:O(R.SignOut)},{ClientId:r,Token:n.refreshToken})}catch{ya.debug("Client signOut error caught but will proceed with token removal")}}async function Iu(e){try{let{userPoolEndpoint:t,userPoolId:o}=e,r=await D.getTokenStore().loadTokens();Lo(r),await ha({endpointResolver:P({endpointOverride:t})})({region:v(o),userAgentValue:O(R.SignOut)},{AccessToken:r.accessToken.toString()})}catch{ya.debug("Global signOut error caught but will proceed with token removal")}}var wu=e=>!!e?.payload?.origin_jti;var Ea={identityId:"identityId"};var Au=new C("DefaultIdentityIdStore"),gt=class{setAuthConfig(t){ct(t.Cognito),this.authConfig=t,this._authKeys=xu("Cognito",t.Cognito.identityPoolId)}constructor(t){this._authKeys={},this._hasGuestIdentityId=!1,this.keyValueStorage=t}async loadIdentityId(){ct(this.authConfig?.Cognito);try{if(this._primaryIdentityId)return{id:this._primaryIdentityId,type:"primary"};{let t=await this.keyValueStorage.getItem(this._authKeys.identityId);return t?(this._hasGuestIdentityId=!0,{id:t,type:"guest"}):null}}catch(t){return Au.log("Error getting stored IdentityId.",t),null}}async storeIdentityId(t){ct(this.authConfig?.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)}},xu=(e,t)=>Zt(Ea)(`com.amplify.${e}`,t);var oo=({endpointOverride:e})=>t=>e?{url:new te(e)}:Mr(t);function sr(e){let t=Q(e).payload.iss,o={};if(!t)throw new g({name:"InvalidIdTokenException",message:"Invalid Idtoken."});let r=t.replace(/(^\w+:|^)\/\//,"");return o[r]=e,o}async function Sa({tokens:e,authConfig:t,identityIdStore:o}){o.setAuthConfig({Cognito:t});let r=await o.loadIdentityId();if(r)return r.id;let n=e?.idToken?sr(e.idToken.toString()):{},i=await Cu(n,t);return o.storeIdentityId({id:i,type:e?"primary":"guest"}),i}async function Cu(e,t){let o=t?.identityPoolId,r=Yt(o),n=Or({endpointResolver:oo({endpointOverride:t.identityPoolEndpoint})}),i;try{i=(await n({region:r},{IdentityPoolId:o,Logins:e})).IdentityId}catch(s){throw B(s),new g(s)}if(!i)throw new g({name:"GetIdResponseException",message:"Received undefined response from getId operation",recoverySuggestion:"Make sure to pass a valid identityPoolId in the configuration."});return i}var ar=new C("CognitoCredentialsProvider"),Ia=3e3*1e3,ht=class{constructor(t){this._nextCredentialsRefresh=0,this._identityIdStore=t}async clearCredentialsAndIdentityId(){ar.debug("Clearing out credentials and identityId"),this._credentialsAndIdentityId=void 0,await this._identityIdStore.clearIdentityId()}async clearCredentials(){ar.debug("Clearing out in-memory credentials"),this._credentialsAndIdentityId=void 0}async getCredentialsAndIdentityId(t){let o=t.authenticated,{tokens:r}=t,{authConfig:n}=t;try{ct(n?.Cognito)}catch{return}if(!o&&!n.Cognito.allowGuestAccess)return;let{forceRefresh:i}=t,s=this.hasTokenChanged(r),a=await Sa({tokens:r,authConfig:n.Cognito,identityIdStore:this._identityIdStore});return(i||s)&&this.clearCredentials(),o?(rs(r),this.credsForOIDCTokens(n.Cognito,r,a)):this.getGuestCredentials(a,n.Cognito)}async getGuestCredentials(t,o){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!1)return ar.info("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();let r=Yt(o.identityPoolId),n=Ao({endpointResolver:oo({endpointOverride:o.identityPoolEndpoint})}),i;try{i=await n({region:r},{IdentityId:t})}catch(s){throw B(s),new g(s)}if(i?.Credentials?.AccessKeyId&&i?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+Ia;let s={credentials:{accessKeyId:i.Credentials.AccessKeyId,secretAccessKey:i.Credentials.SecretKey,sessionToken:i.Credentials.SessionToken,expiration:i.Credentials.Expiration},identityId:t};return i.IdentityId&&(s.identityId=i.IdentityId,this._identityIdStore.storeIdentityId({id:i.IdentityId,type:"guest"})),this._credentialsAndIdentityId={...s,isAuthenticatedCreds:!1},s}else throw new g({name:"CredentialsNotFoundException",message:"Cognito did not respond with either Credentials, AccessKeyId or SecretKey."})}async credsForOIDCTokens(t,o,r){if(this._credentialsAndIdentityId&&!this.isPastTTL()&&this._credentialsAndIdentityId.isAuthenticatedCreds===!0)return ar.debug("returning stored credentials as they neither past TTL nor expired."),this._credentialsAndIdentityId;this.clearCredentials();let n=o.idToken?sr(o.idToken.toString()):{},i=Yt(t.identityPoolId),s=Ao({endpointResolver:oo({endpointOverride:t.identityPoolEndpoint})}),a;try{a=await s({region:i},{IdentityId:r,Logins:n})}catch(c){throw B(c),new g(c)}if(a?.Credentials?.AccessKeyId&&a?.Credentials?.SecretKey){this._nextCredentialsRefresh=new Date().getTime()+Ia;let c={credentials:{accessKeyId:a.Credentials.AccessKeyId,secretAccessKey:a.Credentials.SecretKey,sessionToken:a.Credentials.SessionToken,expiration:a.Credentials.Expiration},identityId:r};return a.IdentityId&&(c.identityId=a.IdentityId,this._identityIdStore.storeIdentityId({id:a.IdentityId,type:"primary"})),this._credentialsAndIdentityId={...c,isAuthenticatedCreds:!0,associatedIdToken:o.idToken?.toString()},c}else throw new g({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){return!!t&&!!this._credentialsAndIdentityId?.associatedIdToken&&t.idToken?.toString()!==this._credentialsAndIdentityId.associatedIdToken}};var dn=new ht(new gt(we));var un={configure(e,t){let o=kt(e),r=new $t({sameSite:"lax"}),n=t?.ssr?r:we,i=t?.ssr?new ht(new gt(r)):dn;if(!o.Auth){w.configure(o,t);return}if(t?.Auth){w.configure(o,t);return}if(!w.libraryOptions.Auth){ft.setAuthConfig(o.Auth),ft.setKeyValueStorage(n),w.configure(o,{...t,Auth:{tokenProvider:ft,credentialsProvider:i}});return}if(t){let s=w.libraryOptions.Auth;t.ssr!==void 0&&(ft.setKeyValueStorage(n),s.credentialsProvider=i),w.configure(o,{Auth:s,...t});return}w.configure(o)},getConfig(){return w.getConfig()}};var wa=new Map;function pn(e,t){wa.set(e,t)}pn("none",async()=>({login:async()=>{},logout:async()=>{},getUser:async()=>{},getTokenSilently:async()=>"none",isAuthenticated:async()=>!0}));async function Aa(e){let t=wa.get(e.provider);if(!t)throw new Error(`Auth provider "${e.provider}" not registered. Import "foundation-sdk/${e.provider}" to register it.`);return t(e)}function xa(e){let t=null,o=[];function r(){o.forEach(i=>{try{i(t)}catch{}})}async function n(){let i=await e.getUser();t=i?{id:i.id,email:i.email,name:i.name,picture:i.picture}:null}return{get user(){return t},get isAuthenticated(){return!!t},async getToken(){return e.getTokenSilently()},async login(i){await e.login(i),await n(),r()},async logout(i){await e.logout(i),t=null,r()},async signIn(i,s){if(!e.signIn)throw new Error("signIn not supported by this auth provider");await e.signIn(i,s),await n(),r()},async signUp(i,s,a){if(!e.signUp)throw new Error("signUp not supported by this auth provider");await e.signUp(i,s,a)},async forgotPassword(i){if(!e.forgotPassword)throw new Error("forgotPassword not supported by this auth provider");await e.forgotPassword(i)},async resetPassword(i,s){if(!e.resetPassword)throw new Error("resetPassword not supported by this auth provider");await e.resetPassword(i,s)},onChange(i){return o.length>=100?(console.warn("[Foundation SDK] Auth listener limit reached."),()=>{}):(o.push(i),()=>{let s=o.indexOf(i);s>-1&&o.splice(s,1)})},async _initUser(){await e.isAuthenticated()&&await n()}}}function vu(e){return e?.response!==void 0?e.response:e?.data!==void 0?e.data:e}function Pu(e,t){let o=t?.error;if(o){let n=o.message||"Unknown error",i=o.details;if(i?.length){let s=i.map(a=>a.field?`${a.field}: ${a.message}`:a.message).join(", ");n=n?`${n} ${s}`:s}return Object.assign(new Error(n),{code:o.code,type:o.code,details:i,status:e})}let r=t?.data?.message||t?.message;return r?Object.assign(new Error(r),{status:e}):Object.assign(new Error(`HTTP ${e}`),{status:e})}function Ca(e){function t(n){return{"X-Foundation-Mvp-Application-Id":e.appId,"X-Foundation-Mvp-Tenant-Id":e.tenantId,"X-Foundation-Mvp-Application-Version":e.version,"Content-Type":"application/json",Authorization:`Bearer ${n}`}}async function o(n,i,s,a={}){let c=await e.getToken(),d=t(c),u=`${n}${i}`;if(a.params){let h=new URLSearchParams;for(let[A,S]of Object.entries(a.params))S!=null&&h.set(A,String(S));let I=h.toString();I&&(u+=`?${I}`)}let p={method:s,headers:d};a.body!==void 0&&(p.body=JSON.stringify(a.body));let l=await fetch(u,p);if(!l.ok){let h={};try{h=await l.json()}catch{}throw Pu(l.status,h)}if(l.status===204)return null;let m=await l.json();return vu(m)}async function r(n,i={}){return fetch(n,i)}return{request:o,rawFetch:r,headers:t}}function ln(e){if(!e)throw new Error("Token parsing failed: Missing auth token");try{let[t,o]=e.split("?"),r=t.split(".");if(r.length!==3)throw new Error("Invalid JWT format");let n=atob(r[1]),i=JSON.parse(n);o&&new URLSearchParams(o).forEach((u,p)=>{i[p]=u});let s=i["BaseApplication/apiBaseUrl"];if(!s)throw new Error("Token missing apiBaseUrl");let a=i["BaseApplication/websocketBaseUrl"]||"",c=i["BaseApplication/accountBaseUrl"]||s;return{sub:i.sub||"",apiBaseUrl:s,accountBaseUrl:c,websocketBaseUrl:a,userId:i["BaseApplication/userId"]||"",namespace:i["BaseApplication/namespace"]}}catch(t){if(t instanceof Error&&t.message.startsWith("Token"))throw t;let o=t instanceof Error?t.message:"Failed to parse token";throw new Error(`Token parsing failed: ${o}`)}}async function va(e){let t=e.configUrl,o=e.appId,r=e.tenantId;try{let x=await fetch("/foundation-env.json");if(x.ok){let X=await x.json();X.configUrl&&(t=X.configUrl,o=X.applicationId||o,r=X.applicationTenant||r)}}catch{}if(!t)throw new Error("No configUrl provided and /foundation-env.json not found");let n={Accept:"application/json","Cache-Control":"no-cache"};o&&(n["X-Foundation-Mvp-Application-Id"]=o),r&&(n["X-Foundation-Mvp-Tenant-Id"]=r);let i=await fetch(t,{headers:n});if(!i.ok)throw new Error(`Failed to fetch config: ${i.statusText}`);let s=await i.json(),a=s.data??s,c=a.auth||{provider:"none"},d=e.auth||await Aa(c),p=xa(d);await p._initUser();let l,m;if(e.baseUrl)l=e.baseUrl,m=e.baseUrl;else if(c.apiUrls?.apiBaseUrl){let x=c.apiUrls;l=x.apiBaseUrl,m=x.accountBaseUrl||l}else{let x=await d.getTokenSilently(),X=ln(x);l=X.apiBaseUrl,m=X.accountBaseUrl}let h=o||a.app?.id||a.tenant?.identifier||"",I=r||a.tenant?.identifier||"",A=a.app?.version||a.core?.version||"0.0.0",S=Ca({appId:h,tenantId:I,version:A,getToken:()=>d.getTokenSilently()}),M={};try{M=await S.request(l,"/api/v1/config/init","GET")||{}}catch(x){console.warn("[Foundation SDK] Backend config fetch failed:",x)}let H={...a,...M},le="";try{let x=await d.getTokenSilently();x&&x!=="none"&&(le=ln(x).namespace||"")}catch{}let ie={get app(){let x=H.app||{};return{id:x.id||h,name:x.name||"",version:x.version||A,environment:x.environment||"",...x}},get features(){return H.features||{}},get plans(){return H.plans||[]},get theme(){let x=H.theme||{};return{colors:x.colors||{},dark:x.dark||{},defaultColorScheme:x.defaultColorScheme}},get connectors(){return H.connectors||{}},get resources(){return H.resources||{}},get auth(){let{provider:x,...X}=c;return{provider:x,...X}},get raw(){return H}},Ee=Tu(S,l),F=Ru(S,l,le),nt=_u(S,m),de=Nu(S,l,m,le),yt=bu(S,l),Et=Uu(),Fe=[];return{get ready(){return Promise.resolve()},get isReady(){return!0},auth:p,db:Ee,files:F,integration:de,account:nt,config:ie,openapi:yt,log:Et,on(x,X){return x==="entity.changed"?(Fe.push(X),()=>{let ro=Fe.indexOf(X);ro>-1&&Fe.splice(ro,1)}):()=>{}}}}function Tu(e,t){return{async list(o,r={}){let{filters:n,limit:i,cursor:s,orderBy:a,orderDir:c}=r,d={...n};return i&&(d.limit=i),s&&(d.next=s),a&&(d.orderBy=a),c&&(d.orderDir=c),e.request(t,`/api/v1/core/${o}`,"GET",{params:d})},async get(o,r){return e.request(t,`/api/v1/core/${o}`,"GET",{params:{id:r}})},async create(o,r){return e.request(t,`/api/v1/core/${o}`,"POST",{body:r})},async update(o,r,n){return e.request(t,`/api/v1/core/${o}`,"PUT",{body:{id:r,...n}})},async save(o,r){try{return await e.request(t,`/api/v1/core/${o}`,"PUT",{body:r})}catch{return e.request(t,`/api/v1/core/${o}`,"POST",{body:r})}},async delete(o,r){await e.request(t,`/api/v1/core/${o}`,"DELETE",{body:{id:r}})}}}function Ru(e,t,o){return{async initiate(r){return e.request(t,"/api/v1/core/upload","POST",{body:{...r,__namespace:o}})},async upload(r){let n;r.file instanceof ArrayBuffer?n=r.file:n=await r.file.arrayBuffer();let i=await e.request(t,"/api/v1/core/upload","POST",{body:{name:r.name,contentType:r.contentType,contentLength:n.byteLength,sha256:r.sha256,__namespace:o}});if(!i.signedUrl||!i.signedData)throw new Error("Missing signedUrl or signedData in response");let s=new FormData;Object.entries(i.signedData).forEach(([c,d])=>{s.append(c,d)}),s.append("file",new Blob([n],{type:r.contentType}),r.name);let a=await fetch(i.signedUrl,{method:"POST",body:s});if(a.status!==204)throw new Error(`S3 upload failed: ${a.status}`);return{id:i.id,name:i.name,status:"uploaded",s3UploadComplete:!0}},async get(r){return e.request(t,"/api/v1/core/files","GET",{params:{id:r,__namespace:o}})},async delete(r){await e.request(t,`/api/v1/core/files/${r}`,"DELETE")},async list(r={}){let n={__namespace:o};r.limit&&(n.limit=r.limit),r.cursor&&(n.cursor=r.cursor);let i=await e.request(t,"/api/v1/core/files","GET",{params:n});return{items:i?.items||[],nextCursor:i?.next}}}}function _u(e,t){return{async get(){return e.request(t,"/api/v1/accounts/account","GET")},async update(o){await e.request(t,"/api/v1/accounts/account","PUT",{body:{user:o}})},async usage(){return e.request(t,"/api/v1/accounts/account/usage","GET")},async resendVerification(){await e.request(t,"/api/v1/accounts/account/resend-verification","POST")}}}function Nu(e,t,o,r){let n={async list(){return e.request(t,"/api/v1/config/connectors","GET")},async connections(){return e.request(t,"/api/v1/core/integrations","GET",{params:{query:"default",__namespace:r}})},async all(){let[i,s]=await Promise.all([n.list(),n.connections()]),a=Array.isArray(i)?i:i?.items||[],c=Array.isArray(s)?s:s?.items||[],d=new Map;for(let u of c){let p=u.source||u.id;d.has(p)||d.set(p,[]),d.get(p).push(u)}return a.map(u=>{let p=d.get(u.id)||[];return{...u,connections:p,connected:p.some(l=>l.connected),connectionCount:p.filter(l=>l.connected).length}})},async status(i){let s=await n.connections(),c=(Array.isArray(s)?s:s?.items||[]).filter(d=>d.source===i&&d.connected);return{connected:c.length>0,connections:c}},async connect(i){return e.request(o,`/api/v1/accounts/integrations/${i}/initialize`,"POST",{body:{__namespace:r}})},async disconnect(i,s){await e.request(o,`/api/v1/accounts/integrations/${i}/remove`,"POST",{body:{configurationId:s}})}};return n}function bu(e,t){return{async get(){return e.request(t,"/api/v1/config/openapi","GET")}}}function Uu(){return{info:(e,t)=>console.log(`[Foundation] ${e}`,t??""),warn:(e,t)=>console.warn(`[Foundation] ${e}`,t??""),error:(e,t)=>console.error(`[Foundation] ${e}`,t??""),event:(e,t)=>console.log(`[Foundation Event] ${e}`,t??"")}}pn("cognito",async e=>{let t=e.cognito;if(!t)throw new Error("Cognito config required");return un.configure({Auth:{Cognito:{userPoolId:t.userPoolId,userPoolClientId:t.clientId,loginWith:{oauth:{domain:t.domain.replace("https://",""),scopes:(t.scope||"openid profile email").split(" "),redirectSignIn:[window.location.origin],redirectSignOut:[window.location.origin],responseType:"code"}}}}}),{login:async()=>{await ir()},logout:async()=>{await cn()},getUser:async()=>{try{let o=await Ze();return{id:o.userId,email:o.signInDetails?.loginId||"",name:o.username}}catch{return}},getTokenSilently:async()=>{let r=(await yo()).tokens?.accessToken?.toString();if(!r)throw new Error("No token");return r},isAuthenticated:async()=>{try{return await Ze(),!0}catch{return!1}},signIn:async(o,r)=>{await bt({username:o,password:r})},signUp:async(o,r,n)=>{await rn({username:o,password:r,options:{userAttributes:{email:o,...n}}})},forgotPassword:async o=>{await nn({username:o})},resetPassword:async(o,r)=>{await sn({username:"",confirmationCode:o,newPassword:r})}}});return Fa(Ou);})();
|
|
30
22
|
/*! Bundled license information:
|
|
31
23
|
|
|
32
24
|
js-cookie/dist/js.cookie.mjs:
|