@realtimex/folio 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -188,22 +188,32 @@ export class ModelCapabilityService {
188
188
  const message = this.errorToMessage(error).toLowerCase();
189
189
  if (!message) return { isCapabilityError: false, reason: "empty_error" };
190
190
 
191
- const capabilityHints = [
191
+ const hardCapabilityHints = [
192
+ "does not support images",
193
+ "model does not support image",
194
+ "invalid model", // e.g. text-only models fed image payloads in realtimexai provider
195
+ ];
196
+
197
+ if (hardCapabilityHints.some((hint) => message.includes(hint))) {
198
+ return { isCapabilityError: true, reason: "capability_mismatch" };
199
+ }
200
+
201
+ const documentSpecificHints = [
192
202
  "image_url",
193
203
  "vision",
194
204
  "multimodal",
195
205
  "multi-modal",
196
206
  "unsupported content type",
197
207
  "unsupported message content",
198
- "does not support images",
199
- "model does not support image",
200
208
  "invalid content type",
201
209
  "invalid image",
202
210
  "unrecognized content type",
211
+ "image too large",
212
+ "base64",
203
213
  ];
204
214
 
205
- if (capabilityHints.some((hint) => message.includes(hint))) {
206
- return { isCapabilityError: true, reason: "capability_mismatch" };
215
+ if (documentSpecificHints.some((hint) => message.includes(hint))) {
216
+ return { isCapabilityError: false, reason: "document_specific_failure" };
207
217
  }
208
218
 
209
219
  const transientHints = [
@@ -465,7 +465,7 @@ async function evaluateCondition(condition: MatchCondition, doc: DocumentObject,
465
465
  role: "user",
466
466
  content: buildMessageContent(`Question: ${prompt}`, doc.text, true)
467
467
  }
468
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
468
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
469
469
  ] as any,
470
470
  { provider, model }
471
471
  );
@@ -592,7 +592,7 @@ ${fieldDescriptions}`;
592
592
  : [
593
593
  { role: "system", content: "You are a precise data extraction engine. Return only valid JSON." },
594
594
  { role: "user", content: buildMessageContent(prompt, doc.text) }
595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
595
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
596
596
  ] as any,
597
597
  { provider, model }
598
598
  );
@@ -733,7 +733,7 @@ Rules:
733
733
  : [
734
734
  { role: "system", content: "You are a precise data extraction engine. Return only valid JSON." },
735
735
  { role: "user", content: buildMessageContent(prompt, doc.text) },
736
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
736
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
737
737
  ] as any,
738
738
  { provider, model }
739
739
  );
@@ -1136,7 +1136,7 @@ export class PolicyEngine {
1136
1136
  : [
1137
1137
  { role: "system", content: systemPrompt },
1138
1138
  { role: "user", content: buildMessageContent(userPrompt, doc.text) },
1139
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1140
1140
  ] as any,
1141
1141
  { provider, model }
1142
1142
  );
@@ -1155,6 +1155,7 @@ export class PolicyEngine {
1155
1155
  if (!parsed) {
1156
1156
  logger.warn("Baseline extraction returned unparseable JSON", { raw: raw.slice(0, 300) });
1157
1157
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction unparseable", raw_response: raw.slice(0, 300) }, doc.supabase);
1158
+ if (isVlmPayload) throw new Error("Unparseable JSON from VLM extraction");
1158
1159
  return { entities: {}, uncertain_fields: [], tags: [] };
1159
1160
  }
1160
1161
 
@@ -1172,6 +1173,7 @@ export class PolicyEngine {
1172
1173
  } catch (err) {
1173
1174
  logger.error("Baseline extraction failed", { err });
1174
1175
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction failed", error: String(err) }, doc.supabase);
1176
+ if (isVlmPayload) throw err;
1175
1177
  return { entities: {}, uncertain_fields: [], tags: [] };
1176
1178
  }
1177
1179
  }
@@ -120,21 +120,29 @@ export class ModelCapabilityService {
120
120
  const message = this.errorToMessage(error).toLowerCase();
121
121
  if (!message)
122
122
  return { isCapabilityError: false, reason: "empty_error" };
123
- const capabilityHints = [
123
+ const hardCapabilityHints = [
124
+ "does not support images",
125
+ "model does not support image",
126
+ "invalid model", // e.g. text-only models fed image payloads in realtimexai provider
127
+ ];
128
+ if (hardCapabilityHints.some((hint) => message.includes(hint))) {
129
+ return { isCapabilityError: true, reason: "capability_mismatch" };
130
+ }
131
+ const documentSpecificHints = [
124
132
  "image_url",
125
133
  "vision",
126
134
  "multimodal",
127
135
  "multi-modal",
128
136
  "unsupported content type",
129
137
  "unsupported message content",
130
- "does not support images",
131
- "model does not support image",
132
138
  "invalid content type",
133
139
  "invalid image",
134
140
  "unrecognized content type",
141
+ "image too large",
142
+ "base64",
135
143
  ];
136
- if (capabilityHints.some((hint) => message.includes(hint))) {
137
- return { isCapabilityError: true, reason: "capability_mismatch" };
144
+ if (documentSpecificHints.some((hint) => message.includes(hint))) {
145
+ return { isCapabilityError: false, reason: "document_specific_failure" };
138
146
  }
139
147
  const transientHints = [
140
148
  "timeout",
@@ -954,6 +954,8 @@ export class PolicyEngine {
954
954
  if (!parsed) {
955
955
  logger.warn("Baseline extraction returned unparseable JSON", { raw: raw.slice(0, 300) });
956
956
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction unparseable", raw_response: raw.slice(0, 300) }, doc.supabase);
957
+ if (isVlmPayload)
958
+ throw new Error("Unparseable JSON from VLM extraction");
957
959
  return { entities: {}, uncertain_fields: [], tags: [] };
958
960
  }
959
961
  const entities = parsed.entities ?? parsed;
@@ -970,6 +972,8 @@ export class PolicyEngine {
970
972
  catch (err) {
971
973
  logger.error("Baseline extraction failed", { err });
972
974
  Actuator.logEvent(doc.ingestionId, doc.userId, "error", "Baseline Extraction", { action: "Baseline extraction failed", error: String(err) }, doc.supabase);
975
+ if (isVlmPayload)
976
+ throw err;
973
977
  return { entities: {}, uncertain_fields: [], tags: [] };
974
978
  }
975
979
  }
@@ -48,7 +48,7 @@ Request ID: ${m}`),g){let k=`
48
48
  Resources:`;for(const C of g){if(!C||typeof C!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${C}`);k+=`
49
49
  - ${C}`}N+=k}return`${_}
50
50
  ${N}`}class Tt extends Error{constructor({message:e,code:s,cause:i,name:l}){var u;super(e,{cause:i}),this.__isWebAuthnError=!0,this.name=(u=l??(i instanceof Error?i.name:void 0))!==null&&u!==void 0?u:"Unknown Error",this.code=s}}class au extends Tt{constructor(e,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:e}),this.name="WebAuthnUnknownError",this.originalError=s}}function QT({error:t,options:e}){var s,i,l;const{publicKey:u}=e;if(!u)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((s=u.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new Tt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((i=u.authenticatorSelection)===null||i===void 0?void 0:i.userVerification)==="required")return new Tt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((l=u.authenticatorSelection)===null||l===void 0?void 0:l.userVerification)==="required")return new Tt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Tt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return u.pubKeyCredParams.filter(h=>h.type==="public-key").length===0?new Tt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Tt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const d=window.location.hostname;if(yw(d)){if(u.rp.id!==d)return new Tt({message:`The RP ID "${u.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(u.user.id.byteLength<1||u.user.id.byteLength>64)return new Tt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function ZT({error:t,options:e}){const{publicKey:s}=e;if(!s)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new Tt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Tt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const i=window.location.hostname;if(yw(i)){if(s.rpId!==i)return new Tt({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Tt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Tt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Tt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class eE{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const tE=new eE;function nE(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:s,excludeCredentials:i}=t,l=pr(t,["challenge","user","excludeCredentials"]),u=or(e).buffer,d=Object.assign(Object.assign({},s),{id:or(s.id).buffer}),h=Object.assign(Object.assign({},l),{challenge:u,user:d});if(i&&i.length>0){h.excludeCredentials=new Array(i.length);for(let m=0;m<i.length;m++){const g=i[m];h.excludeCredentials[m]=Object.assign(Object.assign({},g),{id:or(g.id).buffer,type:g.type||"public-key",transports:g.transports})}}return h}function sE(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:e,allowCredentials:s}=t,i=pr(t,["challenge","allowCredentials"]),l=or(e).buffer,u=Object.assign(Object.assign({},i),{challenge:l});if(s&&s.length>0){u.allowCredentials=new Array(s.length);for(let d=0;d<s.length;d++){const h=s[d];u.allowCredentials[d]=Object.assign(Object.assign({},h),{id:or(h.id).buffer,type:h.type||"public-key",transports:h.transports})}}return u}function aE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t;return{id:t.id,rawId:t.id,response:{attestationObject:Fa(new Uint8Array(t.response.attestationObject)),clientDataJSON:Fa(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function iE(t){var e;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const s=t,i=t.getClientExtensionResults(),l=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:Fa(new Uint8Array(l.authenticatorData)),clientDataJSON:Fa(new Uint8Array(l.clientDataJSON)),signature:Fa(new Uint8Array(l.signature)),userHandle:l.userHandle?Fa(new Uint8Array(l.userHandle)):void 0},type:"public-key",clientExtensionResults:i,authenticatorAttachment:(e=s.authenticatorAttachment)!==null&&e!==void 0?e:void 0}}function yw(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function s0(){var t,e;return!!(Gt()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator?.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((e=navigator?.credentials)===null||e===void 0?void 0:e.get)=="function")}async function rE(t){try{const e=await navigator.credentials.create(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:QT({error:e,options:t})}}}async function oE(t){try{const e=await navigator.credentials.get(t);return e?e instanceof PublicKeyCredential?{data:e,error:null}:{data:null,error:new au("Browser returned unexpected credential type",e)}:{data:null,error:new au("Empty credential response",e)}}catch(e){return{data:null,error:ZT({error:e,options:t})}}}const lE={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},cE={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function iu(...t){const e=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),s=l=>l instanceof ArrayBuffer||ArrayBuffer.isView(l),i={};for(const l of t)if(l)for(const u in l){const d=l[u];if(d!==void 0)if(Array.isArray(d))i[u]=d;else if(s(d))i[u]=d;else if(e(d)){const h=i[u];e(h)?i[u]=iu(h,d):i[u]=iu(d)}else i[u]=d}return i}function uE(t,e){return iu(lE,t,e||{})}function dE(t,e){return iu(cE,t,e||{})}class hE{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:s,friendlyName:i,signal:l},u){var d;try{const{data:h,error:m}=await this.client.mfa.challenge({factorId:e,webauthn:s});if(!h)return{data:null,error:m};const g=l??tE.createNewAbortSignal();if(h.webauthn.type==="create"){const{user:y}=h.webauthn.credential_options.publicKey;if(!y.name){const x=i;if(x)y.name=`${y.id}:${x}`;else{const S=(await this.client.getUser()).data.user,E=((d=S?.user_metadata)===null||d===void 0?void 0:d.name)||S?.email||S?.id||"User";y.name=`${y.id}:${E}`}}y.displayName||(y.displayName=y.name)}switch(h.webauthn.type){case"create":{const y=uE(h.webauthn.credential_options.publicKey,u?.create),{data:x,error:w}=await rE({publicKey:y,signal:g});return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}case"request":{const y=dE(h.webauthn.credential_options.publicKey,u?.request),{data:x,error:w}=await oE(Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:y,signal:g}));return x?{data:{factorId:e,challengeId:h.id,webauthn:{type:h.webauthn.type,credential_response:x}},error:null}:{data:null,error:w}}}}catch(h){return Ne(h)?{data:null,error:h}:{data:null,error:new Ga("Unexpected error in challenge",h)}}}async _verify({challengeId:e,factorId:s,webauthn:i}){return this.client.mfa.verify({factorId:s,challengeId:e,webauthn:i})}async _authenticate({factorId:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:i=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn authentication")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this.challenge({factorId:e,webauthn:{rpId:s,rpOrigins:i},signal:l},{request:u});if(!d)return{data:null,error:h};const{webauthn:m}=d;return this._verify({factorId:e,challengeId:d.challengeId,webauthn:{type:m.type,rpId:s,rpOrigins:i,credential_response:m.credential_response}})}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in authenticate",d)}}}async _register({friendlyName:e,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:i=typeof window<"u"?[window.location.origin]:void 0,signal:l}={}},u){if(!s)return{data:null,error:new zo("rpId is required for WebAuthn registration")};try{if(!s0())return{data:null,error:new Ga("Browser does not support WebAuthn",null)};const{data:d,error:h}=await this._enroll({friendlyName:e});if(!d)return await this.client.mfa.listFactors().then(y=>{var x;return(x=y.data)===null||x===void 0?void 0:x.all.find(w=>w.factor_type==="webauthn"&&w.friendly_name===e&&w.status!=="unverified")}).then(y=>y?this.client.mfa.unenroll({factorId:y?.id}):void 0),{data:null,error:h};const{data:m,error:g}=await this._challenge({factorId:d.id,friendlyName:d.friendly_name,webauthn:{rpId:s,rpOrigins:i},signal:l},{create:u});return m?this._verify({factorId:d.id,challengeId:m.challengeId,webauthn:{rpId:s,rpOrigins:i,type:m.webauthn.type,credential_response:m.webauthn.credential_response}}):{data:null,error:g}}catch(d){return Ne(d)?{data:null,error:d}:{data:null,error:new Ga("Unexpected error in register",d)}}}}YT();const fE={url:uT,storageKey:dT,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:hT,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:1e4,skipAutoInitialize:!1};async function a0(t,e,s){return await s()}const Fi={};class Lo{get jwks(){var e,s;return(s=(e=Fi[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(e){Fi[this.storageKey]=Object.assign(Object.assign({},Fi[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,s;return(s=(e=Fi[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Fi[this.storageKey]=Object.assign(Object.assign({},Fi[this.storageKey]),{cachedAt:e})}constructor(e){var s,i,l;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const u=Object.assign(Object.assign({},fE),e);if(this.storageKey=u.storageKey,this.instanceID=(s=Lo.nextInstanceID[this.storageKey])!==null&&s!==void 0?s:0,Lo.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!u.debug,typeof u.debug=="function"&&(this.logger=u.debug),this.instanceID>0&&Gt()){const d=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(d),this.logDebugMessages&&console.trace(d)}if(this.persistSession=u.persistSession,this.autoRefreshToken=u.autoRefreshToken,this.admin=new FT({url:u.url,headers:u.headers,fetch:u.fetch}),this.url=u.url,this.headers=u.headers,this.fetch=mw(u.fetch),this.lock=u.lock||a0,this.detectSessionInUrl=u.detectSessionInUrl,this.flowType=u.flowType,this.hasCustomAuthorizationHeader=u.hasCustomAuthorizationHeader,this.throwOnError=u.throwOnError,this.lockAcquireTimeout=u.lockAcquireTimeout,u.lock?this.lock=u.lock:this.persistSession&&Gt()&&(!((i=globalThis?.navigator)===null||i===void 0)&&i.locks)?this.lock=KT:this.lock=a0,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new hE(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(u.storage?this.storage=u.storage:fw()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=t0(this.memoryStorage)),u.userStorage&&(this.userStorage=u.userStorage)):(this.memoryStorage={},this.storage=t0(this.memoryStorage)),Gt()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(d){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",d)}(l=this.broadcastChannel)===null||l===void 0||l.addEventListener("message",async d=>{this._debug("received broadcast notification from other tab or client",d);try{await this._notifyAllSubscribers(d.data.event,d.data.session,!1)}catch(h){this._debug("#broadcastChannel","error",h)}})}u.skipAutoInitialize||this.initialize().catch(d=>{this._debug("#initialize()","error",d)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${uw}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let s={},i="none";if(Gt()&&(s=TT(window.location.href),this._isImplicitGrantCallback(s)?i="implicit":await this._isPKCECallback(s)&&(i="pkce")),Gt()&&this.detectSessionInUrl&&i!=="none"){const{data:l,error:u}=await this._getSessionFromURL(s,i);if(u){if(this._debug("#_initialize()","error detecting session from URL",u),yT(u)){const m=(e=u.details)===null||e===void 0?void 0:e.code;if(m==="identity_already_exists"||m==="identity_not_found"||m==="single_identity_not_deletable")return{error:u}}return{error:u}}const{session:d,redirectType:h}=l;return this._debug("#_initialize()","detected session in URL",d,"redirect type",h),await this._saveSession(d),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",d):await this._notifyAllSubscribers("SIGNED_IN",d)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(s){return Ne(s)?this._returnResult({error:s}):this._returnResult({error:new Ga("Unexpected error during initialization",s)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var s,i,l;try{const u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(i=(s=e?.options)===null||s===void 0?void 0:s.data)!==null&&i!==void 0?i:{},gotrue_meta_security:{captcha_token:(l=e?.options)===null||l===void 0?void 0:l.captchaToken}},xform:$n}),{data:d,error:h}=u;if(h||!d)return this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signUp(e){var s,i,l;try{let u;if("email"in e){const{email:y,password:x,options:w}=e;let S=null,E=null;this.flowType==="pkce"&&([S,E]=await qi(this.storage,this.storageKey)),u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:w?.emailRedirectTo,body:{email:y,password:x,data:(s=w?.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:w?.captchaToken},code_challenge:S,code_challenge_method:E},xform:$n})}else if("phone"in e){const{phone:y,password:x,options:w}=e;u=await Re(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:y,password:x,data:(i=w?.data)!==null&&i!==void 0?i:{},channel:(l=w?.channel)!==null&&l!==void 0?l:"sms",gotrue_meta_security:{captcha_token:w?.captchaToken}},xform:$n})}else throw new Cc("You must provide either an email or phone number and a password");const{data:d,error:h}=u;if(h||!d)return await Ht(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:h});const m=d.session,g=d.user;return d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null},error:u});throw u}}async signInWithPassword(e){try{let s;if("email"in e){const{email:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else if("phone"in e){const{phone:u,password:d,options:h}=e;s=await Re(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:u,password:d,gotrue_meta_security:{captcha_token:h?.captchaToken}},xform:Zx})}else throw new Cc("You must provide either an email or phone number and a password");const{data:i,error:l}=s;if(l)return this._returnResult({data:{user:null,session:null},error:l});if(!i||!i.session||!i.user){const u=new $i;return this._returnResult({data:{user:null,session:null},error:u})}return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),this._returnResult({data:Object.assign({user:i.user,session:i.session},i.weak_password?{weakPassword:i.weak_password}:null),error:l})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOAuth(e){var s,i,l,u;return await this._handleProviderSignIn(e.provider,{redirectTo:(s=e.options)===null||s===void 0?void 0:s.redirectTo,scopes:(i=e.options)===null||i===void 0?void 0:i.scopes,queryParams:(l=e.options)===null||l===void 0?void 0:l.queryParams,skipBrowserRedirect:(u=e.options)===null||u===void 0?void 0:u.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:s}=e;switch(s){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(e){var s,i,l,u,d,h,m,g,y,x,w;let S,E;if("message"in e)S=e.message,E=e.signature;else{const{chain:j,wallet:_,statement:N,options:k}=e;let C;if(Gt())if(typeof _=="object")C=_;else{const P=window;if("ethereum"in P&&typeof P.ethereum=="object"&&"request"in P.ethereum&&typeof P.ethereum.request=="function")C=P.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof _!="object"||!k?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");C=_}const A=new URL((s=k?.url)!==null&&s!==void 0?s:window.location.href),D=await C.request({method:"eth_requestAccounts"}).then(P=>P).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!D||D.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const z=gw(D[0]);let V=(i=k?.signInWithEthereum)===null||i===void 0?void 0:i.chainId;if(!V){const P=await C.request({method:"eth_chainId"});V=XT(P)}const R={domain:A.host,address:z,statement:N,uri:A.href,version:"1",chainId:V,nonce:(l=k?.signInWithEthereum)===null||l===void 0?void 0:l.nonce,issuedAt:(d=(u=k?.signInWithEthereum)===null||u===void 0?void 0:u.issuedAt)!==null&&d!==void 0?d:new Date,expirationTime:(h=k?.signInWithEthereum)===null||h===void 0?void 0:h.expirationTime,notBefore:(m=k?.signInWithEthereum)===null||m===void 0?void 0:m.notBefore,requestId:(g=k?.signInWithEthereum)===null||g===void 0?void 0:g.requestId,resources:(y=k?.signInWithEthereum)===null||y===void 0?void 0:y.resources};S=JT(R),E=await C.request({method:"personal_sign",params:[WT(S),z]})}try{const{data:j,error:_}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:S,signature:E},!((x=e.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(w=e.options)===null||w===void 0?void 0:w.captchaToken}}:null),xform:$n});if(_)throw _;if(!j||!j.session||!j.user){const N=new $i;return this._returnResult({data:{user:null,session:null},error:N})}return j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),this._returnResult({data:Object.assign({},j),error:_})}catch(j){if(Ne(j))return this._returnResult({data:{user:null,session:null},error:j});throw j}}async signInWithSolana(e){var s,i,l,u,d,h,m,g,y,x,w,S;let E,j;if("message"in e)E=e.message,j=e.signature;else{const{chain:_,wallet:N,statement:k,options:C}=e;let A;if(Gt())if(typeof N=="object")A=N;else{const z=window;if("solana"in z&&typeof z.solana=="object"&&("signIn"in z.solana&&typeof z.solana.signIn=="function"||"signMessage"in z.solana&&typeof z.solana.signMessage=="function"))A=z.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!C?.url)throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");A=N}const D=new URL((s=C?.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in A&&A.signIn){const z=await A.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},C?.signInWithSolana),{version:"1",domain:D.host,uri:D.href}),k?{statement:k}:null));let V;if(Array.isArray(z)&&z[0]&&typeof z[0]=="object")V=z[0];else if(z&&typeof z=="object"&&"signedMessage"in z&&"signature"in z)V=z;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in V&&"signature"in V&&(typeof V.signedMessage=="string"||V.signedMessage instanceof Uint8Array)&&V.signature instanceof Uint8Array)E=typeof V.signedMessage=="string"?V.signedMessage:new TextDecoder().decode(V.signedMessage),j=V.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in A)||typeof A.signMessage!="function"||!("publicKey"in A)||typeof A!="object"||!A.publicKey||!("toBase58"in A.publicKey)||typeof A.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");E=[`${D.host} wants you to sign in with your Solana account:`,A.publicKey.toBase58(),...k?["",k,""]:[""],"Version: 1",`URI: ${D.href}`,`Issued At: ${(l=(i=C?.signInWithSolana)===null||i===void 0?void 0:i.issuedAt)!==null&&l!==void 0?l:new Date().toISOString()}`,...!((u=C?.signInWithSolana)===null||u===void 0)&&u.notBefore?[`Not Before: ${C.signInWithSolana.notBefore}`]:[],...!((d=C?.signInWithSolana)===null||d===void 0)&&d.expirationTime?[`Expiration Time: ${C.signInWithSolana.expirationTime}`]:[],...!((h=C?.signInWithSolana)===null||h===void 0)&&h.chainId?[`Chain ID: ${C.signInWithSolana.chainId}`]:[],...!((m=C?.signInWithSolana)===null||m===void 0)&&m.nonce?[`Nonce: ${C.signInWithSolana.nonce}`]:[],...!((g=C?.signInWithSolana)===null||g===void 0)&&g.requestId?[`Request ID: ${C.signInWithSolana.requestId}`]:[],...!((x=(y=C?.signInWithSolana)===null||y===void 0?void 0:y.resources)===null||x===void 0)&&x.length?["Resources",...C.signInWithSolana.resources.map(V=>`- ${V}`)]:[]].join(`
51
- `);const z=await A.signMessage(new TextEncoder().encode(E),"utf8");if(!z||!(z instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=z}}try{const{data:_,error:N}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Fa(j)},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(S=e.options)===null||S===void 0?void 0:S.captchaToken}}:null),xform:$n});if(N)throw N;if(!_||!_.session||!_.user){const k=new $i;return this._returnResult({data:{user:null,session:null},error:k})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:N})}catch(_){if(Ne(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async _exchangeCodeForSession(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`),[i,l]=(s??"").split("/");try{if(!i&&this.flowType==="pkce")throw new vT;const{data:u,error:d}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:$n});if(await Ht(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const h=new $i;return this._returnResult({data:{user:null,session:null,redirectType:null},error:h})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:l??null}),error:d})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(e){try{const{options:s,provider:i,token:l,access_token:u,nonce:d}=e,h=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:i,id_token:l,access_token:u,nonce:d,gotrue_meta_security:{captcha_token:s?.captchaToken}},xform:$n}),{data:m,error:g}=h;if(g)return this._returnResult({data:{user:null,session:null},error:g});if(!m||!m.session||!m.user){const y=new $i;return this._returnResult({data:{user:null,session:null},error:y})}return m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("SIGNED_IN",m.session)),this._returnResult({data:m,error:g})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,i,l,u,d;try{if("email"in e){const{email:h,options:m}=e;let g=null,y=null;this.flowType==="pkce"&&([g,y]=await qi(this.storage,this.storageKey));const{error:x}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(s=m?.data)!==null&&s!==void 0?s:{},create_user:(i=m?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},code_challenge:g,code_challenge_method:y},redirectTo:m?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in e){const{phone:h,options:m}=e,{data:g,error:y}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(l=m?.data)!==null&&l!==void 0?l:{},create_user:(u=m?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},channel:(d=m?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:g?.message_id},error:y})}throw new Cc("You must provide either an email or phone number.")}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}async verifyOtp(e){var s,i;try{let l,u;"options"in e&&(l=(s=e.options)===null||s===void 0?void 0:s.redirectTo,u=(i=e.options)===null||i===void 0?void 0:i.captchaToken);const{data:d,error:h}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:$n});if(h)throw h;if(!d)throw new Error("An error occurred on token verification.");const m=d.session,g=d.user;return m?.access_token&&(await this._saveSession(m),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(l){if(Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var s,i,l,u,d;try{let h=null,m=null;this.flowType==="pkce"&&([h,m]=await qi(this.storage,this.storageKey));const g=await Re(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(i=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&i!==void 0?i:void 0}),!((l=e?.options)===null||l===void 0)&&l.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:h,code_challenge_method:m}),headers:this.headers,xform:qT});return!((u=g.data)===null||u===void 0)&&u.url&&Gt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(g.data.url),this._returnResult(g)}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:null,error:h});throw h}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;if(i)throw i;if(!s)throw new xn;const{error:l}=await Re(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:l})})}catch(e){if(Ne(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:i,type:l,options:u}=e,{error:d}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{email:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}},redirectTo:u?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}else if("phone"in e){const{phone:i,type:l,options:u}=e,{data:d,error:h}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{phone:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:h})}throw new Cc("You must provide either an email or phone number and a type")}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const i=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),l=(async()=>(await i,await s()))();return this.pendingInLock.push((async()=>{try{await l}catch{}})()),l}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const i=s();for(this.pendingInLock.push((async()=>{try{await i}catch{}})()),await i;this.pendingInLock.length;){const l=[...this.pendingInLock];await Promise.all(l),this.pendingInLock.splice(0,l.length)}return await i}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await Ua(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const i=e.expires_at?e.expires_at*1e3-Date.now()<rf:!1;if(this._debug("#__loadSession()",`session has${i?"":" not"} expired`,"expires_at",e.expires_at),!i){if(this.userStorage){const d=await Ua(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=cf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=BT(e.user,d),d.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{session:null},error:u}):this._returnResult({data:{session:l},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ua}):await this._useSession(async s=>{var i,l,u;const{data:d,error:h}=s;if(h)throw h;return!(!((i=d.session)===null||i===void 0)&&i.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xn}:await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(u=(l=d.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0,xform:ua})})}catch(s){if(Ne(s))return of(s)&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async i=>{const{data:l,error:u}=i;if(u)throw u;if(!l.session)throw new xn;const d=l.session;let h=null,m=null;this.flowType==="pkce"&&e.email!=null&&([h,m]=await qi(this.storage,this.storageKey));const{data:g,error:y}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:m}),jwt:d.access_token,xform:ua});if(y)throw y;return d.user=g.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(i){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(i))return this._returnResult({data:{user:null},error:i});throw i}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new xn;const s=Date.now()/1e3;let i=s,l=!0,u=null;const{payload:d}=Rc(e.access_token);if(d.exp&&(i=d.exp,l=i<=s),l){const{data:h,error:m}=await this._callRefreshToken(e.refresh_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h)return{data:{user:null,session:null},error:null};u=h}else{const{data:h,error:m}=await this._getUser(e.access_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});u={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:i-s,expires_at:i},await this._saveSession(u),await this._notifyAllSubscribers("SIGNED_IN",u)}return this._returnResult({data:{user:u.user,session:u},error:null})}catch(s){if(Ne(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var i;if(!e){const{data:d,error:h}=s;if(h)throw h;e=(i=d.session)!==null&&i!==void 0?i:void 0}if(!e?.refresh_token)throw new xn;const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{user:null,session:null},error:u}):l?this._returnResult({data:{user:l.user,session:l},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){try{if(!Gt())throw new Ac("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Ac(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Fx("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Ac("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Fx("No code detected.");const{data:k,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const A=new URL(window.location.href);return A.searchParams.delete("code"),window.history.replaceState(window.history.state,"",A.toString()),{data:{session:k.session,redirectType:null},error:null}}const{provider_token:i,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:h,expires_at:m,token_type:g}=e;if(!u||!h||!d||!g)throw new Ac("No session defined in URL");const y=Math.round(Date.now()/1e3),x=parseInt(h);let w=y+x;m&&(w=parseInt(m));const S=w-y;S*1e3<=Ji&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${S}s, should have been closer to ${x}s`);const E=w-x;y-E>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",E,w,y):y-E<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",E,w,y);const{data:j,error:_}=await this._getUser(u);if(_)throw _;const N={provider_token:i,provider_refresh_token:l,access_token:u,expires_in:x,expires_at:w,refresh_token:d,token_type:g,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:N,redirectType:e.type},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u&&!of(u))return this._returnResult({error:u});const d=(i=l.session)===null||i===void 0?void 0:i.access_token;if(d){const{error:h}=await this.admin.signOut(d,e);if(h&&!(gT(h)&&(h.status===404||h.status===401||h.status===403)||of(h)))return this._returnResult({error:h})}return e!=="others"&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=NT(),i={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,i),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:i}}}async _emitInitialSession(e){return await this._useSession(async s=>{var i,l;try{const{data:{session:u},error:d}=s;if(d)throw d;await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",u)),this._debug("INITIAL_SESSION","callback id",e,"session",u)}catch(u){await((l=this.stateChangeEmitters.get(e))===null||l===void 0?void 0:l.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",u),console.error(u)}})}async resetPasswordForEmail(e,s={}){let i=null,l=null;this.flowType==="pkce"&&([i,l]=await qi(this.storage,this.storageKey,!0));try{return await Re(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:i,code_challenge_method:l,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:null,error:u});throw u}}async getUserIdentities(){var e;try{const{data:s,error:i}=await this.getUser();if(i)throw i;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:i,error:l}=await this._useSession(async u=>{var d,h,m,g,y;const{data:x,error:w}=u;if(w)throw w;const S=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(m=e.options)===null||m===void 0?void 0:m.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",S,{headers:this.headers,jwt:(y=(g=x.session)===null||g===void 0?void 0:g.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Gt()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(i?.url),this._returnResult({data:{provider:e.provider,url:i?.url},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{provider:e.provider,url:null},error:i});throw i}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var i;try{const{error:l,data:{session:u}}=s;if(l)throw l;const{options:d,provider:h,token:m,access_token:g,nonce:y}=e,x=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(i=u?.access_token)!==null&&i!==void 0?i:void 0,body:{provider:h,id_token:m,access_token:g,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:$n}),{data:w,error:S}=x;return S?this._returnResult({data:{user:null,session:null},error:S}):!w||!w.session||!w.user?this._returnResult({data:{user:null,session:null},error:new $i}):(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("USER_UPDATED",w.session)),this._returnResult({data:w,error:S}))}catch(l){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)throw d;return await Re(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(l=(i=u.session)===null||i===void 0?void 0:i.access_token)!==null&&l!==void 0?l:void 0})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const i=Date.now();return await CT(async l=>(l>0&&await kT(200*Math.pow(2,l-1)),this._debug(s,"refreshing attempt",l),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:$n})),(l,u)=>{const d=200*Math.pow(2,l);return u&&lf(u)&&Date.now()+d-i<Ji})}catch(i){if(this._debug(s,"error",i),Ne(i))return this._returnResult({data:{session:null,user:null},error:i});throw i}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const i=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",i),Gt()&&!s.skipBrowserRedirect&&window.location.assign(i),{data:{provider:e,url:i},error:null}}async _recoverAndRefresh(){var e,s;const i="#_recoverAndRefresh()";this._debug(i,"begin");try{const l=await Ua(this.storage,this.storageKey);if(l&&this.userStorage){let d=await Ua(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await Qi(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:cf()}else if(l&&!l.user&&!l.user){const d=await Ua(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Ht(this.storage,this.storageKey+"-user"),await Qi(this.storage,this.storageKey,l)):l.user=cf()}if(this._debug(i,"session from storage",l),!this._isValidSession(l)){this._debug(i,"session is not valid"),l!==null&&await this._removeSession();return}const u=((s=l.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<rf;if(this._debug(i,`session has${u?"":" not"} expired with margin of ${rf}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),lf(d)||(this._debug(i,"refresh failed with a non-retryable error, removing the session",d),await this._removeSession()))}}else if(l.user&&l.user.__isUserNotAvailableProxy===!0)try{const{data:d,error:h}=await this._getUser(l.access_token);!h&&d?.user?(l.user=d.user,await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)):this._debug(i,"could not get user data, skipping SIGNED_IN notification")}catch(d){console.error("Error getting user data:",d),this._debug(i,"error getting user data, skipping SIGNED_IN notification",d)}else await this._notifyAllSubscribers("SIGNED_IN",l)}catch(l){this._debug(i,"error",l),console.error(l);return}finally{this._debug(i,"end")}}async _callRefreshToken(e){var s,i;if(!e)throw new xn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Nu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new xn;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const h={data:u.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(u){if(this._debug(l,"error",u),Ne(u)){const d={data:null,error:u};return lf(u)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(d),d}throw(i=this.refreshingDeferred)===null||i===void 0||i.reject(u),u}finally{this.refreshingDeferred=null,this._debug(l,"end")}}async _notifyAllSubscribers(e,s,i=!0){const l=`#_notifyAllSubscribers(${e})`;this._debug(l,"begin",s,`broadcast = ${i}`);try{this.broadcastChannel&&i&&this.broadcastChannel.postMessage({event:e,session:s});const u=[],d=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,s)}catch(m){u.push(m)}});if(await Promise.all(d),u.length>0){for(let h=0;h<u.length;h+=1)console.error(u[h]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ht(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),i=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!i&&s.user&&await Qi(this.userStorage,this.storageKey+"-user",{user:s.user});const l=Object.assign({},s);delete l.user;const u=Jx(l);await Qi(this.storage,this.storageKey,u)}else{const l=Jx(s);await Qi(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ht(this.storage,this.storageKey),await Ht(this.storage,this.storageKey+"-code-verifier"),await Ht(this.storage,this.storageKey+"-user"),this.userStorage&&await Ht(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Gt()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ji);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:i}}=s;if(!i||!i.refresh_token||!i.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const l=Math.floor((i.expires_at*1e3-e)/Ji);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${Ji}ms, refresh threshold is ${Yf} ticks`),l<=Yf&&await this._callRefreshToken(i.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof pw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Gt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,i){const l=[`provider=${encodeURIComponent(s)}`];if(i?.redirectTo&&l.push(`redirect_to=${encodeURIComponent(i.redirectTo)}`),i?.scopes&&l.push(`scopes=${encodeURIComponent(i.scopes)}`),this.flowType==="pkce"){const[u,d]=await qi(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(h.toString())}if(i?.queryParams){const u=new URLSearchParams(i.queryParams);l.push(u.toString())}return i?.skipBrowserRedirect&&l.push(`skip_http_redirect=${i.skipBrowserRedirect}`),`${e}?${l.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;return u?this._returnResult({data:null,error:u}):await Re(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)return this._returnResult({data:null,error:d});const h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:m,error:g}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(i=u?.session)===null||i===void 0?void 0:i.access_token});return g?this._returnResult({data:null,error:g}):(e.factorType==="totp"&&m.type==="totp"&&(!((l=m?.totp)===null||l===void 0)&&l.qr_code)&&(m.totp.qr_code=`data:image/svg+xml;utf-8,${m.totp.qr_code}`),this._returnResult({data:m,error:null}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?aE(e.webauthn.credential_response):iE(e.webauthn.credential_response)})}:{code:e.code}),{data:h,error:m}=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:d,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});return m?this._returnResult({data:null,error:m}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+h.expires_in},h)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",h),this._returnResult({data:h,error:m}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});if(d.error)return d;const{data:h}=d;if(h.type!=="webauthn")return{data:h,error:null};switch(h.webauthn.type){case"create":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:nE(h.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:sE(h.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:i}=await this._challenge({factorId:e.factorId});return i?this._returnResult({data:null,error:i}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:i}=await this.getUser();if(i)return{data:null,error:i};const l={all:[],phone:[],totp:[],webauthn:[]};for(const u of(e=s?.factors)!==null&&e!==void 0?e:[])l.all.push(u),u.status==="verified"&&l[u.factor_type].push(u);return{data:l,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,i,l,u;if(e)try{const{payload:S}=Rc(e);let E=null;S.aal&&(E=S.aal);let j=E;const{data:{user:_},error:N}=await this.getUser(e);if(N)return this._returnResult({data:null,error:N});((i=(s=_?.factors)===null||s===void 0?void 0:s.filter(A=>A.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(j="aal2");const C=S.amr||[];return{data:{currentLevel:E,nextLevel:j,currentAuthenticationMethods:C},error:null}}catch(S){if(Ne(S))return this._returnResult({data:null,error:S});throw S}const{data:{session:d},error:h}=await this.getSession();if(h)return this._returnResult({data:null,error:h});if(!d)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:m}=Rc(d.access_token);let g=null;m.aal&&(g=m.aal);let y=g;((u=(l=d.user.factors)===null||l===void 0?void 0:l.filter(S=>S.status==="verified"))!==null&&u!==void 0?u:[]).length>0&&(y="aal2");const w=m.amr||[];return{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:w},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?await Re(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:i.access_token,xform:u=>({data:u,error:null})}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _denyAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;return i?this._returnResult({data:null,error:i}):s?await Re(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new xn})})}catch(e){if(Ne(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?(await Re(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:i.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let i=s.keys.find(h=>h.kid===e);if(i)return i;const l=Date.now();if(i=this.jwks.keys.find(h=>h.kid===e),i&&this.jwks_cached_at+mT>l)return i;const{data:u,error:d}=await Re(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(d)throw d;return!u.keys||u.keys.length===0||(this.jwks=u,this.jwks_cached_at=l,i=u.keys.find(h=>h.kid===e),!i)?null:i}async getClaims(e,s={}){try{let i=e;if(!i){const{data:S,error:E}=await this.getSession();if(E||!S.session)return this._returnResult({data:null,error:E});i=S.session.access_token}const{header:l,payload:u,signature:d,raw:{header:h,payload:m}}=Rc(i);s?.allowExpired||zT(u.exp);const g=!l.alg||l.alg.startsWith("HS")||!l.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(l.kid,s?.keys?{keys:s.keys}:s?.jwks);if(!g){const{error:S}=await this.getUser(i);if(S)throw S;return{data:{claims:u,header:l,signature:d},error:null}}const y=LT(l.alg),x=await crypto.subtle.importKey("jwk",g,y,!0,["verify"]);if(!await crypto.subtle.verify(y,x,d,jT(`${h}.${m}`)))throw new Jf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}}Lo.nextInstanceID={};const mE=Lo,pE="2.97.0";let wo="";typeof Deno<"u"?wo="deno":typeof document<"u"?wo="web":typeof navigator<"u"&&navigator.product==="ReactNative"?wo="react-native":wo="node";const gE={"X-Client-Info":`supabase-js-${wo}/${pE}`},yE={headers:gE},vE={schema:"public"},xE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},bE={};function Uo(t){"@babel/helpers - typeof";return Uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Uo(t)}function wE(t,e){if(Uo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(Uo(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function SE(t){var e=wE(t,"string");return Uo(e)=="symbol"?e:e+""}function jE(t,e,s){return(e=SE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function i0(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,i)}return s}function yt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?i0(Object(s),!0).forEach(function(i){jE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):i0(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}const _E=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),NE=()=>Headers,TE=(t,e,s)=>{const i=_E(s),l=NE();return async(u,d)=>{var h;const m=(h=await e())!==null&&h!==void 0?h:t;let g=new l(d?.headers);return g.has("apikey")||g.set("apikey",t),g.has("Authorization")||g.set("Authorization",`Bearer ${m}`),i(u,yt(yt({},d),{},{headers:g}))}};function EE(t){return t.endsWith("/")?t:t+"/"}function kE(t,e){var s,i;const{db:l,auth:u,realtime:d,global:h}=t,{db:m,auth:g,realtime:y,global:x}=e,w={db:yt(yt({},m),l),auth:yt(yt({},g),u),realtime:yt(yt({},y),d),storage:{},global:yt(yt(yt({},x),h),{},{headers:yt(yt({},(s=x?.headers)!==null&&s!==void 0?s:{}),(i=h?.headers)!==null&&i!==void 0?i:{})}),accessToken:async()=>""};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}function CE(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(EE(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var AE=class extends mE{constructor(t){super(t)}},RE=class{constructor(t,e,s){var i,l;this.supabaseUrl=t,this.supabaseKey=e;const u=CE(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",u),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",u),this.storageUrl=new URL("storage/v1",u),this.functionsUrl=new URL("functions/v1",u);const d=`sb-${u.hostname.split(".")[0]}-auth-token`,h={db:vE,realtime:bE,auth:yt(yt({},xE),{},{storageKey:d}),global:yE},m=kE(s??{},h);if(this.storageKey=(i=m.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(l=m.global.headers)!==null&&l!==void 0?l:{},m.accessToken)this.accessToken=m.accessToken,this.auth=new Proxy({},{get:(y,x)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(x)} is not possible`)}});else{var g;this.auth=this._initSupabaseAuthClient((g=m.auth)!==null&&g!==void 0?g:{},this.headers,m.global.fetch)}this.fetch=TE(e,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(yt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new g2(new URL("rest/v1",u).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch,timeout:m.db.timeout,urlLengthLimit:m.db.urlLengthLimit}),this.storage=new cT(this.storageUrl.href,this.headers,this.fetch,s?.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new l2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,s;if(t.accessToken)return await t.accessToken();const{data:i}=await t.auth.getSession();return(e=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,storageKey:u,flowType:d,lock:h,debug:m,throwOnError:g},y,x){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new AE({url:this.authUrl.href,headers:yt(yt({},w),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,flowType:d,lock:h,debug:m,throwOnError:g,fetch:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new M2(this.realtimeUrl.href,yt(yt({},t),{},{params:yt(yt({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const zm=(t,e,s)=>new RE(t,e,s);function OE(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}OE()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function vw(t){var e,s,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(e=0;e<l;e++)t[e]&&(s=vw(t[e]))&&(i&&(i+=" "),i+=s)}else for(s in t)t[s]&&(i&&(i+=" "),i+=s);return i}function xw(){for(var t,e,s=0,i="",l=arguments.length;s<l;s++)(t=arguments[s])&&(e=vw(t))&&(i&&(i+=" "),i+=e);return i}const ME=(t,e)=>{const s=new Array(t.length+e.length);for(let i=0;i<t.length;i++)s[i]=t[i];for(let i=0;i<e.length;i++)s[t.length+i]=e[i];return s},DE=(t,e)=>({classGroupId:t,validator:e}),bw=(t=new Map,e=null,s)=>({nextPart:t,validators:e,classGroupId:s}),ru="-",r0=[],PE="arbitrary..",zE=t=>{const e=UE(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return LE(d);const h=d.split(ru),m=h[0]===""&&h.length>1?1:0;return ww(h,m,e)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=i[d],g=s[d];return m?g?ME(g,m):m:g||r0}return s[d]||r0}}},ww=(t,e,s)=>{if(t.length-e===0)return s.classGroupId;const l=t[e],u=s.nextPart.get(l);if(u){const g=ww(t,e+1,u);if(g)return g}const d=s.validators;if(d===null)return;const h=e===0?t.join(ru):t.slice(e).join(ru),m=d.length;for(let g=0;g<m;g++){const y=d[g];if(y.validator(h))return y.classGroupId}},LE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),s=e.indexOf(":"),i=e.slice(0,s);return i?PE+i:void 0})(),UE=t=>{const{theme:e,classGroups:s}=t;return BE(s,e)},BE=(t,e)=>{const s=bw();for(const i in t){const l=t[i];Lm(l,s,i,e)}return s},Lm=(t,e,s,i)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];VE(d,e,s,i)}},VE=(t,e,s,i)=>{if(typeof t=="string"){IE(t,e,s);return}if(typeof t=="function"){$E(t,e,s,i);return}qE(t,e,s,i)},IE=(t,e,s)=>{const i=t===""?e:Sw(e,t);i.classGroupId=s},$E=(t,e,s,i)=>{if(HE(t)){Lm(t(i),e,s,i);return}e.validators===null&&(e.validators=[]),e.validators.push(DE(s,t))},qE=(t,e,s,i)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];Lm(m,Sw(e,h),s,i)}},Sw=(t,e)=>{let s=t;const i=e.split(ru),l=i.length;for(let u=0;u<l;u++){const d=i[u];let h=s.nextPart.get(d);h||(h=bw(),s.nextPart.set(d,h)),s=h}return s},HE=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,GE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,s=Object.create(null),i=Object.create(null);const l=(u,d)=>{s[u]=d,e++,e>t&&(e=0,i=s,s=Object.create(null))};return{get(u){let d=s[u];if(d!==void 0)return d;if((d=i[u])!==void 0)return l(u,d),d},set(u,d){u in s?s[u]=d:l(u,d)}}},Qf="!",o0=":",FE=[],l0=(t,e,s,i,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:s,maybePostfixModifierPosition:i,isExternal:l}),KE=t=>{const{prefix:e,experimentalParseClassName:s}=t;let i=l=>{const u=[];let d=0,h=0,m=0,g;const y=l.length;for(let j=0;j<y;j++){const _=l[j];if(d===0&&h===0){if(_===o0){u.push(l.slice(m,j)),m=j+1;continue}if(_==="/"){g=j;continue}}_==="["?d++:_==="]"?d--:_==="("?h++:_===")"&&h--}const x=u.length===0?l:l.slice(m);let w=x,S=!1;x.endsWith(Qf)?(w=x.slice(0,-1),S=!0):x.startsWith(Qf)&&(w=x.slice(1),S=!0);const E=g&&g>m?g-m:void 0;return l0(u,S,w,E)};if(e){const l=e+o0,u=i;i=d=>d.startsWith(l)?u(d.slice(l.length)):l0(FE,!1,d,void 0,!0)}if(s){const l=i;i=u=>s({className:u,parseClassName:l})}return i},YE=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((s,i)=>{e.set(s,1e6+i)}),s=>{const i=[];let l=[];for(let u=0;u<s.length;u++){const d=s[u],h=d[0]==="[",m=e.has(d);h||m?(l.length>0&&(l.sort(),i.push(...l),l=[]),i.push(d)):l.push(d)}return l.length>0&&(l.sort(),i.push(...l)),i}},XE=t=>({cache:GE(t.cacheSize),parseClassName:KE(t),sortModifiers:YE(t),...zE(t)}),WE=/\s+/,JE=(t,e)=>{const{parseClassName:s,getClassGroupId:i,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],h=t.trim().split(WE);let m="";for(let g=h.length-1;g>=0;g-=1){const y=h[g],{isExternal:x,modifiers:w,hasImportantModifier:S,baseClassName:E,maybePostfixModifierPosition:j}=s(y);if(x){m=y+(m.length>0?" "+m:m);continue}let _=!!j,N=i(_?E.substring(0,j):E);if(!N){if(!_){m=y+(m.length>0?" "+m:m);continue}if(N=i(E),!N){m=y+(m.length>0?" "+m:m);continue}_=!1}const k=w.length===0?"":w.length===1?w[0]:u(w).join(":"),C=S?k+Qf:k,A=C+N;if(d.indexOf(A)>-1)continue;d.push(A);const D=l(N,_);for(let z=0;z<D.length;++z){const V=D[z];d.push(C+V)}m=y+(m.length>0?" "+m:m)}return m},QE=(...t)=>{let e=0,s,i,l="";for(;e<t.length;)(s=t[e++])&&(i=jw(s))&&(l&&(l+=" "),l+=i);return l},jw=t=>{if(typeof t=="string")return t;let e,s="";for(let i=0;i<t.length;i++)t[i]&&(e=jw(t[i]))&&(s&&(s+=" "),s+=e);return s},ZE=(t,...e)=>{let s,i,l,u;const d=m=>{const g=e.reduce((y,x)=>x(y),t());return s=XE(g),i=s.cache.get,l=s.cache.set,u=h,h(m)},h=m=>{const g=i(m);if(g)return g;const y=JE(m,s);return l(m,y),y};return u=d,(...m)=>u(QE(...m))},ek=[],At=t=>{const e=s=>s[t]||ek;return e.isThemeGetter=!0,e},_w=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Nw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,nk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sk=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ak=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ik=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>tk.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),ia=t=>!!t&&Number.isInteger(Number(t)),df=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Es=t=>nk.test(t),Tw=()=>!0,ok=t=>sk.test(t)&&!ak.test(t),Um=()=>!1,lk=t=>ik.test(t),ck=t=>rk.test(t),uk=t=>!xe(t)&&!we(t),dk=t=>ga(t,Cw,Um),xe=t=>_w.test(t),Ba=t=>ga(t,Aw,ok),c0=t=>ga(t,xk,Ue),hk=t=>ga(t,Ow,Tw),fk=t=>ga(t,Rw,Um),u0=t=>ga(t,Ew,Um),mk=t=>ga(t,kw,ck),Oc=t=>ga(t,Mw,lk),we=t=>Nw.test(t),vo=t=>ti(t,Aw),pk=t=>ti(t,Rw),d0=t=>ti(t,Ew),gk=t=>ti(t,Cw),yk=t=>ti(t,kw),Mc=t=>ti(t,Mw,!0),vk=t=>ti(t,Ow,!0),ga=(t,e,s)=>{const i=_w.exec(t);return i?i[1]?e(i[1]):s(i[2]):!1},ti=(t,e,s=!1)=>{const i=Nw.exec(t);return i?i[1]?e(i[1]):s:!1},Ew=t=>t==="position"||t==="percentage",kw=t=>t==="image"||t==="url",Cw=t=>t==="length"||t==="size"||t==="bg-size",Aw=t=>t==="length",xk=t=>t==="number",Rw=t=>t==="family-name",Ow=t=>t==="number"||t==="weight",Mw=t=>t==="shadow",bk=()=>{const t=At("color"),e=At("font"),s=At("text"),i=At("font-weight"),l=At("tracking"),u=At("leading"),d=At("breakpoint"),h=At("container"),m=At("spacing"),g=At("radius"),y=At("shadow"),x=At("inset-shadow"),w=At("text-shadow"),S=At("drop-shadow"),E=At("blur"),j=At("perspective"),_=At("aspect"),N=At("ease"),k=At("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...A(),we,xe],z=()=>["auto","hidden","clip","visible","scroll"],V=()=>["auto","contain","none"],R=()=>[we,xe,m],P=()=>[aa,"full","auto",...R()],Z=()=>[ia,"none","subgrid",we,xe],te=()=>["auto",{span:["full",ia,we,xe]},ia,we,xe],me=()=>[ia,"auto",we,xe],Ee=()=>["auto","min","max","fr",we,xe],ye=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_e=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...R()],Y=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],J=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...R()],pe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],se=()=>[t,we,xe],M=()=>[...A(),d0,u0,{position:[we,xe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",gk,dk,{size:[we,xe]}],ne=()=>[df,vo,Ba],oe=()=>["","none","full",g,we,xe],ue=()=>["",Ue,vo,Ba],q=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ue,df,d0,u0],ze=()=>["","none",E,we,xe],Be=()=>["none",Ue,we,xe],kt=()=>["none",Ue,we,xe],et=()=>[Ue,we,xe],le=()=>[aa,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[Tw],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[uk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Ue],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,xe,we,_]}],container:["container"],columns:[{columns:[Ue,xe,we,h]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:V()}],"overscroll-x":[{"overscroll-x":V()}],"overscroll-y":[{"overscroll-y":V()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[ia,"auto",we,xe]}],basis:[{basis:[aa,"full","auto",h,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,aa,"auto","initial","none",xe]}],grow:[{grow:["",Ue,we,xe]}],shrink:[{shrink:["",Ue,we,xe]}],order:[{order:[ia,"first","last","none",we,xe]}],"grid-cols":[{"grid-cols":Z()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":Z()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ee()}],"auto-rows":[{"auto-rows":Ee()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ye(),"normal"]}],"justify-items":[{"justify-items":[..._e(),"normal"]}],"justify-self":[{"justify-self":["auto",..._e()]}],"align-content":[{content:["normal",...ye()]}],"align-items":[{items:[..._e(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._e(),{baseline:["","last"]}]}],"place-content":[{"place-content":ye()}],"place-items":[{"place-items":[..._e(),"baseline"]}],"place-self":[{"place-self":["auto",..._e()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...pe()]}],"min-block-size":[{"min-block":["auto",...pe()]}],"max-block-size":[{"max-block":["none",...pe()]}],w:[{w:[h,"screen",...Y()]}],"min-w":[{"min-w":[h,"screen","none",...Y()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",s,vo,Ba]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,vk,hk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",df,xe]}],"font-family":[{font:[pk,fk,e]}],"font-features":[{"font-features":[xe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[l,we,xe]}],"line-clamp":[{"line-clamp":[Ue,"none",we,c0]}],leading:[{leading:[u,...R()]}],"list-image":[{"list-image":["none",we,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",we,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:se()}],"text-color":[{text:se()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",we,Ba]}],"text-decoration-color":[{decoration:se()}],"underline-offset":[{"underline-offset":[Ue,"auto",we,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",we,xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",we,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ia,we,xe],radial:["",we,xe],conic:[ia,we,xe]},yk,mk]}],"bg-color":[{bg:se()}],"gradient-from-pos":[{from:ne()}],"gradient-via-pos":[{via:ne()}],"gradient-to-pos":[{to:ne()}],"gradient-from":[{from:se()}],"gradient-via":[{via:se()}],"gradient-to":[{to:se()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:ue()}],"border-w-x":[{"border-x":ue()}],"border-w-y":[{"border-y":ue()}],"border-w-s":[{"border-s":ue()}],"border-w-e":[{"border-e":ue()}],"border-w-bs":[{"border-bs":ue()}],"border-w-be":[{"border-be":ue()}],"border-w-t":[{"border-t":ue()}],"border-w-r":[{"border-r":ue()}],"border-w-b":[{"border-b":ue()}],"border-w-l":[{"border-l":ue()}],"divide-x":[{"divide-x":ue()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ue()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:se()}],"border-color-x":[{"border-x":se()}],"border-color-y":[{"border-y":se()}],"border-color-s":[{"border-s":se()}],"border-color-e":[{"border-e":se()}],"border-color-bs":[{"border-bs":se()}],"border-color-be":[{"border-be":se()}],"border-color-t":[{"border-t":se()}],"border-color-r":[{"border-r":se()}],"border-color-b":[{"border-b":se()}],"border-color-l":[{"border-l":se()}],"divide-color":[{divide:se()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,we,xe]}],"outline-w":[{outline:["",Ue,vo,Ba]}],"outline-color":[{outline:se()}],shadow:[{shadow:["","none",y,Mc,Oc]}],"shadow-color":[{shadow:se()}],"inset-shadow":[{"inset-shadow":["none",x,Mc,Oc]}],"inset-shadow-color":[{"inset-shadow":se()}],"ring-w":[{ring:ue()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:se()}],"ring-offset-w":[{"ring-offset":[Ue,Ba]}],"ring-offset-color":[{"ring-offset":se()}],"inset-ring-w":[{"inset-ring":ue()}],"inset-ring-color":[{"inset-ring":se()}],"text-shadow":[{"text-shadow":["none",w,Mc,Oc]}],"text-shadow-color":[{"text-shadow":se()}],opacity:[{opacity:[Ue,we,xe]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":se()}],"mask-image-linear-to-color":[{"mask-linear-to":se()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":se()}],"mask-image-t-to-color":[{"mask-t-to":se()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":se()}],"mask-image-r-to-color":[{"mask-r-to":se()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":se()}],"mask-image-b-to-color":[{"mask-b-to":se()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":se()}],"mask-image-l-to-color":[{"mask-l-to":se()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":se()}],"mask-image-x-to-color":[{"mask-x-to":se()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":se()}],"mask-image-y-to-color":[{"mask-y-to":se()}],"mask-image-radial":[{"mask-radial":[we,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":se()}],"mask-image-radial-to-color":[{"mask-radial-to":se()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":A()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":se()}],"mask-image-conic-to-color":[{"mask-conic-to":se()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",we,xe]}],filter:[{filter:["","none",we,xe]}],blur:[{blur:ze()}],brightness:[{brightness:[Ue,we,xe]}],contrast:[{contrast:[Ue,we,xe]}],"drop-shadow":[{"drop-shadow":["","none",S,Mc,Oc]}],"drop-shadow-color":[{"drop-shadow":se()}],grayscale:[{grayscale:["",Ue,we,xe]}],"hue-rotate":[{"hue-rotate":[Ue,we,xe]}],invert:[{invert:["",Ue,we,xe]}],saturate:[{saturate:[Ue,we,xe]}],sepia:[{sepia:["",Ue,we,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",we,xe]}],"backdrop-blur":[{"backdrop-blur":ze()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,we,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,we,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,we,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,we,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ue,we,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,we,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,we,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,we,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",we,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",we,xe]}],ease:[{ease:["linear","initial",N,we,xe]}],delay:[{delay:[Ue,we,xe]}],animate:[{animate:["none",k,we,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,we,xe]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Be()}],"rotate-x":[{"rotate-x":Be()}],"rotate-y":[{"rotate-y":Be()}],"rotate-z":[{"rotate-z":Be()}],scale:[{scale:kt()}],"scale-x":[{"scale-x":kt()}],"scale-y":[{"scale-y":kt()}],"scale-z":[{"scale-z":kt()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[we,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:se()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:se()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",we,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",we,xe]}],fill:[{fill:["none",...se()]}],"stroke-w":[{stroke:[Ue,vo,Ba,c0]}],stroke:[{stroke:["none",...se()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},wk=ZE(bk);function ge(...t){return wk(xw(t))}const ht=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("rounded-xl border bg-card text-card-foreground shadow",t),...e}));ht.displayName="Card";const zt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex flex-col space-y-1.5 p-6",t),...e}));zt.displayName="CardHeader";const Lt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("font-semibold leading-none tracking-tight",t),...e}));Lt.displayName="CardTitle";const wn=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm text-muted-foreground",t),...e}));wn.displayName="CardDescription";const xt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("p-6 pt-0",t),...e}));xt.displayName="CardContent";const Tu=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex items-center p-6 pt-0",t),...e}));Tu.displayName="CardFooter";function ou({className:t}){return o.jsx("img",{src:"/folio-logo.svg",alt:"Folio Logo",className:ge("w-full h-full object-contain",t)})}const Dw=(...t)=>t.filter((e,s,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===s).join(" ").trim();const Sk=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const jk=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,i)=>i?i.toUpperCase():s.toLowerCase());const h0=t=>{const e=jk(t);return e.charAt(0).toUpperCase()+e.slice(1)};var _k={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nk=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Tk=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:i,className:l="",children:u,iconNode:d,...h},m)=>v.createElement("svg",{ref:m,..._k,width:e,height:e,stroke:t,strokeWidth:i?Number(s)*24/Number(e):s,className:Dw("lucide",l),...!u&&!Nk(h)&&{"aria-hidden":"true"},...h},[...d.map(([g,y])=>v.createElement(g,y)),...Array.isArray(u)?u:[u]]));const he=(t,e)=>{const s=v.forwardRef(({className:i,...l},u)=>v.createElement(Tk,{ref:u,iconNode:e,className:Dw(`lucide-${Sk(h0(t))}`,`lucide-${t}`,i),...l}));return s.displayName=h0(t),s};const Ek=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ur=he("activity",Ek);const kk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ck=he("arrow-right",kk);const Ak=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Rk=he("book-open",Ak);const Ok=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Zf=he("bot",Ok);const Mk=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Pw=he("brain",Mk);const Dk=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Pk=he("building-2",Dk);const zk=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],zw=he("calendar",zk);const Lk=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Uk=he("camera",Lk);const Bk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],as=he("check",Bk);const Vk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bo=he("chevron-down",Vk);const Ik=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jo=he("chevron-left",Ik);const $k=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],dr=he("chevron-right",$k);const qk=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],lu=he("chevron-up",qk);const Hk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Sn=he("circle-alert",Hk);const Gk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fk=he("circle-check-big",Gk);const Kk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],os=he("circle-check",Kk);const Yk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Lw=he("circle-x",Yk);const Xk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Qo=he("clock",Xk);const Wk=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],f0=he("cloud",Wk);const Jk=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Qk=he("copy",Jk);const Zk=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Bm=he("cpu",Zk);const eC=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Eu=he("database",eC);const tC=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Uw=he("external-link",tC);const nC=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],sC=he("eye-off",nC);const aC=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],iC=he("eye",aC);const rC=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],oC=he("file-digit",rC);const lC=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Vm=he("file-text",lC);const cC=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Bw=he("funnel",cC);const uC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],dC=he("globe",uC);const hC=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],fC=he("hard-drive",hC);const mC=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],pC=he("history",mC);const gC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Im=he("info",gC);const yC=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Zo=he("key",yC);const vC=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],xC=he("layers",vC);const bC=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],m0=he("layout-dashboard",bC);const wC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],rt=he("loader-circle",wC);const SC=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Vw=he("log-in",SC);const jC=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Iw=he("log-out",jC);const _C=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Vo=he("mail",_C);const NC=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],cu=he("message-square",NC);const TC=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],$w=he("minimize-2",TC);const EC=[["path",{d:"M5 12h14",key:"1ays0h"}]],em=he("minus",EC);const kC=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],CC=he("moon",kC);const AC=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],RC=he("package",AC);const OC=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],qw=he("play",OC);const MC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wa=he("plus",MC);const DC=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PC=he("refresh-ccw",DC);const zC=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ma=he("refresh-cw",zC);const LC=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],UC=he("rocket",LC);const BC=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],VC=he("save",BC);const IC=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Hw=he("scroll-text",IC);const $C=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qC=he("search",$C);const HC=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],GC=he("send",HC);const FC=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],KC=he("server",FC);const YC=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],$m=he("settings-2",YC);const XC=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],WC=he("settings",XC);const JC=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],p0=he("share-2",JC);const QC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],uu=he("shield-alert",QC);const ZC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ya=he("shield-check",ZC);const eA=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Cs=he("sparkles",eA);const tA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],nA=he("sun",tA);const sA=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],du=he("tag",sA);const aA=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Io=he("terminal",aA);const iA=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],rA=he("test-tube",iA);const oA=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],lA=he("toggle-left",oA);const cA=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],uA=he("toggle-right",cA);const dA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],el=he("trash-2",dA);const hA=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gw=he("triangle-alert",hA);const fA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tm=he("upload",fA);const mA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],pA=he("user-plus",mA);const gA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ku=he("user",gA);const yA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],nm=he("volume-2",yA);const vA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Fw=he("volume-x",vA);const xA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zn=he("x",xA);const bA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hu=he("zap",bA),Cu="folio_supabase_config";function g0(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.url=="string"&&typeof e.anonKey=="string"&&e.url.startsWith("http")&&e.anonKey.length>20&&!e.url.includes("placeholder.supabase.co")}function $o(){try{const e=localStorage.getItem(Cu);if(e){const s=JSON.parse(e);if(g0(s))return s}}catch{}const t={url:void 0,anonKey:void 0};return g0(t)?t:null}function hf(t){localStorage.setItem(Cu,JSON.stringify(t))}function wA(){localStorage.removeItem(Cu)}async function SA(t,e){if(!t.startsWith("http://")&&!t.startsWith("https://"))return{valid:!1,error:"Invalid URL format"};const s=e.startsWith("eyJ"),i=e.startsWith("sb_publishable_");if(!s&&!i)return{valid:!1,error:"Invalid anon key format"};if(i)return{valid:!0};const l=new AbortController,u=setTimeout(()=>l.abort("Validation timeout"),12e3);try{const d=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`},signal:l.signal});return d.ok?(clearTimeout(u),{valid:!0}):(clearTimeout(u),{valid:!1,error:`Connection failed (${d.status})`})}catch(d){return clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?{valid:!1,error:"Connection validation timed out (12s). Check project URL/key and network."}:{valid:!1,error:d instanceof Error?d.message:"Connection failed"}}}function jA(){return localStorage.getItem(Cu)?"ui":"none"}let Dc=null;function un(){const t=$o();return t?(Dc||(Dc=zm(t.url,t.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}})),Dc):(Dc=null,null)}function ff(){const t=$o(),e=t?`${t.url}/functions/v1`:"",s=t?.anonKey??"",u=window.location.port==="5173"?void 0||"http://localhost:3006":window.location.origin;return{edgeFunctionsUrl:e,expressApiUrl:u,anonKey:s}}class _A{edgeFunctionsUrl;expressApiUrl;anonKey;constructor(){const e=ff();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}async request(e,s,i={}){const{auth:l=!1,token:u,...d}=i,h={"Content-Type":"application/json",...d.headers||{}};l&&u&&(h.Authorization=`Bearer ${u}`);try{const m=await fetch(`${e}${s}`,{...d,headers:h}),g=await m.json().catch(()=>({}));return m.ok?{data:g}:{error:{code:g?.error?.code||"API_ERROR",message:g?.error?.message||g?.error||`Request failed (${m.status})`}}}catch(m){return{error:{code:"NETWORK_ERROR",message:m instanceof Error?m.message:"Network error"}}}}edgeRequest(e,s={}){const i={...s.headers||{},apikey:this.anonKey};return this.request(this.edgeFunctionsUrl,e,{...s,headers:i})}expressRequest(e,s={}){const i=ff(),l={...s.headers||{},"X-Supabase-Url":i.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":i.anonKey};return this.request(this.expressApiUrl,e,{...s,headers:l})}get(e,s={}){return this.expressRequest(e,{method:"GET",...s,auth:!0})}post(e,s,i={}){return this.expressRequest(e,{method:"POST",body:s?JSON.stringify(s):void 0,...i,auth:!0})}getChatSessions(e){return this.expressRequest("/api/chat/sessions",{method:"GET",auth:!!e,token:e})}getDashboardStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}createChatSession(e){return this.expressRequest("/api/chat/sessions",{method:"POST",auth:!!e,token:e})}getChatMessages(e,s){return this.expressRequest(`/api/chat/sessions/${e}/messages`,{method:"GET",auth:!!s,token:s})}sendChatMessage(e,s){return this.expressRequest("/api/chat/message",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getHealth(){return this.expressRequest("/api/health",{method:"GET"})}testSupabase(e,s){return this.expressRequest("/api/setup/test-supabase",{method:"POST",body:JSON.stringify({url:e,anonKey:s})})}dispatchProcessingJob(e,s){return this.expressRequest("/api/processing/dispatch",{method:"POST",auth:!!s,token:s,body:JSON.stringify({source_type:"manual",payload:e})})}getSettings(e){return this.expressRequest("/api/settings",{method:"GET",auth:!!e,token:e})}updateSettings(e,s){return this.expressRequest("/api/settings",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getAccounts(e){return this.expressRequest("/api/accounts",{method:"GET",auth:!!e,token:e})}disconnectAccount(e,s){return this.expressRequest("/api/accounts/disconnect",{method:"POST",auth:!!s,token:s,body:JSON.stringify({accountId:e})})}getRules(e){return this.expressRequest("/api/rules",{method:"GET",auth:!!e,token:e})}createRule(e,s){return this.expressRequest("/api/rules",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}updateRule(e,s,i){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}deleteRule(e,s){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE",auth:!!s,token:s})}toggleRule(e,s){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST",auth:!!s,token:s})}getStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}getProfile(e){return this.edgeRequest("/api-v1-profile",{method:"GET",auth:!!e,token:e})}updateProfile(e,s){return this.edgeRequest("/api-v1-profile",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getChatProviders(e){return this.expressRequest("/api/sdk/providers/chat",{method:"GET",auth:!!e,token:e})}getEmbedProviders(e){return this.expressRequest("/api/sdk/providers/embed",{method:"GET",auth:!!e,token:e})}testLlm(e,s){return this.expressRequest("/api/sdk/test-llm",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getGmailAuthUrl(e,s,i){return this.expressRequest("/api/accounts/gmail/auth-url",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,clientSecret:s})})}connectGmail(e,s,i,l){return this.expressRequest("/api/accounts/gmail/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}getGoogleDriveAuthUrl(e,s){return this.expressRequest("/api/accounts/google-drive/auth-url",{method:"POST",auth:!!s,token:s,body:JSON.stringify({clientId:e})})}connectGoogleDrive(e,s,i,l){return this.expressRequest("/api/accounts/google-drive/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}startMicrosoftDeviceFlow(e,s,i){return this.expressRequest("/api/accounts/microsoft/device-flow",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,tenantId:s})})}pollMicrosoftDeviceCode(e,s,i,l){return this.expressRequest("/api/accounts/microsoft/poll",{method:"POST",auth:!!l,token:l,body:JSON.stringify({deviceCode:e,clientId:s,tenantId:i})})}connectImap(e,s){return this.expressRequest("/api/accounts/imap/connect",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}setup(e){return this.edgeRequest("/setup",{method:"POST",body:JSON.stringify(e)})}getPolicies(e){return this.expressRequest("/api/policies",{auth:!!e,token:e})}savePolicy(e,s){return this.expressRequest("/api/policies",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}deletePolicy(e,s){return this.expressRequest(`/api/policies/${e}`,{method:"DELETE",auth:!!s,token:s})}patchPolicy(e,s,i){return this.expressRequest(`/api/policies/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}reloadPolicies(e){return this.expressRequest("/api/policies/reload",{method:"POST",auth:!!e,token:e})}synthesizePolicy(e,s){return this.expressRequest("/api/policies/synthesize",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getSDKChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}getIngestions(e={},s){const i=new URLSearchParams;e.page&&i.set("page",String(e.page)),e.pageSize&&i.set("pageSize",String(e.pageSize)),e.q&&i.set("q",e.q);const l=i.toString()?`?${i}`:"";return this.expressRequest(`/api/ingestions${l}`,{auth:!!s,token:s})}uploadDocument(e,s){const i=new FormData;i.append("file",e);const l=ff(),u={"X-Supabase-Url":l.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":l.anonKey};return s&&(u.Authorization=`Bearer ${s}`),fetch(`${l.expressApiUrl}/api/ingestions/upload`,{method:"POST",headers:u,body:i}).then(d=>d.json())}rerunIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/rerun`,{method:"POST",auth:!!s,token:s})}matchIngestionToPolicy(e,s,i){const l=s.learn!==!1,u=s.rerun!==!1;return this.expressRequest(`/api/ingestions/${e}/match`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,learn:l,rerun:u,allow_side_effects:s.allowSideEffects===!0})})}suggestPolicyRefinement(e,s,i){return this.expressRequest(`/api/ingestions/${e}/refine-policy`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,provider:s.provider,model:s.model})})}deleteIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}`,{method:"DELETE",auth:!!s,token:s})}updateIngestionTags(e,s,i){return this.expressRequest(`/api/ingestions/${e}/tags`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify({tags:s})})}summarizeIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/summarize`,{method:"POST",auth:!!s,token:s})}getBaselineConfig(e){return this.expressRequest("/api/baseline-config",{auth:!!e,token:e})}getBaselineConfigHistory(e){return this.expressRequest("/api/baseline-config/history",{auth:!!e,token:e})}saveBaselineConfig(e,s){return this.expressRequest("/api/baseline-config",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}activateBaselineConfig(e,s){return this.expressRequest(`/api/baseline-config/${e}/activate`,{method:"POST",auth:!!s,token:s})}suggestBaselineConfig(e,s){return this.expressRequest("/api/baseline-config/suggest",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}}const Te=new _A;let ns=[],sm=new Set;function am(){sm.forEach(t=>t())}const ce={success:(t,e)=>Pc("success",t,e),error:(t,e)=>Pc("error",t,e),info:(t,e)=>Pc("info",t,e),warning:(t,e)=>Pc("warning",t,e)};function Pc(t,e,s=5e3){const i=ns.findIndex(u=>u.message===e&&u.type===t);if(i!==-1){const u=ns[i];ns=[...ns],ns[i]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},am();return}const l=Math.random().toString(36).substr(2,9);ns=[...ns,{id:l,type:t,message:e,duration:s,count:1,lastUpdated:Date.now()}],am(),s>0&&setTimeout(()=>Kw(l),s)}function Kw(t){ns=ns.filter(e=>e.id!==t),am()}function NA(){const[,t]=v.useState(0);return v.useEffect(()=>{const e=()=>t(s=>s+1);return sm.add(e),()=>{sm.delete(e)}},[]),ns}const TA={success:Fk,error:Sn,info:Im,warning:Gw},EA={success:"bg-emerald-500/10 border-emerald-500/20 text-emerald-600 dark:text-emerald-400",error:"bg-destructive/10 border-destructive/20 text-destructive",info:"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400",warning:"bg-yellow-500/10 border-yellow-500/20 text-yellow-600 dark:text-yellow-400"};function kA({toast:t}){const e=TA[t.type];return o.jsxs("div",{className:ge("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",EA[t.type]),children:[o.jsxs("div",{className:"relative",children:[o.jsx(e,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.count&&t.count>1&&o.jsx("span",{className:"absolute -top-2 -right-2 bg-primary text-primary-foreground text-[10px] font-bold px-1.5 rounded-full border border-background scale-90 animate-in zoom-in duration-200",children:t.count})]}),o.jsx("p",{className:"text-sm flex-1",children:t.message}),o.jsx("button",{onClick:()=>Kw(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})}function CA(){const t=NA();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(kA,{toast:e},e.id))})}function AA({configSnapshot:t,configSource:e,setActivePage:s}){const[i,l]=v.useState(null),[u,d]=v.useState(!0),[h,m]=v.useState(!1),[g,y]=v.useState(!1),x=v.useRef(null),w=v.useCallback(async()=>{d(!0);try{const j=un();if(!j)return;const{data:_}=await j.auth.getSession(),N=_.session?.access_token??null;if(!N)return;const k=await Te.getDashboardStats(N);k.data?.success&&l(k.data.stats)}catch(j){console.error("Failed to fetch dashboard stats",j)}finally{d(!1)}},[]);v.useEffect(()=>{w()},[w]);const S=async j=>{const _=Array.from(j);if(_.length){s("funnel"),y(!0);try{const N=un();if(!N)return;const{data:k}=await N.auth.getSession(),C=k.session?.access_token??null;if(!C)return;for(const A of _){ce.info(`Ingesting ${A.name}…`);const D=await Te.uploadDocument?.(A,C);if(D?.success)if(D.ingestion?.status==="duplicate"){const z=D.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${A.name} is a duplicate of "${z}" — skipped.`)}else ce.success(`${A.name} → ${D.ingestion?.status}`);else ce.error(`Failed to ingest ${A.name}`)}await w()}finally{y(!1)}}},E=j=>{j.preventDefault(),m(!1),S(j.dataTransfer.files)};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-12 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsxs("h2",{className:"text-4xl font-black tracking-tight flex items-center justify-center gap-3",children:[o.jsx(ou,{className:"w-10 h-10 animate-pulse"}),"Command Center"]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-2xl mx-auto",children:"Central intelligence hub for document ingestion, routing, and synthetic knowledge."})]}),o.jsxs("div",{className:"w-full space-y-10",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zc,{title:"Documents Ingested",value:i?.totalDocuments,icon:o.jsx(Vm,{className:"w-5 h-5 text-blue-500"}),isLoading:u,colorClass:"bg-blue-500/10"}),o.jsx(zc,{title:"Active Policies",value:i?.activePolicies,icon:o.jsx(p0,{className:"w-5 h-5 text-emerald-500"}),isLoading:u,colorClass:"bg-emerald-500/10"}),o.jsx(zc,{title:"Knowledge Chunks",value:i?.ragChunks,icon:o.jsx(Eu,{className:"w-5 h-5 text-purple-500"}),isLoading:u,colorClass:"bg-purple-500/10"}),o.jsx(zc,{title:"Automation Runs",value:i?.automationRuns,icon:o.jsx(ur,{className:"w-5 h-5 text-amber-500"}),isLoading:u,colorClass:"bg-amber-500/10"})]}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs("div",{onDragOver:j=>{j.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:E,onClick:()=>x.current?.click(),className:ge("h-full rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-4 py-16",h?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:j=>j.target.files&&S(j.target.files)}),g?o.jsx(rt,{className:"w-12 h-12 animate-spin text-primary"}):o.jsx(tm,{className:ge("w-12 h-12 transition-colors",h?"text-primary":"text-muted-foreground/50")}),o.jsxs("div",{className:"text-center space-y-1",children:[o.jsx("p",{className:"text-lg font-medium text-foreground",children:h?"Drop to ingest...":"Drag & drop files to ingest"}),o.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Supports .pdf, .docx, .md, .txt (up to 20MB)"})]})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("chat"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-500/10 flex items-center justify-center mb-4",children:o.jsx(cu,{className:"w-6 h-6 text-indigo-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Chat with Data"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions against your vectorized knowledge base."})]}),o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("policies"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/10 flex items-center justify-center mb-4",children:o.jsx(p0,{className:"w-6 h-6 text-orange-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Create Policy"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a new routing and automation contract."})]})]})]})]})]})}function zc({title:t,value:e,icon:s,isLoading:i,colorClass:l}){return o.jsx(ht,{className:"shadow-sm",children:o.jsxs(xt,{className:"p-6",children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsx("div",{className:ge("w-10 h-10 rounded-xl flex items-center justify-center",l),children:s})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:t}),i?o.jsx("div",{className:"h-8 w-16 bg-muted animate-pulse rounded-md"}):o.jsx("p",{className:"text-3xl font-black",children:e!==void 0?e.toLocaleString():"0"})]})]})})}function y0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Au(...t){return e=>{let s=!1;const i=t.map(l=>{const u=y0(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<i.length;l++){const u=i[l];typeof u=="function"?u():y0(t[l],null)}}}}function ni(...t){return v.useCallback(Au(...t),t)}var RA=Symbol.for("react.lazy"),fu=Mm[" use ".trim().toString()];function OA(t){return typeof t=="object"&&t!==null&&"then"in t}function Yw(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===RA&&"_payload"in t&&OA(t._payload)}function Xw(t){const e=DA(t),s=v.forwardRef((i,l)=>{let{children:u,...d}=i;Yw(u)&&typeof fu=="function"&&(u=fu(u._payload));const h=v.Children.toArray(u),m=h.find(zA);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}var MA=Xw("Slot");function DA(t){const e=v.forwardRef((s,i)=>{let{children:l,...u}=s;if(Yw(l)&&typeof fu=="function"&&(l=fu(l._payload)),v.isValidElement(l)){const d=UA(l),h=LA(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var PA=Symbol("radix.slottable");function zA(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===PA}function LA(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function UA(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}const v0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,x0=xw,qm=(t,e)=>s=>{var i;if(e?.variants==null)return x0(t,s?.class,s?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(g=>{const y=s?.[g],x=u?.[g];if(y===null)return null;const w=v0(y)||v0(x);return l[g][w]}),h=s&&Object.entries(s).reduce((g,y)=>{let[x,w]=y;return w===void 0||(g[x]=w),g},{}),m=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((g,y)=>{let{class:x,className:w,...S}=y;return Object.entries(S).every(E=>{let[j,_]=E;return Array.isArray(_)?_.includes({...u,...h}[j]):{...u,...h}[j]===_})?[...g,x,w]:g},[]);return x0(t,d,m,s?.class,s?.className)},BA=qm("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ae=v.forwardRef(({className:t,variant:e,size:s,asChild:i=!1,...l},u)=>{const d=i?MA:"button";return o.jsx(d,{className:ge(BA({variant:e,size:s,className:t})),ref:u,...l})});ae.displayName="Button";const je=v.forwardRef(({className:t,type:e,...s},i)=>o.jsx("input",{type:e,className:ge("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:i,...s}));je.displayName="Input";var Ww=tw();const VA=Zb(Ww);var IA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$A=IA.reduce((t,e)=>{const s=Xw(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{}),qA="Label",Jw=v.forwardRef((t,e)=>o.jsx($A.label,{...t,ref:e,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Jw.displayName=qA;var HA=Jw;function Je({className:t,...e}){return o.jsx(HA,{"data-slot":"label",className:ge("flex items-center gap-2 text-sm leading-none font-medium select-none text-muted-foreground group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const GA=qm("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pt({className:t,variant:e,...s}){return o.jsx("div",{className:ge(GA({variant:e}),t),...s})}const FA=qm("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),jn=v.forwardRef(({className:t,variant:e,...s},i)=>o.jsx("div",{ref:i,role:"alert",className:ge(FA({variant:e}),t),...s}));jn.displayName="Alert";const Hm=v.forwardRef(({className:t,...e},s)=>o.jsx("h5",{ref:s,className:ge("mb-1 font-medium leading-none tracking-tight",t),...e}));Hm.displayName="AlertTitle";const _n=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm [&_p]:leading-relaxed",t),...e}));_n.displayName="AlertDescription";function KA({supabase:t,initStatus:e,sessionStatus:s,sessionEmail:i,onRefresh:l}){const[u,d]=v.useState(""),[h,m]=v.useState(""),[g,y]=v.useState(""),[x,w]=v.useState(""),[S,E]=v.useState(!1),[j,_]=v.useState(null),N=e==="empty";async function k(){E(!0),_(null);const{error:z}=await t.auth.signInWithPassword({email:u,password:h});z?_(z.message):l(),E(!1)}async function C(){E(!0),_(null);try{const z=await Te.setup({email:u,password:h,first_name:g,last_name:x});if(z.error)throw new Error(typeof z.error=="string"?z.error:z.error.message);const{error:V}=await t.auth.signInWithPassword({email:u,password:h});if(V)throw V;l()}catch(z){_(z.message||"Failed to initialize foundation.")}finally{E(!1)}}async function A(){E(!0),_(null);const{error:z}=await t.auth.signUp({email:u,password:h,options:{data:{first_name:g,last_name:x}}});z?_(z.message):l(),E(!1)}async function D(){E(!0),await t.auth.signOut(),l(),E(!1)}return s==="authenticated"?o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-primary/5 border border-primary/10",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary flex items-center justify-center text-primary-foreground",children:o.jsx(ku,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground leading-none mb-1",children:"Authenticated as"}),o.jsx("p",{className:"text-sm font-medium truncate",children:i})]})]}),e==="missing_view"&&o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20",children:[o.jsx(uu,{className:"w-4 h-4"}),o.jsx(_n,{className:"text-xs",children:"Database views missing. Foundation may be corrupted."})]}),o.jsxs(ae,{variant:"outline",className:"w-full h-11 hover:bg-destructive hover:text-destructive-reveal group transition-all duration-300",onClick:D,disabled:S,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Iw,{className:"w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-500"}),"Logout Protocol"]})]}):o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"grid gap-4",children:[N&&o.jsxs("div",{className:"grid grid-cols-2 gap-4 animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-firstname",children:"First Name"}),o.jsx(je,{id:"auth-firstname",placeholder:"Agent",value:g,onChange:z=>y(z.target.value),className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-lastname",children:"Last Name"}),o.jsx(je,{id:"auth-lastname",placeholder:"Zero",value:x,onChange:z=>w(z.target.value),className:"h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-email",children:"Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx(Vo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-email",type:"email",placeholder:"admin@example.com",value:u,onChange:z=>d(z.target.value),className:"pl-9 h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-password",children:"Security Key"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-password",type:"password",placeholder:"••••••••",value:h,onChange:z=>m(z.target.value),className:"pl-9 h-10",autoComplete:N?"new-password":"current-password"})]})]})]}),j&&o.jsx(jn,{variant:"destructive",className:"py-2 px-3",children:o.jsx(_n,{className:"text-[11px] leading-relaxed italic",children:j})}),o.jsx("div",{className:"pt-2",children:N?o.jsxs(ae,{className:"w-full h-11 shadow-lg shadow-primary/20",onClick:C,disabled:S||!u||!h||!g,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(ya,{className:"w-4 h-4 mr-2"}),"Initialize Primary Admin"]}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs(ae,{className:"h-10",onClick:k,disabled:S||!u||!h,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Vw,{className:"w-4 h-4 mr-2"}),"Login"]}),o.jsxs(ae,{variant:"secondary",className:"h-10",onClick:A,disabled:S||!u||!h,children:[o.jsx(pA,{className:"w-4 h-4 mr-2"}),"Enroll"]})]})}),o.jsx("p",{className:"text-[10px] text-center text-muted-foreground uppercase tracking-widest font-bold opacity-50 pt-2",children:N?"Foundation Assembly Phase":"Foundation Access Required"})]})}const ha="0.1.8",YA="20260228000001";async function XA(t,e){const s=Promise.resolve(t);let i=null;const l=new Promise((u,d)=>{i=setTimeout(()=>{d(new Error(`Operation timed out after ${e}ms`))},e)});try{return await Promise.race([s,l])}finally{i&&clearTimeout(i)}}async function WA(t){try{const{data:e,error:s}=await XA(t.rpc("get_latest_migration_timestamp"),12e3);if(s)return s.code==="42883"?{latestMigrationTimestamp:"0"}:{latestMigrationTimestamp:null};const i=e??null;return i&&i>="29990000000000"?{latestMigrationTimestamp:null}:{latestMigrationTimestamp:i}}catch{return{latestMigrationTimestamp:null}}}async function Qw(t){const e=await WA(t);return!e.latestMigrationTimestamp||e.latestMigrationTimestamp.trim()===""?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database migration state unknown."}:YA>e.latestMigrationTimestamp?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:`Database is behind (${e.latestMigrationTimestamp}).`}:{needsMigration:!1,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database schema is up-to-date."}}function JA({supabase:t,sessionEmail:e,sessionStatus:s,initStatus:i,configSnapshot:l,configSource:u,onRefresh:d,onLaunchSetup:h,onResetSetup:m}){const[g,y]=v.useState("profile"),[x,w]=v.useState(null),[S,E]=v.useState(!1);async function j(){if(!t)return;E(!0);const{data:{user:k}}=await t.auth.getUser();if(k){const{data:C}=await t.from("profiles").select("*").eq("id",k.id).single();C&&w(C)}E(!1)}v.useEffect(()=>{s==="authenticated"&&t&&j()},[s,t]);const _=[{id:"profile",label:"Profile",icon:ku},{id:"security",label:"Security",icon:ya},{id:"supabase",label:"Supabase",icon:Eu}];async function N(){t&&(await t.auth.signOut(),d())}return o.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-4xl font-black tracking-tight",children:"Account Settings"}),o.jsx("p",{className:"text-muted-foreground text-lg",children:"Manage your profile and foundational preferences."})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-12 items-start",children:[o.jsxs("aside",{className:"w-full md:w-72 flex flex-col gap-8 shrink-0",children:[o.jsx("nav",{className:"space-y-1",children:_.map(k=>{const C=k.icon,A=g===k.id;return o.jsxs("button",{onClick:()=>y(k.id),className:ge("w-full flex items-center gap-3 px-4 py-3 text-sm font-bold rounded-xl transition-all duration-300",A?"bg-foreground text-background shadow-lg shadow-foreground/10":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(C,{className:ge("w-5 h-5",A?"text-background":"text-muted-foreground/60")}),k.label]},k.id)})}),o.jsxs("div",{className:"pt-8 border-t space-y-6",children:[o.jsxs("button",{onClick:N,className:"group w-full flex items-center gap-3 px-4 py-2 text-sm font-bold rounded-xl transition-all duration-300 text-destructive hover:bg-destructive/10",children:[o.jsx(Iw,{className:"w-5 h-5 transition-transform group-hover:translate-x-1"}),"Logout"]}),o.jsxs("div",{className:"px-4",children:[o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/40 uppercase tracking-widest mb-1",children:"Version"}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/60",children:["v",ha]})]})]})]}),o.jsxs("div",{className:"flex-1 w-full animate-in slide-in-from-right-4 duration-500",children:[g==="profile"&&o.jsx(QA,{sessionEmail:e,sessionStatus:s,supabase:t,initStatus:i,profile:x,onProfileUpdate:j,onRefresh:d,isLoading:S}),g==="security"&&o.jsx(ZA,{supabase:t}),g==="supabase"&&o.jsx(eR,{configSnapshot:l,configSource:u,onLaunchSetup:h,onResetSetup:m})]})]})]})}function QA({sessionEmail:t,sessionStatus:e,supabase:s,initStatus:i,profile:l,onProfileUpdate:u,onRefresh:d,isLoading:h}){const[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!0),[E,j]=v.useState(!1),[_,N]=v.useState(!1);v.useEffect(()=>{l&&(g(l.first_name||""),x(l.last_name||""))},[l]);const k=async()=>{if(!s||!l)return;j(!0);const{error:A}=await s.from("profiles").update({first_name:m,last_name:y}).eq("id",l.id);A||u(),j(!1)},C=async A=>{const D=A.target.files?.[0];if(!(!D||!s||!l)){N(!0);try{const z=D.name.split(".").pop(),V=`${l.id}/${Math.random()}.${z}`,{error:R}=await s.storage.from("avatars").upload(V,D);if(R)throw R;const{data:{publicUrl:P}}=s.storage.from("avatars").getPublicUrl(V);await s.from("profiles").update({avatar_url:P}).eq("id",l.id),u()}catch(z){console.error("Upload error:",z)}finally{N(!1)}}};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Profile Information"}),o.jsx(wn,{className:"text-base",children:"Update your personal foundation details."})]}),o.jsx(xt,{className:"p-8 space-y-10",children:h?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(rt,{className:"w-8 h-8 animate-spin text-primary"})}):e==="authenticated"?o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-8",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-32 h-32 rounded-full bg-primary/10 border-4 border-background shadow-2xl overflow-hidden flex items-center justify-center",children:l?.avatar_url?o.jsx("img",{src:l.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):t?o.jsx("span",{className:"text-4xl font-black text-primary",children:t.charAt(0).toUpperCase()}):o.jsx(ku,{className:"w-12 h-12 text-primary/40"})}),o.jsxs("label",{className:"absolute bottom-1 right-1 h-10 w-10 rounded-full bg-background border shadow-lg flex items-center justify-center hover:scale-110 transition-transform cursor-pointer",children:[_?o.jsx(rt,{className:"w-4 h-4 animate-spin text-muted-foreground"}):o.jsx(Uk,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:C,disabled:_})]})]}),o.jsxs("div",{className:"flex-1 w-full grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"firstName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{id:"firstName",placeholder:"Trung",value:m,onChange:A=>g(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"lastName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{id:"lastName",placeholder:"Le",value:y,onChange:A=>x(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[o.jsx(Je,{htmlFor:"email",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Address"}),o.jsx(je,{id:"email",value:t||"",disabled:!0,className:"h-12 rounded-xl bg-muted/40 border-border/40 opacity-70 cursor-not-allowed"}),o.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-bold ml-1",children:"This is your login email and cannot be changed."})]})]})]}),o.jsxs("div",{className:"pt-8 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-base font-bold",children:"Sound & Haptic Feedback"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Play chimes and haptic pulses for system events."})]}),o.jsxs(ae,{variant:w?"default":"outline",className:ge("h-11 px-6 rounded-xl font-bold transition-all",w?"shadow-lg shadow-primary/20":""),onClick:()=>S(!w),children:[w?o.jsx(nm,{className:"w-4 h-4 mr-2"}):o.jsx(Fw,{className:"w-4 h-4 mr-2"}),w?"Enabled":"Disabled"]})]})]}):o.jsxs("div",{className:"py-8",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4 mb-6",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(ya,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold",children:"Authentication Gateway"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Access your foundational profile."})]})]}),s&&o.jsx(KA,{supabase:s,initStatus:i,sessionStatus:e,sessionEmail:t,onRefresh:d})]})}),e==="authenticated"&&!h&&o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:k,disabled:E,children:[E?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(VC,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}function ZA({supabase:t}){const[e,s]=v.useState(""),[i,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),g=async()=>{if(!t)return;if(e!==i){m({type:"error",msg:"Passwords do not match."});return}if(e.length<8){m({type:"error",msg:"Password must be at least 8 characters."});return}d(!0),m(null);const{error:y}=await t.auth.updateUser({password:e});y?m({type:"error",msg:y.message}):(m({type:"success",msg:"Password updated successfully."}),s(""),l("")),d(!1)};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Security Protocol"}),o.jsx(wn,{className:"text-base",children:"Manage your foundation credentials and access keys."})]}),o.jsxs(xt,{className:"p-8 space-y-8",children:[h&&o.jsxs(jn,{variant:h.type==="error"?"destructive":"default",className:ge("animate-in fade-in slide-in-from-top-2 duration-300",h.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[h.type==="success"?o.jsx(os,{className:"h-4 w-4"}):o.jsx(uu,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm font-bold",children:h.msg})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"newPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"New Password"}),o.jsx(je,{id:"newPass",type:"password",placeholder:"••••••••",value:e,onChange:y=>s(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"confirmPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Confirm Password"}),o.jsx(je,{id:"confirmPass",type:"password",placeholder:"••••••••",value:i,onChange:y=>l(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]})]}),o.jsxs("div",{className:"bg-muted/30 p-6 rounded-2xl border border-border/40 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(uu,{className:"w-5 h-5"})}),o.jsx("h5",{className:"font-bold",children:"Security Tip"})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Use a password at least 12 characters long with a mix of letters, numbers, and symbols to ensure your foundational data remains secure."})]})]})]}),o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:g,disabled:u||!e||!i,children:[u?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Zo,{className:"w-4 h-4 mr-2"}),"Update Password"]})})]})}function eR({configSnapshot:t,configSource:e,onLaunchSetup:s,onResetSetup:i}){return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Eu,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-bold",children:"Supabase Configuration"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary storage and identity gateway."})]}),o.jsxs(Pt,{variant:"secondary",className:"text-[10px] font-black uppercase tracking-widest px-3 py-1",children:["Source: ",e]})]}),o.jsxs(ht,{className:"border-border/40 shadow-sm bg-card/50 backdrop-blur-sm",children:[o.jsx(xt,{className:"p-8 space-y-8",children:t?o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"API Endpoint"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 backdrop-blur-sm shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold truncate text-foreground/80",children:t.url})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Project Identifier"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 font-mono shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold text-foreground/80",children:t.url.split("//")[1]?.split(".")[0]||"Unknown"})})]}),o.jsxs("div",{className:"md:col-span-2 space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Service Role Access (Masked)"}),o.jsxs("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 flex items-center justify-between shadow-inner",children:[o.jsxs("p",{className:"text-sm font-mono text-muted-foreground",children:[t.anonKey.slice(0,6),"...",t.anonKey.slice(-6)]}),o.jsx(Pt,{variant:"outline",className:"text-[9px] font-bold",children:"Standard Key"})]})]})]}):o.jsxs(jn,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(Sn,{className:"w-5 h-5"}),o.jsx(Hm,{className:"font-bold mb-1",children:"Infrastructure Standby"}),o.jsx(_n,{className:"text-sm opacity-90",children:"The foundation has not been initialized. You must run the setup wizard to continue."})]})}),o.jsxs(Tu,{className:"bg-muted/20 p-8 flex gap-4 border-t",children:[o.jsxs(ae,{variant:t?"outline":"default",className:"flex-1 h-12 rounded-xl font-bold shadow-sm",onClick:s,children:[t?o.jsx(WC,{className:"w-4 h-4 mr-2"}):o.jsx(Wa,{className:"w-4 h-4 mr-2"}),t?"Run Setup Wizard":"Launch Initializer"]}),t&&o.jsx(ae,{variant:"ghost",size:"icon",className:"h-12 w-12 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",onClick:i,title:"Reset All Configuration",children:o.jsx(PC,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"space-y-6 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive",children:o.jsx(Sn,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-destructive",children:"Advanced Maintenance"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Destructive actions and system-level overrides."})]})]}),o.jsx(ht,{className:"border-destructive/20 bg-destructive/5 overflow-hidden shadow-sm",children:o.jsxs(xt,{className:"p-8",children:[o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Fully resetting the foundation will purge all local storage cached parameters. This action is irreversible and will force a fresh bootstrap flow upon next launch."}),o.jsx(ae,{variant:"link",className:"px-0 text-destructive h-auto text-xs font-black uppercase tracking-widest mt-4 hover:no-underline hover:opacity-70 transition-opacity",onClick:i,children:"Wipe Local Foundation Buffer"})]})})]})]})}const tR={theme:"system",setTheme:()=>null},Zw=v.createContext(tR);function nR({children:t,defaultTheme:e="system",storageKey:s="vite-ui-theme"}){const[i,l]=v.useState(()=>localStorage.getItem(s)||e);v.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),i==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(h);return}d.classList.add(i)},[i]);const u=v.useMemo(()=>({theme:i,setTheme:d=>{localStorage.setItem(s,d),l(d)}}),[i,s]);return o.jsx(Zw.Provider,{value:u,children:t})}const sR=()=>{const t=v.useContext(Zw);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function e1(){const{setTheme:t,theme:e}=sR();return o.jsxs(ae,{variant:"ghost",size:"icon",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:bg-muted/60 transition-all duration-300 h-9 w-9 rounded-full",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(nA,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(CC,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function fa(t,e,{checkForDefaultPrevented:s=!0}={}){return function(l){if(t?.(l),s===!1||!l.defaultPrevented)return e?.(l)}}function aR(t,e){const s=v.createContext(e),i=u=>{const{children:d,...h}=u,m=v.useMemo(()=>h,Object.values(h));return o.jsx(s.Provider,{value:m,children:d})};i.displayName=t+"Provider";function l(u){const d=v.useContext(s);if(d)return d;if(e!==void 0)return e;throw new Error(`\`${u}\` must be used within \`${t}\``)}return[i,l]}function iR(t,e=[]){let s=[];function i(u,d){const h=v.createContext(d),m=s.length;s=[...s,d];const g=x=>{const{scope:w,children:S,...E}=x,j=w?.[t]?.[m]||h,_=v.useMemo(()=>E,Object.values(E));return o.jsx(j.Provider,{value:_,children:S})};g.displayName=u+"Provider";function y(x,w){const S=w?.[t]?.[m]||h,E=v.useContext(S);if(E)return E;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[g,y]}const l=()=>{const u=s.map(d=>v.createContext(d));return function(h){const m=h?.[t]||u;return v.useMemo(()=>({[`__scope${t}`]:{...h,[t]:m}}),[h,m])}};return l.scopeName=t,[i,rR(l,...e)]}function rR(...t){const e=t[0];if(t.length===1)return e;const s=()=>{const i=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(u){const d=i.reduce((h,{useScope:m,scopeName:g})=>{const x=m(u)[`__scope${g}`];return{...h,...x}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return s.scopeName=e.scopeName,s}var qo=globalThis?.document?v.useLayoutEffect:()=>{},oR=Mm[" useId ".trim().toString()]||(()=>{}),lR=0;function mf(t){const[e,s]=v.useState(oR());return qo(()=>{s(i=>i??String(lR++))},[t]),t||(e?`radix-${e}`:"")}var cR=Mm[" useInsertionEffect ".trim().toString()]||qo;function uR({prop:t,defaultProp:e,onChange:s=()=>{},caller:i}){const[l,u,d]=dR({defaultProp:e,onChange:s}),h=t!==void 0,m=h?t:l;{const y=v.useRef(t!==void 0);v.useEffect(()=>{const x=y.current;x!==h&&console.warn(`${i} is changing from ${x?"controlled":"uncontrolled"} to ${h?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=h},[h,i])}const g=v.useCallback(y=>{if(h){const x=hR(y)?y(t):y;x!==t&&d.current?.(x)}else u(y)},[h,t,u,d]);return[m,g]}function dR({defaultProp:t,onChange:e}){const[s,i]=v.useState(t),l=v.useRef(s),u=v.useRef(e);return cR(()=>{u.current=e},[e]),v.useEffect(()=>{l.current!==s&&(u.current?.(s),l.current=s)},[s,l]),[s,i,u]}function hR(t){return typeof t=="function"}function fR(t){const e=mR(t),s=v.forwardRef((i,l)=>{const{children:u,...d}=i,h=v.Children.toArray(u),m=h.find(gR);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function mR(t){const e=v.forwardRef((s,i)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=vR(l),h=yR(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pR=Symbol("radix.slottable");function gR(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pR}function yR(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function vR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var xR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Os=xR.reduce((t,e)=>{const s=fR(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function bR(t,e){t&&Ww.flushSync(()=>t.dispatchEvent(e))}function Ho(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...s)=>e.current?.(...s),[])}function wR(t,e=globalThis?.document){const s=Ho(t);v.useEffect(()=>{const i=l=>{l.key==="Escape"&&s(l)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[s,e])}var SR="DismissableLayer",im="dismissableLayer.update",jR="dismissableLayer.pointerDownOutside",_R="dismissableLayer.focusOutside",b0,t1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n1=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:h,...m}=t,g=v.useContext(t1),[y,x]=v.useState(null),w=y?.ownerDocument??globalThis?.document,[,S]=v.useState({}),E=ni(e,V=>x(V)),j=Array.from(g.layers),[_]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(_),k=y?j.indexOf(y):-1,C=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=N,D=ER(V=>{const R=V.target,P=[...g.branches].some(Z=>Z.contains(R));!A||P||(l?.(V),d?.(V),V.defaultPrevented||h?.())},w),z=kR(V=>{const R=V.target;[...g.branches].some(Z=>Z.contains(R))||(u?.(V),d?.(V),V.defaultPrevented||h?.())},w);return wR(V=>{k===g.layers.size-1&&(i?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))},w),v.useEffect(()=>{if(y)return s&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(b0=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w0(),()=>{s&&g.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=b0)}},[y,w,s,g]),v.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w0())},[y,g]),v.useEffect(()=>{const V=()=>S({});return document.addEventListener(im,V),()=>document.removeEventListener(im,V)},[]),o.jsx(Os.div,{...m,ref:E,style:{pointerEvents:C?A?"auto":"none":void 0,...t.style},onFocusCapture:fa(t.onFocusCapture,z.onFocusCapture),onBlurCapture:fa(t.onBlurCapture,z.onBlurCapture),onPointerDownCapture:fa(t.onPointerDownCapture,D.onPointerDownCapture)})});n1.displayName=SR;var NR="DismissableLayerBranch",TR=v.forwardRef((t,e)=>{const s=v.useContext(t1),i=v.useRef(null),l=ni(e,i);return v.useEffect(()=>{const u=i.current;if(u)return s.branches.add(u),()=>{s.branches.delete(u)}},[s.branches]),o.jsx(Os.div,{...t,ref:l})});TR.displayName=NR;function ER(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1),l=v.useRef(()=>{});return v.useEffect(()=>{const u=h=>{if(h.target&&!i.current){let m=function(){s1(jR,s,g,{discrete:!0})};const g={originalEvent:h};h.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=m,e.addEventListener("click",l.current,{once:!0})):m()}else e.removeEventListener("click",l.current);i.current=!1},d=window.setTimeout(()=>{e.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(d),e.removeEventListener("pointerdown",u),e.removeEventListener("click",l.current)}},[e,s]),{onPointerDownCapture:()=>i.current=!0}}function kR(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1);return v.useEffect(()=>{const l=u=>{u.target&&!i.current&&s1(_R,s,{originalEvent:u},{discrete:!1})};return e.addEventListener("focusin",l),()=>e.removeEventListener("focusin",l)},[e,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function w0(){const t=new CustomEvent(im);document.dispatchEvent(t)}function s1(t,e,s,{discrete:i}){const l=s.originalEvent.target,u=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:s});e&&l.addEventListener(t,e,{once:!0}),i?bR(l,u):l.dispatchEvent(u)}var pf="focusScope.autoFocusOnMount",gf="focusScope.autoFocusOnUnmount",S0={bubbles:!1,cancelable:!0},CR="FocusScope",a1=v.forwardRef((t,e)=>{const{loop:s=!1,trapped:i=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[h,m]=v.useState(null),g=Ho(l),y=Ho(u),x=v.useRef(null),w=ni(e,j=>m(j)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(i){let j=function(C){if(S.paused||!h)return;const A=C.target;h.contains(A)?x.current=A:oa(x.current,{select:!0})},_=function(C){if(S.paused||!h)return;const A=C.relatedTarget;A!==null&&(h.contains(A)||oa(x.current,{select:!0}))},N=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&oa(h)};document.addEventListener("focusin",j),document.addEventListener("focusout",_);const k=new MutationObserver(N);return h&&k.observe(h,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",_),k.disconnect()}}},[i,h,S.paused]),v.useEffect(()=>{if(h){_0.add(S);const j=document.activeElement;if(!h.contains(j)){const N=new CustomEvent(pf,S0);h.addEventListener(pf,g),h.dispatchEvent(N),N.defaultPrevented||(AR(PR(i1(h)),{select:!0}),document.activeElement===j&&oa(h))}return()=>{h.removeEventListener(pf,g),setTimeout(()=>{const N=new CustomEvent(gf,S0);h.addEventListener(gf,y),h.dispatchEvent(N),N.defaultPrevented||oa(j??document.body,{select:!0}),h.removeEventListener(gf,y),_0.remove(S)},0)}}},[h,g,y,S]);const E=v.useCallback(j=>{if(!s&&!i||S.paused)return;const _=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(_&&N){const k=j.currentTarget,[C,A]=RR(k);C&&A?!j.shiftKey&&N===A?(j.preventDefault(),s&&oa(C,{select:!0})):j.shiftKey&&N===C&&(j.preventDefault(),s&&oa(A,{select:!0})):N===k&&j.preventDefault()}},[s,i,S.paused]);return o.jsx(Os.div,{tabIndex:-1,...d,ref:w,onKeyDown:E})});a1.displayName=CR;function AR(t,{select:e=!1}={}){const s=document.activeElement;for(const i of t)if(oa(i,{select:e}),document.activeElement!==s)return}function RR(t){const e=i1(t),s=j0(e,t),i=j0(e.reverse(),t);return[s,i]}function i1(t){const e=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const l=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||l?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)e.push(s.currentNode);return e}function j0(t,e){for(const s of t)if(!OR(s,{upTo:e}))return s}function OR(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MR(t){return t instanceof HTMLInputElement&&"select"in t}function oa(t,{select:e=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&MR(t)&&e&&t.select()}}var _0=DR();function DR(){let t=[];return{add(e){const s=t[0];e!==s&&s?.pause(),t=N0(t,e),t.unshift(e)},remove(e){t=N0(t,e),t[0]?.resume()}}}function N0(t,e){const s=[...t],i=s.indexOf(e);return i!==-1&&s.splice(i,1),s}function PR(t){return t.filter(e=>e.tagName!=="A")}var zR="Portal",r1=v.forwardRef((t,e)=>{const{container:s,...i}=t,[l,u]=v.useState(!1);qo(()=>u(!0),[]);const d=s||l&&globalThis?.document?.body;return d?VA.createPortal(o.jsx(Os.div,{...i,ref:e}),d):null});r1.displayName=zR;function LR(t,e){return v.useReducer((s,i)=>e[s][i]??s,t)}var Ru=t=>{const{present:e,children:s}=t,i=UR(e),l=typeof s=="function"?s({present:i.isPresent}):v.Children.only(s),u=ni(i.ref,BR(l));return typeof s=="function"||i.isPresent?v.cloneElement(l,{ref:u}):null};Ru.displayName="Presence";function UR(t){const[e,s]=v.useState(),i=v.useRef(null),l=v.useRef(t),u=v.useRef("none"),d=t?"mounted":"unmounted",[h,m]=LR(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const g=Lc(i.current);u.current=h==="mounted"?g:"none"},[h]),qo(()=>{const g=i.current,y=l.current;if(y!==t){const w=u.current,S=Lc(g);t?m("MOUNT"):S==="none"||g?.display==="none"?m("UNMOUNT"):m(y&&w!==S?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,m]),qo(()=>{if(e){let g;const y=e.ownerDocument.defaultView??window,x=S=>{const j=Lc(i.current).includes(CSS.escape(S.animationName));if(S.target===e&&j&&(m("ANIMATION_END"),!l.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",g=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},w=S=>{S.target===e&&(u.current=Lc(i.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",x),e.addEventListener("animationend",x),()=>{y.clearTimeout(g),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",x),e.removeEventListener("animationend",x)}}else m("ANIMATION_END")},[e,m]),{isPresent:["mounted","unmountSuspended"].includes(h),ref:v.useCallback(g=>{i.current=g?getComputedStyle(g):null,s(g)},[])}}function Lc(t){return t?.animationName||"none"}function BR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var yf=0;function VR(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T0()),document.body.insertAdjacentElement("beforeend",t[1]??T0()),yf++,()=>{yf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),yf--}},[])}function T0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Yc="right-scroll-bar-position",Xc="width-before-scroll-bar",IR="with-scroll-bars-hidden",$R="--removed-body-scroll-bar-size";function vf(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function qR(t,e){var s=v.useState(function(){return{value:t,callback:e,facade:{get current(){return s.value},set current(i){var l=s.value;l!==i&&(s.value=i,s.callback(i,l))}}}})[0];return s.callback=e,s.facade}var HR=typeof window<"u"?v.useLayoutEffect:v.useEffect,E0=new WeakMap;function GR(t,e){var s=qR(null,function(i){return t.forEach(function(l){return vf(l,i)})});return HR(function(){var i=E0.get(s);if(i){var l=new Set(i),u=new Set(t),d=s.current;l.forEach(function(h){u.has(h)||vf(h,null)}),u.forEach(function(h){l.has(h)||vf(h,d)})}E0.set(s,t)},[t]),s}function FR(t){return t}function KR(t,e){e===void 0&&(e=FR);var s=[],i=!1,l={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=e(u,i);return s.push(d),function(){s=s.filter(function(h){return h!==d})}},assignSyncMedium:function(u){for(i=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(h){return u(h)},filter:function(){return s}}},assignMedium:function(u){i=!0;var d=[];if(s.length){var h=s;s=[],h.forEach(u),d=s}var m=function(){var y=d;d=[],y.forEach(u)},g=function(){return Promise.resolve().then(m)};g(),s={push:function(y){d.push(y),g()},filter:function(y){return d=d.filter(y),s}}}};return l}function YR(t){t===void 0&&(t={});var e=KR(null);return e.options=ss({async:!0,ssr:!1},t),e}var o1=function(t){var e=t.sideCar,s=pr(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return v.createElement(i,ss({},s))};o1.isSideCarExport=!0;function XR(t,e){return t.useMedium(e),o1}var l1=YR(),xf=function(){},Ou=v.forwardRef(function(t,e){var s=v.useRef(null),i=v.useState({onScrollCapture:xf,onWheelCapture:xf,onTouchMoveCapture:xf}),l=i[0],u=i[1],d=t.forwardProps,h=t.children,m=t.className,g=t.removeScrollBar,y=t.enabled,x=t.shards,w=t.sideCar,S=t.noRelative,E=t.noIsolation,j=t.inert,_=t.allowPinchZoom,N=t.as,k=N===void 0?"div":N,C=t.gapMode,A=pr(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=w,z=GR([s,e]),V=ss(ss({},A),l);return v.createElement(v.Fragment,null,y&&v.createElement(D,{sideCar:l1,removeScrollBar:g,shards:x,noRelative:S,noIsolation:E,inert:j,setCallbacks:u,allowPinchZoom:!!_,lockRef:s,gapMode:C}),d?v.cloneElement(v.Children.only(h),ss(ss({},V),{ref:z})):v.createElement(k,ss({},V,{className:m,ref:z}),h))});Ou.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ou.classNames={fullWidth:Xc,zeroRight:Yc};var WR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=WR();return e&&t.setAttribute("nonce",e),t}function QR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function ZR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var eO=function(){var t=0,e=null;return{add:function(s){t==0&&(e=JR())&&(QR(e,s),ZR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},tO=function(){var t=eO();return function(e,s){v.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&s])}},c1=function(){var t=tO(),e=function(s){var i=s.styles,l=s.dynamic;return t(i,l),null};return e},nO={left:0,top:0,right:0,gap:0},bf=function(t){return parseInt(t||"",10)||0},sO=function(t){var e=window.getComputedStyle(document.body),s=e[t==="padding"?"paddingLeft":"marginLeft"],i=e[t==="padding"?"paddingTop":"marginTop"],l=e[t==="padding"?"paddingRight":"marginRight"];return[bf(s),bf(i),bf(l)]},aO=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return nO;var e=sO(t),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-s+e[2]-e[0])}},iO=c1(),lr="data-scroll-locked",rO=function(t,e,s,i){var l=t.left,u=t.top,d=t.right,h=t.gap;return s===void 0&&(s="margin"),`
51
+ `);const z=await A.signMessage(new TextEncoder().encode(E),"utf8");if(!z||!(z instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=z}}try{const{data:_,error:N}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:E,signature:Fa(j)},!((w=e.options)===null||w===void 0)&&w.captchaToken?{gotrue_meta_security:{captcha_token:(S=e.options)===null||S===void 0?void 0:S.captchaToken}}:null),xform:$n});if(N)throw N;if(!_||!_.session||!_.user){const k=new $i;return this._returnResult({data:{user:null,session:null},error:k})}return _.session&&(await this._saveSession(_.session),await this._notifyAllSubscribers("SIGNED_IN",_.session)),this._returnResult({data:Object.assign({},_),error:N})}catch(_){if(Ne(_))return this._returnResult({data:{user:null,session:null},error:_});throw _}}async _exchangeCodeForSession(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`),[i,l]=(s??"").split("/");try{if(!i&&this.flowType==="pkce")throw new vT;const{data:u,error:d}=await Re(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:i},xform:$n});if(await Ht(this.storage,`${this.storageKey}-code-verifier`),d)throw d;if(!u||!u.session||!u.user){const h=new $i;return this._returnResult({data:{user:null,session:null,redirectType:null},error:h})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers("SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:l??null}),error:d})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(e){try{const{options:s,provider:i,token:l,access_token:u,nonce:d}=e,h=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:i,id_token:l,access_token:u,nonce:d,gotrue_meta_security:{captcha_token:s?.captchaToken}},xform:$n}),{data:m,error:g}=h;if(g)return this._returnResult({data:{user:null,session:null},error:g});if(!m||!m.session||!m.user){const y=new $i;return this._returnResult({data:{user:null,session:null},error:y})}return m.session&&(await this._saveSession(m.session),await this._notifyAllSubscribers("SIGNED_IN",m.session)),this._returnResult({data:m,error:g})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithOtp(e){var s,i,l,u,d;try{if("email"in e){const{email:h,options:m}=e;let g=null,y=null;this.flowType==="pkce"&&([g,y]=await qi(this.storage,this.storageKey));const{error:x}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(s=m?.data)!==null&&s!==void 0?s:{},create_user:(i=m?.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},code_challenge:g,code_challenge_method:y},redirectTo:m?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in e){const{phone:h,options:m}=e,{data:g,error:y}=await Re(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(l=m?.data)!==null&&l!==void 0?l:{},create_user:(u=m?.shouldCreateUser)!==null&&u!==void 0?u:!0,gotrue_meta_security:{captcha_token:m?.captchaToken},channel:(d=m?.channel)!==null&&d!==void 0?d:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:g?.message_id},error:y})}throw new Cc("You must provide either an email or phone number.")}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:{user:null,session:null},error:h});throw h}}async verifyOtp(e){var s,i;try{let l,u;"options"in e&&(l=(s=e.options)===null||s===void 0?void 0:s.redirectTo,u=(i=e.options)===null||i===void 0?void 0:i.captchaToken);const{data:d,error:h}=await Re(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:u}}),redirectTo:l,xform:$n});if(h)throw h;if(!d)throw new Error("An error occurred on token verification.");const m=d.session,g=d.user;return m?.access_token&&(await this._saveSession(m),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",m)),this._returnResult({data:{user:g,session:m},error:null})}catch(l){if(Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}}async signInWithSSO(e){var s,i,l,u,d;try{let h=null,m=null;this.flowType==="pkce"&&([h,m]=await qi(this.storage,this.storageKey));const g=await Re(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(i=(s=e.options)===null||s===void 0?void 0:s.redirectTo)!==null&&i!==void 0?i:void 0}),!((l=e?.options)===null||l===void 0)&&l.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:h,code_challenge_method:m}),headers:this.headers,xform:qT});return!((u=g.data)===null||u===void 0)&&u.url&&Gt()&&!(!((d=e.options)===null||d===void 0)&&d.skipBrowserRedirect)&&window.location.assign(g.data.url),this._returnResult(g)}catch(h){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(h))return this._returnResult({data:null,error:h});throw h}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;if(i)throw i;if(!s)throw new xn;const{error:l}=await Re(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return this._returnResult({data:{user:null,session:null},error:l})})}catch(e){if(Ne(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const s=`${this.url}/resend`;if("email"in e){const{email:i,type:l,options:u}=e,{error:d}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{email:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}},redirectTo:u?.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:d})}else if("phone"in e){const{phone:i,type:l,options:u}=e,{data:d,error:h}=await Re(this.fetch,"POST",s,{headers:this.headers,body:{phone:i,type:l,gotrue_meta_security:{captcha_token:u?.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:d?.message_id},error:h})}throw new Cc("You must provide either an email or phone number and a type")}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s))}async _acquireLock(e,s){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const i=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),l=(async()=>(await i,await s()))();return this.pendingInLock.push((async()=>{try{await l}catch{}})()),l}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const i=s();for(this.pendingInLock.push((async()=>{try{await i}catch{}})()),await i;this.pendingInLock.length;){const l=[...this.pendingInLock];await Promise.all(l),this.pendingInLock.splice(0,l.length)}return await i}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const s=await this.__loadSession();return await e(s)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const s=await Ua(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?e=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const i=e.expires_at?e.expires_at*1e3-Date.now()<rf:!1;if(this._debug("#__loadSession()",`session has${i?"":" not"} expired`,"expires_at",e.expires_at),!i){if(this.userStorage){const d=await Ua(this.userStorage,this.storageKey+"-user");d?.user?e.user=d.user:e.user=cf()}if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){const d={value:this.suppressGetSessionWarning};e.user=BT(e.user,d),d.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:e},error:null}}const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{session:null},error:u}):this._returnResult({data:{session:l},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(e){if(e)return await this._getUser(e);await this.initializePromise;const s=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser());return s.data.user&&(this.suppressGetSessionWarning=!0),s}async _getUser(e){try{return e?await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:ua}):await this._useSession(async s=>{var i,l,u;const{data:d,error:h}=s;if(h)throw h;return!(!((i=d.session)===null||i===void 0)&&i.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new xn}:await Re(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(u=(l=d.session)===null||l===void 0?void 0:l.access_token)!==null&&u!==void 0?u:void 0,xform:ua})})}catch(s){if(Ne(s))return of(s)&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:s});throw s}}async updateUser(e,s={}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(e,s))}async _updateUser(e,s={}){try{return await this._useSession(async i=>{const{data:l,error:u}=i;if(u)throw u;if(!l.session)throw new xn;const d=l.session;let h=null,m=null;this.flowType==="pkce"&&e.email!=null&&([h,m]=await qi(this.storage,this.storageKey));const{data:g,error:y}=await Re(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s?.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:m}),jwt:d.access_token,xform:ua});if(y)throw y;return d.user=g.user,await this._saveSession(d),await this._notifyAllSubscribers("USER_UPDATED",d),this._returnResult({data:{user:d.user},error:null})})}catch(i){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(i))return this._returnResult({data:{user:null},error:i});throw i}}async setSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new xn;const s=Date.now()/1e3;let i=s,l=!0,u=null;const{payload:d}=Rc(e.access_token);if(d.exp&&(i=d.exp,l=i<=s),l){const{data:h,error:m}=await this._callRefreshToken(e.refresh_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});if(!h)return{data:{user:null,session:null},error:null};u=h}else{const{data:h,error:m}=await this._getUser(e.access_token);if(m)return this._returnResult({data:{user:null,session:null},error:m});u={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:i-s,expires_at:i},await this._saveSession(u),await this._notifyAllSubscribers("SIGNED_IN",u)}return this._returnResult({data:{user:u.user,session:u},error:null})}catch(s){if(Ne(s))return this._returnResult({data:{session:null,user:null},error:s});throw s}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async s=>{var i;if(!e){const{data:d,error:h}=s;if(h)throw h;e=(i=d.session)!==null&&i!==void 0?i:void 0}if(!e?.refresh_token)throw new xn;const{data:l,error:u}=await this._callRefreshToken(e.refresh_token);return u?this._returnResult({data:{user:null,session:null},error:u}):l?this._returnResult({data:{user:l.user,session:l},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(s){if(Ne(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async _getSessionFromURL(e,s){try{if(!Gt())throw new Ac("No browser detected.");if(e.error||e.error_description||e.error_code)throw new Ac(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new Fx("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Ac("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Fx("No code detected.");const{data:k,error:C}=await this._exchangeCodeForSession(e.code);if(C)throw C;const A=new URL(window.location.href);return A.searchParams.delete("code"),window.history.replaceState(window.history.state,"",A.toString()),{data:{session:k.session,redirectType:null},error:null}}const{provider_token:i,provider_refresh_token:l,access_token:u,refresh_token:d,expires_in:h,expires_at:m,token_type:g}=e;if(!u||!h||!d||!g)throw new Ac("No session defined in URL");const y=Math.round(Date.now()/1e3),x=parseInt(h);let w=y+x;m&&(w=parseInt(m));const S=w-y;S*1e3<=Ji&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${S}s, should have been closer to ${x}s`);const E=w-x;y-E>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",E,w,y):y-E<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",E,w,y);const{data:j,error:_}=await this._getUser(u);if(_)throw _;const N={provider_token:i,provider_refresh_token:l,access_token:u,expires_in:x,expires_at:w,refresh_token:d,token_type:g,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:N,redirectType:e.type},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{session:null,redirectType:null},error:i});throw i}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const s=await Ua(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&s)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u&&!of(u))return this._returnResult({error:u});const d=(i=l.session)===null||i===void 0?void 0:i.access_token;if(d){const{error:h}=await this.admin.signOut(d,e);if(h&&!(gT(h)&&(h.status===404||h.status===401||h.status===403)||of(h)))return this._returnResult({error:h})}return e!=="others"&&(await this._removeSession(),await Ht(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const s=NT(),i={id:s,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,i),(async()=>(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:i}}}async _emitInitialSession(e){return await this._useSession(async s=>{var i,l;try{const{data:{session:u},error:d}=s;if(d)throw d;await((i=this.stateChangeEmitters.get(e))===null||i===void 0?void 0:i.callback("INITIAL_SESSION",u)),this._debug("INITIAL_SESSION","callback id",e,"session",u)}catch(u){await((l=this.stateChangeEmitters.get(e))===null||l===void 0?void 0:l.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",u),console.error(u)}})}async resetPasswordForEmail(e,s={}){let i=null,l=null;this.flowType==="pkce"&&([i,l]=await qi(this.storage,this.storageKey,!0));try{return await Re(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:i,code_challenge_method:l,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(u){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(u))return this._returnResult({data:null,error:u});throw u}}async getUserIdentities(){var e;try{const{data:s,error:i}=await this.getUser();if(i)throw i;return this._returnResult({data:{identities:(e=s.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var s;try{const{data:i,error:l}=await this._useSession(async u=>{var d,h,m,g,y;const{data:x,error:w}=u;if(w)throw w;const S=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(d=e.options)===null||d===void 0?void 0:d.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(m=e.options)===null||m===void 0?void 0:m.queryParams,skipBrowserRedirect:!0});return await Re(this.fetch,"GET",S,{headers:this.headers,jwt:(y=(g=x.session)===null||g===void 0?void 0:g.access_token)!==null&&y!==void 0?y:void 0})});if(l)throw l;return Gt()&&!(!((s=e.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(i?.url),this._returnResult({data:{provider:e.provider,url:i?.url},error:null})}catch(i){if(Ne(i))return this._returnResult({data:{provider:e.provider,url:null},error:i});throw i}}async linkIdentityIdToken(e){return await this._useSession(async s=>{var i;try{const{error:l,data:{session:u}}=s;if(l)throw l;const{options:d,provider:h,token:m,access_token:g,nonce:y}=e,x=await Re(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(i=u?.access_token)!==null&&i!==void 0?i:void 0,body:{provider:h,id_token:m,access_token:g,nonce:y,link_identity:!0,gotrue_meta_security:{captcha_token:d?.captchaToken}},xform:$n}),{data:w,error:S}=x;return S?this._returnResult({data:{user:null,session:null},error:S}):!w||!w.session||!w.user?this._returnResult({data:{user:null,session:null},error:new $i}):(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("USER_UPDATED",w.session)),this._returnResult({data:w,error:S}))}catch(l){if(await Ht(this.storage,`${this.storageKey}-code-verifier`),Ne(l))return this._returnResult({data:{user:null,session:null},error:l});throw l}})}async unlinkIdentity(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)throw d;return await Re(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(l=(i=u.session)===null||i===void 0?void 0:i.access_token)!==null&&l!==void 0?l:void 0})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _refreshAccessToken(e){const s=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{const i=Date.now();return await CT(async l=>(l>0&&await kT(200*Math.pow(2,l-1)),this._debug(s,"refreshing attempt",l),await Re(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:$n})),(l,u)=>{const d=200*Math.pow(2,l);return u&&lf(u)&&Date.now()+d-i<Ji})}catch(i){if(this._debug(s,"error",i),Ne(i))return this._returnResult({data:{session:null,user:null},error:i});throw i}finally{this._debug(s,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,s){const i=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:s.redirectTo,scopes:s.scopes,queryParams:s.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",s,"url",i),Gt()&&!s.skipBrowserRedirect&&window.location.assign(i),{data:{provider:e,url:i},error:null}}async _recoverAndRefresh(){var e,s;const i="#_recoverAndRefresh()";this._debug(i,"begin");try{const l=await Ua(this.storage,this.storageKey);if(l&&this.userStorage){let d=await Ua(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!d&&(d={user:l.user},await Qi(this.userStorage,this.storageKey+"-user",d)),l.user=(e=d?.user)!==null&&e!==void 0?e:cf()}else if(l&&!l.user&&!l.user){const d=await Ua(this.storage,this.storageKey+"-user");d&&d?.user?(l.user=d.user,await Ht(this.storage,this.storageKey+"-user"),await Qi(this.storage,this.storageKey,l)):l.user=cf()}if(this._debug(i,"session from storage",l),!this._isValidSession(l)){this._debug(i,"session is not valid"),l!==null&&await this._removeSession();return}const u=((s=l.expires_at)!==null&&s!==void 0?s:1/0)*1e3-Date.now()<rf;if(this._debug(i,`session has${u?"":" not"} expired with margin of ${rf}s`),u){if(this.autoRefreshToken&&l.refresh_token){const{error:d}=await this._callRefreshToken(l.refresh_token);d&&(console.error(d),lf(d)||(this._debug(i,"refresh failed with a non-retryable error, removing the session",d),await this._removeSession()))}}else if(l.user&&l.user.__isUserNotAvailableProxy===!0)try{const{data:d,error:h}=await this._getUser(l.access_token);!h&&d?.user?(l.user=d.user,await this._saveSession(l),await this._notifyAllSubscribers("SIGNED_IN",l)):this._debug(i,"could not get user data, skipping SIGNED_IN notification")}catch(d){console.error("Error getting user data:",d),this._debug(i,"error getting user data, skipping SIGNED_IN notification",d)}else await this._notifyAllSubscribers("SIGNED_IN",l)}catch(l){this._debug(i,"error",l),console.error(l);return}finally{this._debug(i,"end")}}async _callRefreshToken(e){var s,i;if(!e)throw new xn;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const l=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(l,"begin");try{this.refreshingDeferred=new Nu;const{data:u,error:d}=await this._refreshAccessToken(e);if(d)throw d;if(!u.session)throw new xn;await this._saveSession(u.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",u.session);const h={data:u.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(u){if(this._debug(l,"error",u),Ne(u)){const d={data:null,error:u};return lf(u)||await this._removeSession(),(s=this.refreshingDeferred)===null||s===void 0||s.resolve(d),d}throw(i=this.refreshingDeferred)===null||i===void 0||i.reject(u),u}finally{this.refreshingDeferred=null,this._debug(l,"end")}}async _notifyAllSubscribers(e,s,i=!0){const l=`#_notifyAllSubscribers(${e})`;this._debug(l,"begin",s,`broadcast = ${i}`);try{this.broadcastChannel&&i&&this.broadcastChannel.postMessage({event:e,session:s});const u=[],d=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,s)}catch(m){u.push(m)}});if(await Promise.all(d),u.length>0){for(let h=0;h<u.length;h+=1)console.error(u[h]);throw u[0]}}finally{this._debug(l,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await Ht(this.storage,`${this.storageKey}-code-verifier`);const s=Object.assign({},e),i=s.user&&s.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!i&&s.user&&await Qi(this.userStorage,this.storageKey+"-user",{user:s.user});const l=Object.assign({},s);delete l.user;const u=Jx(l);await Qi(this.storage,this.storageKey,u)}else{const l=Jx(s);await Qi(this.storage,this.storageKey,l)}}async _removeSession(){this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,await Ht(this.storage,this.storageKey),await Ht(this.storage,this.storageKey+"-code-verifier"),await Ht(this.storage,this.storageKey+"-user"),this.userStorage&&await Ht(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Gt()&&window?.removeEventListener&&window.removeEventListener("visibilitychange",e)}catch(s){console.error("removing visibilitychange callback failed",s)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Ji);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e);const s=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e);const s=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,s&&clearTimeout(s)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async s=>{const{data:{session:i}}=s;if(!i||!i.refresh_token||!i.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const l=Math.floor((i.expires_at*1e3-e)/Ji);this._debug("#_autoRefreshTokenTick()",`access token expires in ${l} ticks, a tick lasts ${Ji}ms, refresh threshold is ${Yf} ticks`),l<=Yf&&await this._callRefreshToken(i.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof pw)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Gt()||!window?.addEventListener)return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(e){this._debug("#visibilityChangedCallback","error",e)}},window?.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const s=`#_onVisibilityChanged(${e})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,s,i){const l=[`provider=${encodeURIComponent(s)}`];if(i?.redirectTo&&l.push(`redirect_to=${encodeURIComponent(i.redirectTo)}`),i?.scopes&&l.push(`scopes=${encodeURIComponent(i.scopes)}`),this.flowType==="pkce"){const[u,d]=await qi(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(u)}`,code_challenge_method:`${encodeURIComponent(d)}`});l.push(h.toString())}if(i?.queryParams){const u=new URLSearchParams(i.queryParams);l.push(u.toString())}return i?.skipBrowserRedirect&&l.push(`skip_http_redirect=${i.skipBrowserRedirect}`),`${e}?${l.join("&")}`}async _unenroll(e){try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;return u?this._returnResult({data:null,error:u}):await Re(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _enroll(e){try{return await this._useSession(async s=>{var i,l;const{data:u,error:d}=s;if(d)return this._returnResult({data:null,error:d});const h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:m,error:g}=await Re(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(i=u?.session)===null||i===void 0?void 0:i.access_token});return g?this._returnResult({data:null,error:g}):(e.factorType==="totp"&&m.type==="totp"&&(!((l=m?.totp)===null||l===void 0)&&l.qr_code)&&(m.totp.qr_code=`data:image/svg+xml;utf-8,${m.totp.qr_code}`),this._returnResult({data:m,error:null}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _verify(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?aE(e.webauthn.credential_response):iE(e.webauthn.credential_response)})}:{code:e.code}),{data:h,error:m}=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:d,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});return m?this._returnResult({data:null,error:m}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+h.expires_in},h)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",h),this._returnResult({data:h,error:m}))})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challenge(e){return this._acquireLock(this.lockAcquireTimeout,async()=>{try{return await this._useSession(async s=>{var i;const{data:l,error:u}=s;if(u)return this._returnResult({data:null,error:u});const d=await Re(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(i=l?.session)===null||i===void 0?void 0:i.access_token});if(d.error)return d;const{data:h}=d;if(h.type!=="webauthn")return{data:h,error:null};switch(h.webauthn.type){case"create":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:nE(h.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},h),{webauthn:Object.assign(Object.assign({},h.webauthn),{credential_options:Object.assign(Object.assign({},h.webauthn.credential_options),{publicKey:sE(h.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}})}async _challengeAndVerify(e){const{data:s,error:i}=await this._challenge({factorId:e.factorId});return i?this._returnResult({data:null,error:i}):await this._verify({factorId:e.factorId,challengeId:s.id,code:e.code})}async _listFactors(){var e;const{data:{user:s},error:i}=await this.getUser();if(i)return{data:null,error:i};const l={all:[],phone:[],totp:[],webauthn:[]};for(const u of(e=s?.factors)!==null&&e!==void 0?e:[])l.all.push(u),u.status==="verified"&&l[u.factor_type].push(u);return{data:l,error:null}}async _getAuthenticatorAssuranceLevel(e){var s,i,l,u;if(e)try{const{payload:S}=Rc(e);let E=null;S.aal&&(E=S.aal);let j=E;const{data:{user:_},error:N}=await this.getUser(e);if(N)return this._returnResult({data:null,error:N});((i=(s=_?.factors)===null||s===void 0?void 0:s.filter(A=>A.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(j="aal2");const C=S.amr||[];return{data:{currentLevel:E,nextLevel:j,currentAuthenticationMethods:C},error:null}}catch(S){if(Ne(S))return this._returnResult({data:null,error:S});throw S}const{data:{session:d},error:h}=await this.getSession();if(h)return this._returnResult({data:null,error:h});if(!d)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:m}=Rc(d.access_token);let g=null;m.aal&&(g=m.aal);let y=g;((u=(l=d.user.factors)===null||l===void 0?void 0:l.filter(S=>S.status==="verified"))!==null&&u!==void 0?u:[]).length>0&&(y="aal2");const w=m.amr||[];return{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:w},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?await Re(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:i.access_token,xform:u=>({data:u,error:null})}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async _approveAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"approve"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _denyAuthorization(e,s){try{return await this._useSession(async i=>{const{data:{session:l},error:u}=i;if(u)return this._returnResult({data:null,error:u});if(!l)return this._returnResult({data:null,error:new xn});const d=await Re(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:l.access_token,body:{action:"deny"},xform:h=>({data:h,error:null})});return d.data&&d.data.redirect_url&&Gt()&&!s?.skipBrowserRedirect&&window.location.assign(d.data.redirect_url),d})}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:s},error:i}=e;return i?this._returnResult({data:null,error:i}):s?await Re(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:s.access_token,xform:l=>({data:l,error:null})}):this._returnResult({data:null,error:new xn})})}catch(e){if(Ne(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async s=>{const{data:{session:i},error:l}=s;return l?this._returnResult({data:null,error:l}):i?(await Re(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:i.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new xn})})}catch(s){if(Ne(s))return this._returnResult({data:null,error:s});throw s}}async fetchJwk(e,s={keys:[]}){let i=s.keys.find(h=>h.kid===e);if(i)return i;const l=Date.now();if(i=this.jwks.keys.find(h=>h.kid===e),i&&this.jwks_cached_at+mT>l)return i;const{data:u,error:d}=await Re(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(d)throw d;return!u.keys||u.keys.length===0||(this.jwks=u,this.jwks_cached_at=l,i=u.keys.find(h=>h.kid===e),!i)?null:i}async getClaims(e,s={}){try{let i=e;if(!i){const{data:S,error:E}=await this.getSession();if(E||!S.session)return this._returnResult({data:null,error:E});i=S.session.access_token}const{header:l,payload:u,signature:d,raw:{header:h,payload:m}}=Rc(i);s?.allowExpired||zT(u.exp);const g=!l.alg||l.alg.startsWith("HS")||!l.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(l.kid,s?.keys?{keys:s.keys}:s?.jwks);if(!g){const{error:S}=await this.getUser(i);if(S)throw S;return{data:{claims:u,header:l,signature:d},error:null}}const y=LT(l.alg),x=await crypto.subtle.importKey("jwk",g,y,!0,["verify"]);if(!await crypto.subtle.verify(y,x,d,jT(`${h}.${m}`)))throw new Jf("Invalid JWT signature");return{data:{claims:u,header:l,signature:d},error:null}}catch(i){if(Ne(i))return this._returnResult({data:null,error:i});throw i}}}Lo.nextInstanceID={};const mE=Lo,pE="2.97.0";let wo="";typeof Deno<"u"?wo="deno":typeof document<"u"?wo="web":typeof navigator<"u"&&navigator.product==="ReactNative"?wo="react-native":wo="node";const gE={"X-Client-Info":`supabase-js-${wo}/${pE}`},yE={headers:gE},vE={schema:"public"},xE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},bE={};function Uo(t){"@babel/helpers - typeof";return Uo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Uo(t)}function wE(t,e){if(Uo(t)!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e);if(Uo(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function SE(t){var e=wE(t,"string");return Uo(e)=="symbol"?e:e+""}function jE(t,e,s){return(e=SE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function i0(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,i)}return s}function yt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?i0(Object(s),!0).forEach(function(i){jE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):i0(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}const _E=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),NE=()=>Headers,TE=(t,e,s)=>{const i=_E(s),l=NE();return async(u,d)=>{var h;const m=(h=await e())!==null&&h!==void 0?h:t;let g=new l(d?.headers);return g.has("apikey")||g.set("apikey",t),g.has("Authorization")||g.set("Authorization",`Bearer ${m}`),i(u,yt(yt({},d),{},{headers:g}))}};function EE(t){return t.endsWith("/")?t:t+"/"}function kE(t,e){var s,i;const{db:l,auth:u,realtime:d,global:h}=t,{db:m,auth:g,realtime:y,global:x}=e,w={db:yt(yt({},m),l),auth:yt(yt({},g),u),realtime:yt(yt({},y),d),storage:{},global:yt(yt(yt({},x),h),{},{headers:yt(yt({},(s=x?.headers)!==null&&s!==void 0?s:{}),(i=h?.headers)!==null&&i!==void 0?i:{})}),accessToken:async()=>""};return t.accessToken?w.accessToken=t.accessToken:delete w.accessToken,w}function CE(t){const e=t?.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(EE(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var AE=class extends mE{constructor(t){super(t)}},RE=class{constructor(t,e,s){var i,l;this.supabaseUrl=t,this.supabaseKey=e;const u=CE(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",u),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",u),this.storageUrl=new URL("storage/v1",u),this.functionsUrl=new URL("functions/v1",u);const d=`sb-${u.hostname.split(".")[0]}-auth-token`,h={db:vE,realtime:bE,auth:yt(yt({},xE),{},{storageKey:d}),global:yE},m=kE(s??{},h);if(this.storageKey=(i=m.auth.storageKey)!==null&&i!==void 0?i:"",this.headers=(l=m.global.headers)!==null&&l!==void 0?l:{},m.accessToken)this.accessToken=m.accessToken,this.auth=new Proxy({},{get:(y,x)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(x)} is not possible`)}});else{var g;this.auth=this._initSupabaseAuthClient((g=m.auth)!==null&&g!==void 0?g:{},this.headers,m.global.fetch)}this.fetch=TE(e,this._getAccessToken.bind(this),m.global.fetch),this.realtime=this._initRealtimeClient(yt({headers:this.headers,accessToken:this._getAccessToken.bind(this)},m.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(y=>this.realtime.setAuth(y)).catch(y=>console.warn("Failed to set initial Realtime auth token:",y)),this.rest=new g2(new URL("rest/v1",u).href,{headers:this.headers,schema:m.db.schema,fetch:this.fetch,timeout:m.db.timeout,urlLengthLimit:m.db.urlLengthLimit}),this.storage=new cT(this.storageUrl.href,this.headers,this.fetch,s?.storage),m.accessToken||this._listenForAuthEvents()}get functions(){return new l2(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},s={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,s)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,s;if(t.accessToken)return await t.accessToken();const{data:i}=await t.auth.getSession();return(e=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,storageKey:u,flowType:d,lock:h,debug:m,throwOnError:g},y,x){const w={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new AE({url:this.authUrl.href,headers:yt(yt({},w),y),storageKey:u,autoRefreshToken:t,persistSession:e,detectSessionInUrl:s,storage:i,userStorage:l,flowType:d,lock:h,debug:m,throwOnError:g,fetch:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(S=>S.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new M2(this.realtimeUrl.href,yt(yt({},t),{},{params:yt(yt({},{apikey:this.supabaseKey}),t?.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e?.access_token)})}_handleTokenChanged(t,e,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?(this.changedAccessToken=s,this.realtime.setAuth(s)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const zm=(t,e,s)=>new RE(t,e,s);function OE(){if(typeof window<"u")return!1;const t=globalThis.process;if(!t)return!1;const e=t.version;if(e==null)return!1;const s=e.match(/^v(\d+)\./);return s?parseInt(s[1],10)<=18:!1}OE()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");function vw(t){var e,s,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var l=t.length;for(e=0;e<l;e++)t[e]&&(s=vw(t[e]))&&(i&&(i+=" "),i+=s)}else for(s in t)t[s]&&(i&&(i+=" "),i+=s);return i}function xw(){for(var t,e,s=0,i="",l=arguments.length;s<l;s++)(t=arguments[s])&&(e=vw(t))&&(i&&(i+=" "),i+=e);return i}const ME=(t,e)=>{const s=new Array(t.length+e.length);for(let i=0;i<t.length;i++)s[i]=t[i];for(let i=0;i<e.length;i++)s[t.length+i]=e[i];return s},DE=(t,e)=>({classGroupId:t,validator:e}),bw=(t=new Map,e=null,s)=>({nextPart:t,validators:e,classGroupId:s}),ru="-",r0=[],PE="arbitrary..",zE=t=>{const e=UE(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return LE(d);const h=d.split(ru),m=h[0]===""&&h.length>1?1:0;return ww(h,m,e)},getConflictingClassGroupIds:(d,h)=>{if(h){const m=i[d],g=s[d];return m?g?ME(g,m):m:g||r0}return s[d]||r0}}},ww=(t,e,s)=>{if(t.length-e===0)return s.classGroupId;const l=t[e],u=s.nextPart.get(l);if(u){const g=ww(t,e+1,u);if(g)return g}const d=s.validators;if(d===null)return;const h=e===0?t.join(ru):t.slice(e).join(ru),m=d.length;for(let g=0;g<m;g++){const y=d[g];if(y.validator(h))return y.classGroupId}},LE=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),s=e.indexOf(":"),i=e.slice(0,s);return i?PE+i:void 0})(),UE=t=>{const{theme:e,classGroups:s}=t;return BE(s,e)},BE=(t,e)=>{const s=bw();for(const i in t){const l=t[i];Lm(l,s,i,e)}return s},Lm=(t,e,s,i)=>{const l=t.length;for(let u=0;u<l;u++){const d=t[u];VE(d,e,s,i)}},VE=(t,e,s,i)=>{if(typeof t=="string"){IE(t,e,s);return}if(typeof t=="function"){$E(t,e,s,i);return}qE(t,e,s,i)},IE=(t,e,s)=>{const i=t===""?e:Sw(e,t);i.classGroupId=s},$E=(t,e,s,i)=>{if(HE(t)){Lm(t(i),e,s,i);return}e.validators===null&&(e.validators=[]),e.validators.push(DE(s,t))},qE=(t,e,s,i)=>{const l=Object.entries(t),u=l.length;for(let d=0;d<u;d++){const[h,m]=l[d];Lm(m,Sw(e,h),s,i)}},Sw=(t,e)=>{let s=t;const i=e.split(ru),l=i.length;for(let u=0;u<l;u++){const d=i[u];let h=s.nextPart.get(d);h||(h=bw(),s.nextPart.set(d,h)),s=h}return s},HE=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,GE=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,s=Object.create(null),i=Object.create(null);const l=(u,d)=>{s[u]=d,e++,e>t&&(e=0,i=s,s=Object.create(null))};return{get(u){let d=s[u];if(d!==void 0)return d;if((d=i[u])!==void 0)return l(u,d),d},set(u,d){u in s?s[u]=d:l(u,d)}}},Qf="!",o0=":",FE=[],l0=(t,e,s,i,l)=>({modifiers:t,hasImportantModifier:e,baseClassName:s,maybePostfixModifierPosition:i,isExternal:l}),KE=t=>{const{prefix:e,experimentalParseClassName:s}=t;let i=l=>{const u=[];let d=0,h=0,m=0,g;const y=l.length;for(let j=0;j<y;j++){const _=l[j];if(d===0&&h===0){if(_===o0){u.push(l.slice(m,j)),m=j+1;continue}if(_==="/"){g=j;continue}}_==="["?d++:_==="]"?d--:_==="("?h++:_===")"&&h--}const x=u.length===0?l:l.slice(m);let w=x,S=!1;x.endsWith(Qf)?(w=x.slice(0,-1),S=!0):x.startsWith(Qf)&&(w=x.slice(1),S=!0);const E=g&&g>m?g-m:void 0;return l0(u,S,w,E)};if(e){const l=e+o0,u=i;i=d=>d.startsWith(l)?u(d.slice(l.length)):l0(FE,!1,d,void 0,!0)}if(s){const l=i;i=u=>s({className:u,parseClassName:l})}return i},YE=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((s,i)=>{e.set(s,1e6+i)}),s=>{const i=[];let l=[];for(let u=0;u<s.length;u++){const d=s[u],h=d[0]==="[",m=e.has(d);h||m?(l.length>0&&(l.sort(),i.push(...l),l=[]),i.push(d)):l.push(d)}return l.length>0&&(l.sort(),i.push(...l)),i}},XE=t=>({cache:GE(t.cacheSize),parseClassName:KE(t),sortModifiers:YE(t),...zE(t)}),WE=/\s+/,JE=(t,e)=>{const{parseClassName:s,getClassGroupId:i,getConflictingClassGroupIds:l,sortModifiers:u}=e,d=[],h=t.trim().split(WE);let m="";for(let g=h.length-1;g>=0;g-=1){const y=h[g],{isExternal:x,modifiers:w,hasImportantModifier:S,baseClassName:E,maybePostfixModifierPosition:j}=s(y);if(x){m=y+(m.length>0?" "+m:m);continue}let _=!!j,N=i(_?E.substring(0,j):E);if(!N){if(!_){m=y+(m.length>0?" "+m:m);continue}if(N=i(E),!N){m=y+(m.length>0?" "+m:m);continue}_=!1}const k=w.length===0?"":w.length===1?w[0]:u(w).join(":"),C=S?k+Qf:k,A=C+N;if(d.indexOf(A)>-1)continue;d.push(A);const D=l(N,_);for(let z=0;z<D.length;++z){const V=D[z];d.push(C+V)}m=y+(m.length>0?" "+m:m)}return m},QE=(...t)=>{let e=0,s,i,l="";for(;e<t.length;)(s=t[e++])&&(i=jw(s))&&(l&&(l+=" "),l+=i);return l},jw=t=>{if(typeof t=="string")return t;let e,s="";for(let i=0;i<t.length;i++)t[i]&&(e=jw(t[i]))&&(s&&(s+=" "),s+=e);return s},ZE=(t,...e)=>{let s,i,l,u;const d=m=>{const g=e.reduce((y,x)=>x(y),t());return s=XE(g),i=s.cache.get,l=s.cache.set,u=h,h(m)},h=m=>{const g=i(m);if(g)return g;const y=JE(m,s);return l(m,y),y};return u=d,(...m)=>u(QE(...m))},ek=[],At=t=>{const e=s=>s[t]||ek;return e.isThemeGetter=!0,e},_w=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Nw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,tk=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,nk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sk=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ak=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ik=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>tk.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),ia=t=>!!t&&Number.isInteger(Number(t)),df=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Es=t=>nk.test(t),Tw=()=>!0,ok=t=>sk.test(t)&&!ak.test(t),Um=()=>!1,lk=t=>ik.test(t),ck=t=>rk.test(t),uk=t=>!xe(t)&&!we(t),dk=t=>ga(t,Cw,Um),xe=t=>_w.test(t),Ba=t=>ga(t,Aw,ok),c0=t=>ga(t,xk,Ue),hk=t=>ga(t,Ow,Tw),fk=t=>ga(t,Rw,Um),u0=t=>ga(t,Ew,Um),mk=t=>ga(t,kw,ck),Oc=t=>ga(t,Mw,lk),we=t=>Nw.test(t),vo=t=>ti(t,Aw),pk=t=>ti(t,Rw),d0=t=>ti(t,Ew),gk=t=>ti(t,Cw),yk=t=>ti(t,kw),Mc=t=>ti(t,Mw,!0),vk=t=>ti(t,Ow,!0),ga=(t,e,s)=>{const i=_w.exec(t);return i?i[1]?e(i[1]):s(i[2]):!1},ti=(t,e,s=!1)=>{const i=Nw.exec(t);return i?i[1]?e(i[1]):s:!1},Ew=t=>t==="position"||t==="percentage",kw=t=>t==="image"||t==="url",Cw=t=>t==="length"||t==="size"||t==="bg-size",Aw=t=>t==="length",xk=t=>t==="number",Rw=t=>t==="family-name",Ow=t=>t==="number"||t==="weight",Mw=t=>t==="shadow",bk=()=>{const t=At("color"),e=At("font"),s=At("text"),i=At("font-weight"),l=At("tracking"),u=At("leading"),d=At("breakpoint"),h=At("container"),m=At("spacing"),g=At("radius"),y=At("shadow"),x=At("inset-shadow"),w=At("text-shadow"),S=At("drop-shadow"),E=At("blur"),j=At("perspective"),_=At("aspect"),N=At("ease"),k=At("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...A(),we,xe],z=()=>["auto","hidden","clip","visible","scroll"],V=()=>["auto","contain","none"],R=()=>[we,xe,m],P=()=>[aa,"full","auto",...R()],Z=()=>[ia,"none","subgrid",we,xe],te=()=>["auto",{span:["full",ia,we,xe]},ia,we,xe],me=()=>[ia,"auto",we,xe],Ee=()=>["auto","min","max","fr",we,xe],ye=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_e=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...R()],Y=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],J=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...R()],pe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],se=()=>[t,we,xe],M=()=>[...A(),d0,u0,{position:[we,xe]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",gk,dk,{size:[we,xe]}],ne=()=>[df,vo,Ba],oe=()=>["","none","full",g,we,xe],ue=()=>["",Ue,vo,Ba],q=()=>["solid","dashed","dotted","double"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[Ue,df,d0,u0],ze=()=>["","none",E,we,xe],Be=()=>["none",Ue,we,xe],kt=()=>["none",Ue,we,xe],et=()=>[Ue,we,xe],le=()=>[aa,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Es],breakpoint:[Es],color:[Tw],container:[Es],"drop-shadow":[Es],ease:["in","out","in-out"],font:[uk],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Es],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Es],shadow:[Es],spacing:["px",Ue],text:[Es],"text-shadow":[Es],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,xe,we,_]}],container:["container"],columns:[{columns:[Ue,xe,we,h]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:V()}],"overscroll-x":[{"overscroll-x":V()}],"overscroll-y":[{"overscroll-y":V()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{"inset-s":P(),start:P()}],end:[{"inset-e":P(),end:P()}],"inset-bs":[{"inset-bs":P()}],"inset-be":[{"inset-be":P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[ia,"auto",we,xe]}],basis:[{basis:[aa,"full","auto",h,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,aa,"auto","initial","none",xe]}],grow:[{grow:["",Ue,we,xe]}],shrink:[{shrink:["",Ue,we,xe]}],order:[{order:[ia,"first","last","none",we,xe]}],"grid-cols":[{"grid-cols":Z()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":Z()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Ee()}],"auto-rows":[{"auto-rows":Ee()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...ye(),"normal"]}],"justify-items":[{"justify-items":[..._e(),"normal"]}],"justify-self":[{"justify-self":["auto",..._e()]}],"align-content":[{content:["normal",...ye()]}],"align-items":[{items:[..._e(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._e(),{baseline:["","last"]}]}],"place-content":[{"place-content":ye()}],"place-items":[{"place-items":[..._e(),"baseline"]}],"place-self":[{"place-self":["auto",..._e()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...pe()]}],"min-block-size":[{"min-block":["auto",...pe()]}],"max-block-size":[{"max-block":["none",...pe()]}],w:[{w:[h,"screen",...Y()]}],"min-w":[{"min-w":[h,"screen","none",...Y()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[d]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",s,vo,Ba]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,vk,hk]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",df,xe]}],"font-family":[{font:[pk,fk,e]}],"font-features":[{"font-features":[xe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[l,we,xe]}],"line-clamp":[{"line-clamp":[Ue,"none",we,c0]}],leading:[{leading:[u,...R()]}],"list-image":[{"list-image":["none",we,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",we,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:se()}],"text-color":[{text:se()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",we,Ba]}],"text-decoration-color":[{decoration:se()}],"underline-offset":[{"underline-offset":[Ue,"auto",we,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",we,xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",we,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ia,we,xe],radial:["",we,xe],conic:[ia,we,xe]},yk,mk]}],"bg-color":[{bg:se()}],"gradient-from-pos":[{from:ne()}],"gradient-via-pos":[{via:ne()}],"gradient-to-pos":[{to:ne()}],"gradient-from":[{from:se()}],"gradient-via":[{via:se()}],"gradient-to":[{to:se()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:ue()}],"border-w-x":[{"border-x":ue()}],"border-w-y":[{"border-y":ue()}],"border-w-s":[{"border-s":ue()}],"border-w-e":[{"border-e":ue()}],"border-w-bs":[{"border-bs":ue()}],"border-w-be":[{"border-be":ue()}],"border-w-t":[{"border-t":ue()}],"border-w-r":[{"border-r":ue()}],"border-w-b":[{"border-b":ue()}],"border-w-l":[{"border-l":ue()}],"divide-x":[{"divide-x":ue()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ue()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:se()}],"border-color-x":[{"border-x":se()}],"border-color-y":[{"border-y":se()}],"border-color-s":[{"border-s":se()}],"border-color-e":[{"border-e":se()}],"border-color-bs":[{"border-bs":se()}],"border-color-be":[{"border-be":se()}],"border-color-t":[{"border-t":se()}],"border-color-r":[{"border-r":se()}],"border-color-b":[{"border-b":se()}],"border-color-l":[{"border-l":se()}],"divide-color":[{divide:se()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,we,xe]}],"outline-w":[{outline:["",Ue,vo,Ba]}],"outline-color":[{outline:se()}],shadow:[{shadow:["","none",y,Mc,Oc]}],"shadow-color":[{shadow:se()}],"inset-shadow":[{"inset-shadow":["none",x,Mc,Oc]}],"inset-shadow-color":[{"inset-shadow":se()}],"ring-w":[{ring:ue()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:se()}],"ring-offset-w":[{"ring-offset":[Ue,Ba]}],"ring-offset-color":[{"ring-offset":se()}],"inset-ring-w":[{"inset-ring":ue()}],"inset-ring-color":[{"inset-ring":se()}],"text-shadow":[{"text-shadow":["none",w,Mc,Oc]}],"text-shadow-color":[{"text-shadow":se()}],opacity:[{opacity:[Ue,we,xe]}],"mix-blend":[{"mix-blend":[...fe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":fe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":se()}],"mask-image-linear-to-color":[{"mask-linear-to":se()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":se()}],"mask-image-t-to-color":[{"mask-t-to":se()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":se()}],"mask-image-r-to-color":[{"mask-r-to":se()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":se()}],"mask-image-b-to-color":[{"mask-b-to":se()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":se()}],"mask-image-l-to-color":[{"mask-l-to":se()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":se()}],"mask-image-x-to-color":[{"mask-x-to":se()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":se()}],"mask-image-y-to-color":[{"mask-y-to":se()}],"mask-image-radial":[{"mask-radial":[we,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":se()}],"mask-image-radial-to-color":[{"mask-radial-to":se()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":A()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":se()}],"mask-image-conic-to-color":[{"mask-conic-to":se()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",we,xe]}],filter:[{filter:["","none",we,xe]}],blur:[{blur:ze()}],brightness:[{brightness:[Ue,we,xe]}],contrast:[{contrast:[Ue,we,xe]}],"drop-shadow":[{"drop-shadow":["","none",S,Mc,Oc]}],"drop-shadow-color":[{"drop-shadow":se()}],grayscale:[{grayscale:["",Ue,we,xe]}],"hue-rotate":[{"hue-rotate":[Ue,we,xe]}],invert:[{invert:["",Ue,we,xe]}],saturate:[{saturate:[Ue,we,xe]}],sepia:[{sepia:["",Ue,we,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",we,xe]}],"backdrop-blur":[{"backdrop-blur":ze()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,we,xe]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,we,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,we,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,we,xe]}],"backdrop-invert":[{"backdrop-invert":["",Ue,we,xe]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,we,xe]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,we,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,we,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",we,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",we,xe]}],ease:[{ease:["linear","initial",N,we,xe]}],delay:[{delay:[Ue,we,xe]}],animate:[{animate:["none",k,we,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,we,xe]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Be()}],"rotate-x":[{"rotate-x":Be()}],"rotate-y":[{"rotate-y":Be()}],"rotate-z":[{"rotate-z":Be()}],scale:[{scale:kt()}],"scale-x":[{"scale-x":kt()}],"scale-y":[{"scale-y":kt()}],"scale-z":[{"scale-z":kt()}],"scale-3d":["scale-3d"],skew:[{skew:et()}],"skew-x":[{"skew-x":et()}],"skew-y":[{"skew-y":et()}],transform:[{transform:[we,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:le()}],"translate-x":[{"translate-x":le()}],"translate-y":[{"translate-y":le()}],"translate-z":[{"translate-z":le()}],"translate-none":["translate-none"],accent:[{accent:se()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:se()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",we,xe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",we,xe]}],fill:[{fill:["none",...se()]}],"stroke-w":[{stroke:[Ue,vo,Ba,c0]}],stroke:[{stroke:["none",...se()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},wk=ZE(bk);function ge(...t){return wk(xw(t))}const ht=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("rounded-xl border bg-card text-card-foreground shadow",t),...e}));ht.displayName="Card";const zt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex flex-col space-y-1.5 p-6",t),...e}));zt.displayName="CardHeader";const Lt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("font-semibold leading-none tracking-tight",t),...e}));Lt.displayName="CardTitle";const wn=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm text-muted-foreground",t),...e}));wn.displayName="CardDescription";const xt=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("p-6 pt-0",t),...e}));xt.displayName="CardContent";const Tu=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("flex items-center p-6 pt-0",t),...e}));Tu.displayName="CardFooter";function ou({className:t}){return o.jsx("img",{src:"/folio-logo.svg",alt:"Folio Logo",className:ge("w-full h-full object-contain",t)})}const Dw=(...t)=>t.filter((e,s,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===s).join(" ").trim();const Sk=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const jk=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,s,i)=>i?i.toUpperCase():s.toLowerCase());const h0=t=>{const e=jk(t);return e.charAt(0).toUpperCase()+e.slice(1)};var _k={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nk=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const Tk=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:s=2,absoluteStrokeWidth:i,className:l="",children:u,iconNode:d,...h},m)=>v.createElement("svg",{ref:m,..._k,width:e,height:e,stroke:t,strokeWidth:i?Number(s)*24/Number(e):s,className:Dw("lucide",l),...!u&&!Nk(h)&&{"aria-hidden":"true"},...h},[...d.map(([g,y])=>v.createElement(g,y)),...Array.isArray(u)?u:[u]]));const he=(t,e)=>{const s=v.forwardRef(({className:i,...l},u)=>v.createElement(Tk,{ref:u,iconNode:e,className:Dw(`lucide-${Sk(h0(t))}`,`lucide-${t}`,i),...l}));return s.displayName=h0(t),s};const Ek=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ur=he("activity",Ek);const kk=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Ck=he("arrow-right",kk);const Ak=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Rk=he("book-open",Ak);const Ok=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Zf=he("bot",Ok);const Mk=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Pw=he("brain",Mk);const Dk=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],Pk=he("building-2",Dk);const zk=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],zw=he("calendar",zk);const Lk=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Uk=he("camera",Lk);const Bk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],as=he("check",Bk);const Vk=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bo=he("chevron-down",Vk);const Ik=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Jo=he("chevron-left",Ik);const $k=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],dr=he("chevron-right",$k);const qk=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],lu=he("chevron-up",qk);const Hk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Sn=he("circle-alert",Hk);const Gk=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Fk=he("circle-check-big",Gk);const Kk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],os=he("circle-check",Kk);const Yk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Lw=he("circle-x",Yk);const Xk=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],Qo=he("clock",Xk);const Wk=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],f0=he("cloud",Wk);const Jk=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Qk=he("copy",Jk);const Zk=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Bm=he("cpu",Zk);const eC=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Eu=he("database",eC);const tC=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Uw=he("external-link",tC);const nC=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],sC=he("eye-off",nC);const aC=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],iC=he("eye",aC);const rC=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],oC=he("file-digit",rC);const lC=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Vm=he("file-text",lC);const cC=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Bw=he("funnel",cC);const uC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],dC=he("globe",uC);const hC=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],fC=he("hard-drive",hC);const mC=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],pC=he("history",mC);const gC=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Im=he("info",gC);const yC=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Zo=he("key",yC);const vC=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],xC=he("layers",vC);const bC=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],m0=he("layout-dashboard",bC);const wC=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],rt=he("loader-circle",wC);const SC=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],Vw=he("log-in",SC);const jC=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Iw=he("log-out",jC);const _C=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Vo=he("mail",_C);const NC=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],cu=he("message-square",NC);const TC=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],$w=he("minimize-2",TC);const EC=[["path",{d:"M5 12h14",key:"1ays0h"}]],em=he("minus",EC);const kC=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],CC=he("moon",kC);const AC=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],RC=he("package",AC);const OC=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],qw=he("play",OC);const MC=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Wa=he("plus",MC);const DC=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PC=he("refresh-ccw",DC);const zC=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ma=he("refresh-cw",zC);const LC=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],UC=he("rocket",LC);const BC=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],VC=he("save",BC);const IC=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],Hw=he("scroll-text",IC);const $C=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],qC=he("search",$C);const HC=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],GC=he("send",HC);const FC=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],KC=he("server",FC);const YC=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],$m=he("settings-2",YC);const XC=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],WC=he("settings",XC);const JC=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],p0=he("share-2",JC);const QC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],uu=he("shield-alert",QC);const ZC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ya=he("shield-check",ZC);const eA=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Cs=he("sparkles",eA);const tA=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],nA=he("sun",tA);const sA=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],du=he("tag",sA);const aA=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Io=he("terminal",aA);const iA=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],rA=he("test-tube",iA);const oA=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],lA=he("toggle-left",oA);const cA=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],uA=he("toggle-right",cA);const dA=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],el=he("trash-2",dA);const hA=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gw=he("triangle-alert",hA);const fA=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tm=he("upload",fA);const mA=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],pA=he("user-plus",mA);const gA=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ku=he("user",gA);const yA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],nm=he("volume-2",yA);const vA=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Fw=he("volume-x",vA);const xA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],zn=he("x",xA);const bA=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],hu=he("zap",bA),Cu="folio_supabase_config";function g0(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.url=="string"&&typeof e.anonKey=="string"&&e.url.startsWith("http")&&e.anonKey.length>20&&!e.url.includes("placeholder.supabase.co")}function $o(){try{const e=localStorage.getItem(Cu);if(e){const s=JSON.parse(e);if(g0(s))return s}}catch{}const t={url:void 0,anonKey:void 0};return g0(t)?t:null}function hf(t){localStorage.setItem(Cu,JSON.stringify(t))}function wA(){localStorage.removeItem(Cu)}async function SA(t,e){if(!t.startsWith("http://")&&!t.startsWith("https://"))return{valid:!1,error:"Invalid URL format"};const s=e.startsWith("eyJ"),i=e.startsWith("sb_publishable_");if(!s&&!i)return{valid:!1,error:"Invalid anon key format"};if(i)return{valid:!0};const l=new AbortController,u=setTimeout(()=>l.abort("Validation timeout"),12e3);try{const d=await fetch(`${t}/rest/v1/`,{method:"GET",headers:{apikey:e,Authorization:`Bearer ${e}`},signal:l.signal});return d.ok?(clearTimeout(u),{valid:!0}):(clearTimeout(u),{valid:!1,error:`Connection failed (${d.status})`})}catch(d){return clearTimeout(u),d instanceof DOMException&&d.name==="AbortError"?{valid:!1,error:"Connection validation timed out (12s). Check project URL/key and network."}:{valid:!1,error:d instanceof Error?d.message:"Connection failed"}}}function jA(){return localStorage.getItem(Cu)?"ui":"none"}let Dc=null;function un(){const t=$o();return t?(Dc||(Dc=zm(t.url,t.anonKey,{auth:{autoRefreshToken:!0,persistSession:!0}})),Dc):(Dc=null,null)}function ff(){const t=$o(),e=t?`${t.url}/functions/v1`:"",s=t?.anonKey??"",u=window.location.port==="5173"?void 0||"http://localhost:3006":window.location.origin;return{edgeFunctionsUrl:e,expressApiUrl:u,anonKey:s}}class _A{edgeFunctionsUrl;expressApiUrl;anonKey;constructor(){const e=ff();this.edgeFunctionsUrl=e.edgeFunctionsUrl,this.expressApiUrl=e.expressApiUrl,this.anonKey=e.anonKey}async request(e,s,i={}){const{auth:l=!1,token:u,...d}=i,h={"Content-Type":"application/json",...d.headers||{}};l&&u&&(h.Authorization=`Bearer ${u}`);try{const m=await fetch(`${e}${s}`,{...d,headers:h}),g=await m.json().catch(()=>({}));return m.ok?{data:g}:{error:{code:g?.error?.code||"API_ERROR",message:g?.error?.message||g?.error||`Request failed (${m.status})`}}}catch(m){return{error:{code:"NETWORK_ERROR",message:m instanceof Error?m.message:"Network error"}}}}edgeRequest(e,s={}){const i={...s.headers||{},apikey:this.anonKey};return this.request(this.edgeFunctionsUrl,e,{...s,headers:i})}expressRequest(e,s={}){const i=ff(),l={...s.headers||{},"X-Supabase-Url":i.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":i.anonKey};return this.request(this.expressApiUrl,e,{...s,headers:l})}get(e,s={}){return this.expressRequest(e,{method:"GET",...s,auth:!0})}post(e,s,i={}){return this.expressRequest(e,{method:"POST",body:s?JSON.stringify(s):void 0,...i,auth:!0})}getChatSessions(e){return this.expressRequest("/api/chat/sessions",{method:"GET",auth:!!e,token:e})}getDashboardStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}createChatSession(e){return this.expressRequest("/api/chat/sessions",{method:"POST",auth:!!e,token:e})}getChatMessages(e,s){return this.expressRequest(`/api/chat/sessions/${e}/messages`,{method:"GET",auth:!!s,token:s})}sendChatMessage(e,s){return this.expressRequest("/api/chat/message",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getHealth(){return this.expressRequest("/api/health",{method:"GET"})}testSupabase(e,s){return this.expressRequest("/api/setup/test-supabase",{method:"POST",body:JSON.stringify({url:e,anonKey:s})})}dispatchProcessingJob(e,s){return this.expressRequest("/api/processing/dispatch",{method:"POST",auth:!!s,token:s,body:JSON.stringify({source_type:"manual",payload:e})})}getSettings(e){return this.expressRequest("/api/settings",{method:"GET",auth:!!e,token:e})}updateSettings(e,s){return this.expressRequest("/api/settings",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getAccounts(e){return this.expressRequest("/api/accounts",{method:"GET",auth:!!e,token:e})}disconnectAccount(e,s){return this.expressRequest("/api/accounts/disconnect",{method:"POST",auth:!!s,token:s,body:JSON.stringify({accountId:e})})}getRules(e){return this.expressRequest("/api/rules",{method:"GET",auth:!!e,token:e})}createRule(e,s){return this.expressRequest("/api/rules",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}updateRule(e,s,i){return this.expressRequest(`/api/rules/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}deleteRule(e,s){return this.expressRequest(`/api/rules/${e}`,{method:"DELETE",auth:!!s,token:s})}toggleRule(e,s){return this.expressRequest(`/api/rules/${e}/toggle`,{method:"POST",auth:!!s,token:s})}getStats(e){return this.expressRequest("/api/stats",{method:"GET",auth:!!e,token:e})}getProfile(e){return this.edgeRequest("/api-v1-profile",{method:"GET",auth:!!e,token:e})}updateProfile(e,s){return this.edgeRequest("/api-v1-profile",{method:"PATCH",auth:!!s,token:s,body:JSON.stringify(e)})}getChatProviders(e){return this.expressRequest("/api/sdk/providers/chat",{method:"GET",auth:!!e,token:e})}getEmbedProviders(e){return this.expressRequest("/api/sdk/providers/embed",{method:"GET",auth:!!e,token:e})}testLlm(e,s){return this.expressRequest("/api/sdk/test-llm",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getGmailAuthUrl(e,s,i){return this.expressRequest("/api/accounts/gmail/auth-url",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,clientSecret:s})})}connectGmail(e,s,i,l){return this.expressRequest("/api/accounts/gmail/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}getGoogleDriveAuthUrl(e,s){return this.expressRequest("/api/accounts/google-drive/auth-url",{method:"POST",auth:!!s,token:s,body:JSON.stringify({clientId:e})})}connectGoogleDrive(e,s,i,l){return this.expressRequest("/api/accounts/google-drive/connect",{method:"POST",auth:!!l,token:l,body:JSON.stringify({authCode:e,clientId:s,clientSecret:i})})}startMicrosoftDeviceFlow(e,s,i){return this.expressRequest("/api/accounts/microsoft/device-flow",{method:"POST",auth:!!i,token:i,body:JSON.stringify({clientId:e,tenantId:s})})}pollMicrosoftDeviceCode(e,s,i,l){return this.expressRequest("/api/accounts/microsoft/poll",{method:"POST",auth:!!l,token:l,body:JSON.stringify({deviceCode:e,clientId:s,tenantId:i})})}connectImap(e,s){return this.expressRequest("/api/accounts/imap/connect",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}setup(e){return this.edgeRequest("/setup",{method:"POST",body:JSON.stringify(e)})}getPolicies(e){return this.expressRequest("/api/policies",{auth:!!e,token:e})}savePolicy(e,s){return this.expressRequest("/api/policies",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}deletePolicy(e,s){return this.expressRequest(`/api/policies/${e}`,{method:"DELETE",auth:!!s,token:s})}patchPolicy(e,s,i){return this.expressRequest(`/api/policies/${e}`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify(s)})}reloadPolicies(e){return this.expressRequest("/api/policies/reload",{method:"POST",auth:!!e,token:e})}synthesizePolicy(e,s){return this.expressRequest("/api/policies/synthesize",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}getSDKChatProviders(){return this.expressRequest("/api/sdk/providers/chat")}getIngestions(e={},s){const i=new URLSearchParams;e.page&&i.set("page",String(e.page)),e.pageSize&&i.set("pageSize",String(e.pageSize)),e.q&&i.set("q",e.q);const l=i.toString()?`?${i}`:"";return this.expressRequest(`/api/ingestions${l}`,{auth:!!s,token:s})}uploadDocument(e,s){const i=new FormData;i.append("file",e);const l=ff(),u={"X-Supabase-Url":l.edgeFunctionsUrl.replace("/functions/v1",""),"X-Supabase-Anon-Key":l.anonKey};return s&&(u.Authorization=`Bearer ${s}`),fetch(`${l.expressApiUrl}/api/ingestions/upload`,{method:"POST",headers:u,body:i}).then(d=>d.json())}rerunIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/rerun`,{method:"POST",auth:!!s,token:s})}matchIngestionToPolicy(e,s,i){const l=s.learn!==!1,u=s.rerun!==!1;return this.expressRequest(`/api/ingestions/${e}/match`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,learn:l,rerun:u,allow_side_effects:s.allowSideEffects===!0})})}suggestPolicyRefinement(e,s,i){return this.expressRequest(`/api/ingestions/${e}/refine-policy`,{method:"POST",auth:!!i,token:i,body:JSON.stringify({policy_id:s.policyId,provider:s.provider,model:s.model})})}deleteIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}`,{method:"DELETE",auth:!!s,token:s})}updateIngestionTags(e,s,i){return this.expressRequest(`/api/ingestions/${e}/tags`,{method:"PATCH",auth:!!i,token:i,body:JSON.stringify({tags:s})})}summarizeIngestion(e,s){return this.expressRequest(`/api/ingestions/${e}/summarize`,{method:"POST",auth:!!s,token:s})}getBaselineConfig(e){return this.expressRequest("/api/baseline-config",{auth:!!e,token:e})}getBaselineConfigHistory(e){return this.expressRequest("/api/baseline-config/history",{auth:!!e,token:e})}saveBaselineConfig(e,s){return this.expressRequest("/api/baseline-config",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}activateBaselineConfig(e,s){return this.expressRequest(`/api/baseline-config/${e}/activate`,{method:"POST",auth:!!s,token:s})}suggestBaselineConfig(e,s){return this.expressRequest("/api/baseline-config/suggest",{method:"POST",auth:!!s,token:s,body:JSON.stringify(e)})}}const Te=new _A;let ns=[],sm=new Set;function am(){sm.forEach(t=>t())}const ce={success:(t,e)=>Pc("success",t,e),error:(t,e)=>Pc("error",t,e),info:(t,e)=>Pc("info",t,e),warning:(t,e)=>Pc("warning",t,e)};function Pc(t,e,s=5e3){const i=ns.findIndex(u=>u.message===e&&u.type===t);if(i!==-1){const u=ns[i];ns=[...ns],ns[i]={...u,count:(u.count||1)+1,lastUpdated:Date.now()},am();return}const l=Math.random().toString(36).substr(2,9);ns=[...ns,{id:l,type:t,message:e,duration:s,count:1,lastUpdated:Date.now()}],am(),s>0&&setTimeout(()=>Kw(l),s)}function Kw(t){ns=ns.filter(e=>e.id!==t),am()}function NA(){const[,t]=v.useState(0);return v.useEffect(()=>{const e=()=>t(s=>s+1);return sm.add(e),()=>{sm.delete(e)}},[]),ns}const TA={success:Fk,error:Sn,info:Im,warning:Gw},EA={success:"bg-emerald-500/10 border-emerald-500/20 text-emerald-600 dark:text-emerald-400",error:"bg-destructive/10 border-destructive/20 text-destructive",info:"bg-blue-500/10 border-blue-500/20 text-blue-600 dark:text-blue-400",warning:"bg-yellow-500/10 border-yellow-500/20 text-yellow-600 dark:text-yellow-400"};function kA({toast:t}){const e=TA[t.type];return o.jsxs("div",{className:ge("flex items-start gap-3 p-4 rounded-lg border shadow-lg backdrop-blur-sm","animate-in slide-in-from-left-full duration-300",EA[t.type]),children:[o.jsxs("div",{className:"relative",children:[o.jsx(e,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.count&&t.count>1&&o.jsx("span",{className:"absolute -top-2 -right-2 bg-primary text-primary-foreground text-[10px] font-bold px-1.5 rounded-full border border-background scale-90 animate-in zoom-in duration-200",children:t.count})]}),o.jsx("p",{className:"text-sm flex-1",children:t.message}),o.jsx("button",{onClick:()=>Kw(t.id),className:"p-1 hover:bg-black/10 rounded transition-colors",children:o.jsx(zn,{className:"w-4 h-4"})})]})}function CA(){const t=NA();return t.length===0?null:o.jsx("div",{className:"fixed bottom-4 left-4 z-[100] flex flex-col-reverse gap-2 max-w-sm w-full",children:t.map(e=>o.jsx(kA,{toast:e},e.id))})}function AA({configSnapshot:t,configSource:e,setActivePage:s}){const[i,l]=v.useState(null),[u,d]=v.useState(!0),[h,m]=v.useState(!1),[g,y]=v.useState(!1),x=v.useRef(null),w=v.useCallback(async()=>{d(!0);try{const j=un();if(!j)return;const{data:_}=await j.auth.getSession(),N=_.session?.access_token??null;if(!N)return;const k=await Te.getDashboardStats(N);k.data?.success&&l(k.data.stats)}catch(j){console.error("Failed to fetch dashboard stats",j)}finally{d(!1)}},[]);v.useEffect(()=>{w()},[w]);const S=async j=>{const _=Array.from(j);if(_.length){s("funnel"),y(!0);try{const N=un();if(!N)return;const{data:k}=await N.auth.getSession(),C=k.session?.access_token??null;if(!C)return;for(const A of _){ce.info(`Ingesting ${A.name}…`);const D=await Te.uploadDocument?.(A,C);if(D?.success)if(D.ingestion?.status==="duplicate"){const z=D.ingestion.extracted?.original_filename??"a previous upload";ce.warning(`${A.name} is a duplicate of "${z}" — skipped.`)}else ce.success(`${A.name} → ${D.ingestion?.status}`);else ce.error(`Failed to ingest ${A.name}`)}await w()}finally{y(!1)}}},E=j=>{j.preventDefault(),m(!1),S(j.dataTransfer.files)};return o.jsxs("div",{className:"w-full mx-auto px-8 py-10 space-y-12 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"text-center space-y-3",children:[o.jsxs("h2",{className:"text-4xl font-black tracking-tight flex items-center justify-center gap-3",children:[o.jsx(ou,{className:"w-10 h-10 animate-pulse"}),"Command Center"]}),o.jsx("p",{className:"text-muted-foreground text-lg max-w-2xl mx-auto",children:"Central intelligence hub for document ingestion, routing, and synthetic knowledge."})]}),o.jsxs("div",{className:"w-full space-y-10",children:[o.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[o.jsx(zc,{title:"Documents Ingested",value:i?.totalDocuments,icon:o.jsx(Vm,{className:"w-5 h-5 text-blue-500"}),isLoading:u,colorClass:"bg-blue-500/10"}),o.jsx(zc,{title:"Active Policies",value:i?.activePolicies,icon:o.jsx(p0,{className:"w-5 h-5 text-emerald-500"}),isLoading:u,colorClass:"bg-emerald-500/10"}),o.jsx(zc,{title:"Knowledge Chunks",value:i?.ragChunks,icon:o.jsx(Eu,{className:"w-5 h-5 text-purple-500"}),isLoading:u,colorClass:"bg-purple-500/10"}),o.jsx(zc,{title:"Automation Runs",value:i?.automationRuns,icon:o.jsx(ur,{className:"w-5 h-5 text-amber-500"}),isLoading:u,colorClass:"bg-amber-500/10"})]}),o.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs("div",{onDragOver:j=>{j.preventDefault(),m(!0)},onDragLeave:()=>m(!1),onDrop:E,onClick:()=>x.current?.click(),className:ge("h-full rounded-2xl border-2 border-dashed transition-all cursor-pointer flex flex-col items-center justify-center gap-4 py-16",h?"border-primary bg-primary/5 scale-[1.01]":"border-muted-foreground/20 hover:border-primary/50 hover:bg-muted/30"),children:[o.jsx("input",{ref:x,type:"file",multiple:!0,hidden:!0,onChange:j=>j.target.files&&S(j.target.files)}),g?o.jsx(rt,{className:"w-12 h-12 animate-spin text-primary"}):o.jsx(tm,{className:ge("w-12 h-12 transition-colors",h?"text-primary":"text-muted-foreground/50")}),o.jsxs("div",{className:"text-center space-y-1",children:[o.jsx("p",{className:"text-lg font-medium text-foreground",children:h?"Drop to ingest...":"Drag & drop files to ingest"}),o.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Supports .pdf, .docx, .md, .txt (up to 20MB)"})]})]})}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("chat"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-indigo-500/10 flex items-center justify-center mb-4",children:o.jsx(cu,{className:"w-6 h-6 text-indigo-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Chat with Data"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions against your vectorized knowledge base."})]}),o.jsxs(ht,{className:"flex-1 cursor-pointer hover:border-primary/50 hover:bg-muted/30 transition-all flex flex-col items-center justify-center p-6 text-center shadow-sm",onClick:()=>s("policies"),children:[o.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/10 flex items-center justify-center mb-4",children:o.jsx(p0,{className:"w-6 h-6 text-orange-500"})}),o.jsx("h3",{className:"font-bold mb-1",children:"Create Policy"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a new routing and automation contract."})]})]})]})]})]})}function zc({title:t,value:e,icon:s,isLoading:i,colorClass:l}){return o.jsx(ht,{className:"shadow-sm",children:o.jsxs(xt,{className:"p-6",children:[o.jsx("div",{className:"flex items-center justify-between mb-4",children:o.jsx("div",{className:ge("w-10 h-10 rounded-xl flex items-center justify-center",l),children:s})}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:t}),i?o.jsx("div",{className:"h-8 w-16 bg-muted animate-pulse rounded-md"}):o.jsx("p",{className:"text-3xl font-black",children:e!==void 0?e.toLocaleString():"0"})]})]})})}function y0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Au(...t){return e=>{let s=!1;const i=t.map(l=>{const u=y0(l,e);return!s&&typeof u=="function"&&(s=!0),u});if(s)return()=>{for(let l=0;l<i.length;l++){const u=i[l];typeof u=="function"?u():y0(t[l],null)}}}}function ni(...t){return v.useCallback(Au(...t),t)}var RA=Symbol.for("react.lazy"),fu=Mm[" use ".trim().toString()];function OA(t){return typeof t=="object"&&t!==null&&"then"in t}function Yw(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===RA&&"_payload"in t&&OA(t._payload)}function Xw(t){const e=DA(t),s=v.forwardRef((i,l)=>{let{children:u,...d}=i;Yw(u)&&typeof fu=="function"&&(u=fu(u._payload));const h=v.Children.toArray(u),m=h.find(zA);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}var MA=Xw("Slot");function DA(t){const e=v.forwardRef((s,i)=>{let{children:l,...u}=s;if(Yw(l)&&typeof fu=="function"&&(l=fu(l._payload)),v.isValidElement(l)){const d=UA(l),h=LA(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var PA=Symbol("radix.slottable");function zA(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===PA}function LA(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function UA(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}const v0=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,x0=xw,qm=(t,e)=>s=>{var i;if(e?.variants==null)return x0(t,s?.class,s?.className);const{variants:l,defaultVariants:u}=e,d=Object.keys(l).map(g=>{const y=s?.[g],x=u?.[g];if(y===null)return null;const w=v0(y)||v0(x);return l[g][w]}),h=s&&Object.entries(s).reduce((g,y)=>{let[x,w]=y;return w===void 0||(g[x]=w),g},{}),m=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((g,y)=>{let{class:x,className:w,...S}=y;return Object.entries(S).every(E=>{let[j,_]=E;return Array.isArray(_)?_.includes({...u,...h}[j]):{...u,...h}[j]===_})?[...g,x,w]:g},[]);return x0(t,d,m,s?.class,s?.className)},BA=qm("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 focus-visible:ring-4 focus-visible:outline-1 aria-invalid:focus-visible:ring-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ae=v.forwardRef(({className:t,variant:e,size:s,asChild:i=!1,...l},u)=>{const d=i?MA:"button";return o.jsx(d,{className:ge(BA({variant:e,size:s,className:t})),ref:u,...l})});ae.displayName="Button";const je=v.forwardRef(({className:t,type:e,...s},i)=>o.jsx("input",{type:e,className:ge("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:i,...s}));je.displayName="Input";var Ww=tw();const VA=Zb(Ww);var IA=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$A=IA.reduce((t,e)=>{const s=Xw(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{}),qA="Label",Jw=v.forwardRef((t,e)=>o.jsx($A.label,{...t,ref:e,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(t.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));Jw.displayName=qA;var HA=Jw;function Je({className:t,...e}){return o.jsx(HA,{"data-slot":"label",className:ge("flex items-center gap-2 text-sm leading-none font-medium select-none text-muted-foreground group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const GA=qm("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Pt({className:t,variant:e,...s}){return o.jsx("div",{className:ge(GA({variant:e}),t),...s})}const FA=qm("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),jn=v.forwardRef(({className:t,variant:e,...s},i)=>o.jsx("div",{ref:i,role:"alert",className:ge(FA({variant:e}),t),...s}));jn.displayName="Alert";const Hm=v.forwardRef(({className:t,...e},s)=>o.jsx("h5",{ref:s,className:ge("mb-1 font-medium leading-none tracking-tight",t),...e}));Hm.displayName="AlertTitle";const _n=v.forwardRef(({className:t,...e},s)=>o.jsx("div",{ref:s,className:ge("text-sm [&_p]:leading-relaxed",t),...e}));_n.displayName="AlertDescription";function KA({supabase:t,initStatus:e,sessionStatus:s,sessionEmail:i,onRefresh:l}){const[u,d]=v.useState(""),[h,m]=v.useState(""),[g,y]=v.useState(""),[x,w]=v.useState(""),[S,E]=v.useState(!1),[j,_]=v.useState(null),N=e==="empty";async function k(){E(!0),_(null);const{error:z}=await t.auth.signInWithPassword({email:u,password:h});z?_(z.message):l(),E(!1)}async function C(){E(!0),_(null);try{const z=await Te.setup({email:u,password:h,first_name:g,last_name:x});if(z.error)throw new Error(typeof z.error=="string"?z.error:z.error.message);const{error:V}=await t.auth.signInWithPassword({email:u,password:h});if(V)throw V;l()}catch(z){_(z.message||"Failed to initialize foundation.")}finally{E(!1)}}async function A(){E(!0),_(null);const{error:z}=await t.auth.signUp({email:u,password:h,options:{data:{first_name:g,last_name:x}}});z?_(z.message):l(),E(!1)}async function D(){E(!0),await t.auth.signOut(),l(),E(!1)}return s==="authenticated"?o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-xl bg-primary/5 border border-primary/10",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary flex items-center justify-center text-primary-foreground",children:o.jsx(ku,{className:"w-5 h-5"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground leading-none mb-1",children:"Authenticated as"}),o.jsx("p",{className:"text-sm font-medium truncate",children:i})]})]}),e==="missing_view"&&o.jsxs(jn,{variant:"destructive",className:"bg-destructive/5 text-destructive border-destructive/20",children:[o.jsx(uu,{className:"w-4 h-4"}),o.jsx(_n,{className:"text-xs",children:"Database views missing. Foundation may be corrupted."})]}),o.jsxs(ae,{variant:"outline",className:"w-full h-11 hover:bg-destructive hover:text-destructive-reveal group transition-all duration-300",onClick:D,disabled:S,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Iw,{className:"w-4 h-4 mr-2 group-hover:rotate-180 transition-transform duration-500"}),"Logout Protocol"]})]}):o.jsxs("div",{className:"space-y-4 animate-in fade-in duration-500",children:[o.jsxs("div",{className:"grid gap-4",children:[N&&o.jsxs("div",{className:"grid grid-cols-2 gap-4 animate-in slide-in-from-top-2 duration-300",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-firstname",children:"First Name"}),o.jsx(je,{id:"auth-firstname",placeholder:"Agent",value:g,onChange:z=>y(z.target.value),className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-lastname",children:"Last Name"}),o.jsx(je,{id:"auth-lastname",placeholder:"Zero",value:x,onChange:z=>w(z.target.value),className:"h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-email",children:"Email Address"}),o.jsxs("div",{className:"relative",children:[o.jsx(Vo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-email",type:"email",placeholder:"admin@example.com",value:u,onChange:z=>d(z.target.value),className:"pl-9 h-10"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"auth-password",children:"Security Key"}),o.jsxs("div",{className:"relative",children:[o.jsx(Zo,{className:"absolute left-3 top-2.5 h-4 w-4 text-muted-foreground"}),o.jsx(je,{id:"auth-password",type:"password",placeholder:"••••••••",value:h,onChange:z=>m(z.target.value),className:"pl-9 h-10",autoComplete:N?"new-password":"current-password"})]})]})]}),j&&o.jsx(jn,{variant:"destructive",className:"py-2 px-3",children:o.jsx(_n,{className:"text-[11px] leading-relaxed italic",children:j})}),o.jsx("div",{className:"pt-2",children:N?o.jsxs(ae,{className:"w-full h-11 shadow-lg shadow-primary/20",onClick:C,disabled:S||!u||!h||!g,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(ya,{className:"w-4 h-4 mr-2"}),"Initialize Primary Admin"]}):o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs(ae,{className:"h-10",onClick:k,disabled:S||!u||!h,children:[S?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Vw,{className:"w-4 h-4 mr-2"}),"Login"]}),o.jsxs(ae,{variant:"secondary",className:"h-10",onClick:A,disabled:S||!u||!h,children:[o.jsx(pA,{className:"w-4 h-4 mr-2"}),"Enroll"]})]})}),o.jsx("p",{className:"text-[10px] text-center text-muted-foreground uppercase tracking-widest font-bold opacity-50 pt-2",children:N?"Foundation Assembly Phase":"Foundation Access Required"})]})}const ha="0.1.10",YA="20260228000001";async function XA(t,e){const s=Promise.resolve(t);let i=null;const l=new Promise((u,d)=>{i=setTimeout(()=>{d(new Error(`Operation timed out after ${e}ms`))},e)});try{return await Promise.race([s,l])}finally{i&&clearTimeout(i)}}async function WA(t){try{const{data:e,error:s}=await XA(t.rpc("get_latest_migration_timestamp"),12e3);if(s)return s.code==="42883"?{latestMigrationTimestamp:"0"}:{latestMigrationTimestamp:null};const i=e??null;return i&&i>="29990000000000"?{latestMigrationTimestamp:null}:{latestMigrationTimestamp:i}}catch{return{latestMigrationTimestamp:null}}}async function Qw(t){const e=await WA(t);return!e.latestMigrationTimestamp||e.latestMigrationTimestamp.trim()===""?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database migration state unknown."}:YA>e.latestMigrationTimestamp?{needsMigration:!0,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:`Database is behind (${e.latestMigrationTimestamp}).`}:{needsMigration:!1,appVersion:ha,latestMigrationTimestamp:e.latestMigrationTimestamp,message:"Database schema is up-to-date."}}function JA({supabase:t,sessionEmail:e,sessionStatus:s,initStatus:i,configSnapshot:l,configSource:u,onRefresh:d,onLaunchSetup:h,onResetSetup:m}){const[g,y]=v.useState("profile"),[x,w]=v.useState(null),[S,E]=v.useState(!1);async function j(){if(!t)return;E(!0);const{data:{user:k}}=await t.auth.getUser();if(k){const{data:C}=await t.from("profiles").select("*").eq("id",k.id).single();C&&w(C)}E(!1)}v.useEffect(()=>{s==="authenticated"&&t&&j()},[s,t]);const _=[{id:"profile",label:"Profile",icon:ku},{id:"security",label:"Security",icon:ya},{id:"supabase",label:"Supabase",icon:Eu}];async function N(){t&&(await t.auth.signOut(),d())}return o.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex flex-col gap-2",children:[o.jsx("h1",{className:"text-4xl font-black tracking-tight",children:"Account Settings"}),o.jsx("p",{className:"text-muted-foreground text-lg",children:"Manage your profile and foundational preferences."})]}),o.jsxs("div",{className:"flex flex-col md:flex-row gap-12 items-start",children:[o.jsxs("aside",{className:"w-full md:w-72 flex flex-col gap-8 shrink-0",children:[o.jsx("nav",{className:"space-y-1",children:_.map(k=>{const C=k.icon,A=g===k.id;return o.jsxs("button",{onClick:()=>y(k.id),className:ge("w-full flex items-center gap-3 px-4 py-3 text-sm font-bold rounded-xl transition-all duration-300",A?"bg-foreground text-background shadow-lg shadow-foreground/10":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:[o.jsx(C,{className:ge("w-5 h-5",A?"text-background":"text-muted-foreground/60")}),k.label]},k.id)})}),o.jsxs("div",{className:"pt-8 border-t space-y-6",children:[o.jsxs("button",{onClick:N,className:"group w-full flex items-center gap-3 px-4 py-2 text-sm font-bold rounded-xl transition-all duration-300 text-destructive hover:bg-destructive/10",children:[o.jsx(Iw,{className:"w-5 h-5 transition-transform group-hover:translate-x-1"}),"Logout"]}),o.jsxs("div",{className:"px-4",children:[o.jsx("p",{className:"text-[10px] font-black text-muted-foreground/40 uppercase tracking-widest mb-1",children:"Version"}),o.jsxs("p",{className:"text-xs font-mono text-muted-foreground/60",children:["v",ha]})]})]})]}),o.jsxs("div",{className:"flex-1 w-full animate-in slide-in-from-right-4 duration-500",children:[g==="profile"&&o.jsx(QA,{sessionEmail:e,sessionStatus:s,supabase:t,initStatus:i,profile:x,onProfileUpdate:j,onRefresh:d,isLoading:S}),g==="security"&&o.jsx(ZA,{supabase:t}),g==="supabase"&&o.jsx(eR,{configSnapshot:l,configSource:u,onLaunchSetup:h,onResetSetup:m})]})]})]})}function QA({sessionEmail:t,sessionStatus:e,supabase:s,initStatus:i,profile:l,onProfileUpdate:u,onRefresh:d,isLoading:h}){const[m,g]=v.useState(""),[y,x]=v.useState(""),[w,S]=v.useState(!0),[E,j]=v.useState(!1),[_,N]=v.useState(!1);v.useEffect(()=>{l&&(g(l.first_name||""),x(l.last_name||""))},[l]);const k=async()=>{if(!s||!l)return;j(!0);const{error:A}=await s.from("profiles").update({first_name:m,last_name:y}).eq("id",l.id);A||u(),j(!1)},C=async A=>{const D=A.target.files?.[0];if(!(!D||!s||!l)){N(!0);try{const z=D.name.split(".").pop(),V=`${l.id}/${Math.random()}.${z}`,{error:R}=await s.storage.from("avatars").upload(V,D);if(R)throw R;const{data:{publicUrl:P}}=s.storage.from("avatars").getPublicUrl(V);await s.from("profiles").update({avatar_url:P}).eq("id",l.id),u()}catch(z){console.error("Upload error:",z)}finally{N(!1)}}};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Profile Information"}),o.jsx(wn,{className:"text-base",children:"Update your personal foundation details."})]}),o.jsx(xt,{className:"p-8 space-y-10",children:h?o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(rt,{className:"w-8 h-8 animate-spin text-primary"})}):e==="authenticated"?o.jsxs("div",{className:"space-y-10",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-8",children:[o.jsxs("div",{className:"relative group",children:[o.jsx("div",{className:"w-32 h-32 rounded-full bg-primary/10 border-4 border-background shadow-2xl overflow-hidden flex items-center justify-center",children:l?.avatar_url?o.jsx("img",{src:l.avatar_url,alt:"Avatar",className:"w-full h-full object-cover"}):t?o.jsx("span",{className:"text-4xl font-black text-primary",children:t.charAt(0).toUpperCase()}):o.jsx(ku,{className:"w-12 h-12 text-primary/40"})}),o.jsxs("label",{className:"absolute bottom-1 right-1 h-10 w-10 rounded-full bg-background border shadow-lg flex items-center justify-center hover:scale-110 transition-transform cursor-pointer",children:[_?o.jsx(rt,{className:"w-4 h-4 animate-spin text-muted-foreground"}):o.jsx(Uk,{className:"w-5 h-5 text-muted-foreground"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:C,disabled:_})]})]}),o.jsxs("div",{className:"flex-1 w-full grid grid-cols-1 sm:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"firstName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"First Name"}),o.jsx(je,{id:"firstName",placeholder:"Trung",value:m,onChange:A=>g(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"lastName",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Last Name"}),o.jsx(je,{id:"lastName",placeholder:"Le",value:y,onChange:A=>x(A.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[o.jsx(Je,{htmlFor:"email",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Email Address"}),o.jsx(je,{id:"email",value:t||"",disabled:!0,className:"h-12 rounded-xl bg-muted/40 border-border/40 opacity-70 cursor-not-allowed"}),o.jsx("p",{className:"text-[10px] text-muted-foreground/60 font-bold ml-1",children:"This is your login email and cannot be changed."})]})]})]}),o.jsxs("div",{className:"pt-8 border-t flex items-center justify-between",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("h4",{className:"text-base font-bold",children:"Sound & Haptic Feedback"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Play chimes and haptic pulses for system events."})]}),o.jsxs(ae,{variant:w?"default":"outline",className:ge("h-11 px-6 rounded-xl font-bold transition-all",w?"shadow-lg shadow-primary/20":""),onClick:()=>S(!w),children:[w?o.jsx(nm,{className:"w-4 h-4 mr-2"}):o.jsx(Fw,{className:"w-4 h-4 mr-2"}),w?"Enabled":"Disabled"]})]})]}):o.jsxs("div",{className:"py-8",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4 mb-6",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(ya,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold",children:"Authentication Gateway"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Access your foundational profile."})]})]}),s&&o.jsx(KA,{supabase:s,initStatus:i,sessionStatus:e,sessionEmail:t,onRefresh:d})]})}),e==="authenticated"&&!h&&o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:k,disabled:E,children:[E?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(VC,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}function ZA({supabase:t}){const[e,s]=v.useState(""),[i,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),g=async()=>{if(!t)return;if(e!==i){m({type:"error",msg:"Passwords do not match."});return}if(e.length<8){m({type:"error",msg:"Password must be at least 8 characters."});return}d(!0),m(null);const{error:y}=await t.auth.updateUser({password:e});y?m({type:"error",msg:y.message}):(m({type:"success",msg:"Password updated successfully."}),s(""),l("")),d(!1)};return o.jsxs(ht,{className:"border-border/40 shadow-xl shadow-black/5 bg-card/50 backdrop-blur-sm overflow-hidden",children:[o.jsxs(zt,{className:"p-8 border-b bg-muted/20",children:[o.jsx(Lt,{className:"text-2xl font-black",children:"Security Protocol"}),o.jsx(wn,{className:"text-base",children:"Manage your foundation credentials and access keys."})]}),o.jsxs(xt,{className:"p-8 space-y-8",children:[h&&o.jsxs(jn,{variant:h.type==="error"?"destructive":"default",className:ge("animate-in fade-in slide-in-from-top-2 duration-300",h.type==="success"?"bg-emerald-500/10 text-emerald-600 border-emerald-500/20":""),children:[h.type==="success"?o.jsx(os,{className:"h-4 w-4"}):o.jsx(uu,{className:"h-4 w-4"}),o.jsx(_n,{className:"text-sm font-bold",children:h.msg})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-8",children:[o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"newPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"New Password"}),o.jsx(je,{id:"newPass",type:"password",placeholder:"••••••••",value:e,onChange:y=>s(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Je,{htmlFor:"confirmPass",className:"text-xs font-black uppercase tracking-widest text-muted-foreground ml-1",children:"Confirm Password"}),o.jsx(je,{id:"confirmPass",type:"password",placeholder:"••••••••",value:i,onChange:y=>l(y.target.value),className:"h-12 rounded-xl bg-background/50 border-border/40"})]})]}),o.jsxs("div",{className:"bg-muted/30 p-6 rounded-2xl border border-border/40 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(uu,{className:"w-5 h-5"})}),o.jsx("h5",{className:"font-bold",children:"Security Tip"})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Use a password at least 12 characters long with a mix of letters, numbers, and symbols to ensure your foundational data remains secure."})]})]})]}),o.jsx(Tu,{className:"bg-muted/20 p-8 flex justify-end",children:o.jsxs(ae,{className:"h-12 px-8 rounded-xl font-bold shadow-xl shadow-primary/20",onClick:g,disabled:u||!e||!i,children:[u?o.jsx(rt,{className:"w-4 h-4 animate-spin mr-2"}):o.jsx(Zo,{className:"w-4 h-4 mr-2"}),"Update Password"]})})]})}function eR({configSnapshot:t,configSource:e,onLaunchSetup:s,onResetSetup:i}){return o.jsxs("div",{className:"space-y-8 animate-in fade-in duration-700",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary",children:o.jsx(Eu,{className:"w-6 h-6"})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-lg font-bold",children:"Supabase Configuration"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Primary storage and identity gateway."})]}),o.jsxs(Pt,{variant:"secondary",className:"text-[10px] font-black uppercase tracking-widest px-3 py-1",children:["Source: ",e]})]}),o.jsxs(ht,{className:"border-border/40 shadow-sm bg-card/50 backdrop-blur-sm",children:[o.jsx(xt,{className:"p-8 space-y-8",children:t?o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"API Endpoint"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 backdrop-blur-sm shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold truncate text-foreground/80",children:t.url})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Project Identifier"}),o.jsx("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 font-mono shadow-inner",children:o.jsx("p",{className:"text-sm font-semibold text-foreground/80",children:t.url.split("//")[1]?.split(".")[0]||"Unknown"})})]}),o.jsxs("div",{className:"md:col-span-2 space-y-2",children:[o.jsx("span",{className:"text-[10px] font-black uppercase text-muted-foreground tracking-widest pl-1",children:"Service Role Access (Masked)"}),o.jsxs("div",{className:"bg-muted/30 p-4 rounded-2xl border border-border/40 flex items-center justify-between shadow-inner",children:[o.jsxs("p",{className:"text-sm font-mono text-muted-foreground",children:[t.anonKey.slice(0,6),"...",t.anonKey.slice(-6)]}),o.jsx(Pt,{variant:"outline",className:"text-[9px] font-bold",children:"Standard Key"})]})]})]}):o.jsxs(jn,{className:"bg-amber-500/5 border-amber-500/20 text-amber-600 dark:text-amber-400 p-6 rounded-2xl shadow-sm",children:[o.jsx(Sn,{className:"w-5 h-5"}),o.jsx(Hm,{className:"font-bold mb-1",children:"Infrastructure Standby"}),o.jsx(_n,{className:"text-sm opacity-90",children:"The foundation has not been initialized. You must run the setup wizard to continue."})]})}),o.jsxs(Tu,{className:"bg-muted/20 p-8 flex gap-4 border-t",children:[o.jsxs(ae,{variant:t?"outline":"default",className:"flex-1 h-12 rounded-xl font-bold shadow-sm",onClick:s,children:[t?o.jsx(WC,{className:"w-4 h-4 mr-2"}):o.jsx(Wa,{className:"w-4 h-4 mr-2"}),t?"Run Setup Wizard":"Launch Initializer"]}),t&&o.jsx(ae,{variant:"ghost",size:"icon",className:"h-12 w-12 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",onClick:i,title:"Reset All Configuration",children:o.jsx(PC,{className:"w-5 h-5"})})]})]}),o.jsxs("div",{className:"space-y-6 pt-4",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b pb-4",children:[o.jsx("div",{className:"w-10 h-10 rounded-xl bg-destructive/10 flex items-center justify-center text-destructive",children:o.jsx(Sn,{className:"w-6 h-6"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-bold text-destructive",children:"Advanced Maintenance"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Destructive actions and system-level overrides."})]})]}),o.jsx(ht,{className:"border-destructive/20 bg-destructive/5 overflow-hidden shadow-sm",children:o.jsxs(xt,{className:"p-8",children:[o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Fully resetting the foundation will purge all local storage cached parameters. This action is irreversible and will force a fresh bootstrap flow upon next launch."}),o.jsx(ae,{variant:"link",className:"px-0 text-destructive h-auto text-xs font-black uppercase tracking-widest mt-4 hover:no-underline hover:opacity-70 transition-opacity",onClick:i,children:"Wipe Local Foundation Buffer"})]})})]})]})}const tR={theme:"system",setTheme:()=>null},Zw=v.createContext(tR);function nR({children:t,defaultTheme:e="system",storageKey:s="vite-ui-theme"}){const[i,l]=v.useState(()=>localStorage.getItem(s)||e);v.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),i==="system"){const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(h);return}d.classList.add(i)},[i]);const u=v.useMemo(()=>({theme:i,setTheme:d=>{localStorage.setItem(s,d),l(d)}}),[i,s]);return o.jsx(Zw.Provider,{value:u,children:t})}const sR=()=>{const t=v.useContext(Zw);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function e1(){const{setTheme:t,theme:e}=sR();return o.jsxs(ae,{variant:"ghost",size:"icon",onClick:()=>t(e==="dark"?"light":"dark"),className:"text-muted-foreground hover:bg-muted/60 transition-all duration-300 h-9 w-9 rounded-full",title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:[e==="dark"?o.jsx(nA,{className:"h-[1.2rem] w-[1.2rem]"}):o.jsx(CC,{className:"h-[1.2rem] w-[1.2rem]"}),o.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}function fa(t,e,{checkForDefaultPrevented:s=!0}={}){return function(l){if(t?.(l),s===!1||!l.defaultPrevented)return e?.(l)}}function aR(t,e){const s=v.createContext(e),i=u=>{const{children:d,...h}=u,m=v.useMemo(()=>h,Object.values(h));return o.jsx(s.Provider,{value:m,children:d})};i.displayName=t+"Provider";function l(u){const d=v.useContext(s);if(d)return d;if(e!==void 0)return e;throw new Error(`\`${u}\` must be used within \`${t}\``)}return[i,l]}function iR(t,e=[]){let s=[];function i(u,d){const h=v.createContext(d),m=s.length;s=[...s,d];const g=x=>{const{scope:w,children:S,...E}=x,j=w?.[t]?.[m]||h,_=v.useMemo(()=>E,Object.values(E));return o.jsx(j.Provider,{value:_,children:S})};g.displayName=u+"Provider";function y(x,w){const S=w?.[t]?.[m]||h,E=v.useContext(S);if(E)return E;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${u}\``)}return[g,y]}const l=()=>{const u=s.map(d=>v.createContext(d));return function(h){const m=h?.[t]||u;return v.useMemo(()=>({[`__scope${t}`]:{...h,[t]:m}}),[h,m])}};return l.scopeName=t,[i,rR(l,...e)]}function rR(...t){const e=t[0];if(t.length===1)return e;const s=()=>{const i=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(u){const d=i.reduce((h,{useScope:m,scopeName:g})=>{const x=m(u)[`__scope${g}`];return{...h,...x}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:d}),[d])}};return s.scopeName=e.scopeName,s}var qo=globalThis?.document?v.useLayoutEffect:()=>{},oR=Mm[" useId ".trim().toString()]||(()=>{}),lR=0;function mf(t){const[e,s]=v.useState(oR());return qo(()=>{s(i=>i??String(lR++))},[t]),t||(e?`radix-${e}`:"")}var cR=Mm[" useInsertionEffect ".trim().toString()]||qo;function uR({prop:t,defaultProp:e,onChange:s=()=>{},caller:i}){const[l,u,d]=dR({defaultProp:e,onChange:s}),h=t!==void 0,m=h?t:l;{const y=v.useRef(t!==void 0);v.useEffect(()=>{const x=y.current;x!==h&&console.warn(`${i} is changing from ${x?"controlled":"uncontrolled"} to ${h?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=h},[h,i])}const g=v.useCallback(y=>{if(h){const x=hR(y)?y(t):y;x!==t&&d.current?.(x)}else u(y)},[h,t,u,d]);return[m,g]}function dR({defaultProp:t,onChange:e}){const[s,i]=v.useState(t),l=v.useRef(s),u=v.useRef(e);return cR(()=>{u.current=e},[e]),v.useEffect(()=>{l.current!==s&&(u.current?.(s),l.current=s)},[s,l]),[s,i,u]}function hR(t){return typeof t=="function"}function fR(t){const e=mR(t),s=v.forwardRef((i,l)=>{const{children:u,...d}=i,h=v.Children.toArray(u),m=h.find(gR);if(m){const g=m.props.children,y=h.map(x=>x===m?v.Children.count(g)>1?v.Children.only(null):v.isValidElement(g)?g.props.children:null:x);return o.jsx(e,{...d,ref:l,children:v.isValidElement(g)?v.cloneElement(g,void 0,y):null})}return o.jsx(e,{...d,ref:l,children:u})});return s.displayName=`${t}.Slot`,s}function mR(t){const e=v.forwardRef((s,i)=>{const{children:l,...u}=s;if(v.isValidElement(l)){const d=vR(l),h=yR(u,l.props);return l.type!==v.Fragment&&(h.ref=i?Au(i,d):d),v.cloneElement(l,h)}return v.Children.count(l)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var pR=Symbol("radix.slottable");function gR(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===pR}function yR(t,e){const s={...e};for(const i in e){const l=t[i],u=e[i];/^on[A-Z]/.test(i)?l&&u?s[i]=(...h)=>{const m=u(...h);return l(...h),m}:l&&(s[i]=l):i==="style"?s[i]={...l,...u}:i==="className"&&(s[i]=[l,u].filter(Boolean).join(" "))}return{...t,...s}}function vR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var xR=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Os=xR.reduce((t,e)=>{const s=fR(`Primitive.${e}`),i=v.forwardRef((l,u)=>{const{asChild:d,...h}=l,m=d?s:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(m,{...h,ref:u})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function bR(t,e){t&&Ww.flushSync(()=>t.dispatchEvent(e))}function Ho(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...s)=>e.current?.(...s),[])}function wR(t,e=globalThis?.document){const s=Ho(t);v.useEffect(()=>{const i=l=>{l.key==="Escape"&&s(l)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[s,e])}var SR="DismissableLayer",im="dismissableLayer.update",jR="dismissableLayer.pointerDownOutside",_R="dismissableLayer.focusOutside",b0,t1=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),n1=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:i,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:d,onDismiss:h,...m}=t,g=v.useContext(t1),[y,x]=v.useState(null),w=y?.ownerDocument??globalThis?.document,[,S]=v.useState({}),E=ni(e,V=>x(V)),j=Array.from(g.layers),[_]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(_),k=y?j.indexOf(y):-1,C=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=N,D=ER(V=>{const R=V.target,P=[...g.branches].some(Z=>Z.contains(R));!A||P||(l?.(V),d?.(V),V.defaultPrevented||h?.())},w),z=kR(V=>{const R=V.target;[...g.branches].some(Z=>Z.contains(R))||(u?.(V),d?.(V),V.defaultPrevented||h?.())},w);return wR(V=>{k===g.layers.size-1&&(i?.(V),!V.defaultPrevented&&h&&(V.preventDefault(),h()))},w),v.useEffect(()=>{if(y)return s&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(b0=w.body.style.pointerEvents,w.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w0(),()=>{s&&g.layersWithOutsidePointerEventsDisabled.size===1&&(w.body.style.pointerEvents=b0)}},[y,w,s,g]),v.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w0())},[y,g]),v.useEffect(()=>{const V=()=>S({});return document.addEventListener(im,V),()=>document.removeEventListener(im,V)},[]),o.jsx(Os.div,{...m,ref:E,style:{pointerEvents:C?A?"auto":"none":void 0,...t.style},onFocusCapture:fa(t.onFocusCapture,z.onFocusCapture),onBlurCapture:fa(t.onBlurCapture,z.onBlurCapture),onPointerDownCapture:fa(t.onPointerDownCapture,D.onPointerDownCapture)})});n1.displayName=SR;var NR="DismissableLayerBranch",TR=v.forwardRef((t,e)=>{const s=v.useContext(t1),i=v.useRef(null),l=ni(e,i);return v.useEffect(()=>{const u=i.current;if(u)return s.branches.add(u),()=>{s.branches.delete(u)}},[s.branches]),o.jsx(Os.div,{...t,ref:l})});TR.displayName=NR;function ER(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1),l=v.useRef(()=>{});return v.useEffect(()=>{const u=h=>{if(h.target&&!i.current){let m=function(){s1(jR,s,g,{discrete:!0})};const g={originalEvent:h};h.pointerType==="touch"?(e.removeEventListener("click",l.current),l.current=m,e.addEventListener("click",l.current,{once:!0})):m()}else e.removeEventListener("click",l.current);i.current=!1},d=window.setTimeout(()=>{e.addEventListener("pointerdown",u)},0);return()=>{window.clearTimeout(d),e.removeEventListener("pointerdown",u),e.removeEventListener("click",l.current)}},[e,s]),{onPointerDownCapture:()=>i.current=!0}}function kR(t,e=globalThis?.document){const s=Ho(t),i=v.useRef(!1);return v.useEffect(()=>{const l=u=>{u.target&&!i.current&&s1(_R,s,{originalEvent:u},{discrete:!1})};return e.addEventListener("focusin",l),()=>e.removeEventListener("focusin",l)},[e,s]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function w0(){const t=new CustomEvent(im);document.dispatchEvent(t)}function s1(t,e,s,{discrete:i}){const l=s.originalEvent.target,u=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:s});e&&l.addEventListener(t,e,{once:!0}),i?bR(l,u):l.dispatchEvent(u)}var pf="focusScope.autoFocusOnMount",gf="focusScope.autoFocusOnUnmount",S0={bubbles:!1,cancelable:!0},CR="FocusScope",a1=v.forwardRef((t,e)=>{const{loop:s=!1,trapped:i=!1,onMountAutoFocus:l,onUnmountAutoFocus:u,...d}=t,[h,m]=v.useState(null),g=Ho(l),y=Ho(u),x=v.useRef(null),w=ni(e,j=>m(j)),S=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(i){let j=function(C){if(S.paused||!h)return;const A=C.target;h.contains(A)?x.current=A:oa(x.current,{select:!0})},_=function(C){if(S.paused||!h)return;const A=C.relatedTarget;A!==null&&(h.contains(A)||oa(x.current,{select:!0}))},N=function(C){if(document.activeElement===document.body)for(const D of C)D.removedNodes.length>0&&oa(h)};document.addEventListener("focusin",j),document.addEventListener("focusout",_);const k=new MutationObserver(N);return h&&k.observe(h,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",_),k.disconnect()}}},[i,h,S.paused]),v.useEffect(()=>{if(h){_0.add(S);const j=document.activeElement;if(!h.contains(j)){const N=new CustomEvent(pf,S0);h.addEventListener(pf,g),h.dispatchEvent(N),N.defaultPrevented||(AR(PR(i1(h)),{select:!0}),document.activeElement===j&&oa(h))}return()=>{h.removeEventListener(pf,g),setTimeout(()=>{const N=new CustomEvent(gf,S0);h.addEventListener(gf,y),h.dispatchEvent(N),N.defaultPrevented||oa(j??document.body,{select:!0}),h.removeEventListener(gf,y),_0.remove(S)},0)}}},[h,g,y,S]);const E=v.useCallback(j=>{if(!s&&!i||S.paused)return;const _=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(_&&N){const k=j.currentTarget,[C,A]=RR(k);C&&A?!j.shiftKey&&N===A?(j.preventDefault(),s&&oa(C,{select:!0})):j.shiftKey&&N===C&&(j.preventDefault(),s&&oa(A,{select:!0})):N===k&&j.preventDefault()}},[s,i,S.paused]);return o.jsx(Os.div,{tabIndex:-1,...d,ref:w,onKeyDown:E})});a1.displayName=CR;function AR(t,{select:e=!1}={}){const s=document.activeElement;for(const i of t)if(oa(i,{select:e}),document.activeElement!==s)return}function RR(t){const e=i1(t),s=j0(e,t),i=j0(e.reverse(),t);return[s,i]}function i1(t){const e=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const l=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||l?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)e.push(s.currentNode);return e}function j0(t,e){for(const s of t)if(!OR(s,{upTo:e}))return s}function OR(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function MR(t){return t instanceof HTMLInputElement&&"select"in t}function oa(t,{select:e=!1}={}){if(t&&t.focus){const s=document.activeElement;t.focus({preventScroll:!0}),t!==s&&MR(t)&&e&&t.select()}}var _0=DR();function DR(){let t=[];return{add(e){const s=t[0];e!==s&&s?.pause(),t=N0(t,e),t.unshift(e)},remove(e){t=N0(t,e),t[0]?.resume()}}}function N0(t,e){const s=[...t],i=s.indexOf(e);return i!==-1&&s.splice(i,1),s}function PR(t){return t.filter(e=>e.tagName!=="A")}var zR="Portal",r1=v.forwardRef((t,e)=>{const{container:s,...i}=t,[l,u]=v.useState(!1);qo(()=>u(!0),[]);const d=s||l&&globalThis?.document?.body;return d?VA.createPortal(o.jsx(Os.div,{...i,ref:e}),d):null});r1.displayName=zR;function LR(t,e){return v.useReducer((s,i)=>e[s][i]??s,t)}var Ru=t=>{const{present:e,children:s}=t,i=UR(e),l=typeof s=="function"?s({present:i.isPresent}):v.Children.only(s),u=ni(i.ref,BR(l));return typeof s=="function"||i.isPresent?v.cloneElement(l,{ref:u}):null};Ru.displayName="Presence";function UR(t){const[e,s]=v.useState(),i=v.useRef(null),l=v.useRef(t),u=v.useRef("none"),d=t?"mounted":"unmounted",[h,m]=LR(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const g=Lc(i.current);u.current=h==="mounted"?g:"none"},[h]),qo(()=>{const g=i.current,y=l.current;if(y!==t){const w=u.current,S=Lc(g);t?m("MOUNT"):S==="none"||g?.display==="none"?m("UNMOUNT"):m(y&&w!==S?"ANIMATION_OUT":"UNMOUNT"),l.current=t}},[t,m]),qo(()=>{if(e){let g;const y=e.ownerDocument.defaultView??window,x=S=>{const j=Lc(i.current).includes(CSS.escape(S.animationName));if(S.target===e&&j&&(m("ANIMATION_END"),!l.current)){const _=e.style.animationFillMode;e.style.animationFillMode="forwards",g=y.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=_)})}},w=S=>{S.target===e&&(u.current=Lc(i.current))};return e.addEventListener("animationstart",w),e.addEventListener("animationcancel",x),e.addEventListener("animationend",x),()=>{y.clearTimeout(g),e.removeEventListener("animationstart",w),e.removeEventListener("animationcancel",x),e.removeEventListener("animationend",x)}}else m("ANIMATION_END")},[e,m]),{isPresent:["mounted","unmountSuspended"].includes(h),ref:v.useCallback(g=>{i.current=g?getComputedStyle(g):null,s(g)},[])}}function Lc(t){return t?.animationName||"none"}function BR(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning;return s?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,s=e&&"isReactWarning"in e&&e.isReactWarning,s?t.props.ref:t.props.ref||t.ref)}var yf=0;function VR(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??T0()),document.body.insertAdjacentElement("beforeend",t[1]??T0()),yf++,()=>{yf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),yf--}},[])}function T0(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Yc="right-scroll-bar-position",Xc="width-before-scroll-bar",IR="with-scroll-bars-hidden",$R="--removed-body-scroll-bar-size";function vf(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function qR(t,e){var s=v.useState(function(){return{value:t,callback:e,facade:{get current(){return s.value},set current(i){var l=s.value;l!==i&&(s.value=i,s.callback(i,l))}}}})[0];return s.callback=e,s.facade}var HR=typeof window<"u"?v.useLayoutEffect:v.useEffect,E0=new WeakMap;function GR(t,e){var s=qR(null,function(i){return t.forEach(function(l){return vf(l,i)})});return HR(function(){var i=E0.get(s);if(i){var l=new Set(i),u=new Set(t),d=s.current;l.forEach(function(h){u.has(h)||vf(h,null)}),u.forEach(function(h){l.has(h)||vf(h,d)})}E0.set(s,t)},[t]),s}function FR(t){return t}function KR(t,e){e===void 0&&(e=FR);var s=[],i=!1,l={read:function(){if(i)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:t},useMedium:function(u){var d=e(u,i);return s.push(d),function(){s=s.filter(function(h){return h!==d})}},assignSyncMedium:function(u){for(i=!0;s.length;){var d=s;s=[],d.forEach(u)}s={push:function(h){return u(h)},filter:function(){return s}}},assignMedium:function(u){i=!0;var d=[];if(s.length){var h=s;s=[],h.forEach(u),d=s}var m=function(){var y=d;d=[],y.forEach(u)},g=function(){return Promise.resolve().then(m)};g(),s={push:function(y){d.push(y),g()},filter:function(y){return d=d.filter(y),s}}}};return l}function YR(t){t===void 0&&(t={});var e=KR(null);return e.options=ss({async:!0,ssr:!1},t),e}var o1=function(t){var e=t.sideCar,s=pr(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var i=e.read();if(!i)throw new Error("Sidecar medium not found");return v.createElement(i,ss({},s))};o1.isSideCarExport=!0;function XR(t,e){return t.useMedium(e),o1}var l1=YR(),xf=function(){},Ou=v.forwardRef(function(t,e){var s=v.useRef(null),i=v.useState({onScrollCapture:xf,onWheelCapture:xf,onTouchMoveCapture:xf}),l=i[0],u=i[1],d=t.forwardProps,h=t.children,m=t.className,g=t.removeScrollBar,y=t.enabled,x=t.shards,w=t.sideCar,S=t.noRelative,E=t.noIsolation,j=t.inert,_=t.allowPinchZoom,N=t.as,k=N===void 0?"div":N,C=t.gapMode,A=pr(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=w,z=GR([s,e]),V=ss(ss({},A),l);return v.createElement(v.Fragment,null,y&&v.createElement(D,{sideCar:l1,removeScrollBar:g,shards:x,noRelative:S,noIsolation:E,inert:j,setCallbacks:u,allowPinchZoom:!!_,lockRef:s,gapMode:C}),d?v.cloneElement(v.Children.only(h),ss(ss({},V),{ref:z})):v.createElement(k,ss({},V,{className:m,ref:z}),h))});Ou.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Ou.classNames={fullWidth:Xc,zeroRight:Yc};var WR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function JR(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=WR();return e&&t.setAttribute("nonce",e),t}function QR(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function ZR(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var eO=function(){var t=0,e=null;return{add:function(s){t==0&&(e=JR())&&(QR(e,s),ZR(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},tO=function(){var t=eO();return function(e,s){v.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&s])}},c1=function(){var t=tO(),e=function(s){var i=s.styles,l=s.dynamic;return t(i,l),null};return e},nO={left:0,top:0,right:0,gap:0},bf=function(t){return parseInt(t||"",10)||0},sO=function(t){var e=window.getComputedStyle(document.body),s=e[t==="padding"?"paddingLeft":"marginLeft"],i=e[t==="padding"?"paddingTop":"marginTop"],l=e[t==="padding"?"paddingRight":"marginRight"];return[bf(s),bf(i),bf(l)]},aO=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return nO;var e=sO(t),s=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-s+e[2]-e[0])}},iO=c1(),lr="data-scroll-locked",rO=function(t,e,s,i){var l=t.left,u=t.top,d=t.right,h=t.gap;return s===void 0&&(s="margin"),`
52
52
  .`.concat(IR,` {
53
53
  overflow: hidden `).concat(i,`;
54
54
  padding-right: `).concat(h,"px ").concat(i,`;
package/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <title>Folio</title>
8
- <script type="module" crossorigin src="/assets/index-rbTzu75B.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-_NgwdVu8.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DzN8-j-e.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realtimex/folio",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "main": "dist/api/server.js",
6
6
  "bin": {