@clerk/clerk-js
Version:
Clerk JS library
18 lines (15 loc) • 292 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var r in i)("object"==typeof exports?exports:e)[r]=i[r]}}(globalThis,()=>(()=>{var e,t,i,r={7791(e,t,i){"use strict";let r,n,s,a,o,l,c,d,h,u,p,f,_;try{let e=new URL(document.currentScript.src),t=new URL(e.href.split("/").slice(0,-1).join("/")).href;i.p=(t+=t.endsWith("/")?"":"/").replace(/(^.*\/@clerk\/clerk-js@)(.+?)(\/dist.*)/,"$16.25.13$3")}catch{}function m(){return"u">typeof window}let g=RegExp("bot|spider|crawl|APIs-Google|AdsBot|Googlebot|mediapartners|Google Favicon|FeedFetcher|Google-Read-Aloud|DuplexWeb-Google|googleweblight|bing|yandex|baidu|duckduck|yahoo|ecosia|ia_archiver|facebook|instagram|pinterest|reddit|slack|twitter|whatsapp|youtube|semrush","i"),y=/^(Cloudflare-Workers|Node\.js|Deno|Bun)\b/i;function w(){if("u">typeof window&&window.navigator)return window.navigator;let e=globalThis;return"function"==typeof e.WorkerGlobalScope&&e.self instanceof e.WorkerGlobalScope&&e.self.navigator&&!y.test(e.self.navigator.userAgent??"")?e.self.navigator:null}function b(){var e;let t=w();return!!t&&!((e=t?.userAgent)&&g.test(e))&&!t?.webdriver}function v(){let e=w();return!!e&&("boolean"!=typeof e.onLine||!!e.onLine)}function k(){return v()&&b()}let S=(e,t,i,r,n)=>{let{notify:s}=n||{},a=e.get(i);a||(a=[],e.set(i,a)),a.push(r),s&&t.has(i)&&r(t.get(i))},U=(e,t,i)=>(e.get(t)||[]).map(e=>e(i)),I=(e,t,i)=>{let r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},C=()=>{let e=new Map,t=new Map,i=new Map;return{on:(...i)=>S(e,t,...i),prioritizedOn:(...e)=>S(i,t,...e),emit:(r,n)=>{t.set(r,n),U(i,r,n),U(e,r,n)},off:(...t)=>I(e,...t),prioritizedOff:(...e)=>I(i,...e),internal:{retrieveListeners:t=>e.get(t)||[]}}},A="status";function P(e){return function(t){let i=t??this;if(!i)throw TypeError(`${e.kind||e.name} type guard requires an error object`);return!!e.kind&&"object"==typeof i&&null!==i&&"constructor"in i&&i.constructor?.kind===e.kind||i instanceof e}}var T,O,E,x=class e extends Error{static kind="ClerkError";clerkError=!0;code;longMessage;docsUrl;cause;get name(){return this.constructor.name}constructor(t){super(new.target.formatMessage(new.target.kind,t.message,t.code,t.docsUrl),{cause:t.cause}),Object.setPrototypeOf(this,e.prototype),this.code=t.code,this.docsUrl=t.docsUrl,this.longMessage=t.longMessage,this.cause=t.cause}toString(){return`[${this.name}]
Message:${this.message}`}static formatMessage(e,t,i,r){let n="Clerk:",s=RegExp(n.replace(" ","\\s*"),"i");return t=t.replace(s,""),t=`${n} ${t.trim()}
(code="${i}")
`,r&&(t+=`
Docs: ${r}`),t}},R=class e extends x{static kind="ClerkRuntimeError";clerkRuntimeError=!0;constructor(t,i){super({...i,message:t}),Object.setPrototypeOf(this,e.prototype)}};let z=P(R);var M=class{static kind="ClerkAPIError";code;message;longMessage;meta;constructor(e){const t={code:e.code,message:e.message,longMessage:e.long_message,meta:{paramName:e.meta?.param_name,sessionId:e.meta?.session_id,emailAddresses:e.meta?.email_addresses,identifiers:e.meta?.identifiers,zxcvbn:e.meta?.zxcvbn,plan:e.meta?.plan,isPlanUpgradePossible:e.meta?.is_plan_upgrade_possible,seatsQuantityToAdd:e.meta?.seats_quantity_to_add,seatsQuantity:e.meta?.seats_quantity}};this.code=t.code,this.message=t.message,this.longMessage=t.longMessage,this.meta=t.meta}};P(M);var F=class e extends x{static kind="ClerkAPIResponseError";status;clerkTraceId;retryAfter;errors;constructor(t,i){const{data:r,status:n,clerkTraceId:s,retryAfter:a}=i;super({...i,message:t,code:"api_response_error"}),Object.setPrototypeOf(this,e.prototype),this.status=n,this.clerkTraceId=s,this.retryAfter=a,this.errors=(r||[]).map(e=>new M(e))}toString(){let e=`[${this.name}]
Message:${this.message}
Status:${this.status}
Serialized errors: ${this.errors.map(e=>JSON.stringify(e))}`;return this.clerkTraceId&&(e+=`
Clerk Trace ID: ${this.clerkTraceId}`),e}static formatMessage(e,t,i,r){return t}};let N=P(F);var D=class e extends F{static kind="MissingExpiredTokenError";static ERROR_CODE="missing_expired_token";static STATUS=422;static is(t){return N(t)&&t.status===e.STATUS&&t.errors.length>0&&t.errors[0].code===e.ERROR_CODE}},W=class e extends R{static kind="ClerkOfflineError";static ERROR_CODE="clerk_offline";constructor(t){super(t,{code:e.ERROR_CODE}),Object.setPrototypeOf(this,e.prototype)}static is(t){return null!=t&&(t instanceof e||z(t)&&t.code===e.ERROR_CODE)}};let L=Object.freeze({InvalidProxyUrlErrorMessage:"The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})",InvalidPublishableKeyErrorMessage:"The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})",MissingPublishableKeyErrorMessage:"Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.",MissingSecretKeyErrorMessage:"Missing secretKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.",MissingClerkProvider:"{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider"});function $({packageName:e,customMessages:t}){let i=e;function r(e,t){if(!t)return`${i}: ${e}`;let r=e;for(let i of e.matchAll(/{{([a-zA-Z0-9-_]+)}}/g)){let e=(t[i[1]]||"").toString();r=r.replace(`{{${i[1]}}}`,e)}return`${i}: ${r}`}let n={...L,...t};return{setPackageName({packageName:e}){return"string"==typeof e&&(i=e),this},setMessages({customMessages:e}){return Object.assign(n,e||{}),this},throwInvalidPublishableKeyError(e){throw Error(r(n.InvalidPublishableKeyErrorMessage,e))},throwInvalidProxyUrl(e){throw Error(r(n.InvalidProxyUrlErrorMessage,e))},throwMissingPublishableKeyError(){throw Error(r(n.MissingPublishableKeyErrorMessage))},throwMissingSecretKeyError(){throw Error(r(n.MissingSecretKeyErrorMessage))},throwMissingClerkProviderError(e){throw Error(r(n.MissingClerkProvider,e))},throw(e){throw Error(r(e))}}}var j=class e extends Error{code;constructor(t){super(t),this.code=t,this.name="EmailLinkError",Object.setPrototypeOf(this,e.prototype)}},B=class extends R{code;constructor(e,t){super(e,t),this.code=t.code}};function J(e){return["captcha_invalid","captcha_not_enabled","captcha_missing_token"].includes(e.errors[0].code)}function K(e){let t=e?.status;return!!t&&t>=400&&t<500}let V=new Set(["user_banned","user_deactivated"]);function q(e){let t=e?.status,i=Array.isArray(e?.errors)&&e.errors.some(e=>V.has(e?.code));return 401===t||422===t||403===t&&i}function H(e){for(let[t,i]of Object.entries({isClerkAPIResponseError:N,isClerkRuntimeError:z}))Object.assign(e,{[t]:i});return e}let G=(e,t)=>!!(e.isSignedIn&&t?.authConfig.singleSessionMode),Q=(e,t)=>!t?.commerceSettings.billing.user.enabled&&!t?.commerceSettings.billing.organization.enabled,Y=(e,t)=>!t?.apiKeysSettings?.user_api_keys_enabled,X=(e,t)=>!t?.apiKeysSettings?.orgs_api_keys_enabled,Z="__clerk_synced",ee="false",et="true",ei="suffixed_cookies",er="__clerk_satellite_url",en="external_account_exists",es="clerk-captcha",ea="clerk-invisible-captcha";function eo(e){return e?e.replace(/([-_][a-z])/g,e=>e.toUpperCase().replace(/-|_/,"")):""}function el(e){return e?e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`):""}let ec=e=>{let t=i=>{if(!i)return i;if(Array.isArray(i))return i.map(e=>"object"==typeof e||Array.isArray(e)?t(e):e);let r={...i};for(let i of Object.keys(r)){let n=e(i.toString());n!==i&&(r[n]=r[i],delete r[i]),"object"==typeof r[n]&&(r[n]=t(r[n]))}return r};return t},ed=ec(el),eh=ec(eo);function eu(e){if("boolean"==typeof e)return e;if(null==e)return!1;if("string"==typeof e){if("true"===e.toLowerCase())return!0;if("false"===e.toLowerCase())return!1}let t=parseInt(e,10);return!isNaN(t)&&t>0}let ep=(e,t)=>{let i={};for(let r in e)i[r]=t(e[r],r);return i},ef=(e,t)=>{let i={};for(let r in e)e[r]&&t(e[r])&&(i[r]=e[r]);return i},e_=[".lcl.dev",".lclstage.dev",".lclclerk.com"],em=[".accounts.dev",".accountsstage.dev",".accounts.lclclerk.com"],eg=[".lcl.dev",".stg.dev",".lclstage.dev",".stgstage.dev",".dev.lclclerk.com",".stg.lclclerk.com",".accounts.lclclerk.com","accountsstage.dev","accounts.dev"],ey=e=>"u">typeof atob&&"function"==typeof atob?atob(e):void 0!==globalThis.Buffer?globalThis.Buffer.from(e,"base64").toString():e,ew="pk_live_";function eb(e){if(!e.endsWith("$"))return!1;let t=e.slice(0,-1);return!t.includes("$")&&t.includes(".")}function ev(e,t={}){let i;if(!(e=e||"")||!ek(e)){if(t.fatal&&!e)throw Error("Publishable key is missing. Ensure that your publishable key is correctly configured. Double-check your environment configuration for your keys, or access them here: https://dashboard.clerk.com/last-active?path=api-keys");if(t.fatal&&!ek(e))throw Error("Publishable key not valid.");return null}let r=e.startsWith(ew)?"production":"development";try{i=ey(e.split("_")[2])}catch{if(t.fatal)throw Error("Publishable key not valid: Failed to decode key.");return null}if(!eb(i)){if(t.fatal)throw Error("Publishable key not valid: Decoded key has invalid format.");return null}let n=i.slice(0,-1);return t.proxyUrl?n=t.proxyUrl:"development"!==r&&t.domain&&t.isSatellite&&(n=`clerk.${t.domain}`),{instanceType:r,frontendApi:n}}function ek(e=""){try{if(!(e.startsWith(ew)||e.startsWith("pk_test_")))return!1;let t=e.split("_");if(3!==t.length)return!1;let i=t[2];if(!i)return!1;return eb(ey(i))}catch{return!1}}async function eS(e,t=globalThis.crypto.subtle){var i;let r=new TextEncoder().encode(e);return(i=String.fromCharCode(...new Uint8Array(await t.digest("sha-1",r))),"u">typeof btoa&&"function"==typeof btoa?btoa(i):void 0!==globalThis.Buffer?globalThis.Buffer.from(i).toString("base64"):i).replace(/\+/gi,"-").replace(/\//gi,"_").substring(0,8)}let eU=(e,t)=>`${e}_${t}`;var eI=i(547);function eC(e=""){return(e||"").replace(/^.+:\/\//,"")}let eA=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,eP=new Set,eT=e=>{eP.has(e)||(eP.add(e),console.warn(e))},eO=RegExp("/{1,}","g"),eE=(e,t={})=>{if(null==e||!e||"object"!=typeof e)return"";let i=new URLSearchParams;return Object.keys(e).forEach(r=>{let n=t.keyEncoder?t.keyEncoder(r):r,s=e[r];if(Array.isArray(s))s.forEach(e=>void 0!==e&&i.append(n,e||""));else{if(void 0===s)return;"object"==typeof s&&null!==s?i.append(n,JSON.stringify(s)):i.append(n,String(s??""))}}),i.toString()},ex="http://clerk-dummy",eR=["javascript:"],{isDevOrStagingUrl:ez}=(a=new Map,{isDevOrStagingUrl:e=>{if(!e)return!1;let t="string"==typeof e?e:e.hostname,i=a.get(t);return void 0===i&&(i=eg.some(e=>t.endsWith(e)),a.set(t,i)),i}}),eM=new Map;function eF(e){return e.replace("clerk.","")}function eN(e,t={}){let{base:i,hashPath:r,hashSearch:n,searchParams:s,hashSearchParams:a,...o}=e,l=new URL(i||"","u">typeof window&&window.location?window.location.href:"http://react-native-fake-base-url");if(s instanceof URLSearchParams&&s.forEach((e,t)=>{null!=e&&l.searchParams.set(el(t),e)}),Object.assign(l,o),r||n||a){var c;let e,t=new URL(ex+l.hash.substring(1));for(let[i,s]of(c=t.pathname,t.pathname=[c,r||""].filter(e=>e).join("/").replace(eO,"/"),Object.entries((e={},new URLSearchParams(n||"").forEach((t,i)=>{if(i in e){let r=e[i];Array.isArray(r)?r.push(t):e[i]=[r,t]}else e[i]=t}),e))))t.searchParams.append(i,s);if(a)for(let e of Array.isArray(a)?a:[a])(e instanceof URLSearchParams||"object"==typeof e)&&new URLSearchParams(e).forEach((e,i)=>{null!=e&&t.searchParams.set(el(i),e)});let i=t.href.replace(ex,"");"/"!==i&&(l.hash=i)}let{stringify:d,skipOrigin:h}=t;return d?h?l.href.replace(l.origin,""):l.href:l}function eD(e){return void 0===window.location&&"string"==typeof e?e:(e=new URL(e.toString(),window.location.origin)).href.replace(e.origin,"")}let eW=e=>(e||"").replace(/\/+$/,"");function eL(e,t){try{return new URL(e)}catch{return new URL(e,t)}}let e$=[/\0/,/^\/\//,/[\x00-\x1F]/],ej=["/oauth/authorize"],eB=["/v1/verify","/v1/tickets/accept","/oauth/authorize-with-immediate-redirect","/oauth/end_session"];var eJ=class e{static keys=["signInForceRedirectUrl","signInFallbackRedirectUrl","signUpForceRedirectUrl","signUpFallbackRedirectUrl","redirectUrl"];static preserved=["redirectUrl"];options;fromOptions;fromProps;fromSearchParams;mode;constructor(e,t={},i={},r){this.options=e,this.fromOptions=this.#e(e||{}),this.fromProps=this.#e(t||{}),this.fromSearchParams=this.#t(i||{}),this.mode=r}getAfterSignInUrl(){return this.#i("signIn")}getAfterSignUpUrl(){return this.#i("signUp")}getPreservedSearchParams(){return this.#r(this.#n())}toSearchParams(){return this.#r(this.#s())}#r(e){return new URLSearchParams(Object.entries(Object.fromEntries(Object.entries(e).map(([e,t])=>[el(e),t]))).reduce((e,[t,i])=>(null!=i&&(e[t]=i),e),{}))}#n(){return Object.fromEntries(Object.entries({...this.fromSearchParams}).filter(([t])=>e.preserved.includes(t)))}#s(){let e=this.fromSearchParams.signUpForceRedirectUrl||this.fromProps.signUpForceRedirectUrl||this.fromOptions.signUpForceRedirectUrl,t=this.fromSearchParams.signUpFallbackRedirectUrl||this.fromProps.signUpFallbackRedirectUrl||this.fromOptions.signUpFallbackRedirectUrl,i=this.fromSearchParams.signInForceRedirectUrl||this.fromProps.signInForceRedirectUrl||this.fromOptions.signInForceRedirectUrl,r={signUpForceRedirectUrl:e,signUpFallbackRedirectUrl:t,signInFallbackRedirectUrl:this.fromSearchParams.signInFallbackRedirectUrl||this.fromProps.signInFallbackRedirectUrl||this.fromOptions.signInFallbackRedirectUrl,signInForceRedirectUrl:i,redirectUrl:this.fromSearchParams.redirectUrl||this.fromProps.redirectUrl};return e&&delete r.signUpFallbackRedirectUrl,i&&delete r.signInFallbackRedirectUrl,r}#i(e){let t,i=`${e}ForceRedirectUrl`,r=`${e}FallbackRedirectUrl`;return(t=this.fromSearchParams[i]||this.fromProps[i]||this.fromOptions[i],t||=this.fromSearchParams.redirectUrl,(t||=this.fromSearchParams[r]||this.fromProps[r]||this.fromOptions[r])||"modal"!==this.mode)?t||"/":window.location.href}#e(t){let i={};return e.keys.forEach(e=>{i[e]=t[e]}),ep(this.#a(this.#o(ef(i,Boolean))),e=>e.toString())}#t(t){let i={};return e.keys.forEach(e=>{t instanceof URLSearchParams?i[e]=t.get(el(e)):i[e]=t[el(e)]}),ep(this.#a(this.#o(ef(i,Boolean))),e=>e.toString())}#o(e){return ep(e,e=>eL(e,window.location.origin))}#a=e=>{let t,i;return ef(e,(t=this.options?.allowedRedirectOrigins,i=window.location.origin,e=>{let r=e;if("string"==typeof r&&(r=eL(r,i)),!t)return!0;let n=i===r.origin,s=!function(e){if(function(e){if(!function(e){if(!e)return!1;try{return new URL(e),!0}catch{return!1}}(e))return!1;let t=new URL(e).protocol;return eR.some(e=>e===t)}(e))return!0;for(let t of e$)if(t.test(e.pathname))return!0;return!1}(r)&&(n||t.map(e=>"string"==typeof e?(e=>{try{return eI(e)}catch(t){throw Error(`Invalid pattern: ${e}.
Consult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.
${t.message}`)}})(eW(e)):e).some(e=>e.test(eW(r.origin))));return s||eT(`Clerk: Redirect URL ${r} is not on one of the allowedRedirectOrigins, falling back to the default redirect URL.`),s}))}};let eK="__clerk_netlify_cache_bust",eV=["__clerk_status","__clerk_created_session","__clerk_invitation_token","__clerk_ticket","__clerk_modal_state","__clerk_handshake","__clerk_handshake_nonce","__clerk_help",eK,Z,er,ei];function eq(e){return new URL(window.location.href).searchParams.get(e)||null}function eH(e){let t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState(window.history.state,"",t))}function eG(e){let t=new URLSearchParams(window.location.search),i=e||new URLSearchParams;for(let e of eV){let r=t.get(e);r&&i.set(e,r)}return i}let eQ={"choose-organization":"choose-organization","reset-password":"reset-password","setup-mfa":"setup-mfa"},eY=e=>`/tasks/${eQ[e.key]}`;function eX(e,{navigate:t,baseUrl:i}){let r=e.currentTask;if(r){var n;let e;return t((n={base:i},e=eG(),eN({base:n.base,hashPath:eY(r),searchParams:e},{stringify:!0})))}}let eZ=e=>`🔒 Clerk:
${e.trim()}
(This notice only appears in development)`,e0=e=>eZ(`${e} as a function is not supported in this environment. The value will be ignored. Provide an absolute URL instead.`),e1={proxyUrlAsFunctionNotSupported:e0("proxyUrl"),domainAsFunctionNotSupported:e0("domain"),cannotRenderComponentWhenSessionExists:"The <SignUp/> and <SignIn/> components cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the Home URL instead.",cannotRenderSignUpComponentWhenSessionExists:"The <SignUp/> component cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the value set in `afterSignUp` URL instead.",cannotRenderSignUpComponentWhenTaskExists:"The <SignUp/> component cannot render when a user has a pending task, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the task instead.",cannotRenderComponentWhenTaskDoesNotExist:"<TaskChooseOrganization/> cannot render unless a session task is pending. Clerk is redirecting to the value set in `redirectUrlComplete` instead.",cannotRenderSignInComponentWhenSessionExists:"The <SignIn/> component cannot render when a user is already signed in, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the `afterSignIn` URL instead.",cannotRenderSignInComponentWhenTaskExists:"The <SignIn/> component cannot render when a user has a pending task, unless the application allows multiple sessions. Since a user is signed in and this application only allows a single session, Clerk is redirecting to the task instead.",cannotRenderComponentWhenUserDoesNotExist:"<UserProfile/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.",createCannotRenderComponentWhenOrgDoesNotExist:e=>eZ(`<${e}/> cannot render unless an organization is active. Since no organization is currently active, this is no-op.`),cannotRenderAnyOrganizationComponent:e=>eZ(`The <${e}/> cannot be rendered when the feature is turned off. Visit 'dashboard.clerk.com' to enable the feature. Since the feature is turned off, this is no-op.`),cannotRenderAnyBillingComponent:e=>eZ(`The <${e}/> component cannot be rendered when billing is disabled. Visit 'https://dashboard.clerk.com/last-active?path=billing/settings' to follow the necessary steps to enable billing. Since billing is disabled, this is no-op.`),cannotOpenUserProfile:"The UserProfile modal cannot render unless a user is signed in. Since no user is signed in, this is no-op.",cannotOpenCheckout:"The Checkout drawer cannot render unless a user is signed in. Since no user is signed in, this is no-op.",cannotOpenSignInOrSignUp:"The <SignIn/> and <SignUp/> modals are hidden because a user is already signed in and this application is configured for single-session mode. This is expected behavior — no action is needed. To allow rendering while signed in, enable multi-session mode in your Clerk Dashboard.",cannotRenderAPIKeysComponent:"The <APIKeys/> component cannot be rendered when API keys is disabled. Since API keys is disabled, this is no-op.",cannotRenderAPIKeysComponentForOrgWhenUnauthorized:"The <APIKeys/> component cannot be rendered for an organization unless a user has the required permissions. Since the user does not have the necessary permissions, this is no-op.",cannotRenderAPIKeysComponentForUserWhenDisabled:"The <APIKeys/> component cannot be rendered when user API keys are disabled. Since user API keys are disabled, this is no-op.",cannotRenderAPIKeysComponentForOrgWhenDisabled:"The <APIKeys/> component cannot be rendered when organization API keys are disabled. Since organization API keys are disabled, this is no-op.",cannotRenderOAuthConsentComponentWhenUserDoesNotExist:"<OAuthConsent/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.",cannotRenderConfigureSSOComponentWhenUserDoesNotExist:"<ConfigureSSO/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.",cannotRenderConfigureSSOComponentWhenDisabled:"The <ConfigureSSO/> component cannot be rendered when self-serve SSO is disabled. Visit `https://dashboard.clerk.com` to enable the feature. Since self-serve SSO is disabled, this is no-op.",cannotRenderConfigureSSOComponentWhenEmailAddressDisabled:"The <ConfigureSSO/> component cannot be rendered when email addresses are disabled on the instance. Visit `https://dashboard.clerk.com` to enable email addresses. Since email addresses are disabled, this is no-op."};for(let e of Object.keys(e1)){let t=e1[e];"function"!=typeof t&&(e1[e]=eZ(t))}let e3="clerk:beforeunload",e2=["http:","https:","wails:","chrome-extension:"],e4=/^[/\\][/\\]/;function e5(e){return/^http(s)?:\/\//.test(e||"")}function e6(e){return e.startsWith("/")}let e9=[".vercel.app"],e7=["CI","CONTINUOUS_INTEGRATION","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","TRAVIS","BUILDKITE","BITBUCKET_BUILD_NUMBER","APPVEYOR","CODEBUILD_BUILD_ID","TF_BUILD","TEAMCITY_VERSION","JENKINS_URL","HUDSON_URL","BAMBOO_BUILDKEY","CF_PAGES"],e8=Symbol.for("@clerk/shared.telemetryNoticeShown"),te=["Attention: Clerk collects telemetry data from its SDKs when connected to development instances.","The data collected is used to inform Clerk's product roadmap.","To learn more, including how to opt-out from the telemetry program, visit: https://clerk.com/docs/telemetry."];var tt=class{#l;#c=864e5;constructor(e){this.#l=e}isEventThrottled(e){let t=Date.now(),i=this.#d(e),r=this.#l.getItem(i);return!!r&&!(t-r>this.#c)||(this.#l.setItem(i,t),!1)}#d(e){let{sk:t,pk:i,payload:r,...n}=e,s={...r,...n};return JSON.stringify(Object.keys({...r,...n}).sort().map(e=>s[e]))}},ti=class{#h="clerk_telemetry_throttler";getItem(e){return this.#u()[e]}setItem(e,t){try{let i=this.#u();i[e]=t,localStorage.setItem(this.#h,JSON.stringify(i))}catch(e){e instanceof DOMException&&("QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&localStorage.length>0&&localStorage.removeItem(this.#h)}}removeItem(e){try{let t=this.#u();delete t[e],localStorage.setItem(this.#h,JSON.stringify(t))}catch{}}#u(){try{let e=localStorage.getItem(this.#h);if(!e)return{};return JSON.parse(e)}catch{return{}}}static isSupported(){return"u">typeof window&&!!window.localStorage}},tr=class{#l=new Map;#p=1e4;getItem(e){return this.#l.size>this.#p?void this.#l.clear():this.#l.get(e)}setItem(e,t){this.#l.set(e,t)}removeItem(e){this.#l.delete(e)}};let tn=new Set(["error","warn","info","debug","trace"]);var ts=class{#f;#_;#m={};#g=[];#y=null;constructor(e){this.#f={maxBufferSize:e.maxBufferSize??5,samplingRate:e.samplingRate??1,perEventSampling:e.perEventSampling??!0,disabled:e.disabled??!1,debug:e.debug??!1,endpoint:"https://clerk-telemetry.com"},!e.clerkVersion&&"u"<typeof window?this.#m.clerkVersion="":this.#m.clerkVersion=e.clerkVersion??"",this.#m.sdk=e.sdk,this.#m.sdkVersion=e.sdkVersion,this.#m.publishableKey=e.publishableKey??"";const t=ev(e.publishableKey);t&&(this.#m.instanceType=t.instanceType),e.secretKey&&(this.#m.secretKey=e.secretKey.substring(0,16));const i=ti.isSupported()?new ti:new tr;this.#_=new tt(i),function(e={}){if(!e.skip)try{if("u">typeof window||void 0!==globalThis.EdgeRuntime||!("u"<typeof process)&&process.env&&e7.some(e=>eu(process.env[e]))||globalThis[e8])return;if("u">typeof console&&"function"==typeof console.log){for(let e of te)console.log(e);console.log("")}globalThis[e8]=!0}catch{}}({skip:!this.isEnabled})}get isEnabled(){return!("development"!==this.#m.instanceType||this.#f.disabled||"u">typeof process&&process.env&&eu(process.env.CLERK_TELEMETRY_DISABLED)||"u">typeof window&&window?.navigator?.webdriver)}get isDebug(){return this.#f.debug||"u">typeof process&&process.env&&eu(process.env.CLERK_TELEMETRY_DEBUG)}record(e){try{let t=this.#w(e.event,e.payload);if(this.#b(t.event,t),!this.#v(t,e.eventSamplingRate))return;this.#g.push({kind:"event",value:t}),this.#k()}catch(e){console.error("[clerk/telemetry] Error recording telemetry event",e)}}recordLog(e){try{if(!this.#S(e))return;let t="string"==typeof e?.level&&tn.has(e.level),i="string"==typeof e?.message&&e.message.trim().length>0,r=null,n=e?.timestamp;if("number"==typeof n||"string"==typeof n){let e=new Date(n);Number.isNaN(e.getTime())||(r=e)}if(!t||!i||null===r){this.isDebug&&"u">typeof console&&console.warn("[clerk/telemetry] Dropping invalid telemetry log entry",{levelIsValid:t,messageIsValid:i,timestampIsValid:null!==r});return}let s=this.#U(),a={sdk:s.name,sdkv:s.version,cv:this.#m.clerkVersion??"",lvl:e.level,msg:e.message,ts:r.toISOString(),pk:this.#m.publishableKey||null,payload:this.#I(e.context)};this.#g.push({kind:"log",value:a}),this.#k()}catch(e){console.error("[clerk/telemetry] Error recording telemetry log entry",e)}}#v(e,t){return this.isEnabled&&!this.isDebug&&this.#C(e,t)}#S(e){return!0}#C(e,t){let i=Math.random();return!!(i<=this.#f.samplingRate&&(!1===this.#f.perEventSampling||void 0===t||i<=t))&&!this.#_.isEventThrottled(e)}#k(){if("u"<typeof window)return void this.#A();if(this.#g.length>=this.#f.maxBufferSize){this.#y&&("u">typeof cancelIdleCallback?cancelIdleCallback(Number(this.#y)):clearTimeout(Number(this.#y))),this.#A();return}this.#y||("requestIdleCallback"in window?this.#y=requestIdleCallback(()=>{this.#A(),this.#y=null}):this.#y=setTimeout(()=>{this.#A(),this.#y=null},0))}#A(){let e=[...this.#g];if(this.#g=[],this.#y=null,0===e.length)return;let t=e.filter(e=>"event"===e.kind).map(e=>e.value),i=e.filter(e=>"log"===e.kind).map(e=>e.value);t.length>0&&fetch(new URL("/v1/event",this.#f.endpoint),{headers:{"Content-Type":"application/json"},keepalive:!0,method:"POST",body:JSON.stringify({events:t})}).catch(()=>void 0),i.length>0&&fetch(new URL("/v1/logs",this.#f.endpoint),{headers:{"Content-Type":"application/json"},keepalive:!0,method:"POST",body:JSON.stringify({logs:i})}).catch(()=>void 0)}#b(e,t){this.isDebug&&(void 0!==console.groupCollapsed?(console.groupCollapsed("[clerk/telemetry]",e),console.log(t),console.groupEnd()):console.log("[clerk/telemetry]",e,t))}#U(){let e={name:this.#m.sdk,version:this.#m.sdkVersion};if("u">typeof window){let t=window;if(t.Clerk){let i=t.Clerk;if("object"==typeof i&&null!==i&&"constructor"in i&&"function"==typeof i.constructor&&i.constructor.sdkMetadata){let{name:t,version:r}=i.constructor.sdkMetadata;void 0!==t&&(e.name=t),void 0!==r&&(e.version=r)}}}return e}#w(e,t){let i=this.#U();return{event:e,cv:this.#m.clerkVersion??"",it:this.#m.instanceType??"",sdk:i.name,sdkv:i.version,...this.#m.publishableKey?{pk:this.#m.publishableKey}:{},...this.#m.secretKey?{sk:this.#m.secretKey}:{},payload:t}}#I(e){if(null==e||"object"!=typeof e)return null;try{let t=JSON.parse(JSON.stringify(e));if(t&&"object"==typeof t&&!Array.isArray(t))return t;return null}catch{return null}}};let ta="COMPONENT_MOUNTED",to=new Set(["SignIn","SignUp"]);function tl(e){return function(t,i,r){return{event:e,eventSamplingRate:e===ta?to.has(t)?1:.1:.1,payload:{component:t,appearanceProp:!!i?.appearance,theme:!!i?.appearance?.theme,elements:!!i?.appearance?.elements,variables:!!i?.appearance?.variables,...r}}}}function tc(e,t,i){return tl(ta)(e,t,i)}function td(e,t,i){return tl("COMPONENT_OPENED")(e,t,i)}function th(e){return"string"==typeof e?e:"object"==typeof e&&null!==e&&"name"in e&&"string"==typeof e.name?e.name:void 0}var tu=i(6100);let tp=!1,tf=null,t_=!1,tm=[];function tg(e,t,i,r){tp&&(tm.push({level:e,message:t,context:i,source:r,ts:Date.now()}),tm.length>200&&tm.shift())}async function ty(e){try{if(!tp||tf)return;let{getDebugLogger:t}=await i.e(321).then(i.bind(i,9296)),r=await t({logLevel:e?.logLevel,telemetryCollector:e?.telemetryCollector});if(r&&(tf=r)&&0!==tm.length){for(let e of tm){let t={...e.context||{},__preInit:!0,__preInitTs:e.ts};switch(e.level){case"error":tf.error(e.message,t,e.source);break;case"warn":tf.warn(e.message,t,e.source);break;case"info":tf.info(e.message,t,e.source);break;case"debug":tf.debug(e.message,t,e.source)}}tm.length=0}}catch(e){try{console.debug?.("Debug logger initialization failed",e)}catch{}return}}let tw={debug(e,t,i){tf?tf.debug(e,t,i):tg("debug",e,t,i)},error(e,t,i){tf?tf.error(e,t,i):tg("error",e,t,i)},info(e,t,i){tf?tf.info(e,t,i):tg("info",e,t,i)},warn(e,t,i){tf?tf.warn(e,t,i):tg("warn",e,t,i)}},tb={initialDelay:125,maxDelayBetweenRetries:0,factor:2,shouldRetry:(e,t)=>t<5,retryImmediately:!1,jitter:!0},tv=async e=>new Promise(t=>setTimeout(t,e)),tk=(e,t)=>t?e*(1+Math.random()):e,tS=async(e,t={})=>{var i;let r,n=0,{shouldRetry:s,initialDelay:a,maxDelayBetweenRetries:o,factor:l,retryImmediately:c,jitter:d,onBeforeRetry:h}={...tb,...t},u=(i={initialDelay:a,maxDelayBetweenRetries:o,factor:l,jitter:d},r=0,async()=>{let e;await tv((e=tk(e=i.initialDelay*Math.pow(i.factor,r),i.jitter),Math.min(i.maxDelayBetweenRetries||e,e))),r++});for(;;)try{return await e()}catch(e){if(!s(e,++n))throw e;h&&await h(n),c&&1===n?await tv(tk(100,d)):await u()}},tU=async e=>tS(e,{initialDelay:100,shouldRetry:(e,t)=>t<=3,retryImmediately:!0,factor:2});class tI{#P={"@zxcvbn-ts/core":()=>tU(()=>i.e(729).then(i.bind(i,3239))),"@zxcvbn-ts/language-common":()=>tU(()=>i.e(873).then(i.bind(i,9144))),"@base-org/account":()=>tU(()=>Promise.all([i.e(994),i.e(929),i.e(545)]).then(i.bind(i,7003))),"@coinbase/wallet-sdk":()=>tU(()=>Promise.all([i.e(994),i.e(929),i.e(545)]).then(i.bind(i,2172))),"@stripe/stripe-js":()=>tU(()=>i.e(279).then(i.bind(i,7544)))};import(e){return this.#P[e]?this.#P[e]():Promise.resolve(void 0)}}let tC=(e=!1)=>{let t,i;if(!e)return{track:async e=>{await e()},isUnloading:()=>!1};let r=(t=!1,i=()=>t=!0,{startListening:()=>{window.addEventListener("beforeunload",i),window.addEventListener(e3,i)},stopListening:()=>{window.removeEventListener("beforeunload",i),window.removeEventListener(e3,i)},isUnloading:()=>t});return{track:async e=>{r.startListening(),await e(),r.stopListening()},isUnloading:r.isUnloading}};function tA(e){let t=new Date(e||new Date);return t instanceof Date&&!isNaN(t.getTime())?t:new Date}let tP=e=>({amount:e.amount,amountFormatted:e.amount_formatted,currency:e.currency,currencySymbol:e.currency_symbol}),tT=e=>({quantity:e.quantity,feePerBlock:tP(e.fee_per_block),total:tP(e.total)}),tO=e=>e.map(e=>({name:e.name,blockSize:e.block_size,tiers:e.tiers.map(tT)})),tE=e=>({name:e.name,blockSize:e.block_size,tiers:e.tiers.map(e=>({id:e.id,startsAtBlock:e.starts_at_block,endsAfterBlock:e.ends_after_block,feePerBlock:tP(e.fee_per_block)}))}),tx=e=>({proration:e.proration?{amount:tP(e.proration.amount),cycleDaysRemaining:e.proration.cycle_days_remaining,cycleDaysTotal:e.proration.cycle_days_total,cycleRemainingPercent:e.proration.cycle_remaining_percent}:null,payer:e.payer?{remainingBalance:tP(e.payer.remaining_balance),appliedAmount:tP(e.payer.applied_amount)}:null,total:tP(e.total)}),tR=e=>({proration:e.proration?{amount:tP(e.proration.amount),cycleDaysPassed:e.proration.cycle_days_passed,cycleDaysTotal:e.proration.cycle_days_total,cyclePassedPercent:e.proration.cycle_passed_percent}:null,total:tP(e.total)}),tz=e=>({subtotal:tP(e.subtotal),baseFee:tP(e.base_fee),taxTotal:tP(e.tax_total),grandTotal:tP(e.grand_total),perUnitTotals:e.per_unit_totals?tO(e.per_unit_totals):void 0}),tM=e=>({subtotal:tP(e.subtotal),baseFee:e.base_fee?tP(e.base_fee):null,taxTotal:tP(e.tax_total),grandTotal:tP(e.grand_total),totalDueAfterFreeTrial:e.total_due_after_free_trial?tP(e.total_due_after_free_trial):null,credit:e.credit?tP(e.credit):e.credit,credits:e.credits?tx(e.credits):null,discounts:e.discounts?tR(e.discounts):null,pastDue:e.past_due?tP(e.past_due):e.past_due,totalDueNow:e.total_due_now?tP(e.total_due_now):void 0,perUnitTotals:e.per_unit_totals?tO(e.per_unit_totals):void 0,totalsDuePerPeriod:e.totals_due_per_period?tz(e.totals_due_per_period):void 0,totalDuePerPeriod:e.total_due_per_period?tP(e.total_due_per_period):void 0}),tF=e=>({amount:tP(e.amount),date:tA(e.date),perUnitTotals:e.per_unit_totals?tO(e.per_unit_totals):void 0,totals:e.totals?tM(e.totals):void 0});function tN(e,t=""){return e.errors&&!!e.errors.find(e=>e.code===t)}let tD=$({packageName:"@clerk/clerk-js"});function tW(e){return decodeURIComponent(globalThis.atob(e.replace(/_/g,"/").replace(/-/g,"+")).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}function tL(e){let t=(e||"").split("."),[i,r,n]=t;if(3!==t.length||!i||!r||!n)throw Error("JWT could not be decoded");let s=JSON.parse(tW(r)),a={__raw:e};return Object.keys(s).forEach(e=>{a[e]=s[e]}),{encoded:{header:i,payload:r,signature:n},header:JSON.parse(tW(i)),claims:a}}function t$(){if(!m())return null;try{let e=navigator?.language;if(!e||"string"!=typeof e||""===e.trim())return null;return e}catch{return null}}function tj(){return void 0!==globalThis.document}function tB(){if(!function(){if(!tj())return!1;try{return window.self!==window.top}catch{return!0}}())return!1;try{return window.top?.location.href,!1}catch{return!0}}var tJ=class e{#T=[];#O={metamask:"MetaMask",okx_wallet:"OKX Wallet"};static #E=null;constructor(){if("u"<typeof window)return;window.addEventListener("eip6963:announceProvider",this.#x),window.dispatchEvent(new Event("eip6963:requestProvider"))}static getInstance(){return e.#E||(e.#E=new e),e.#E}get=e=>{let t=this.#T.find(t=>t.info.name===this.#O[e])?.provider;return void 0!==t?t:window.ethereum};#x=e=>{this.#T.some(t=>t.info.uuid===e.detail.info.uuid)||this.#T.push(e.detail)}},tK=class e{#R=void 0;#z=!1;static #E=null;async #M(){if(this.#z)return;this.#z=!0;let e=await i.e(494).then(i.bind(i,1629)).then(e=>e.getWallets());this.#R=e.get(),e.on("register",()=>{this.#R=e.get()}),e.on("unregister",()=>{this.#R=e.get()})}#F(e){return e.chains?.some(e=>e.startsWith("solana:"))??!1}#N(e){return"solana:signMessage"in e.features}static getInstance(){return e.#E||(e.#E=new e),e.#E}get=async e=>{await this.#M();let t=(this.#R||[]).find(t=>t.name===e&&this.#F(t)&&this.#N(t));if(t&&this.#F(t))return t;if("u"<typeof window)return;let i=window.solana;if(i&&"function"==typeof i.connect&&"function"==typeof i.signMessage)return i}};let tV=()=>(function(e){let t=$({packageName:"@clerk/shared"});async function i(e){let{provider:t,walletName:i}=e,r=await f(t,i);if(!r)return"";if("solana"===t){let e=await r.features["standard:connect"].connect();return e&&e.accounts[0].address||""}let n=await r.request({method:"eth_requestAccounts"});return n&&n[0]||""}let r=async e=>{let{identifier:t,nonce:i,provider:r,walletName:n=""}=e,s=await f(r,n);if(!s)return"";if("solana"===r)try{let e=s.accounts.find(e=>e.address===t);if(!e)return console.warn(`Wallet account with address ${t} not found`),"";let r=await s.features["solana:signMessage"]?.signMessage({account:e,message:new TextEncoder().encode(i)});return r?.[0]?.signature?btoa(String.fromCharCode(...r[0].signature)):""}catch(e){if(e instanceof Error&&e.message.includes("User rejected the request."))throw new R("Web3 signature request was rejected by the user.",{code:"web3_signature_request_rejected"});throw new R("An error occurred while generating the Solana signature.",{code:"web3_solana_signature_generation_failed",cause:e instanceof Error?e:void 0})}return await s.request({method:"personal_sign",params:[`0x${i.split("").map(e=>e.charCodeAt(0).toString(16).padStart(2,"0")).join("")}`,t]})};async function n(){return await i({provider:"metamask"})}async function s(){return await i({provider:"coinbase_wallet"})}async function a(){return await i({provider:"okx_wallet"})}async function o(){return await i({provider:"base"})}async function l(e){return await i({provider:"solana",walletName:e})}async function c(e){return await r({...e,provider:"metamask"})}async function d(e){return await r({...e,provider:"coinbase_wallet"})}async function h(e){return await r({...e,provider:"okx_wallet"})}async function u(e){return await r({...e,provider:"base"})}async function p(e){return await r({...e,provider:"solana"})}async function f(i,r){if("coinbase_wallet"===i){let t=await e.import("@coinbase/wallet-sdk");return t?t.createCoinbaseWalletSDK({appName:"u">typeof window&&window.Clerk?.__internal_environment?.displayConfig?.applicationName||"u">typeof document&&document.title||"Web3 Application",preference:{options:"all"}}).getProvider():null}if("base"===i)try{let t=await e.import("@base-org/account");if(!t)return null;return t.createBaseAccountSDK({appName:"u">typeof window&&window.Clerk?.__internal_environment?.displayConfig?.applicationName||"u">typeof document&&document.title||"Web3 Application"}).getProvider()}catch{return null}return"solana"===i?r&&0!==r.length?await tK.getInstance().get(r):void t.throw("Wallet name must be provided to get Solana wallet provider"):tJ.getInstance().get(i)}return{getWeb3Identifier:i,generateWeb3Signature:r,getMetamaskIdentifier:n,getCoinbaseWalletIdentifier:s,getOKXWalletIdentifier:a,getBaseIdentifier:o,getSolanaIdentifier:l,generateSignatureWithMetamask:c,generateSignatureWithCoinbaseWallet:d,generateSignatureWithOKXWallet:h,generateSignatureWithBase:u,generateSignatureWithSolana:p}})(new tI),tq="environment",tH=JSON.stringify,tG=JSON.parse;class tQ{static _key(e){return`__clerk_${e}`}static isExpired(e){return!!e.exp&&Date.now()>e.exp}static setItem(e,t,i){try{let r={value:t,...i&&{exp:Date.now()+i}};window.localStorage.setItem(this._key(e),tH(r))}catch{}}static getItem(e,t){try{let i=window.localStorage.getItem(this._key(e));if(!i)return t;let r=tG(i);if(!r)return t;if(this.isExpired(r))return this.removeItem(e),t;return r?.value??t}catch{return t}}static removeItem(e){try{window.localStorage.removeItem(this._key(e))}catch{}}}let tY="ClerkJS:";function tX(e=""){throw Error(`${tY} Something went wrong initializing Clerk in development mode.${e&&` ${e}`}`)}function tZ(e){throw Error(`${tY} Something went wrong initializing Clerk during the ${e} flow. Please contact support.`)}function t0(e){throw Error(`${tY} You need to start a ${e} flow by calling ${e}.create() first.`)}function t1(e,t){throw Error(`${tY} Strategy "${t}" is not a valid strategy for ${e}.`)}function t3(e){throw Error(`${tY} You need to start a ${e} flow by calling ${e}.create({ identifier: 'your web3 wallet address' }) first`)}function t2(e=""){throw Error(`${tY} Missing '${e}' option`)}function t4(e,t){throw Error(`${tY} Response: ${e||0} not supported yet.
For more information contact us at ${t}`)}function t5(e){throw Error(`${tY} Calling ${e}.reload is not currently supported. Please contact support.`)}function t6(e){throw Error(`${tY} Missing publicKey. When calling 'navigator.credentials.${e}()' it is required to pass a publicKey object.`)}async function t9(e="",t){let{async:i,defer:r,beforeLoad:n,crossOrigin:s,nonce:a}=t||{};return tS(()=>new Promise((t,o)=>{e||o(Error("loadScript cannot be called without a src")),document&&document.body||o(Error("loadScript cannot be called when document does not exist"));let l=document.createElement("script");s&&l.setAttribute("crossorigin",s),l.async=i||!1,l.defer=r||!1,l.addEventListener("load",()=>{l.remove(),t(l)}),l.addEventListener("error",t=>{l.remove(),o(t.error??Error(`failed to load script: ${e}`))}),l.src=e,a&&(l.nonce=a),n?.(l),document.body.appendChild(l)}),{shouldRetry:(e,t)=>t<=5})}async function t7(e){return window.turnstile||await t8(e).catch(()=>{throw{captchaError:"captcha_script_failed_to_load"}}),window.turnstile}async function t8(e){try{return await t9("https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",{defer:!0,nonce:e})}catch(e){throw console.warn("Clerk: Failed to load the CAPTCHA script from Cloudflare. If you see a CSP error in your browser, please add the necessary CSP rules to your app. Visit https://clerk.com/docs/security/clerk-csp for more information."),e}}function ie(e){try{let t=e.getAttribute("data-cl-theme")||void 0,i=e.getAttribute("data-cl-language")||void 0,r=e.getAttribute("data-cl-size")||void 0;return{theme:t,language:i,size:r}}catch{return{theme:void 0,language:void 0,size:void 0}}}let it=async e=>{let t,i,r,n,{siteKey:s,widgetType:a,invisibleSiteKey:o,nonce:l}=e,{modalContainerQuerySelector:c,modalWrapperQuerySelector:d,closeModal:h,openModal:u}=e,p=await t7(l),f=[],_="",m="",g=s,y=0,w=null,b="invisible";if(c&&d){w=a,n=c,b="modal";try{await u?.()}catch{throw{captchaError:"modal_component_not_ready"}}let e=await new Promise(e=>{if(document.querySelector(c))return e(document.querySelector(c));let t=new MutationObserver(()=>{document.querySelector(c)&&(t.disconnect(),e(document.querySelector(c)))});t.observe(document.body,{childList:!0,subtree:!0})});if(e){let{theme:n,language:s,size:a}=ie(e);t=n,r=s,i=a}}if(!n&&"smart"===a){let e=document.getElementById(es);if(e){b="smart",w="smart",n=`#${es}`,e.style.maxHeight="0";let{theme:s,language:a,size:o}=ie(e);t=s,r=a,i=o}else console.error("Cannot initialize Smart CAPTCHA widget because the `clerk-captcha` DOM element was not found; falling back to Invisible CAPTCHA widget. If you are using a custom flow, visit https://clerk.com/docs/guides/development/custom-flows/authentication/bot-sign-up-protection for instructions")}if(!n){b="invisible",g=o,w="invisible",n=`.${ea}`;let e=document.createElement("div");e.classList.add(ea),e.style.display="none",document.body.appendChild(e)}let v=async()=>new Promise((s,a)=>{try{let o=p.render(n,{sitekey:g,appearance:"interaction-only",theme:t||"auto",size:i||"normal",language:r||"auto",action:e.action,retry:"never","refresh-expired":"auto",callback:function(e){h?.(),s([e,o])},"before-interactive-callback":()=>{if(d){let e=document.querySelector(d);e?.style.setProperty("visibility","visible"),e?.style.setProperty("pointer-events","all")}else{let e=document.getElementById(es);e&&(e.style.maxHeight="unset",e.style.minHeight="compact"===i?"140px":"68px",e.style.marginBottom="1.5rem",e.dataset.clInteractive="true")}},"error-callback":function(e){var t;(f.push(e),y<2&&(t=e.toString(),["crashed","undefined_error","102","103","104","106","110600","300","600"].find(e=>t.startsWith(e))))?setTimeout(()=>{n&&!document.querySelector(n)?a([f.join(","),o]):(p.reset(o),y++)},250):a([f.join(","),o])},"unsupported-callback":function(){return a(["This browser is not supported by the CAPTCHA.",o]),!0}})}catch(e){a([e,void 0])}});try{[_,m]=await v(),p.remove(m)}catch([e,t]){throw t&&p.remove(t),{captchaError:e}}finally{if("modal"===b&&h?.(),"invisible"===b){let e=document.querySelector(`.${ea}`);e&&document.body.removeChild(e)}if("smart"===b){let e=document.getElementById(es);e&&(delete e.dataset.clInteractive,e.style.maxHeight="0",e.style.minHeight="unset",e.style.marginBottom="unset")}}return{captchaToken:_,captchaWidgetType:w}},ii=e=>{let t=e.__internal_environment,i=t?t.displayConfig.captchaProvider:"turnstile",r=e.__internal_getOption?.("nonce");return{captchaSiteKey:t?t.displayConfig.captchaPublicKey:null,captchaWidgetType:t?t.displayConfig.captchaWidgetType:null,captchaProvider:i,captchaPublicKeyInvisible:t?t.displayConfig.captchaPublicKeyInvisible:null,canUseCaptcha:t?t.userSettings.signUp.captcha_enabled&&e.isStandardBrowser:null,nonce:r||void 0}};class ir{clerk;constructor(e){this.clerk=e}async invisible(e){let{captchaSiteKey:t,canUseCaptcha:i,captchaPublicKeyInvisible:r,nonce:n}=ii(this.clerk);return i&&t&&r?{...await it({action:e?.action,captchaProvider:"turnstile",invisibleSiteKey:r,nonce:e?.nonce||n||void 0,siteKey:r,widgetType:"invisible"}).catch(e=>e.captchaError?{captchaError:e.captchaError}:{captchaError:e?.message||e||"unexpected_captcha_error"}),captchaAction:e?.action}:{captchaError:"captcha_unavailable",captchaAction:e?.action}}async managedOrInvisible(e){let{captchaSiteKey:t,canUseCaptcha:i,captchaWidgetType:r,captchaProvider:n,captchaPublicKeyInvisible:s,nonce:a}=ii(this.clerk);if(i&&t&&s){let i=await it({captchaProvider:n,invisibleSiteKey:s,nonce:a||void 0,siteKey:t,widgetType:r,...e}).catch(t=>t.captchaError?{captchaError:t.captchaError}:e?.action==="verify"?{captchaError:t?.message||t||"unexpected_captcha_error"}:void 0);return e?.action==="verify"?{...i,captchaAction:"verify"}:i}return e?.action==="verify"?{captchaError:"captcha_unavailable",captchaAction:e?.action}:{}}async managedInModal(e){if("u"<typeof document)throw new R("Captcha is not supported in non-browser environments",{code:"captcha_unavailable"});return this.managedOrInvisible({modalWrapperQuerySelector:"#cl-modal-captcha-wrapper",modalContainerQuerySelector:"#cl-modal-captcha-container",openModal:()=>this.clerk.__internal_openBlankCaptchaModal(),closeModal:()=>this.clerk.__internal_closeBlankCaptchaModal(),action:e?.action})}}class is{client;CaptchaChallengeImpl;static instance;inflightException=null;captchaRetryCount=0;MAX_RETRY_ATTEMPTS=3;static getInstance(){return is.instance||(is.instance=new is(rS,ir)),is.instance}constructor(e,t){this.client=e,this.CaptchaChallengeImpl=t}async execute(e,t){if(this.captchaAttemptsExceeded())throw new R("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 t()}catch(r){let i;if(!N(r)||z(r)&&"network_error"===r.code||r.errors[0]?.code!=="requires_captcha")throw r;if(this.inflightException)return await this.inflightException,await t();this.inflightException=new Promise(e=>i=e);try{let t=await this.managedChallenge(e);t?.captchaError!=="modal_component_not_ready"&&(await this.client.getOrCreateInstance().__internal_sendCaptchaToken(t),this.captchaRetryCount=0)}catch(e){throw this.captchaRetryCount++,e}finally{i(),this.inflightException=null}return await t()}}managedChallenge(e){return new this.CaptchaChallengeImpl(e).managedInModal({action:"verify"})}captchaAttemptsExceeded=()=>this.captchaRetryCount>=this.MAX_RETRY_ATTEMPTS}class ia{static clerk;id;pathRoot="";#D;static get fapiClient(){return ia.clerk.getFapiClient()}async reload(e){let{rotatingTokenNonce:t}=e||{};return this._baseGet({forceUpdateClient:!0,rotatingTokenNonce:t})}isNew(){return!this.id}static async _fetch(e,t={}){return is.getInstance().execute(this.clerk,()=>this._baseFetch(e,t))}static async _baseFetch(e,t={}){let i;ia.fapiClient||function(){throw Error(`${tY} Missing FAPI client in resources.`)}();let{fetchMaxTries:r}=t;try{i=await ia.fapiClient.request(e,{fetchMaxTries:r})}catch(t){if(this.shouldRethrowOfflineNetworkErrors())throw new R(t?.message||t,{code:"network_error"});if(!k())return tw.warn("Network request failed while offline, returning null",{method:e.method,path:e.path},"baseResource"),null;throw t}let{payload:n,status:s,statusText:a,headers:o}=i;if(o){let e=o.get("x-country");this.clerk.__internal_setCountry(e?e.toLowerCase():null)}if(("GET"!==e.method||t.forceUpdateClient)&&!t.skipUpdateClient&&this._updateClient(n),s>=200&&s<=299)return n;if(s>=400){let e=n?.errors,t=e?.[0]?.long_message,i=e?.[0]?.code;401===s&&"dev_browser_unauthenticated"===i?await ia.clerk.__internal_handleUnauthenticatedDevBrowser():401===s&&"requires_captcha"!==i&&await ia.clerk.handleUnauthenticated(),function(e,t){var i;if(!t||!t[0])return;let r=t[0],n=r.long_message;if("origin_invalid"===r.code&&((i=ia.clerk.publishableKey).startsWith("live_")||i.startsWith("pk_live_"))){let i=ia.clerk.frontendApi.replace("clerk.","");throw new F(`Clerk: Production Keys are only allowed for domain "${i}".
API Error: ${n}`,{data:t,status:e})}}(s,e);let r={data:e,status:s};if(429===s&&o){let e=o.get("retry-after");if(e){let t=parseInt(e,10);isNaN(t)||(r.retryAfter=t)}}throw new F(t||a,r)}return null}static _updateClient(e){let t=rk(e);t&&ia.clerk&&ia.clerk.updateClient(t)}path(e){let t=this.pathRoot;if(this.isNew())return t;let i=t.replace(/[^/]$/,"$&/")+encodeURIComponent(this.id);return e?i.replace(/[^/]$/,"$&/")+encodeURIComponent(e):i}withDefault(e,t){return e??t}async _baseGet(e={}){let t=await ia._fetch({method:"GET",path:this.path(),rotatingTokenNonce:e.rotatingTokenNonce,signal:e.abortSignal},e);return this.fromJSON(t?.response||t)}async _baseMutate(e){let{action:t,body:i,method:r,path:n,signal:s}=e,a=await ia._fetch({method:r,path:n||this.path(t),body:i,signal:s});return this.fromJSON(a?.response||a)}async _baseMutateBypass(e){let{action:t,body:i,method:r,path:n}=e,s=await ia._baseFetch({method:r,path:n||this.path(t),body:i});return this.fromJSON(s?.response||s)}async _basePost(e={}){if(!e.coalesce)return this._baseMutate({...e,method:"POST"});let t=this.#W(e),i=this.#D??=new Map,r=i.get(t);if(r&&Date.now()<r.expiresAt)return r.promise;let n=new AbortController,s=this._baseMutate({...e,method:"POST",signal:n.signal}).finally(()=>{i.get(t)?.promise===s&&i.delete(t)});return i.set(t,{promise:s,controller:n,expiresAt:Date.now()+3e4}),s}#W(e){let t=Object.entries(e.body??{}).filter(([,e])=>void 0!==e).sort(([e],[t])=>e<t?-1:1);return JSON.stringify([this.id,e.path,e.action,t])}async _basePostBypass(e={}){return this._baseMutateBypass({...e,method:"POST"})}async _basePut(e={}){return this._baseMutate({...e,method:"PUT"})}async _basePatch(e={}){return this._baseMutate({...e,method:"PATCH"})}async _baseDelete(e={}){await this._baseMutate({...e,method:"DELETE"})}static shouldRethrowOfflineNetworkErrors(){let e=ia.clerk?.__internal_getOption?.("experimental");return e?.rethrowOfflineNetworkErrors||!1}}class io extends ia{pathRoot="/api_keys";id;type;name;subject;scopes;claims;revoked;revocationReason;expired;expiration;createdBy;description;secret;lastUsedAt;createdAt;updatedAt;constructor(e){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.type=e.type,this.name=e.name,this.subject=e.subject,this.scopes=e.scopes,this.claims=e.claims,thi