UNPKG

@clerk/clerk-js

Version:
1 lines • 418 kB
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(globalThis,()=>(()=>{var t={80753:function(t,e,i){"use strict";i.d(e,{O1:()=>l,Yt:()=>n,bf:()=>u,cD:()=>a,cc:()=>s,ci:()=>d,gR:()=>p,hz:()=>h,im:()=>c,v_:()=>r,w9:()=>o});let n=["redirect_url","after_sign_in_url","after_sign_up_url","sign_in_force_redirect_url","sign_in_fallback_redirect_url","sign_up_force_redirect_url","sign_up_fallback_redirect_url"],r="__clerk_modal_state",a="__clerk_synced",s="suffixed_cookies",o="__clerk_satellite_url",l={FORM_IDENTIFIER_NOT_FOUND:"form_identifier_not_found",FORM_PASSWORD_INCORRECT:"form_password_incorrect",FORM_PASSWORD_PWNED:"form_password_pwned",INVALID_STRATEGY_FOR_USER:"strategy_for_user_invalid",NOT_ALLOWED_TO_SIGN_UP:"not_allowed_to_sign_up",OAUTH_ACCESS_DENIED:"oauth_access_denied",OAUTH_EMAIL_DOMAIN_RESERVED_BY_SAML:"oauth_email_domain_reserved_by_saml",NOT_ALLOWED_ACCESS:"not_allowed_access",SAML_USER_ATTRIBUTE_MISSING:"saml_user_attribute_missing",USER_LOCKED:"user_locked",EXTERNAL_ACCOUNT_NOT_FOUND:"external_account_not_found",SIGN_UP_MODE_RESTRICTED:"sign_up_mode_restricted",SIGN_UP_MODE_RESTRICTED_WAITLIST:"sign_up_restricted_waitlist",ENTERPRISE_SSO_USER_ATTRIBUTE_MISSING:"enterprise_sso_user_attribute_missing",ENTERPRISE_SSO_EMAIL_ADDRESS_DOMAIN_MISMATCH:"enterprise_sso_email_address_domain_mismatch",ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH:"enterprise_sso_hosted_domain_mismatch",SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH:"saml_email_address_domain_mismatch",INVITATION_ACCOUNT_NOT_EXISTS:"invitation_account_not_exists",ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO:"organization_membership_quota_exceeded_for_sso",CAPTCHA_INVALID:"captcha_invalid",FRAUD_DEVICE_BLOCKED:"device_blocked",FRAUD_ACTION_BLOCKED:"action_blocked",SIGNUP_RATE_LIMIT_EXCEEDED:"signup_rate_limit_exceeded"},c=["email_address","phone_number","username"],u=["email_address","phone_number","username","first_name","last_name"],h=350,d={PUBLIC:"public",RESTRICTED:"restricted",WAITLIST:"waitlist"},p="2025-04-10"},24152:function(t,e,i){"use strict";i.d(e,{$C:()=>E,C:()=>p,Dg:()=>s,FI:()=>x,G6:()=>c,HE:()=>u,O7:()=>d,PQ:()=>O,RE:()=>U,Rz:()=>f,WC:()=>v,Ws:()=>g,Xp:()=>a,_5:()=>S,an:()=>r,cT:()=>b,ep:()=>m,k2:()=>l,lb:()=>_,qO:()=>y,qW:()=>k,rn:()=>h,sY:()=>A,xZ:()=>w,yI:()=>o}),i(92037);let n="ClerkJS:";function r(t,e){throw Error("".concat(n,' Network error at "').concat(t,'" - ').concat(e,". Please try again."))}function a(){throw Error("".concat(n," Something went wrong initializing Clerk."))}function s(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";throw Error("".concat(n," Something went wrong initializing Clerk in development mode.").concat(t&&" ".concat(t)))}function o(t){throw Error("".concat(n," Missing path option. The ").concat(t,' component was mounted with path routing so you need to specify the path where the component is mounted on e.g. path="/sign-in".'))}function l(t){throw Error("".concat(n," You must wrap your application in a <").concat(t,"> component."))}function c(){throw Error("".concat(n," Clerk is undefined"))}function u(){throw Error("".concat(n," The target element is empty. Provide a valid DOM element."))}function h(){throw Error("".concat(n," Missing FAPI client in resources."))}function d(t){throw Error("".concat(n," Something went wrong initializing Clerk during the ").concat(t," flow. Please contact support."))}function p(t){throw Error("".concat(n," You need to start a ").concat(t," flow by calling ").concat(t,".create() first."))}function f(t,e){throw Error("".concat(n,' Strategy "').concat(e,'" is not a valid strategy for ').concat(t,"."))}function _(t){throw Error("".concat(n," You need to start a ").concat(t," flow by calling ").concat(t,".create({ identifier: 'your web3 wallet address' }) first"))}function m(){throw Error("".concat(n," You need to start a SignIn flow by calling SignIn.create({ strategy: 'passkey' }) first"))}function v(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";throw Error("".concat(n," Missing '").concat(t,"' option"))}function g(t,e){throw Error("".concat(n," Response: ").concat(t||0," not supported yet.\nFor more information contact us at ").concat(e))}function y(){throw Error("".concat(n," Missing dev browser jwt. Please contact support."))}function w(){throw Error("".concat(n," Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl."))}function b(){throw Error("".concat(n," The signInUrl needs to be on a different origin than your satellite application."))}function S(){throw Error("".concat(n," The signInUrl needs to have a absolute url format."))}function k(){throw Error("".concat(n," Missing signInUrl. A satellite application needs to specify the signInUrl for development instances."))}function A(){throw Error("".concat(n," Invalid redirect_url. A valid http or https url should be used for the redirection."))}function x(t){throw Error("".concat(n," Unable to retrieve a third party script").concat(t?" ".concat(t):"","."))}function O(t){throw Error("".concat(n," Invalid routing strategy, path cannot be used in tandem with ").concat(t,"."))}function U(t){throw Error("".concat(n," Calling ").concat(t,".reload is not currently supported. Please contact support."))}function E(t){throw Error("".concat(n," Missing publicKey. When calling 'navigator.credentials.").concat(t,"()' it is required to pass a publicKey object."))}},50005:function(t,e,i){"use strict";i.d(e,{Y:()=>a,U:()=>r});var n=i(86225);i(64310);let r={TokenUpdate:"token:update",UserSignOut:"user:signOut",EnvironmentUpdate:"environment:update",SessionTokenResolved:"session:tokenResolved"},a=(0,n.n)()},4843:function(t,e,i){"use strict";i.d(e,{C9:()=>l,iL:()=>s,_G:()=>o,QE:()=>c});var n=i(17431),r=i(90750),a=i(73139);class s{constructor(){(0,n._)(this,"getPlans",async t=>{let{for:e,...i}=t||{},n={...i,payer_type:"organization"===e?"org":"user"};return await a.i._fetch({path:"/commerce/plans",method:"GET",search:(0,r.C)(n)}).then(t=>{let{data:e,total_count:i}=t;return{total_count:i,data:e.map(t=>new a.Cs(t))}})}),(0,n._)(this,"getPlan",async t=>{let e=await a.i._fetch({path:"/commerce/plans/".concat(t.id),method:"GET"});return new a.Cs(e)}),(0,n._)(this,"getSubscription",async t=>await a.i._fetch({path:t.orgId?"/organizations/".concat(t.orgId,"/commerce/subscription"):"/me/commerce/subscription",method:"GET"}).then(t=>new a.gU(null==t?void 0:t.response))),(0,n._)(this,"getSubscriptions",async t=>{let{orgId:e,...i}=t;return await a.i._fetch({path:e?"/organizations/".concat(e,"/commerce/subscriptions"):"/me/commerce/subscriptions",method:"GET",search:(0,r.C)(i)}).then(t=>{let{data:e,total_count:i}=null==t?void 0:t.response;return{total_count:i,data:e.map(t=>new a.oq(t))}})}),(0,n._)(this,"getStatements",async t=>{let{orgId:e,...i}=t;return await a.i._fetch({path:e?"/organizations/".concat(e,"/commerce/statements"):"/me/commerce/statements",method:"GET",search:(0,r.C)(i)}).then(t=>{let{data:e,total_count:i}=null==t?void 0:t.response;return{total_count:i,data:e.map(t=>new a.j3(t))}})}),(0,n._)(this,"getStatement",async t=>{var e;let i=null==(e=await a.i._fetch({path:t.orgId?"/organizations/".concat(t.orgId,"/commerce/statements/").concat(t.id):"/me/commerce/statements/".concat(t.id),method:"GET"}))?void 0:e.response;return new a.j3(i)}),(0,n._)(this,"getPaymentAttempts",async t=>{let{orgId:e,...i}=t;return await a.i._fetch({path:e?"/organizations/".concat(e,"/commerce/payment_attempts"):"/me/commerce/payment_attempts",method:"GET",search:(0,r.C)(i)}).then(t=>{let{data:e,total_count:i}=t;return{total_count:i,data:e.map(t=>new a.Pm(t))}})}),(0,n._)(this,"getPaymentAttempt",async t=>{let e=await a.i._fetch({path:t.orgId?"/organizations/".concat(t.orgId,"/commerce/payment_attempts/").concat(t.id):"/me/commerce/payment_attempts/".concat(t.id),method:"GET"});return new a.Pm(e)}),(0,n._)(this,"startCheckout",async t=>{var e;let{orgId:i,...n}=t,r=null==(e=await a.i._fetch({path:i?"/organizations/".concat(i,"/commerce/checkouts"):"/me/commerce/checkouts",method:"POST",body:n}))?void 0:e.response;return new a.Dl(r,i)})}}let o=async t=>{var e;let{orgId:i,...n}=t,r=null==(e=await a.i._fetch({path:i?"/organizations/".concat(i,"/commerce/payment_sources/initialize"):"/me/commerce/payment_sources/initialize",method:"POST",body:n}))?void 0:e.response;return new a.zv(r)},l=async t=>{var e;let{orgId:i,...n}=t,r=null==(e=await a.i._fetch({path:i?"/organizations/".concat(i,"/commerce/payment_sources"):"/me/commerce/payment_sources",method:"POST",body:n}))?void 0:e.response;return new a.wg(r)},c=async t=>{let{orgId:e,...i}=t;return await a.i._fetch({path:e?"/organizations/".concat(e,"/commerce/payment_sources"):"/me/commerce/payment_sources",method:"GET",search:(0,r.C)(i)}).then(t=>{let{data:e,total_count:i}=null==t?void 0:t.response;return{total_count:i,data:e.map(t=>new a.wg(t))}})}},60104:function(t,e,i){"use strict";i.d(e,{T:()=>s});var n=i(17431),r=i(46630),a=i(73139);class s extends a.i{fromJSON(t){return t&&(this.claimedAt=this.withDefault(t.claimed_at?(0,r.V)(t.claimed_at):null,this.claimedAt),this.reverification=this.withDefault(t.reverification,this.reverification),this.singleSessionMode=this.withDefault(t.single_session_mode,this.singleSessionMode),this.preferredChannels=this.withDefault(t.preferred_channels,this.preferredChannels)),this}__internal_toSnapshot(){var t;return{claimed_at:this.claimedAt?this.claimedAt.getTime():null,id:null!=(t=this.id)?t:"",object:"auth_config",reverification:this.reverification,single_session_mode:this.singleSessionMode}}constructor(t=null){super(),(0,n._)(this,"claimedAt",null),(0,n._)(this,"reverification",!1),(0,n._)(this,"singleSessionMode",!1),(0,n._)(this,"preferredChannels",null),this.fromJSON(t)}}},28069:function(t,e,i){"use strict";i.d(e,{i:()=>u});var n=i(17431);i(87945),i(56113),i(50725);var r=i(72708),a=i(41402),s=i(24152),o=i(97976),l=i(73139);class c{static getInstance(){return c.instance||(c.instance=new c(l.KU,o.E)),c.instance}async execute(t,e){if(this.captchaAttemptsExceeded())throw new l.w$("Security verification failed. Please try again by refreshing the page, clearing your browser cookies, or using a different web browser.",{code:"captcha_client_attempts_exceeded"});try{return this.inflightException&&await this.inflightException,await e()}catch(r){var i;let n;if(!(0,l.kD)(r)||(null==(i=r.errors[0])?void 0:i.code)!=="requires_captcha")throw r;if(this.inflightException)return await this.inflightException,await e();this.inflightException=new Promise(t=>n=t);try{let e=await this.managedChallenge(t);(null==e?void 0:e.captchaError)!=="modal_component_not_ready"&&(await this.client.getOrCreateInstance().__internal_sendCaptchaToken(e),this.captchaRetryCount=0)}catch(t){throw this.captchaRetryCount++,t}finally{n(),this.inflightException=null}return await e()}}managedChallenge(t){return new this.CaptchaChallengeImpl(t).managedInModal({action:"verify"})}constructor(t,e){(0,n._)(this,"client",void 0),(0,n._)(this,"CaptchaChallengeImpl",void 0),(0,n._)(this,"inflightException",void 0),(0,n._)(this,"captchaRetryCount",void 0),(0,n._)(this,"MAX_RETRY_ATTEMPTS",void 0),(0,n._)(this,"captchaAttemptsExceeded",void 0),this.client=t,this.CaptchaChallengeImpl=e,this.inflightException=null,this.captchaRetryCount=0,this.MAX_RETRY_ATTEMPTS=3,this.captchaAttemptsExceeded=()=>this.captchaRetryCount>=this.MAX_RETRY_ATTEMPTS}}(0,n._)(c,"instance",void 0);class u{static get fapiClient(){return u.clerk.getFapiClient()}async reload(t){let{rotatingTokenNonce:e}=t||{};return this._baseGet({forceUpdateClient:!0,rotatingTokenNonce:e})}isNew(){return!this.id}static async _fetch(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c.getInstance().execute(this.clerk,()=>this._baseFetch(t,e))}static async _baseFetch(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};u.fapiClient||(0,s.rn)();let{fetchMaxTries:n}=i;try{e=await u.fapiClient.request(t,{fetchMaxTries:n})}catch(t){if(this.shouldRethrowOfflineNetworkErrors())throw new l.w$((null==t?void 0:t.message)||t,{code:"network_error"});if(!(0,r.af)())return console.warn(t),null;throw t}let{payload:o,status:c,statusText:h,headers:d}=e;if(d){let t=d.get("x-country");this.clerk.__internal_setCountry(t?t.toLowerCase():null)}if(("GET"!==t.method||i.forceUpdateClient)&&this._updateClient(o),c>=200&&c<=299)return o;if(c>=400){var p,f;let t=null==o?void 0:o.errors,e=null==t||null==(p=t[0])?void 0:p.long_message,i=null==t||null==(f=t[0])?void 0:f.code;401===c&&"requires_captcha"!==i&&await u.clerk.handleUnauthenticated(),function(t,e){if(!e||!e[0])return;let i=e[0],n=i.long_message;if("origin_invalid"===i.code&&(0,a.mA)(u.clerk.publishableKey)){let i=u.clerk.frontendApi.replace("clerk.","");throw new l.gO('Clerk: Production Keys are only allowed for domain "'.concat(i,'". \nAPI Error: ').concat(n),{data:e,status:t})}}(c,t);let n={data:t,status:c};if(429===c&&d){let t=d.get("retry-after");if(t){let e=parseInt(t,10);isNaN(e)||(n.retryAfter=e)}}throw new l.gO(e||h,n)}return null}static _updateClient(t){var e;if(!t)return;let i=t.client||(null==(e=t.meta)?void 0:e.client);i&&u.clerk&&u.clerk.updateClient(l.KU.getOrCreateInstance().fromJSON(i))}path(t){let e=this.pathRoot;if(this.isNew())return e;let i=e.replace(/[^/]$/,"$&/")+encodeURIComponent(this.id);return t?i.replace(/[^/]$/,"$&/")+encodeURIComponent(t):i}withDefault(t,e){return null!=t?t:e}async _baseGet(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=await u._fetch({method:"GET",path:this.path(),rotatingTokenNonce:t.rotatingTokenNonce},t);return this.fromJSON((null==e?void 0:e.response)||e)}async _baseMutate(t){let{action:e,body:i,method:n,path:r}=t,a=await u._fetch({method:n,path:r||this.path(e),body:i});return this.fromJSON((null==a?void 0:a.response)||a)}async _baseMutateBypass(t){let{action:e,body:i,method:n,path:r}=t,a=await u._baseFetch({method:n,path:r||this.path(e),body:i});return this.fromJSON((null==a?void 0:a.response)||a)}async _basePost(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._baseMutate({...t,method:"POST"})}async _basePostBypass(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._baseMutateBypass({...t,method:"POST"})}async _basePut(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._baseMutate({...t,method:"PUT"})}async _basePatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._baseMutate({...t,method:"PATCH"})}async _baseDelete(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await this._baseMutate({...t,method:"DELETE"})}static shouldRethrowOfflineNetworkErrors(){var t,e;let i=null==(e=u.clerk)||null==(t=e.__internal_getOption)?void 0:t.call(e,"experimental");return(null==i?void 0:i.rethrowOfflineNetworkErrors)||!1}constructor(){(0,n._)(this,"id",void 0),(0,n._)(this,"pathRoot","")}}(0,n._)(u,"clerk",void 0)},29401:function(t,e,i){"use strict";i.d(e,{K:()=>o});var n=i(17431);i(50725);var r=i(46630),a=i(7292),s=i(73139);class o extends s.i{static getOrCreateInstance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return o.instance||(o.instance=new o(t)),o.instance}static clearInstance(){o.instance=null}static isClientResource(t){return!!t&&t instanceof o}get signUpAttempt(){return this.signUp}get signInAttempt(){return this.signIn}get activeSessions(){return this.sessions.filter(t=>"active"===t.status)}get signedInSessions(){return this.sessions.filter(t=>"active"===t.status||"pending"===t.status)}create(){return this._basePut()}fetch(){let{fetchMaxTries:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._baseGet({fetchMaxTries:t})}async destroy(){return this._baseDelete({path:"/client"}).then(()=>{a.O.clear(),this.id="",this.sessions=[],this.signUp=new s.Mo(null),this.signIn=new s.cL(null),this.lastActiveSessionId=null,this.cookieExpiresAt=null,this.createdAt=null,this.updatedAt=null})}removeSessions(){return this._baseDelete({path:this.path()+"/sessions"}).then(t=>(a.O.clear(),t))}clearCache(){return this.sessions.forEach(t=>t.clearCache())}isEligibleForTouch(){return!!this.cookieExpiresAt&&this.cookieExpiresAt.getTime()-Date.now()<=6912e5}buildTouchUrl(t){let{redirectUrl:e}=t;return s.i.fapiClient.buildUrl({method:"GET",path:"/client/touch",pathPrefix:"v1",search:{redirect_url:e.toString()}}).toString()}__internal_sendCaptchaToken(t){return this._basePostBypass({body:t,path:this.path()+"/verify"})}fromJSON(t){return t&&(this.id=t.id,this.sessions=(t.sessions||[]).map(t=>new s.z_(t)),this.signUp=new s.Mo(t.sign_up),this.signIn=new s.cL(t.sign_in),this.lastActiveSessionId=t.last_active_session_id,this.captchaBypass=t.captcha_bypass||!1,this.cookieExpiresAt=t.cookie_expires_at?(0,r.V)(t.cookie_expires_at):null,this.createdAt=(0,r.V)(t.created_at||void 0),this.updatedAt=(0,r.V)(t.updated_at||void 0)),this}__internal_toSnapshot(){var t,e,i,n;return{object:"client",id:this.id||"",sessions:this.sessions.map(t=>t.__internal_toSnapshot()),sign_up:this.signUp.__internal_toSnapshot(),sign_in:this.signIn.__internal_toSnapshot(),last_active_session_id:this.lastActiveSessionId,captcha_bypass:this.captchaBypass,cookie_expires_at:this.cookieExpiresAt?this.cookieExpiresAt.getTime():null,created_at:null!=(i=null==(t=this.createdAt)?void 0:t.getTime())?i:null,updated_at:null!=(n=null==(e=this.updatedAt)?void 0:e.getTime())?n:null}}path(){return this.pathRoot}constructor(t=null){super(),(0,n._)(this,"pathRoot","/client"),(0,n._)(this,"sessions",[]),(0,n._)(this,"signUp",new s.Mo),(0,n._)(this,"signIn",new s.cL),(0,n._)(this,"lastActiveSessionId",null),(0,n._)(this,"captchaBypass",!1),(0,n._)(this,"cookieExpiresAt",null),(0,n._)(this,"createdAt",null),(0,n._)(this,"updatedAt",null),this.fromJSON(t)}}(0,n._)(o,"instance",void 0)},74498:function(t,e,i){"use strict";i.d(e,{l:()=>a});var n=i(17431),r=i(73139);class a extends r.i{fromJSON(t){return t&&(this.afterCreateOrganizationUrl=this.withDefault(t.after_create_organization_url,this.afterCreateOrganizationUrl),this.afterJoinWaitlistUrl=this.withDefault(t.after_join_waitlist_url,this.afterJoinWaitlistUrl),this.afterLeaveOrganizationUrl=this.withDefault(t.after_leave_organization_url,this.afterLeaveOrganizationUrl),this.afterSignInUrl=this.withDefault(t.after_sign_in_url,this.afterSignInUrl),this.afterSignOutAllUrl=this.withDefault(t.after_sign_out_all_url,this.afterSignOutAllUrl),this.afterSignOutOneUrl=this.withDefault(t.after_sign_out_one_url,this.afterSignOutOneUrl),this.afterSignUpUrl=this.withDefault(t.after_sign_up_url,this.afterSignUpUrl),this.afterSwitchSessionUrl=this.withDefault(t.after_switch_session_url,this.afterSwitchSessionUrl),this.applicationName=this.withDefault(t.application_name,this.applicationName),this.branded=this.withDefault(t.branded,this.branded),this.captchaHeartbeat=this.withDefault(t.captcha_heartbeat,this.captchaHeartbeat),this.captchaHeartbeatIntervalMs=this.withDefault(t.captcha_heartbeat_interval_ms,this.captchaHeartbeatIntervalMs),this.captchaOauthBypass=this.withDefault(t.captcha_oauth_bypass,this.captchaOauthBypass),this.captchaProvider=this.withDefault(t.captcha_provider,this.captchaProvider),this.captchaPublicKey=this.withDefault(t.captcha_public_key,this.captchaPublicKey),this.captchaPublicKeyInvisible=this.withDefault(t.captcha_public_key_invisible,this.captchaPublicKeyInvisible),this.captchaWidgetType=this.withDefault(t.captcha_widget_type,this.captchaWidgetType),this.clerkJSVersion=this.withDefault(t.clerk_js_version,this.clerkJSVersion),this.createOrganizationUrl=this.withDefault(t.create_organization_url,this.createOrganizationUrl),this.faviconImageUrl=this.withDefault(t.favicon_image_url,this.faviconImageUrl),this.googleOneTapClientId=this.withDefault(t.google_one_tap_client_id,this.googleOneTapClientId),this.homeUrl=this.withDefault(t.home_url,this.homeUrl),this.id=this.withDefault(t.id,this.id),this.instanceEnvironmentType=this.withDefault(t.instance_environment_type,this.instanceEnvironmentType),this.logoImageUrl=this.withDefault(t.logo_image_url,this.logoImageUrl),this.organizationProfileUrl=this.withDefault(t.organization_profile_url,this.organizationProfileUrl),this.preferredSignInStrategy=this.withDefault(t.preferred_sign_in_strategy,this.preferredSignInStrategy),this.privacyPolicyUrl=this.withDefault(t.privacy_policy_url,this.privacyPolicyUrl),this.showDevModeWarning=this.withDefault(t.show_devmode_warning,this.showDevModeWarning),this.signInUrl=this.withDefault(t.sign_in_url,this.signInUrl),this.signUpUrl=this.withDefault(t.sign_up_url,this.signUpUrl),this.supportEmail=this.withDefault(t.support_email,this.supportEmail),this.termsUrl=this.withDefault(t.terms_url,this.termsUrl),this.theme=this.withDefault(t.theme,this.theme),this.userProfileUrl=this.withDefault(t.user_profile_url,this.userProfileUrl),this.waitlistUrl=this.withDefault(t.waitlist_url,this.waitlistUrl)),this}__internal_toSnapshot(){return{object:"display_config",after_create_organization_url:this.afterCreateOrganizationUrl,after_join_waitlist_url:this.afterJoinWaitlistUrl,after_leave_organization_url:this.afterLeaveOrganizationUrl,after_sign_in_url:this.afterSignInUrl,after_sign_out_all_url:this.afterSignOutAllUrl,after_sign_out_one_url:this.afterSignOutOneUrl,after_sign_up_url:this.afterSignUpUrl,after_switch_session_url:this.afterSwitchSessionUrl,application_name:this.applicationName,branded:this.branded,captcha_heartbeat_interval_ms:this.captchaHeartbeatIntervalMs,captcha_heartbeat:this.captchaHeartbeat,captcha_oauth_bypass:this.captchaOauthBypass,captcha_provider:this.captchaProvider,captcha_public_key_invisible:this.captchaPublicKeyInvisible,captcha_public_key:this.captchaPublicKey,captcha_widget_type:this.captchaWidgetType,clerk_js_version:this.clerkJSVersion,create_organization_url:this.createOrganizationUrl,favicon_image_url:this.faviconImageUrl,google_one_tap_client_id:this.googleOneTapClientId,home_url:this.homeUrl,id:this.id,instance_environment_type:this.instanceEnvironmentType,logo_image_url:this.logoImageUrl,organization_profile_url:this.organizationProfileUrl,preferred_sign_in_strategy:this.preferredSignInStrategy,privacy_policy_url:this.privacyPolicyUrl,show_devmode_warning:this.showDevModeWarning,sign_in_url:this.signInUrl,sign_up_url:this.signUpUrl,support_email:this.supportEmail,terms_url:this.termsUrl,theme:this.theme,user_profile_url:this.userProfileUrl,waitlist_url:this.waitlistUrl}}constructor(t=null){super(),(0,n._)(this,"afterCreateOrganizationUrl",""),(0,n._)(this,"afterJoinWaitlistUrl",""),(0,n._)(this,"afterLeaveOrganizationUrl",""),(0,n._)(this,"afterSignInUrl",""),(0,n._)(this,"afterSignOutAllUrl",""),(0,n._)(this,"afterSignOutOneUrl",""),(0,n._)(this,"afterSignOutUrl",""),(0,n._)(this,"afterSignUpUrl",""),(0,n._)(this,"afterSwitchSessionUrl",""),(0,n._)(this,"applicationName",""),(0,n._)(this,"backendHost",""),(0,n._)(this,"branded",!1),(0,n._)(this,"captchaHeartbeat",!1),(0,n._)(this,"captchaHeartbeatIntervalMs",void 0),(0,n._)(this,"captchaOauthBypass",["oauth_google","oauth_microsoft","oauth_apple"]),(0,n._)(this,"captchaProvider","turnstile"),(0,n._)(this,"captchaPublicKey",null),(0,n._)(this,"captchaPublicKeyInvisible",null),(0,n._)(this,"captchaWidgetType",null),(0,n._)(this,"clerkJSVersion",void 0),(0,n._)(this,"createOrganizationUrl",""),(0,n._)(this,"experimental__forceOauthFirst",void 0),(0,n._)(this,"faviconImageUrl",""),(0,n._)(this,"googleOneTapClientId",void 0),(0,n._)(this,"homeUrl",""),(0,n._)(this,"id",""),(0,n._)(this,"instanceEnvironmentType",""),(0,n._)(this,"logoImageUrl",""),(0,n._)(this,"organizationProfileUrl",""),(0,n._)(this,"preferredSignInStrategy","password"),(0,n._)(this,"privacyPolicyUrl",""),(0,n._)(this,"showDevModeWarning",!1),(0,n._)(this,"signInUrl",""),(0,n._)(this,"signUpUrl",""),(0,n._)(this,"supportEmail",""),(0,n._)(this,"termsUrl",""),(0,n._)(this,"theme",{}),(0,n._)(this,"userProfileUrl",""),(0,n._)(this,"waitlistUrl",""),this.fromJSON(t)}}},82986:function(t,e,i){"use strict";i.d(e,{b:()=>s});var n=i(17431);i(50725),i(92037);var r=i(96111),a=i(73139);class s extends a.i{create(){return this._basePost({body:{email_address:this.emailAddress}})}fromJSON(t){return t&&(this.id=t.id,this.emailAddress=t.email_address,this.verification=new a.GX(t.verification),this.matchesSsoConnection=t.matches_sso_connection,this.linkedTo=(t.linked_to||[]).map(t=>new a.YN(t))),this}__internal_toSnapshot(){return{object:"email_address",id:this.id,email_address:this.emailAddress,verification:this.verification.__internal_toSnapshot(),linked_to:this.linkedTo.map(t=>t.__internal_toSnapshot()),matches_sso_connection:this.matchesSsoConnection}}constructor(t,e){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"emailAddress",""),(0,n._)(this,"matchesSsoConnection",!1),(0,n._)(this,"linkedTo",[]),(0,n._)(this,"verification",void 0),(0,n._)(this,"prepareVerification",t=>this._basePost({action:"prepare_verification",body:{...t}})),(0,n._)(this,"attemptVerification",t=>{let{code:e}=t||{};return this._basePost({action:"attempt_verification",body:{code:e}})}),(0,n._)(this,"createEmailLinkFlow",()=>{let{run:t,stop:e}=(0,r.W)();return{startEmailLinkFlow:async i=>{let{redirectUrl:n}=i;return await this.prepareVerification({strategy:"email_link",redirectUrl:n}),new Promise((i,n)=>{t(()=>this.reload().then(t=>{"verified"===t.verification.status&&(e(),i(t))}).catch(t=>{e(),n(t)}))})},cancelEmailLinkFlow:e}}),(0,n._)(this,"createEnterpriseSSOLinkFlow",()=>{let{run:t,stop:e}=(0,r.W)();return{startEnterpriseSSOLinkFlow:async i=>{let{redirectUrl:n}=i;if(!(await this.prepareVerification({strategy:"enterprise_sso",redirectUrl:n})).verification.externalVerificationRedirectURL)throw Error("Unexpected: External verification redirect URL is missing");return new Promise((i,n)=>{t(()=>this.reload().then(t=>{"verified"===t.verification.status&&(e(),i(t))}).catch(t=>{e(),n(t)}))})},cancelEnterpriseSSOLinkFlow:e}}),(0,n._)(this,"destroy",()=>this._baseDelete()),(0,n._)(this,"toString",()=>this.emailAddress),this.pathRoot=e,this.fromJSON(t)}}},39357:function(t,e,i){"use strict";i.d(e,{q:()=>l});var n=i(17431),r=i(50005),a=i(73139);class s extends a.i{fromJSON(t){return t&&(this.enabled=this.withDefault(t.enabled,!1)),this}__internal_toSnapshot(){return{enabled:this.enabled}}constructor(t=null){super(),(0,n._)(this,"enabled",!1),this.fromJSON(t)}}class o extends a.i{fromJSON(t){return t&&(t.actions&&(this.actions.adminDelete=this.withDefault(t.actions.admin_delete,this.actions.adminDelete)),t.domains&&(this.domains.enabled=this.withDefault(t.domains.enabled,this.domains.enabled),this.domains.enrollmentModes=this.withDefault(t.domains.enrollment_modes,this.domains.enrollmentModes),this.domains.defaultRole=this.withDefault(t.domains.default_role,this.domains.defaultRole)),this.enabled=this.withDefault(t.enabled,this.enabled),this.maxAllowedMemberships=this.withDefault(t.max_allowed_memberships,this.maxAllowedMemberships),this.forceOrganizationSelection=this.withDefault(t.force_organization_selection,this.forceOrganizationSelection)),this}__internal_toSnapshot(){return{actions:{admin_delete:this.actions.adminDelete},domains:{enabled:this.domains.enabled,enrollment_modes:this.domains.enrollmentModes,default_role:this.domains.defaultRole},enabled:this.enabled,max_allowed_memberships:this.maxAllowedMemberships}}constructor(t=null){super(),(0,n._)(this,"actions",{adminDelete:!1}),(0,n._)(this,"domains",{enabled:!1,enrollmentModes:[],defaultRole:null}),(0,n._)(this,"enabled",!1),(0,n._)(this,"maxAllowedMemberships",1),(0,n._)(this,"forceOrganizationSelection",void 0),this.fromJSON(t)}}class l extends a.i{static getInstance(){return l.instance||(l.instance=new l),l.instance}fromJSON(t){return t&&(this.authConfig=new a.Tg(t.auth_config),this.displayConfig=new a.lR(t.display_config),this.maintenanceMode=this.withDefault(t.maintenance_mode,this.maintenanceMode),this.organizationSettings=new o(t.organization_settings),this.userSettings=new a.PG(t.user_settings),this.commerceSettings=new a.mM(t.commerce_settings),this.apiKeysSettings=new s(t.api_keys_settings)),this}fetch(){let{touch:t,fetchMaxTries:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{touch:!1};return(t?this._basePatch({}):this._baseGet({fetchMaxTries:e})).then(t=>(r.Y.emit(r.U.EnvironmentUpdate,null),t))}__internal_toSnapshot(){var t;return{object:"environment",auth_config:this.authConfig.__internal_toSnapshot(),display_config:this.displayConfig.__internal_toSnapshot(),id:null!=(t=this.id)?t:"",maintenance_mode:this.maintenanceMode,organization_settings:this.organizationSettings.__internal_toSnapshot(),user_settings:this.userSettings.__internal_toSnapshot(),commerce_settings:this.commerceSettings.__internal_toSnapshot(),api_keys_settings:this.apiKeysSettings.__internal_toSnapshot()}}constructor(t=null){super(),(0,n._)(this,"authConfig",new a.Tg),(0,n._)(this,"displayConfig",new a.lR),(0,n._)(this,"maintenanceMode",!1),(0,n._)(this,"pathRoot","/environment"),(0,n._)(this,"userSettings",new a.PG),(0,n._)(this,"organizationSettings",new o),(0,n._)(this,"commerceSettings",new a.mM),(0,n._)(this,"apiKeysSettings",new s),(0,n._)(this,"isDevelopmentOrStaging",()=>!this.isProduction()),(0,n._)(this,"isProduction",()=>"production"===this.displayConfig.instanceEnvironmentType),(0,n._)(this,"isSingleSession",()=>this.authConfig.singleSessionMode),(0,n._)(this,"onWindowLocationHost",()=>this.displayConfig.backendHost===window.location.host),this.fromJSON(t)}}(0,n._)(l,"instance",void 0)},83767:function(t,e,i){"use strict";i.d(e,{N:()=>n.N,ZC:()=>n.ZC,gO:()=>n.gO,kD:()=>n.kD,sZ:()=>n.sZ,uX:()=>n.uX,w$:()=>n.w$});var n=i(73531)},56516:function(t,e,i){"use strict";i.d(e,{z:()=>o});var n=i(17431);i(87945),i(56113);var r=i(65027),a=i(28069),s=i(69596);class o extends a.i{fromJSON(t){return t&&(this.id=t.id,this.identificationId=t.identification_id,this.providerUserId=t.provider_user_id,this.approvedScopes=t.approved_scopes,this.imageUrl=t.image_url,this.emailAddress=t.email_address,this.firstName=t.first_name,this.lastName=t.last_name,this.provider=(t.provider||"").replace("oauth_",""),this.username=t.username,this.phoneNumber=t.phone_number,this.publicMetadata=t.public_metadata,this.label=t.label,t.verification&&(this.verification=new s.GX(t.verification))),this}__internal_toSnapshot(){var t;return{object:"external_account",id:this.id,identification_id:this.identificationId,provider:this.provider,provider_user_id:this.providerUserId,email_address:this.emailAddress,approved_scopes:this.approvedScopes,first_name:this.firstName,last_name:this.lastName,image_url:this.imageUrl,username:this.username,phone_number:this.phoneNumber,public_metadata:this.publicMetadata,label:this.label,verification:(null==(t=this.verification)?void 0:t.__internal_toSnapshot())||null}}providerSlug(){return this.provider}providerTitle(){return[(0,r.MI)(this.providerSlug()),"Account"].join(" ")}accountIdentifier(){return this.username||this.emailAddress||this.label}constructor(t,e){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"identificationId",void 0),(0,n._)(this,"provider",void 0),(0,n._)(this,"providerUserId",""),(0,n._)(this,"emailAddress",""),(0,n._)(this,"approvedScopes",""),(0,n._)(this,"firstName",""),(0,n._)(this,"lastName",""),(0,n._)(this,"imageUrl",""),(0,n._)(this,"username",""),(0,n._)(this,"phoneNumber",""),(0,n._)(this,"publicMetadata",{}),(0,n._)(this,"label",""),(0,n._)(this,"verification",null),(0,n._)(this,"reauthorize",t=>{let{additionalScopes:e,redirectUrl:i}=t||{};return this._basePatch({action:"reauthorize",body:{additional_scope:e,redirect_url:i}})}),(0,n._)(this,"destroy",()=>this._baseDelete()),this.pathRoot=e,this.fromJSON(t)}}},71956:function(t,e,i){"use strict";i.d(e,{Y:()=>a});var n=i(17431),r=i(28069);class a extends r.i{fromJSON(t){return t&&(this.id=t.id,this.type=t.type),this}__internal_toSnapshot(){return{object:"identification_link",id:this.id,type:this.type}}constructor(t){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"type",void 0),this.fromJSON(t)}}},36890:function(t,e,i){"use strict";i.d(e,{E:()=>a});var n=i(17431);i(50725);var r=i(73139);class a extends r.i{static async create(t){var e;let i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=n;return"string"==typeof n.file?(s=n.file,i=new Headers({"Content-Type":"application/octet-stream"})):n.file&&(s=new FormData).append("file",n.file),new a(null==(e=await r.i._fetch({path:t,method:"POST",body:s,headers:i}))?void 0:e.response)}static async delete(t){var e;return new a(null==(e=await r.i._fetch({path:t,method:"DELETE"}))?void 0:e.response)}fromJSON(t){return t&&(this.id=t.id,this.name=t.name,this.publicUrl=t.public_url),this}constructor(t){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"name",null),(0,n._)(this,"publicUrl",null),this.fromJSON(t)}}},19210:function(t,e,i){"use strict";i.d(e,{B:()=>a});var n=i(17431);i(56113);var r=i(73139);class a extends r.i{fromJSON(t){return t&&(this.id=t.id,this.phoneNumber=t.phone_number,this.reservedForSecondFactor=t.reserved_for_second_factor,this.defaultSecondFactor=t.default_second_factor,this.verification=new r.GX(t.verification),this.linkedTo=(t.linked_to||[]).map(t=>new r.YN(t)),this.backupCodes=t.backup_codes),this}__internal_toSnapshot(){return{object:"phone_number",id:this.id||"",phone_number:this.phoneNumber,reserved_for_second_factor:this.reservedForSecondFactor,default_second_factor:this.defaultSecondFactor,verification:this.verification.__internal_toSnapshot(),linked_to:this.linkedTo.map(t=>t.__internal_toSnapshot()),backup_codes:this.backupCodes}}constructor(t,e){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"phoneNumber",""),(0,n._)(this,"reservedForSecondFactor",!1),(0,n._)(this,"defaultSecondFactor",!1),(0,n._)(this,"linkedTo",[]),(0,n._)(this,"verification",void 0),(0,n._)(this,"backupCodes",void 0),(0,n._)(this,"create",()=>this._basePost({body:{phone_number:this.phoneNumber}})),(0,n._)(this,"prepareVerification",()=>this._basePost({action:"prepare_verification",body:{strategy:"phone_code"}})),(0,n._)(this,"attemptVerification",t=>{let{code:e}=t||{};return this._basePost({action:"attempt_verification",body:{code:e}})}),(0,n._)(this,"setReservedForSecondFactor",t=>{let{reserved:e}=t||{};return this._basePatch({body:{reserved_for_second_factor:e}})}),(0,n._)(this,"makeDefaultSecondFactor",()=>this._basePatch({body:{default_second_factor:!0}})),(0,n._)(this,"destroy",()=>this._baseDelete()),(0,n._)(this,"toString",()=>{let t=this.phoneNumber.match(/^(\d{3})(\d{3})(\d{4})$/);return t?"("+t[1]+") "+t[2]+"-"+t[3]:this.phoneNumber}),this.pathRoot=e,this.fromJSON(t)}}},52724:function(t,e,i){"use strict";i.d(e,{g:()=>o});var n=i(17431),r=i(46630),a=i(28069),s=i(69596);class o extends a.i{fromJSON(t){return t&&(this.id=t.id,this.provider=t.provider,this.providerUserId=t.provider_user_id,this.active=t.active,this.emailAddress=t.email_address,this.firstName=t.first_name,this.lastName=t.last_name,t.verification&&(this.verification=new s.GX(t.verification)),t.saml_connection&&(this.samlConnection=new l(t.saml_connection))),this}__internal_toSnapshot(){var t,e;return{object:"saml_account",id:this.id,provider:this.provider,provider_user_id:this.providerUserId,active:this.active,email_address:this.emailAddress,first_name:this.firstName,last_name:this.lastName,verification:(null==(t=this.verification)?void 0:t.__internal_toSnapshot())||null,saml_connection:null==(e=this.samlConnection)?void 0:e.__internal_toSnapshot()}}constructor(t,e){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"provider","saml_custom"),(0,n._)(this,"providerUserId",null),(0,n._)(this,"active",!1),(0,n._)(this,"emailAddress",""),(0,n._)(this,"firstName",""),(0,n._)(this,"lastName",""),(0,n._)(this,"verification",null),(0,n._)(this,"samlConnection",null),this.pathRoot=e,this.fromJSON(t)}}class l extends a.i{fromJSON(t){return t&&(this.id=t.id,this.name=t.name,this.domain=t.domain,this.active=t.active,this.provider=t.provider,this.syncUserAttributes=t.sync_user_attributes,this.allowSubdomains=t.allow_subdomains,this.allowIdpInitiated=t.allow_idp_initiated,this.disableAdditionalIdentifications=t.disable_additional_identifications,this.createdAt=(0,r.V)(t.created_at),this.updatedAt=(0,r.V)(t.updated_at)),this}__internal_toSnapshot(){return{object:"saml_account_connection",id:this.id,name:this.name,domain:this.domain,active:this.active,provider:this.provider,sync_user_attributes:this.syncUserAttributes,allow_subdomains:this.allowSubdomains,allow_idp_initiated:this.allowIdpInitiated,disable_additional_identifications:this.disableAdditionalIdentifications,created_at:this.createdAt.getTime(),updated_at:this.updatedAt.getTime()}}constructor(t){super(),(0,n._)(this,"id",void 0),(0,n._)(this,"name",void 0),(0,n._)(this,"domain",void 0),(0,n._)(this,"active",void 0),(0,n._)(this,"provider",void 0),(0,n._)(this,"syncUserAttributes",void 0),(0,n._)(this,"allowSubdomains",void 0),(0,n._)(this,"allowIdpInitiated",void 0),(0,n._)(this,"disableAdditionalIdentifications",void 0),(0,n._)(this,"createdAt",void 0),(0,n._)(this,"updatedAt",void 0),this.fromJSON(t)}}},67045:function(t,e,i){"use strict";i.d(e,{z:()=>S});var n=i(34056),r=i(12499),a=i(17970),s=i(91412),o=i(17431);i(65223),i(92037),i(50725);var l=i(71353);i(64310);var c=i(73531),u=i(60153),h=i(32208),d=i(46630),p=i(93367),f=i(24152),_=i(50005),m=i(7292),v=i(73139),g=i(65027);class y extends v.i{fromJSON(t){return t&&(this.id=t.id,this.status=t.status,this.session=new v.z_(t.session),this.level=t.level,this.supportedFirstFactors=(0,g.aw)(t.supported_first_factors),this.supportedSecondFactors=(0,g.aw)(t.supported_second_factors),this.firstFactorVerification=new v.GX(t.first_factor_verification),this.secondFactorVerification=new v.GX(t.second_factor_verification)),this}constructor(t=null){super(),(0,o._)(this,"status",void 0),(0,o._)(this,"level",void 0),(0,o._)(this,"session",void 0),(0,o._)(this,"supportedFirstFactors",[]),(0,o._)(this,"supportedSecondFactors",[]),(0,o._)(this,"firstFactorVerification",new v.GX(null)),(0,o._)(this,"secondFactorVerification",new v.GX(null)),this.fromJSON(t)}}var w=new WeakMap,b=new WeakSet;class S extends v.i{static isSessionResource(t){return!!t&&t instanceof S}fromJSON(t){return t&&(this.id=t.id,this.status=t.status,this.expireAt=(0,d.V)(t.expire_at),this.abandonAt=(0,d.V)(t.abandon_at),this.factorVerificationAge=t.factor_verification_age,this.lastActiveAt=(0,d.V)(t.last_active_at||void 0),this.lastActiveOrganizationId=t.last_active_organization_id,this.actor=t.actor||null,this.createdAt=(0,d.V)(t.created_at),this.updatedAt=(0,d.V)(t.updated_at),this.user=new v.n5(t.user),this.tasks=t.tasks||null,t.public_user_data&&(this.publicUserData=new v.VO(t.public_user_data)),this.lastActiveToken=t.last_active_token?new v.WU(t.last_active_token):null),this}__internal_toSnapshot(){var t,e;return{object:"session",id:this.id,status:this.status,expire_at:this.expireAt.getTime(),abandon_at:this.abandonAt.getTime(),factor_verification_age:this.factorVerificationAge,last_active_at:this.lastActiveAt.getTime(),last_active_organization_id:this.lastActiveOrganizationId,actor:this.actor,tasks:this.tasks,user:(null==(t=this.user)?void 0:t.__internal_toSnapshot())||null,public_user_data:this.publicUserData.__internal_toSnapshot(),last_active_token:(null==(e=this.lastActiveToken)?void 0:e.__internal_toSnapshot())||null,created_at:this.createdAt.getTime(),updated_at:this.updatedAt.getTime()}}async _getToken(t){if(!this.user)return null;let{leewayInSeconds:e,template:i,skipCache:n=!1}=t||{},r=void 0===(null==t?void 0:t.organizationId)?this.lastActiveOrganizationId:null==t?void 0:t.organizationId;if(!i&&Number(e)>=60)throw Error("Leeway can not exceed the token lifespan (60 seconds)");let s=(0,a._)(this,b,k).call(this,i,r),o=n?void 0:m.O.get({tokenId:s},e),l=!i&&r===this.lastActiveOrganizationId;if(o){let t=await o.tokenResolver;return l&&_.Y.emit(_.U.TokenUpdate,{token:t}),t.getRawString()||null}let c=i?"".concat(this.path(),"/tokens/").concat(i):"".concat(this.path(),"/tokens"),u=i?{}:{organizationId:r},h=v.WU.create(c,u);return m.O.set({tokenId:s,tokenResolver:h}),h.then(t=>(l&&(_.Y.emit(_.U.TokenUpdate,{token:t}),t.jwt&&(this.lastActiveToken=t,_.Y.emit(_.U.SessionTokenResolved,null))),t.getRawString()||null))}get currentTask(){var t;let[e]=null!=(t=this.tasks)?t:[];return e}constructor(t){super(),(0,s._)(this,b),(0,o._)(this,"pathRoot","/client/sessions"),(0,o._)(this,"id",void 0),(0,o._)(this,"status",void 0),(0,o._)(this,"lastActiveAt",void 0),(0,o._)(this,"lastActiveToken",void 0),(0,o._)(this,"lastActiveOrganizationId",void 0),(0,o._)(this,"actor",void 0),(0,o._)(this,"user",void 0),(0,o._)(this,"publicUserData",void 0),(0,o._)(this,"factorVerificationAge",null),(0,o._)(this,"tasks",null),(0,o._)(this,"expireAt",void 0),(0,o._)(this,"abandonAt",void 0),(0,o._)(this,"createdAt",void 0),(0,o._)(this,"updatedAt",void 0),(0,o._)(this,"end",()=>(m.O.clear(),this._basePost({action:"end"}))),(0,o._)(this,"remove",()=>(m.O.clear(),this._basePost({action:"remove"}))),(0,o._)(this,"touch",()=>this._basePost({action:"touch",body:{active_organization_id:this.lastActiveOrganizationId}}).then(t=>(t.lastActiveToken&&_.Y.emit(_.U.TokenUpdate,{token:t.lastActiveToken}),t))),(0,o._)(this,"clearCache",()=>m.O.clear()),(0,o._)(this,"getToken",async t=>(0,u.X)(()=>this._getToken(t),{factor:1.55,initialDelay:3e3,maxDelayBetweenRetries:5e4,jitter:!1,shouldRetry:(t,e)=>!(0,c.ix)(t)&&e<=8})),(0,o._)(this,"checkAuthorization",t=>{var e,i,n,r,a,s;let o=((null==(e=this.user)?void 0:e.organizationMemberships)||[]).find(t=>t.organization.id===this.lastActiveOrganizationId);return(0,l.QL)({userId:null==(i=this.user)?void 0:i.id,factorVerificationAge:this.factorVerificationAge,orgId:null==o?void 0:o.id,orgRole:null==o?void 0:o.role,orgPermissions:null==o?void 0:o.permissions,features:(null==(r=this.lastActiveToken)||null==(n=r.jwt)?void 0:n.claims.fea)||"",plans:(null==(s=this.lastActiveToken)||null==(a=s.jwt)?void 0:a.claims.pla)||""})(t)}),(0,r._)(this,w,{writable:!0,value:t=>{t&&m.O.set({tokenId:(0,a._)(this,b,k).call(this),tokenResolver:Promise.resolve(t)})}}),(0,o._)(this,"startVerification",async t=>{var e;let{level:i}=t;return new y(null==(e=await v.i._fetch({method:"POST",path:"/client/sessions/".concat(this.id,"/verify"),body:{level:i}}))?void 0:e.response)}),(0,o._)(this,"prepareFirstFactorVerification",async t=>{var e;let i;switch(t.strategy){case"email_code":i={emailAddressId:t.emailAddressId};break;case"phone_code":i={phoneNumberId:t.phoneNumberId,default:t.default};break;case"passkey":i={};break;default:(0,f.Rz)("Session.prepareFirstFactorVerification",t.strategy)}return new y(null==(e=await v.i._fetch({method:"POST",path:"/client/sessions/".concat(this.id,"/verify/prepare_first_factor"),body:{...i,strategy:t.strategy}}))?void 0:e.response)}),(0,o._)(this,"attemptFirstFactorVerification",async t=>{var e;let i;return i="passkey"===t.strategy?{publicKeyCredential:JSON.stringify((0,p.zQ)(t.publicKeyCredential))}:{...t},new y(null==(e=await v.i._fetch({method:"POST",path:"/client/sessions/".concat(this.id,"/verify/attempt_first_factor"),body:{...i,strategy:t.strategy}}))?void 0:e.response)}),(0,o._)(this,"verifyWithPasskey",async()=>{let{nonce:t=null}=(await this.prepareFirstFactorVerification({strategy:"passkey"})).firstFactorVerification,e=S.clerk.__internal_isWebAuthnSupported||h.iW,i=S.clerk.__internal_getPublicCredentials||p.t1;if(!e())throw new c.RK("Passkeys are not supported",{code:"passkey_not_supported"});let n=t?(0,p.N7)(JSON.parse(t)):null;n||(0,f.$C)("get");let{publicKeyCredential:r,error:a}=await i({publicKeyOptions:n,conditionalUI:!1});if(!r)throw a;return this.attemptFirstFactorVerification({strategy:"passkey",publicKeyCredential:r})}),(0,o._)(this,"prepareSecondFactorVerification",async t=>{var e;return new y(null==(e=await v.i._fetch({method:"POST",path:"/client/sessions/".concat(this.id,"/verify/prepare_second_factor"),body:t}))?void 0:e.response)}),(0,o._)(this,"attemptSecondFactorVerification",async t=>{var e;return new y(null==(e=await v.i._fetch({method:"POST",path:"/client/sessions/".concat(this.id,"/verify/attempt_second_factor"),body:t}))?void 0:e.response)}),this.fromJSON(t),(0,n._)(this,w).call(this,this.lastActiveToken)}}function k(t,e){let i=void 0===e?this.lastActiveOrganizationId:e;return[this.id,t,i,this.updatedAt.getTime()].filter(Boolean).join("-")}},28076:function(t,e,i){"use strict";i.d(e,{A:()=>s});var n=i(17431),r=i(46630),a=i(73139);class s extends a.i{static retrieve(){var t;let e=null==(t=a.i.clerk.session)?void 0:t.id;return this.clerk.getFapiClient().request({method:"GET",path:"/me/sessions/active",sessionId:e}).then(t=>t.payload.map(t=>new s(t,"/me/sessions"))).catch(()=>[])}revoke(){return this._basePost({action:"revoke",body:{}})}fromJSON(t){var e;let i;return t?(this.id=t.id,this.status=t.status,this.expireAt=(0,r.V)(t.expire_at),this.abandonAt=(0,r.V)(t.abandon_at),this.lastActiveAt=(0,r.V)(t.last_active_at||void 0),this.latestActivity={id:(i=null!=(e=t.latest_activity)?e:{}).id,deviceType:i.device_type,browserName:i.browser_name,browserVersion:i.browser_version,country:i.country,city:i.city,isMobile:i.is_mobile,ipAddress:i.ip_address},this.actor=t.actor,this):this}constructor(t,e){super(),(0,n._)(this,"pathRoot",""),(0,n._)(this,"id",void 0),(0,n._)(this,"status",void 0),(0,n._)(this,"abandonAt",void 0),(0,n._)(this,"expireAt",void 0),(0,n._)(this,"lastActiveAt",void 0),(0,n._)(this,"latestActivity",void 0),(0,n._)(this,"actor",void 0),this.pathRoot=e,this.fromJSON(t)}}},53898:function(t,e,i){"use strict";i.d(e,{c:()=>f});var n=i(17431);i(50725),i(87945),i(56113);var r=i(73531),a=i(96111),s=i(65027),o=i(32208),l=i(93344),c=i(73837),u=i(93367),h=i(30529),d=i(24152),p=i(73139);class f extends p.i{fromJSON(t){return t&&(this.id=t.id,this.status=t.status,this.supportedIdentifiers=t.supported_identifiers,this.identifier=t.identifier,this.supportedFirstFactors=(0,s.aw)(t.supported_first_factors),this.supportedSecondFactors=(0,s.aw)(t.supported_second_factors),this.firstFactorVerification=new p.GX(t.first_factor_verification),this.secondFactorVerification=new p.GX(t.second_factor_verification),this.createdSessionId=t.created_session_id,this.userData=new p.mt(t.user_data)),this}__internal_toSnapshot(){return{object:"sign_in",id:this.id||"",status:this.status||null,supported_identifiers:this.supportedIdentifiers,supported_first_factors:(0,s.zb)(this.supportedFirstFactors),supported_second_factors:(0,s.zb)(this.supportedSecondFactors),first_factor_verification:this.firstFactorVerification.__internal_toSnapshot(),second_factor_verification:this.secondFactorVerification.__internal_toSnapshot(),identifier:this.identifier,created_session_id:this.createdSessionId,user_data:this.userData.__internal_toSnapshot()}}constructor(t=null){super(),(0,n._)(this,"pathRoot","/client/sign_ins"),(0,n._)(this,"id",void 0),(0,n._)(this,"status",null),(0,n._)(this,"supportedIdentifiers",[]),(0,n._)(this,"supportedFirstFactors",[]),(0,n._)(this,"supportedSecondFactors",null),(0,n._)(this,"firstFactorVerification",new p.GX(null)),(0,n._)(this,"secondFactorVerification",new p.GX(null)),(0,n._)(this,"identifier",null),(0,n._)(this,"createdSessionId",null),(0,n._)(this,"userData",new p.mt(null)),(0,n._)(this,"create",t=>this._basePost({path:this.pathRoot,body:t})),(0,n._)(this,"resetPassword",t=>this._basePost({body:t,action:"reset_password"})),(0,n._)(this,"prepareFirstFactor",t=>{let e;switch(t.strategy){case"passkey":e={};break;case"email_link":e={emailAddressId:t.emailAddressId,redirectUrl:t.redirectUrl};break;case"email_code":case"reset_password_email_code":e={emailAddressId:t.emailAddressId};break;case"phone_code":e={phoneNumberId:t.phoneNumberId,default:t.default,channel:t.channel};break;case"web3_metamask_signature":case"web3_coinbase_wallet_signature":case"web3_okx_wallet_signature":e={web3WalletId:t.web3WalletId};break;case"reset_password_phone_code":e={phoneNumberId:t.phoneNumberId};break;case"saml":e={redirectUrl:t.redirectUrl,actionCompleteRedirectUrl:t.actionCompleteRedirectUrl};break;case"enterprise_sso":e={redirectUrl:t.redirectUrl,actionCompleteRedirectUrl:t.actionCompleteRedirectUrl,oidcPrompt:t.oidcPrompt};break;default:(0,d.Rz)("SignIn.prepareFirstFactor",t.strategy)}return this._basePost({body:{...e,strategy:t.strategy},action:"prepare_first_factor"})}),(0,n._)(this,"attemptFirstFactor",t=>{let e;return e="passkey"===t.strategy?{publicKeyCredential:JSON.stringify((0,u.zQ)(t.publicKeyCredential))}:{...t},this._basePost({body:{...e,strategy:t.strategy},action:"attempt_first_factor"})}),(0,n._)(this,"createEmailLinkFlow",()=>{let{run:t,stop:e}=(0,a.W)();return{startEmailLinkFlow:async i=>{let{emailAddressId:n,redirectUrl:r}=i;return this.id||(0,d.C)("SignIn"),await this.prepareFirstFactor({strategy:"email_link",emailAddressId:n,redirectUrl:r}),new Promise((i,n)=>{t(()=>this.reload().then(t=>{let n=t.firstFactorVerification.status;("verified"===n||"expired"===n)&&(e(),i(t))}).catch(t=>{e(),n(t)}))})},cancelEmailLinkFlow:e}}),(0,n._)(this,"prepareSecondFactor",t=>this._basePost({body:t,action:"prepare_second_factor"})),(0,n._)(this,"attemptSecondFactor",t=>this._basePost({body:t,action:"attempt_second_factor"})),(0,n._)(this,"authenticateWithRedirectOrPopup",async(t,e)=>{let{strategy:i,redirectUrl:n,redirectUrlComplete:r,identifier:a,oidcPrompt:s,continueSignIn:o}=t||{},c=f.clerk.buildUrlWithAuth(n),u=f.clerk.__internal_hasAfterAuthFlows?(0,l.KV)({base:c,search:"?redirect_url=".concat(r)}).toString():r;this.id&&o||await this.create({strategy:i,identifier:a,redirectUrl:c,actionCompleteRedirectUrl:u}),("saml"===i||"enterprise_sso"===i)&&await this.prepareFirstFactor({strategy:i,redirectUrl:f.clerk.buildUrlWithAuth(n),