@wacht/jsx 1.0.0-beta.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +65 -64
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1811 -1810
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),Co=require("react-dom"),Ua=require("@wacht/types"),Vr="__dev_session__",Ol="__dev_session_updated_at",Pi="__dev_session_updated_at";function Jr(){return typeof window<"u"&&typeof document<"u"}function Ba(t){if(!Jr())return null;const r=document.cookie?document.cookie.split(";"):[];for(const n of r){const[o,...i]=n.trim().split("=");if(o===t)return decodeURIComponent(i.join("="))}return null}function Wa(t,r){Jr()&&(document.cookie=`${t}=${encodeURIComponent(r)}; Path=/; Secure; SameSite=Lax`)}function Ri(t){if(!Jr())return null;try{return window.localStorage.getItem(t)}catch{return null}}function mo(t,r){if(Jr())try{window.localStorage.setItem(t,r)}catch{}}function Va(t){if(!t)return 0;const r=Number(t);return Number.isFinite(r)?r:0}function Uu(){const t=Ba(Vr);if(!t)return null;const r=Va(Ba(Ol)),n=Ri(Vr),o=Va(Ri(Pi)),i=r>o||r===0&&t!==n;return(!n||i)&&(mo(Vr,t),mo(Pi,String(r||Date.now()))),t}function tt(){if(!Jr())return null;const t=Uu();return t||Ri(Vr)}function io(t){if(!Jr()||!t)return;const r=Date.now();Wa(Vr,t),Wa(Ol,String(r)),mo(Vr,t),mo(Pi,String(r))}const Al=s.createContext(void 0);function Bu({children:t,publicKey:r,adapter:n,uiOverwrites:o}){const[i,a]=s.useState(!0),[u,c]=s.useState(null),d=s.useRef(!1);s.useEffect(()=>{async function l(){if(!d.current)try{d.current=!0,a(!0);const[f,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),$=m==="test",S=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){S=new URLSearchParams(window.location.search).get("__dev_session__"),io(S);const b=new URL(window.location.href);b.searchParams.delete("__dev_session__"),window.history.replaceState({},"",b.toString())}else S=tt(),S&&io(S);let _={};const k=new URLSearchParams;$?k.append("__dev_session__",S??""):_={credentials:"include"};const P=await fetch(`${v}/deployment${$?"?":""}${k.toString()}`,_);if(!P.ok){a(!1);return}const y=await P.json();y.data.backend_host=v,o&&(y.data.ui_settings={...y.data.ui_settings,...o}),c(y.data),$&&P.headers.get("x-development-session")&&io(P.headers.get("x-development-session")),a(!1)}catch(f){console.error("Failed to initialize deployment:",f)}}l()},[r]);const p=s.useMemo(()=>({loading:i,deployment:u,adapter:n}),[i,u,n]);return e.jsx(Al.Provider,{value:p,children:t})}async function N(t){if(!t.ok){let n=`HTTP ${t.status}: ${t.statusText}`,o;try{const a=await t.json();a.message?n=a.message:a.errors&&a.errors.length>0&&(n=a.errors[0].message||n,o=a.errors[0].code)}catch{}const i=new Error(n);throw o&&(i.code=o),i}return{data:(await t.json()).data}}function be(){const t=s.useContext(Al);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function $e(){const{deployment:t,loading:r}=be();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(o,i)=>{const a=Wu(t),u=new Headers(a.headers);i!=null&&i.headers&&new Headers(i.headers).forEach((l,f)=>{u.set(f,l)});const c=new URL(`${t.backend_host??""}${o}`);t.mode==="staging"&&c.searchParams.append("__dev_session__",tt()??"");const d=await fetch(c,{...a,...i,headers:u});return t.mode==="staging"&&d.headers.get("x-development-session")&&io(d.headers.get("x-development-session")),d},loading:r}}function Wu(t){return t.mode==="staging"?{}:{credentials:"include"}}var Ll=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Ll||{});function Vu(t,r){const n={username:Gu(t,r),email:Hu(t,r),phone:qu(t,r),email_otp:Yu(t,r),magic_link:Ku(t,r),oauth:Qu(t),passkey:Zu(t),generic:Ju(t,r)};return function(i){return n[i]}}function Gu(t,r){return async({username:n,password:o})=>{var c,d;const i=new FormData;i.append("strategy","plain_username"),i.append("username",n),i.append("password",o);const a=await t("/auth/signin",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signin_attempts)!=null&&d.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function Hu(t,r){return async({email:n,password:o})=>{var c,d;const i=new FormData;i.append("strategy","plain_email"),i.append("email",n),i.append("password",o);const a=await t("/auth/signin",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signin_attempts)!=null&&d.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function qu(t,r){return async({phone:n})=>{var u,c;const o=new FormData;o.append("strategy","phone_otp"),o.append("phone",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Yu(t,r){return async({email:n})=>{var u,c;const o=new FormData;o.append("strategy","email_otp"),o.append("email",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Ku(t,r){return async({email:n})=>{var u,c;const o=new FormData;o.append("strategy","magic_link"),o.append("email",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Qu(t){return async({provider:r,redirectUri:n})=>{const o=new URLSearchParams({provider:r});n&&o.append("redirect_uri",n);const i=await t(`/auth/oauth2/init?${o.toString()}`,{method:"POST"}),a=await N(i);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function nn(t){const r=new Uint8Array(t);let n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ga(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"="),o=atob(n),i=new Uint8Array(o.length);for(let a=0;a<o.length;a++)i[a]=o.charCodeAt(a);return i.buffer}function Zu(t){return async()=>{var p;const r=await t("/auth/passkey/login/begin",{method:"POST"}),n=await N(r);if(!("data"in n))return n;const o=n.data.options.publicKey,i={challenge:Ga(o.challenge),timeout:o.timeout,rpId:o.rpId,userVerification:o.userVerification,allowCredentials:(p=o.allowCredentials)==null?void 0:p.map(l=>({type:l.type,id:Ga(l.id),transports:l.transports}))};let a;try{const l=await navigator.credentials.get({publicKey:i});if(!l)throw new Error("Failed to get credential");a=l}catch(l){throw l.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):l.name==="AbortError"?new Error("Passkey sign-in was cancelled."):l}const u=a.response,c=new FormData;c.append("id",a.id),c.append("rawId",nn(a.rawId)),c.append("type",a.type),c.append("clientDataJSON",nn(u.clientDataJSON)),c.append("authenticatorData",nn(u.authenticatorData)),c.append("signature",nn(u.signature)),u.userHandle&&c.append("userHandle",nn(u.userHandle));const d=await t("/auth/passkey/login/finish",{method:"POST",body:c});return N(d)}}function Ju(t,r){return async({email:n,username:o,password:i,phone:a,strategy:u})=>{var l,f;const c=new FormData;u&&c.append("strategy",u),n&&c.append("email",n),o&&c.append("username",o),i&&c.append("password",i),a&&c.append("phone",a);const d=await t("/auth/signin",{method:"POST",body:c}),p=await N(d);return"data"in p&&((f=(l=p.data)==null?void 0:l.signin_attempts)!=null&&f.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function Ml(){const{client:t,loading:r}=$e(),[n,o]=s.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{o(null)},setSignInAttempt:o}:{loading:!1,signinAttempt:n,signIn:{createStrategy:Vu(t,o),completeVerification:async i=>{var d,p;const a=new FormData;a.append("verification_code",i);const u=await t(`/auth/attempt-verification?attempt_identifier=${n==null?void 0:n.id}&identifier_type=signin`,{method:"POST",body:a}),c=await N(u);if("data"in c&&((p=(d=c.data)==null?void 0:d.signin_attempts)!=null&&p.length)){const l=c.data.signin_attempts.at(-1);return o(l||null),c.data}else throw new Error("Verification failed")},prepareVerification:async i=>{var c;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((c=n==null?void 0:n.id)==null?void 0:c.toString())||""),a.searchParams.set("strategy",i.strategy),a.searchParams.set("identifier_type","signin"),i.strategy==="phone_otp"&&i.lastDigits?a.searchParams.set("last_digits",i.lastDigits):(i.strategy==="email_otp"&&i.redirectUri||i.strategy==="magic_link"&&i.redirectUri)&&a.searchParams.set("redirect_uri",i.redirectUri);const u=await t(a.pathname+a.search,{method:"POST"});return N(u)},completeProfile:async i=>{var d;if(!n)throw new Error("No signin attempt found");const a=new FormData;for(const[p,l]of Object.entries(i))l&&a.append(p,l);const u=await t(`/auth/complete-profile?attempt_id=${n.id}`,{method:"POST",body:a}),c=await N(u);if("data"in c&&c.data){const p=(d=c.data.signin_attempts)==null?void 0:d.find(l=>l.id===n.id);return p&&o(p),c.data}else throw new Error("Profile completion failed")},identify:async i=>{const a=new FormData;a.append("identifier",i);const u=await t("/auth/identify",{method:"POST",body:a});return(await N(u)).data},initEnterpriseSso:async(i,a)=>{const u=new URLSearchParams({connection_id:i});a&&u.append("redirect_uri",a);const c=await t(`/auth/sso/login?${u.toString()}`,{method:"POST"});return(await N(c)).data}},discardSignInAttempt:()=>{o(null)},setSignInAttempt:o}}function Gr(t){const{loading:r,signIn:n,signinAttempt:o,discardSignInAttempt:i,setSignInAttempt:a}=Ml();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:i,setSignInAttempt:a};const u=(()=>{switch(t){case"username":return n.createStrategy("username");case"email":return n.createStrategy("email");case"phone":return n.createStrategy("phone");case"email_otp":return n.createStrategy("email_otp");case"magic_link":return n.createStrategy("magic_link");case"oauth":return n.createStrategy("oauth");case"passkey":return n.createStrategy("passkey");case"generic":return n.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:o,signIn:{create:u,completeVerification:n.completeVerification,prepareVerification:n.prepareVerification,completeProfile:n.completeProfile,identify:n.identify,initEnterpriseSso:n.initEnterpriseSso},discardSignInAttempt:i,setSignInAttempt:a}}function Xu(t,r,n){return{create:async o=>{var c,d,p;const i=new FormData;for(const[l,f]of Object.entries(o))i.append(l,f);const a=await t("/auth/signup",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signup_attempts)!=null&&d.length)&&n(((p=u.data.signup_attempts)==null?void 0:p.at(-1))||null),u},prepareVerification:async o=>{var u;const i=new URL("/auth/prepare-verification",window.location.origin);i.searchParams.set("attempt_identifier",((u=r==null?void 0:r.id)==null?void 0:u.toString())||""),i.searchParams.set("strategy",o.strategy),i.searchParams.set("identifier_type","signup"),o.strategy==="phone_otp"&&o.lastDigits?i.searchParams.set("last_digits",o.lastDigits):o.strategy==="email_otp"&&o.redirectUri&&i.searchParams.set("redirect_uri",o.redirectUri);const a=await t(i.pathname+i.search,{method:"POST"});return N(a)},completeVerification:async o=>{var c,d;const i=new FormData;i.append("verification_code",o);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signup_attempts)!=null&&d.length)&&n(u.data.signup_attempts.at(-1)||null),u},validateDeploymentInvitation:async o=>{try{const i=await t(`/deployment/invitations/validate?token=${encodeURIComponent(o)}`,{method:"GET"}),a=await N(i);return"data"in a&&a.data?a.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(i){return{valid:!1,message:i.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function Dl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{o(null)}}:{loading:!1,signupAttempt:n,discardSignupAttempt:()=>{o(null)},signUp:Xu(t,n,o)}}var Cn={exports:{}},Bo={};/**
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),Co=require("react-dom"),Ua=require("@wacht/types"),Vr="__dev_session__",Ol="__dev_session_updated_at",Pi="__dev_session_updated_at";function Jr(){return typeof window<"u"&&typeof document<"u"}function Ba(t){if(!Jr())return null;const r=document.cookie?document.cookie.split(";"):[];for(const n of r){const[o,...i]=n.trim().split("=");if(o===t)return decodeURIComponent(i.join("="))}return null}function Wa(t,r){Jr()&&(document.cookie=`${t}=${encodeURIComponent(r)}; Path=/; Secure; SameSite=Lax`)}function Ri(t){if(!Jr())return null;try{return window.localStorage.getItem(t)}catch{return null}}function mo(t,r){if(Jr())try{window.localStorage.setItem(t,r)}catch{}}function Va(t){if(!t)return 0;const r=Number(t);return Number.isFinite(r)?r:0}function Uu(){const t=Ba(Vr);if(!t)return null;const r=Va(Ba(Ol)),n=Ri(Vr),o=Va(Ri(Pi)),i=r>o||r===0&&t!==n;return(!n||i)&&(mo(Vr,t),mo(Pi,String(r||Date.now()))),t}function tt(){if(!Jr())return null;const t=Uu();return t||Ri(Vr)}function io(t){if(!Jr()||!t)return;const r=Date.now();Wa(Vr,t),Wa(Ol,String(r)),mo(Vr,t),mo(Pi,String(r))}const Al=s.createContext(void 0);function Bu({children:t,publicKey:r,adapter:n,uiOverwrites:o}){const[i,a]=s.useState(!0),[u,c]=s.useState(null),d=s.useRef(!1);s.useEffect(()=>{async function l(){if(!d.current)try{d.current=!0,a(!0);const[f,x,m]=r.split("_");if(!m)throw new Error("Invalid public key");let v=atob(m),C=x==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),io($);const b=new URL(window.location.href);b.searchParams.delete("__dev_session__"),window.history.replaceState({},"",b.toString())}else $=tt(),$&&io($);let _={};const k=new URLSearchParams;C?k.append("__dev_session__",$??""):_={credentials:"include"};const R=await fetch(`${v}/deployment${C?"?":""}${k.toString()}`,_);if(!R.ok){a(!1);return}const y=await R.json();y.data.backend_host=v,o&&(y.data.ui_settings={...y.data.ui_settings,...o}),c(y.data),C&&R.headers.get("x-development-session")&&io(R.headers.get("x-development-session")),a(!1)}catch(f){console.error("Failed to initialize deployment:",f)}}l()},[r]);const p=s.useMemo(()=>({loading:i,deployment:u,adapter:n}),[i,u,n]);return e.jsx(Al.Provider,{value:p,children:t})}async function N(t){if(!t.ok){let n=`HTTP ${t.status}: ${t.statusText}`,o;try{const a=await t.json();a.message?n=a.message:a.errors&&a.errors.length>0&&(n=a.errors[0].message||n,o=a.errors[0].code)}catch{}const i=new Error(n);throw o&&(i.code=o),i}return{data:(await t.json()).data}}function be(){const t=s.useContext(Al);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function $e(){const{deployment:t,loading:r}=be();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(o,i)=>{const a=Wu(t),u=new Headers(a.headers);i!=null&&i.headers&&new Headers(i.headers).forEach((l,f)=>{u.set(f,l)});const c=new URL(`${t.backend_host??""}${o}`);t.mode==="staging"&&c.searchParams.append("__dev_session__",tt()??"");const d=await fetch(c,{...a,...i,headers:u});return t.mode==="staging"&&d.headers.get("x-development-session")&&io(d.headers.get("x-development-session")),d},loading:r}}function Wu(t){return t.mode==="staging"?{}:{credentials:"include"}}var Ll=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Ll||{});function Vu(t,r){const n={username:Gu(t,r),email:Hu(t,r),phone:qu(t,r),email_otp:Yu(t,r),magic_link:Ku(t,r),oauth:Qu(t),passkey:Zu(t),generic:Ju(t,r)};return function(i){return n[i]}}function Gu(t,r){return async({username:n,password:o})=>{var c,d;const i=new FormData;i.append("strategy","plain_username"),i.append("username",n),i.append("password",o);const a=await t("/auth/signin",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signin_attempts)!=null&&d.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function Hu(t,r){return async({email:n,password:o})=>{var c,d;const i=new FormData;i.append("strategy","plain_email"),i.append("email",n),i.append("password",o);const a=await t("/auth/signin",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signin_attempts)!=null&&d.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function qu(t,r){return async({phone:n})=>{var u,c;const o=new FormData;o.append("strategy","phone_otp"),o.append("phone",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Yu(t,r){return async({email:n})=>{var u,c;const o=new FormData;o.append("strategy","email_otp"),o.append("email",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Ku(t,r){return async({email:n})=>{var u,c;const o=new FormData;o.append("strategy","magic_link"),o.append("email",n);const i=await t("/auth/signin",{method:"POST",body:o}),a=await N(i);return"data"in a&&((c=(u=a.data)==null?void 0:u.signin_attempts)!=null&&c.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Qu(t){return async({provider:r,redirectUri:n})=>{const o=new URLSearchParams({provider:r});n&&o.append("redirect_uri",n);const i=await t(`/auth/oauth2/init?${o.toString()}`,{method:"POST"}),a=await N(i);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function nn(t){const r=new Uint8Array(t);let n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ga(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"="),o=atob(n),i=new Uint8Array(o.length);for(let a=0;a<o.length;a++)i[a]=o.charCodeAt(a);return i.buffer}function Zu(t){return async()=>{var p;const r=await t("/auth/passkey/login/begin",{method:"POST"}),n=await N(r);if(!("data"in n))return n;const o=n.data.options.publicKey,i={challenge:Ga(o.challenge),timeout:o.timeout,rpId:o.rpId,userVerification:o.userVerification,allowCredentials:(p=o.allowCredentials)==null?void 0:p.map(l=>({type:l.type,id:Ga(l.id),transports:l.transports}))};let a;try{const l=await navigator.credentials.get({publicKey:i});if(!l)throw new Error("Failed to get credential");a=l}catch(l){throw l.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):l.name==="AbortError"?new Error("Passkey sign-in was cancelled."):l}const u=a.response,c=new FormData;c.append("id",a.id),c.append("rawId",nn(a.rawId)),c.append("type",a.type),c.append("clientDataJSON",nn(u.clientDataJSON)),c.append("authenticatorData",nn(u.authenticatorData)),c.append("signature",nn(u.signature)),u.userHandle&&c.append("userHandle",nn(u.userHandle));const d=await t("/auth/passkey/login/finish",{method:"POST",body:c});return N(d)}}function Ju(t,r){return async({email:n,username:o,password:i,phone:a,strategy:u})=>{var l,f;const c=new FormData;u&&c.append("strategy",u),n&&c.append("email",n),o&&c.append("username",o),i&&c.append("password",i),a&&c.append("phone",a);const d=await t("/auth/signin",{method:"POST",body:c}),p=await N(d);return"data"in p&&((f=(l=p.data)==null?void 0:l.signin_attempts)!=null&&f.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function Ml(){const{client:t,loading:r}=$e(),[n,o]=s.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{o(null)},setSignInAttempt:o}:{loading:!1,signinAttempt:n,signIn:{createStrategy:Vu(t,o),completeVerification:async i=>{var d,p;const a=new FormData;a.append("verification_code",i);const u=await t(`/auth/attempt-verification?attempt_identifier=${n==null?void 0:n.id}&identifier_type=signin`,{method:"POST",body:a}),c=await N(u);if("data"in c&&((p=(d=c.data)==null?void 0:d.signin_attempts)!=null&&p.length)){const l=c.data.signin_attempts.at(-1);return o(l||null),c.data}else throw new Error("Verification failed")},prepareVerification:async i=>{var c;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((c=n==null?void 0:n.id)==null?void 0:c.toString())||""),a.searchParams.set("strategy",i.strategy),a.searchParams.set("identifier_type","signin"),i.strategy==="phone_otp"&&i.lastDigits?a.searchParams.set("last_digits",i.lastDigits):(i.strategy==="email_otp"&&i.redirectUri||i.strategy==="magic_link"&&i.redirectUri)&&a.searchParams.set("redirect_uri",i.redirectUri);const u=await t(a.pathname+a.search,{method:"POST"});return N(u)},completeProfile:async i=>{var d;if(!n)throw new Error("No signin attempt found");const a=new FormData;for(const[p,l]of Object.entries(i))l&&a.append(p,l);const u=await t(`/auth/complete-profile?attempt_id=${n.id}`,{method:"POST",body:a}),c=await N(u);if("data"in c&&c.data){const p=(d=c.data.signin_attempts)==null?void 0:d.find(l=>l.id===n.id);return p&&o(p),c.data}else throw new Error("Profile completion failed")},identify:async i=>{const a=new FormData;a.append("identifier",i);const u=await t("/auth/identify",{method:"POST",body:a});return(await N(u)).data},initEnterpriseSso:async(i,a)=>{const u=new URLSearchParams({connection_id:i});a&&u.append("redirect_uri",a);const c=await t(`/auth/sso/login?${u.toString()}`,{method:"POST"});return(await N(c)).data}},discardSignInAttempt:()=>{o(null)},setSignInAttempt:o}}function Gr(t){const{loading:r,signIn:n,signinAttempt:o,discardSignInAttempt:i,setSignInAttempt:a}=Ml();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:i,setSignInAttempt:a};const u=(()=>{switch(t){case"username":return n.createStrategy("username");case"email":return n.createStrategy("email");case"phone":return n.createStrategy("phone");case"email_otp":return n.createStrategy("email_otp");case"magic_link":return n.createStrategy("magic_link");case"oauth":return n.createStrategy("oauth");case"passkey":return n.createStrategy("passkey");case"generic":return n.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:o,signIn:{create:u,completeVerification:n.completeVerification,prepareVerification:n.prepareVerification,completeProfile:n.completeProfile,identify:n.identify,initEnterpriseSso:n.initEnterpriseSso},discardSignInAttempt:i,setSignInAttempt:a}}function Xu(t,r,n){return{create:async o=>{var c,d,p;const i=new FormData;for(const[l,f]of Object.entries(o))i.append(l,f);const a=await t("/auth/signup",{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signup_attempts)!=null&&d.length)&&n(((p=u.data.signup_attempts)==null?void 0:p.at(-1))||null),u},prepareVerification:async o=>{var u;const i=new URL("/auth/prepare-verification",window.location.origin);i.searchParams.set("attempt_identifier",((u=r==null?void 0:r.id)==null?void 0:u.toString())||""),i.searchParams.set("strategy",o.strategy),i.searchParams.set("identifier_type","signup"),o.strategy==="phone_otp"&&o.lastDigits?i.searchParams.set("last_digits",o.lastDigits):o.strategy==="email_otp"&&o.redirectUri&&i.searchParams.set("redirect_uri",o.redirectUri);const a=await t(i.pathname+i.search,{method:"POST"});return N(a)},completeVerification:async o=>{var c,d;const i=new FormData;i.append("verification_code",o);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:i}),u=await N(a);return"data"in u&&((d=(c=u.data)==null?void 0:c.signup_attempts)!=null&&d.length)&&n(u.data.signup_attempts.at(-1)||null),u},validateDeploymentInvitation:async o=>{try{const i=await t(`/deployment/invitations/validate?token=${encodeURIComponent(o)}`,{method:"GET"}),a=await N(i);return"data"in a&&a.data?a.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(i){return{valid:!1,message:i.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function Dl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{o(null)}}:{loading:!1,signupAttempt:n,discardSignupAttempt:()=>{o(null)},signUp:Xu(t,n,o)}}var Cn={exports:{}},Bo={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var Ha;function ep(){if(Ha)return Bo;Ha=1;var t=s;function r(f,
|
|
10
|
+
*/var Ha;function ep(){if(Ha)return Bo;Ha=1;var t=s;function r(f,x){return f===x&&(f!==0||1/f===1/x)||f!==f&&x!==x}var n=typeof Object.is=="function"?Object.is:r,o=t.useState,i=t.useEffect,a=t.useLayoutEffect,u=t.useDebugValue;function c(f,x){var m=x(),v=o({inst:{value:m,getSnapshot:x}}),C=v[0].inst,$=v[1];return a(function(){C.value=m,C.getSnapshot=x,d(C)&&$({inst:C})},[f,m,x]),i(function(){return d(C)&&$({inst:C}),f(function(){d(C)&&$({inst:C})})},[f]),u(m),m}function d(f){var x=f.getSnapshot;f=f.value;try{var m=x();return!n(f,m)}catch{return!0}}function p(f,x){return x()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:c;return Bo.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,Bo}var Wo={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.development.js
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var qa;function tp(){return qa||(qa=1,process.env.NODE_ENV!=="production"&&(function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){l||i.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var $=v();if(!f){var S=v();a($,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}S=u({inst:{value:$,getSnapshot:v}});var _=S[0].inst,k=S[1];return d(function(){_.value=$,_.getSnapshot=v,n(_)&&k({inst:_})},[x,$,v]),c(function(){return n(_)&&k({inst:_}),x(function(){n(_)&&k({inst:_})})},[x]),p($),$}function n(x){var v=x.getSnapshot;x=x.value;try{var $=v();return!a(x,$)}catch{return!0}}function o(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=s,a=typeof Object.is=="function"?Object.is:t,u=i.useState,c=i.useEffect,d=i.useLayoutEffect,p=i.useDebugValue,l=!1,f=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:r;Wo.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Wo}var Ya;function rp(){return Ya||(Ya=1,process.env.NODE_ENV==="production"?Cn.exports=ep():Cn.exports=tp()),Cn.exports}var Ii=rp();const Fl=0,Nl=1,Ul=2,Ka=3;var Qa=Object.prototype.hasOwnProperty;function Ti(t,r){var n,o;if(t===r)return!0;if(t&&r&&(n=t.constructor)===r.constructor){if(n===Date)return t.getTime()===r.getTime();if(n===RegExp)return t.toString()===r.toString();if(n===Array){if((o=t.length)===r.length)for(;o--&&Ti(t[o],r[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Qa.call(t,n)&&++o&&!Qa.call(r,n)||!(n in r)||!Ti(t[n],r[n]))return!1;return Object.keys(r).length===o}}return t!==t&&r!==r}const Pt=new WeakMap,Gt=()=>{},Je=Gt(),Oi=Object,ye=t=>t===Je,vt=t=>typeof t=="function",nr=(t,r)=>({...t,...r}),Bl=t=>vt(t.then),Vo={},Sn={},sa="undefined",jn=typeof window!=sa,Ai=typeof document!=sa,np=jn&&"Deno"in window,op=()=>jn&&typeof window.requestAnimationFrame!=sa,Xt=(t,r)=>{const n=Pt.get(t);return[()=>!ye(r)&&t.get(r)||Vo,o=>{if(!ye(r)){const i=t.get(r);r in Sn||(Sn[r]=i),n[5](r,nr(i,o),i||Vo)}},n[6],()=>!ye(r)&&r in Sn?Sn[r]:!ye(r)&&t.get(r)||Vo]};let Li=!0;const ip=()=>Li,[Mi,Di]=jn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Gt,Gt],ap=()=>{const t=Ai&&document.visibilityState;return ye(t)||t!=="hidden"},sp=t=>(Ai&&document.addEventListener("visibilitychange",t),Mi("focus",t),()=>{Ai&&document.removeEventListener("visibilitychange",t),Di("focus",t)}),cp=t=>{const r=()=>{Li=!0,t()},n=()=>{Li=!1};return Mi("online",r),Mi("offline",n),()=>{Di("online",r),Di("offline",n)}},lp={isOnline:ip,isVisible:ap},dp={initFocus:sp,initReconnect:cp},Za=!s.useId,Hr=!jn||np,up=t=>op()?window.requestAnimationFrame(t):setTimeout(t,1),ao=Hr?s.useEffect:s.useLayoutEffect,Go=typeof navigator<"u"&&navigator.connection,Ja=!Hr&&Go&&(["slow-2g","2g"].includes(Go.effectiveType)||Go.saveData),$n=new WeakMap,pp=t=>Oi.prototype.toString.call(t),Ho=(t,r)=>t===`[object ${r}]`;let hp=0;const Fi=t=>{const r=typeof t,n=pp(t),o=Ho(n,"Date"),i=Ho(n,"RegExp"),a=Ho(n,"Object");let u,c;if(Oi(t)===t&&!o&&!i){if(u=$n.get(t),u)return u;if(u=++hp+"~",$n.set(t,u),Array.isArray(t)){for(u="@",c=0;c<t.length;c++)u+=Fi(t[c])+",";$n.set(t,u)}if(a){u="#";const d=Oi.keys(t).sort();for(;!ye(c=d.pop());)ye(t[c])||(u+=c+":"+Fi(t[c])+",");$n.set(t,u)}}else u=o?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},yn=t=>{if(vt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Fi(t):"",[t,r]};let fp=0;const Ni=()=>++fp;async function Wl(...t){const[r,n,o,i]=t,a=nr({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let u=a.populateCache;const c=a.rollbackOnError;let d=a.optimisticData;const p=m=>typeof c=="function"?c(m):c!==!1,l=a.throwOnError;if(vt(n)){const m=n,x=[],v=r.keys();for(const $ of v)!/^\$(inf|sub)\$/.test($)&&m(r.get($)._k)&&x.push($);return Promise.all(x.map(f))}return f(n);async function f(m){const[x]=yn(m);if(!x)return;const[v,$]=Xt(r,x),[S,_,k,P]=Pt.get(r),y=()=>{const T=S[x];return(vt(a.revalidate)?a.revalidate(v().data,m):a.revalidate!==!1)&&(delete k[x],delete P[x],T&&T[0])?T[0](Ul).then(()=>v().data):v().data};if(t.length<3)return y();let b=o,C,g=!1;const j=Ni();_[x]=[j,0];const w=!ye(d),E=v(),I=E.data,O=E._c,z=ye(O)?I:O;if(w&&(d=vt(d)?d(z,I):d,$({data:d,_c:z})),vt(b))try{b=b(z)}catch(T){C=T,g=!0}if(b&&Bl(b))if(b=await b.catch(T=>{C=T,g=!0}),j!==_[x][0]){if(g)throw C;return b}else g&&w&&p(C)&&(u=!0,$({data:z,_c:Je}));if(u&&!g)if(vt(u)){const T=u(b,z);$({data:T,error:Je,_c:Je})}else $({data:b,error:Je,_c:Je});if(_[x][1]=Ni(),Promise.resolve(y()).then(()=>{$({_c:Je})}),g){if(l)throw C;return}return b}}const Xa=(t,r)=>{for(const n in t)t[n][0]&&t[n][0](r)},gp=(t,r)=>{if(!Pt.has(t)){const n=nr(dp,r),o=Object.create(null),i=Wl.bind(Je,t);let a=Gt;const u=Object.create(null),c=(l,f)=>{const m=u[l]||[];return u[l]=m,m.push(f),()=>m.splice(m.indexOf(f),1)},d=(l,f,m)=>{t.set(l,f);const x=u[l];if(x)for(const v of x)v(f,m)},p=()=>{if(!Pt.has(t)&&(Pt.set(t,[o,Object.create(null),Object.create(null),Object.create(null),i,d,c]),!Hr)){const l=n.initFocus(setTimeout.bind(Je,Xa.bind(Je,o,Fl))),f=n.initReconnect(setTimeout.bind(Je,Xa.bind(Je,o,Nl)));a=()=>{l&&l(),f&&f(),Pt.delete(t)}}};return p(),[t,i,p,a]}return[t,Pt.get(t)[4]]},mp=(t,r,n,o,i)=>{const a=n.errorRetryCount,u=i.retryCount,c=~~((Math.random()+.5)*(1<<(u<8?u:8)))*n.errorRetryInterval;!ye(a)&&u>a||setTimeout(o,c,i)},xp=Ti,[ca,un]=gp(new Map),vp=nr({onLoadingSlow:Gt,onSuccess:Gt,onError:Gt,onErrorRetry:mp,onDiscarded:Gt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ja?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ja?5e3:3e3,compare:xp,isPaused:()=>!1,cache:ca,mutate:un,fallback:{}},lp),yp=(t,r)=>{const n=nr(t,r);if(r){const{use:o,fallback:i}=t,{use:a,fallback:u}=r;o&&a&&(n.use=o.concat(a)),i&&u&&(n.fallback=nr(i,u))}return n},bp=s.createContext({}),Vl="$inf$",Gl=jn&&window.__SWR_DEVTOOLS_USE__,wp=Gl?window.__SWR_DEVTOOLS_USE__:[],jp=()=>{Gl&&(window.__SWR_DEVTOOLS_REACT__=s)},Hl=t=>vt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],ql=()=>{const t=s.useContext(bp);return s.useMemo(()=>nr(vp,t),[t])},_p=t=>(r,n,o)=>t(r,n&&((...a)=>{const[u]=yn(r),[,,,c]=Pt.get(ca);if(u.startsWith(Vl))return n(...a);const d=c[u];return ye(d)?n(...a):(delete c[u],d)}),o),kp=wp.concat(_p),Cp=t=>function(...n){const o=ql(),[i,a,u]=Hl(n),c=yp(o,u);let d=t;const{use:p}=c,l=(p||[]).concat(kp);for(let f=l.length;f--;)d=l[f](d);return d(i,a||c.fetcher||null,c)},Sp=(t,r,n)=>{const o=r[t]||(r[t]=[]);return o.push(n),()=>{const i=o.indexOf(n);i>=0&&(o[i]=o[o.length-1],o.pop())}},$p=(t,r)=>(...n)=>{const[o,i,a]=Hl(n),u=(a.use||[]).concat(r);return t(o,i,{...a,use:u})};jp();const qo=s.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),Yo={dedupe:!0},es=Promise.resolve(Je),Ep=()=>Gt,zp=(t,r,n)=>{const{cache:o,compare:i,suspense:a,fallbackData:u,revalidateOnMount:c,revalidateIfStale:d,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:f,keepPreviousData:m,strictServerPrefetchWarning:x}=n,[v,$,S,_]=Pt.get(o),[k,P]=yn(t),y=s.useRef(!1),b=s.useRef(!1),C=s.useRef(k),g=s.useRef(r),j=s.useRef(n),w=()=>j.current,E=()=>w().isVisible()&&w().isOnline(),[I,O,z,T]=Xt(o,k),D=s.useRef({}).current,F=ye(u)?ye(n.fallback)?Je:n.fallback[k]:u,M=(q,te)=>{for(const de in D){const ie=de;if(ie==="data"){if(!i(q[ie],te[ie])&&(!ye(q[ie])||!i(ge,te[ie])))return!1}else if(te[ie]!==q[ie])return!1}return!0},L=!y.current,A=s.useMemo(()=>{const q=I(),te=T(),de=W=>{const xe=nr(W);return delete xe._k,(()=>{if(!k||!r||w().isPaused())return!1;if(L&&!ye(c))return c;const it=ye(F)?xe.data:F;return ye(it)||d})()?{isValidating:!0,isLoading:!0,...xe}:xe},ie=de(q),Y=q===te?ie:de(te);let ve=ie;return[()=>{const W=de(I());return M(W,ve)?(ve.data=W.data,ve.isLoading=W.isLoading,ve.isValidating=W.isValidating,ve.error=W.error,ve):(ve=W,W)},()=>Y]},[o,k]),R=Ii.useSyncExternalStore(s.useCallback(q=>z(k,(te,de)=>{M(de,te)||q()}),[o,k]),A[0],A[1]),U=v[k]&&v[k].length>0,V=R.data,H=ye(V)?F&&Bl(F)?qo(F):F:V,ae=R.error,ee=s.useRef(H),ge=m?ye(V)?ye(ee.current)?H:ee.current:V:H,pe=k&&ye(H),Q=s.useRef(null);!Hr&&Ii.useSyncExternalStore(Ep,()=>(Q.current=!1,Q),()=>(Q.current=!0,Q));const he=Q.current;x&&he&&!a&&pe&&console.warn(`Missing pre-initiated data for serialized key "${k}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const X=!k||!r||w().isPaused()||U&&!ye(ae)?!1:L&&!ye(c)?c:a?ye(H)?!1:d:ye(H)||d,Oe=L&&X,se=ye(R.isValidating)?Oe:R.isValidating,ce=ye(R.isLoading)?Oe:R.isLoading,_e=s.useCallback(async q=>{const te=g.current;if(!k||!te||b.current||w().isPaused())return!1;let de,ie,Y=!0;const ve=q||{},W=!S[k]||!ve.dedupe,xe=()=>Za?!b.current&&k===C.current&&y.current:k===C.current,qe={isValidating:!1,isLoading:!1},it=()=>{O(qe)},G=()=>{const Me=S[k];Me&&Me[1]===ie&&delete S[k]},fe={isValidating:!0};ye(I().data)&&(fe.isLoading=!0);try{if(W&&(O(fe),n.loadingTimeout&&ye(I().data)&&setTimeout(()=>{Y&&xe()&&w().onLoadingSlow(k,n)},n.loadingTimeout),S[k]=[te(P),Ni()]),[de,ie]=S[k],de=await de,W&&setTimeout(G,n.dedupingInterval),!S[k]||S[k][1]!==ie)return W&&xe()&&w().onDiscarded(k),!1;qe.error=Je;const Me=$[k];if(!ye(Me)&&(ie<=Me[0]||ie<=Me[1]||Me[1]===0))return it(),W&&xe()&&w().onDiscarded(k),!1;const Ve=I().data;qe.data=i(Ve,de)?Ve:de,W&&xe()&&w().onSuccess(de,k,n)}catch(Me){G();const Ve=w(),{shouldRetryOnError:nt}=Ve;Ve.isPaused()||(qe.error=Me,W&&xe()&&(Ve.onError(Me,k,Ve),(nt===!0||vt(nt)&&nt(Me))&&(!w().revalidateOnFocus||!w().revalidateOnReconnect||E())&&Ve.onErrorRetry(Me,k,Ve,ct=>{const Xe=v[k];Xe&&Xe[0]&&Xe[0](Ka,ct)},{retryCount:(ve.retryCount||0)+1,dedupe:!0})))}return Y=!1,it(),!0},[k,o]),me=s.useCallback((...q)=>Wl(o,C.current,...q),[]);if(ao(()=>{g.current=r,j.current=n,ye(V)||(ee.current=V)}),ao(()=>{if(!k)return;const q=_e.bind(Je,Yo);let te=0;w().revalidateOnFocus&&(te=Date.now()+w().focusThrottleInterval);const ie=Sp(k,v,(Y,ve={})=>{if(Y==Fl){const W=Date.now();w().revalidateOnFocus&&W>te&&E()&&(te=W+w().focusThrottleInterval,q())}else if(Y==Nl)w().revalidateOnReconnect&&E()&&q();else{if(Y==Ul)return _e();if(Y==Ka)return _e(ve)}});return b.current=!1,C.current=k,y.current=!0,O({_k:P}),X&&(S[k]||(ye(H)||Hr?q():up(q))),()=>{b.current=!0,ie()}},[k]),ao(()=>{let q;function te(){const ie=vt(p)?p(I().data):p;ie&&q!==-1&&(q=setTimeout(de,ie))}function de(){!I().error&&(l||w().isVisible())&&(f||w().isOnline())?_e(Yo).then(te):te()}return te(),()=>{q&&(clearTimeout(q),q=-1)}},[p,l,f,k]),s.useDebugValue(ge),a){if(!Za&&Hr&&pe)throw new Error("Fallback data is required when using Suspense in SSR.");pe&&(g.current=r,j.current=n,b.current=!1);const q=_[k],te=!ye(q)&&pe?me(q):es;if(qo(te),!ye(ae)&&pe)throw ae;const de=pe?_e(Yo):es;!ye(ge)&&pe&&(de.status="fulfilled",de.value=!0),qo(de)}return{mutate:me,get data(){return D.data=!0,ge},get error(){return D.error=!0,ae},get isValidating(){return D.isValidating=!0,se},get isLoading(){return D.isLoading=!0,ce}}},Re=Cp(zp),lt=()=>{const{adapter:t,deployment:r}=be(),n=t.useNavigate(),o=(d,p)=>{n?n(d,p):window.location.href=d},i=d=>{if(d)return d;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:o,navigateToSignIn:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function Pp(t){const r=await t("/session",{method:"GET"});return(await N(r)).data}async function Rp(t,r){const n=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return N(n)}async function Ip(t,r){const n=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",o=await t(n,{method:"POST"});return N(o)}async function Tp(t,r){const n=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return N(n)}async function Op(t,r){const n=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return N(n)}async function Ap(t,r){const n=await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return N(n)}const Ui=new Map,pn=new Map;function Rt(){Ui.clear(),pn.clear()}async function Lp(t,r){const n=await t(`/session/token${r?`?template=${r}`:""}`);return N(n)}function He(){const{client:t,loading:r}=$e(),{deployment:n}=be(),{navigate:o}=lt(),{cache:i}=ql(),{data:a,error:u,mutate:c,isLoading:d}=Re(r?null:"/session",()=>Pp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=s.useCallback(async()=>{await c(void 0,{revalidate:!0})},[c]),l=s.useCallback(async(f="default")=>{if(!a)throw new Error("no session");const m=Ui.get(f);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";pn.get(f)||pn.set(f,Lp(t,f));const x=await pn.get(f);return pn.delete(f),Ui.set(f,x.data),x.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||d?{loading:!0,error:u,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:p}:{loading:d,error:u,session:a,switchSignIn:async f=>{await Rp(t,f),Rt(),await un("/me/organization-memberships",void 0,{revalidate:!1}),await un("/me/workspace-memberships",void 0,{revalidate:!1}),await c(void 0,{revalidate:!0}),await un("/me/organization-memberships"),await un("/me/workspace-memberships")},signOut:async f=>{await Ip(t,f);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const v=Array.from(i.keys());for(const $ of v){let S=!1;(m.includes($)||typeof $=="string"&&x.some(_=>$.startsWith(_)))&&(S=!0),S&&i.delete($)}}Rt(),await c(void 0,{revalidate:!0}),n!=null&&n.ui_settings&&(f&&n.ui_settings.after_sign_out_one_page_url?o(n.ui_settings.after_sign_out_one_page_url):!f&&n.ui_settings.after_sign_out_all_page_url&&o(n.ui_settings.after_sign_out_all_page_url))},switchOrganization:async f=>{await Tp(t,f),Rt(),await c(void 0,{revalidate:!0})},switchWorkspace:async f=>{await Op(t,f),Rt(),await c(void 0,{revalidate:!0})},exchangeTicket:async f=>{await Ap(t,f),Rt(),await c(void 0,{revalidate:!0})},getToken:l,refetch:p}}const Tt=()=>{const{organizationMemberships:t,refetch:r,loading:n}=Kt(),{client:o}=$e(),{refetch:i}=He(),a=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[o]),u=s.useCallback(async(L,A)=>{const R=new URLSearchParams;return A&&(R.set("page",A.page.toString()),R.set("limit",A.limit.toString()),A.search&&R.set("search",A.search)),(await N(await o(`/organizations/${L.id}/members?${R.toString()}`,{method:"GET"}))).data},[o]),c=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[o]),d=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[o]),p=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/members/${A.id}/remove`,{method:"POST"})},[o]),l=s.useCallback(async L=>{const A=new FormData;A.append("name",L.name),L.image&&A.append("image",L.image),L.description&&A.append("description",L.description);const R=await N(await o("/organizations",{method:"POST",body:A}));return Rt(),await r(),await i(),R},[i,r,o]),f=s.useCallback(async(L,A)=>{const R=Object.entries(A).reduce((V,[H,ae])=>(ae!=null&&(Array.isArray(ae)?ae.forEach(ee=>V.append(H,ee)):V.append(H,ae)),V),new FormData),U=await N(await o(`/organizations/${L.id}/update`,{method:"POST",body:R}));return await r(),U},[r,o]),m=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/roles/${A.id}/remove`,{method:"POST"})},[o]),x=s.useCallback(async(L,A)=>{const R=new FormData;return R.append("domain",A.fqdn),await N(await o(`/organizations/${L.id}/domains`,{method:"POST",body:R}))},[o]),v=s.useCallback(async(L,A)=>await N(await o(`/organizations/${L.id}/domains/${A.id}/verify`,{method:"POST"})),[o]),$=s.useCallback(async(L,A)=>await N(await o(`/organizations/${L.id}/domains/${A.id}/delete`,{method:"POST"})),[o]),S=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[o]),_=s.useCallback(async(L,A)=>{const R=new FormData;return R.append("protocol",A.protocol),A.domain_id&&R.append("domain_id",A.domain_id),A.idp_entity_id&&R.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&R.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&R.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&R.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&R.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&R.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&R.append("oidc_scopes",A.oidc_scopes),A.jit_enabled!==void 0&&R.append("jit_enabled",String(A.jit_enabled)),A.attribute_mapping&&R.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await N(await o(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:R}))).data},[o]),k=s.useCallback(async(L,A,R)=>{const U=new FormData;return R.domain_id&&U.append("domain_id",R.domain_id),R.idp_entity_id&&U.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&U.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&U.append("idp_certificate",R.idp_certificate),R.oidc_client_id&&U.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&U.append("oidc_client_secret",R.oidc_client_secret),R.oidc_issuer_url&&U.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_scopes&&U.append("oidc_scopes",R.oidc_scopes),R.attribute_mapping&&U.append("attribute_mapping",JSON.stringify(R.attribute_mapping)),(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/update`,{method:"POST",body:U}))).data},[o]),P=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/enterprise-connections/${A}/delete`,{method:"POST"})},[o]),y=s.useCallback(async(L,A)=>{const R=new FormData;return R.append("protocol",A.protocol),A.idp_entity_id&&R.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&R.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&R.append("idp_certificate",A.idp_certificate),A.oidc_issuer_url&&R.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_client_id&&R.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&R.append("oidc_client_secret",A.oidc_client_secret),(await N(await o(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:R}))).data},[o]),b=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/test`,{method:"POST"}))).data,[o]),C=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"POST"}))).data,[o]),g=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"GET"}))).data,[o]),j=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token/revoke`,{method:"POST"})},[o]),w=s.useCallback(async(L,A)=>{const R=new FormData;return R.append("name",A.name),A.permissions&&A.permissions.forEach((V,H)=>{R.append(`permissions[${H}]`,V)}),await N(await o(`/organizations/${L.id}/roles`,{method:"POST",body:R}))},[o]),E=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[o]),I=s.useCallback(async L=>{const A=await N(await o(`/organizations/${L.id}/delete`,{method:"POST"}));return Rt(),await r(),await i(),A.data},[o,r,i]),O=s.useCallback(async(L,A,R)=>(await N(await o(`/organizations/${L.id}/members/${A.id}/roles/${R.id}/add`,{method:"POST"}))).data,[o]),z=s.useCallback(async(L,A,R)=>(await N(await o(`/organizations/${L.id}/members/${A.id}/roles/${R.id}/remove`,{method:"POST"}))).data,[o]),T=s.useCallback(async(L,A)=>{var V,H;const R=new FormData;return R.append("email",A.email),R.append("role_id",A.organizationRole.id),(V=A.workspace)!=null&&V.id&&R.append("workspace_id",A.workspace.id),(H=A.workspaceRole)!=null&&H.id&&R.append("workspace_role_id",A.workspaceRole.id),(await N(await o(`/organizations/${L.id}/invitations`,{method:"POST",body:R}))).data},[o]),D=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/invitations/${A.id}/discard`,{method:"POST"}))).data,[o]),F=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/invitations/${A.id}/resend`,{method:"POST"}))).data,[o]);return{organizations:s.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:n,error:null,refetch:r,leaveOrganization:E,getOrganizationRoles:a,getOrganizationMembers:u,removeOrganizationMember:p,createOrganization:l,getOrganizationInvitations:c,getOrganizationDomains:d,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:$,addRoleToOrganizationMember:O,removeRoleFromOrganizationMember:z,inviteOrganizationMember:T,discardOrganizationInvitation:D,resendOrganizationInvitation:F,updateOrganization:f,addRole:w,removeOrganizationRoles:m,deleteOrganization:I,getEnterpriseConnections:S,createEnterpriseConnection:_,updateEnterpriseConnection:k,deleteEnterpriseConnection:P,testEnterpriseConnectionConfig:y,testEnterpriseConnection:b,generateSCIMToken:C,getSCIMToken:g,revokeSCIMToken:j}},Tr=()=>{const{loading:t,error:r,refetch:n,getOrganizationMembers:o,getOrganizationRoles:i,leaveOrganization:a,removeOrganizationMember:u,getOrganizationInvitations:c,getOrganizationDomains:d,removeOrganizationDomain:p,addOrganizationDomain:l,verifyOrganizationDomain:f,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:$,resendOrganizationInvitation:S,updateOrganization:_,removeOrganizationRoles:k,getEnterpriseConnections:P,createEnterpriseConnection:y,updateEnterpriseConnection:b,deleteEnterpriseConnection:C,testEnterpriseConnectionConfig:g,testEnterpriseConnection:j,generateSCIMToken:w,getSCIMToken:E,revokeSCIMToken:I}=Tt(),{session:O,error:z,loading:T}=He(),{organizationMemberships:D}=Kt(),F=s.useMemo(()=>(D==null?void 0:D.find(W=>{var xe;return W.id===((xe=O==null?void 0:O.active_signin)==null?void 0:xe.active_organization_membership_id)}))||null,[D,O]),M=s.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),L=s.useCallback(async W=>M?await _(M,W):[],[M,_]),A=s.useCallback(async()=>M?await o(M):[],[M,o]),R=s.useCallback(async()=>M?await i(M):[],[M,i]),U=s.useCallback(async W=>M?await u(M,W):[],[M,u]),V=s.useCallback(async W=>M?await k(M,W):void 0,[M,k]),H=s.useCallback(async()=>M?await d(M):[],[M,d]),ae=s.useCallback(async W=>M?await l(M,W):void 0,[M,l]),ee=s.useCallback(async W=>M?await f(M,W):void 0,[M,f]),ge=s.useCallback(async W=>M?await p(M,W):void 0,[M,p]),pe=s.useCallback(async(W,xe)=>M?await m(M,W,xe):void 0,[M,m]),Q=s.useCallback(async(W,xe)=>M?await x(M,W,xe):void 0,[M,x]),he=s.useCallback(async W=>M?await v(M,W):void 0,[M,v]),X=s.useCallback(async W=>M?await $(M,W):void 0,[M,$]),Oe=s.useCallback(async W=>M?await S(M,W):void 0,[M,S]),se=s.useCallback(async()=>{M&&await a(M)},[M,a]),ce=s.useCallback(async()=>M?await c(M):[],[M,c]),_e=s.useCallback(async()=>M?await P(M):[],[M,P]),me=s.useCallback(async W=>{if(M)return await y(M,W)},[M,y]),Ce=s.useCallback(async(W,xe)=>{if(M)return await b(M,W,xe)},[M,b]),q=s.useCallback(async W=>{M&&await C(M,W)},[M,C]),te=s.useCallback(async W=>M?await g(M,W):null,[M,g]),de=s.useCallback(async W=>M?await j(M,W):null,[M,j]),ie=s.useCallback(async W=>{if(M)return await w(M,W)},[M,w]),Y=s.useCallback(async W=>{if(M)return await E(M,W)},[M,E]),ve=s.useCallback(async W=>{M&&await I(M,W)},[M,I]);return T||t?{activeOrganization:null,activeMembership:null,loading:!0,error:z||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:M,activeMembership:F,loading:!1,refetch:n,getRoles:R,updateOrganization:L,getMembers:A,getDomains:H,addDomain:ae,verifyDomain:ee,removeDomain:ge,getInvitations:ce,removeMember:U,leave:se,removeRole:V,addMemberRole:pe,removeMemberRole:Q,inviteMember:he,discardInvitation:X,resendInvitation:Oe,getEnterpriseConnections:_e,createEnterpriseConnection:me,updateEnterpriseConnection:Ce,deleteEnterpriseConnection:q,testEnterpriseConnectionConfig:te,testEnterpriseConnection:de,generateSCIMToken:ie,getSCIMToken:Y,revokeSCIMToken:ve,error:null}};async function Mp(t){return(await N(await t("/me/organization-memberships"))).data}const Kt=()=>{const{client:t,loading:r}=$e(),{data:n,isLoading:o,error:i,mutate:a}=Re(r?null:"/me/organization-memberships",()=>Mp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=s.useCallback(async()=>{await a()},[a]);return{organizationMemberships:n,loading:r||o,error:i,refetch:u}};async function Dp(t){return(await N(await t("/me/workspace-memberships"))).data}async function Fp(t,r,n){return(await N(await t(`/workspaces/${r}/members/${n}/remove`,{method:"POST"}))).data}const So=()=>{const{client:t,loading:r}=$e(),{deployment:n}=be(),{data:o,isLoading:i,error:a,mutate:u}=Re(!r&&(n!=null&&n.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Dp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=s.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]);return{workspaceMemberships:o,loading:r||i,error:a,refetch:c}},ar=()=>{const{workspaceMemberships:t,refetch:r,loading:n,error:o}=So(),{client:i}=$e(),a=s.useMemo(()=>t==null?void 0:t.map(b=>({...b.workspace,organization:b.organization,eligibility_restriction:b.eligibility_restriction})),[t]),u=s.useCallback(async(b,C,g,j)=>{const w=new FormData;w.append("name",C),g&&w.append("image",g),j&&w.append("description",j),w.append("organization_id",b);const E=await N(await i("/workspaces",{method:"POST",body:w}));return Rt(),await r(),E.data},[i,r]),c=s.useCallback(async(b,C)=>{const g=await Fp(i,b,C);return await r(),g},[i,r]),d=s.useCallback(async(b,C)=>{const g=new FormData;C.name&&g.append("name",C.name),C.description&&g.append("description",C.description),C.image&&g.append("image",C.image),C.enforce_2fa!==void 0&&g.append("enforce_2fa",String(C.enforce_2fa)),C.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(C.enable_ip_restriction)),C.whitelisted_ips&&C.whitelisted_ips.forEach(w=>g.append("whitelisted_ips",w));const j=await N(await i(`/workspaces/${b.id}/update`,{method:"POST",body:g}));return await r(),j.data},[i,r]),p=s.useCallback(async b=>{const C=await N(await i(`/workspaces/${b.id}/delete`,{method:"POST"}));return Rt(),await r(),C.data},[i,r]),l=s.useCallback(async(b,C)=>{const g=new URLSearchParams;return C&&(g.set("page",C.page.toString()),g.set("limit",C.limit.toString()),C.search&&g.set("search",C.search)),(await N(await i(`/workspaces/${b.id}/members?${g.toString()}`,{method:"GET"}))).data},[i]),f=s.useCallback(async b=>(await N(await i(`/workspaces/${b.id}/roles`,{method:"GET"}))).data,[i]),m=s.useCallback(async(b,C,g)=>{const j=new FormData;return j.append("name",C),g.forEach(E=>j.append("permissions",E)),(await N(await i(`/workspaces/${b.id}/roles`,{method:"POST",body:j}))).data},[i]),x=s.useCallback(async(b,C)=>(await N(await i(`/workspaces/${b.id}/roles/${C.id}/delete`,{method:"POST"}))).data,[i]),v=s.useCallback(async(b,C)=>{const g=await N(await i(`/workspaces/${b.id}/members/${C}/remove`,{method:"POST"}));return await r(),g.data},[i,r]),$=s.useCallback(async(b,C,g)=>(await N(await i(`/workspaces/${b.id}/members/${C}/roles/${g}/add`,{method:"POST"}))).data,[i]),S=s.useCallback(async(b,C,g)=>(await N(await i(`/workspaces/${b.id}/members/${C}/roles/${g}/remove`,{method:"POST"}))).data,[i]),_=s.useCallback(async b=>(await N(await i(`/organizations/${b.organization.id}/invitations?workspace_id=${b.id}`,{method:"GET"}))).data,[i]),k=s.useCallback(async(b,C,g)=>{const j=new FormData;return j.append("email",C),j.append("workspace_id",b.id),g&&j.append("workspace_role_id",g),(await N(await i(`/organizations/${b.organization.id}/invitations`,{method:"POST",body:j}))).data},[i]),P=s.useCallback(async(b,C)=>(await N(await i(`/organizations/${b.organization.id}/invitations/${C}/discard`,{method:"POST"}))).data,[i]),y=s.useCallback(async(b,C)=>(await N(await i(`/organizations/${b.organization.id}/invitations/${C}/resend`,{method:"POST"}))).data,[i]);return{workspaces:a||[],loading:n,error:o,refetch:r,leaveWorkspace:c,createWorkspace:u,updateWorkspace:d,deleteWorkspace:p,getWorkspaceMembers:l,getWorkspaceRoles:f,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:S,getWorkspaceInvitations:_,createWorkspaceInvitation:k,discardWorkspaceInvitation:P,resendWorkspaceInvitation:y}},Qt=()=>{const{refetch:t,loading:r,error:n,workspaces:o,leaveWorkspace:i,updateWorkspace:a,deleteWorkspace:u,getWorkspaceMembers:c,getWorkspaceRoles:d,createWorkspaceRole:p,deleteWorkspaceRole:l,removeWorkspaceMember:f,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:$,discardWorkspaceInvitation:S,resendWorkspaceInvitation:_}=ar(),{workspaceMemberships:k}=So(),{session:P,loading:y,error:b}=He(),C=s.useMemo(()=>(k==null?void 0:k.find(ee=>{var ge;return ee.id===((ge=P==null?void 0:P.active_signin)==null?void 0:ge.active_workspace_membership_id)}))||null,[k,P]),g=s.useMemo(()=>(C==null?void 0:C.workspace)||null,[C]),j=s.useCallback(async()=>{var ee;if(!(!g||!((ee=P==null?void 0:P.active_signin)!=null&&ee.user_id)))return await i(g.id,P.active_signin.user_id)},[g,i,P]),w=s.useCallback(async ee=>{if(g)return await a(g,ee)},[g,a]),E=s.useCallback(async()=>{if(g)return await u(g)},[g,u]),I=s.useCallback(async ee=>g?await c(g,ee):{data:[],meta:{total:0,page:1,limit:10}},[g,c]),O=s.useCallback(async()=>g?await d(g):[],[g,d]),z=s.useCallback(async(ee,ge)=>{if(g)return await p(g,ee,ge)},[g,p]),T=s.useCallback(async ee=>{if(g)return await l(g,ee)},[g,l]),D=s.useCallback(async ee=>{if(g)return await f(g,ee)},[g,f]),F=s.useCallback(async(ee,ge)=>{if(g)return await m(g,ee,ge)},[g,m]),M=s.useCallback(async(ee,ge)=>{if(g)return await x(g,ee,ge)},[g,x]),L=s.useMemo(()=>(o==null?void 0:o.find(ee=>ee.id===(g==null?void 0:g.id)))||null,[o,g]),A=s.useCallback(async()=>L?await v(L):[],[L,v]),R=s.useCallback(async ee=>{if(L)return await $(L,ee.email,ee.workspaceRoleId)},[L,$]),U=s.useCallback(async ee=>{if(L)return await S(L,ee)},[L,S]),V=s.useCallback(async ee=>{if(L)return await _(L,ee)},[L,_]),H=r||y,ae=n||b;return H?{activeWorkspace:null,activeMembership:null,loading:!0,error:ae,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:g,activeMembership:C,loading:!1,error:ae,refetch:t,leave:j,updateWorkspace:w,deleteWorkspace:E,getMembers:I,getRoles:O,createRole:z,deleteRole:T,inviteMember:R,removeMember:D,addMemberRole:F,removeMemberRole:M,getInvitations:A,discardInvitation:U,resendInvitation:V}};function Ko(t){const r=new Uint8Array(t);let n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Qo(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"="),o=atob(n),i=new Uint8Array(o.length);for(let a=0;a<o.length;a++)i[a]=o.charCodeAt(a);return i.buffer}const Np=async t=>(await N(await t("/me"))).data,Up=async t=>(await N(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=$e(),{data:n,error:o,isLoading:i,mutate:a}=Re(r?null:"/user",()=>Np(t)),u=async L=>{const A=new FormData;for(const[U,V]of Object.entries(L))V!=null&&V!==""&&A.append(U,String(V));const R=await N(await t("/me",{method:"POST",body:A}));return a(),R},c=async()=>await N(await t("/me/email-addresses",{method:"GET"})),d=async L=>await N(await t(`/me/email-addresses/${L}`,{method:"GET"})),p=async L=>{const A=new FormData;return A.append("email",L),await N(await t("/me/email-addresses",{method:"POST",body:A}))},l=async L=>await N(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),f=async L=>await N(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,A)=>await N(await t(`/me/email-addresses/${L}/attempt-verification?code=${A}`,{method:"POST"})),x=async(L,A)=>{const R=new FormData;return R.append("phone_number",L),R.append("country_code",A),await N(await t("/me/phone-numbers",{method:"POST",body:R}))},v=async L=>await N(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),$=async L=>await N(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),S=async(L,A)=>{const R=new FormData;return R.append("code",A),await N(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:R}))},_=async L=>{const A=await N(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return a(),A},k=async L=>await N(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),P=async()=>(await N(await t("/me/authenticator",{method:"POST"}))).data,y=async(L,A)=>{const R=new FormData;return R.append("authenticator_id",L),A.forEach(V=>{R.append("codes",V)}),await N(await t("/me/authenticator/attempt-verification",{method:"POST",body:R}))},b=async L=>await N(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),C=async()=>(await N(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const A=new FormData;return A.append("file",L),await N(await t("/me/profile-picture",{method:"POST",body:A}))},j=async()=>(await N(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,w=async(L,A)=>{const R=new FormData;return R.append("current_password",L),R.append("new_password",A),await N(await t("/me/update-password",{method:"POST",body:R}))},E=async L=>{const A=new FormData;A.append("current_password",L);const R=await N(await t("/me/remove-password",{method:"POST",body:A}));return a(),R},I=async L=>{const A=new FormData;return A.append("password",L),await N(await t("/me/account/delete",{method:"POST",body:A}))},O=async L=>await N(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),z=async({provider:L,redirectUri:A})=>{var V;const R=new URLSearchParams({provider:L});A&&R.append("redirect_uri",A);const U=await N(await t(`/me/init-sso-connection?${R.toString()}`,{method:"POST"}));return"data"in U&&((V=U.data)!=null&&V.oauth_url)&&window.open(U.data.oauth_url,"_blank"),U},T=async()=>await N(await t("/me/passkeys",{method:"GET"})),D=async L=>{var ge,pe;const A=await N(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in A))return A;const R=A.data.options.publicKey,U={challenge:Qo(R.challenge),rp:R.rp,user:{id:Qo(R.user.id),name:R.user.name,displayName:R.user.displayName},pubKeyCredParams:R.pubKeyCredParams,timeout:R.timeout,attestation:R.attestation,authenticatorSelection:R.authenticatorSelection,excludeCredentials:(ge=R.excludeCredentials)==null?void 0:ge.map(Q=>({type:Q.type,id:Qo(Q.id),transports:Q.transports}))},V=await navigator.credentials.create({publicKey:U});if(!V)throw new Error("Failed to create credential");const H=V.response,ae={id:V.id,rawId:Ko(V.rawId),type:V.type,response:{clientDataJSON:Ko(H.clientDataJSON),attestationObject:Ko(H.attestationObject),transports:((pe=H.getTransports)==null?void 0:pe.call(H))||[]}};return await N(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)}))},F=async L=>await N(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),M=async(L,A)=>await N(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}));return{user:{...n,refetch:a},loading:r||i,error:o||null,updateProfile:u,getEmailAddresses:c,getEmailAddress:d,createEmailAddress:p,deleteEmailAddress:l,prepareEmailVerification:f,attemptEmailVerification:m,makeEmailPrimary:k,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:$,attemptPhoneVerification:S,makePhonePrimary:_,setupAuthenticator:P,verifyAuthenticator:y,deleteAuthenticator:b,generateBackupCodes:C,regenerateBackupCodes:j,updateProfilePicture:g,disconnectSocialConnection:O,connectSocialAccount:z,updatePassword:w,removePassword:E,deleteAccount:I,getPasskeys:T,registerPasskey:D,deletePasskey:F,renamePasskey:M}}function Yl(){const{client:t,loading:r}=$e(),{data:n,error:o,isLoading:i,mutate:a}=Re(r?null:"/me/signins",()=>Up(t));return{signins:n,error:o||null,removeSignin:async c=>await N(await t(`/me/signins/${c}/signout`,{method:"POST"})),refetch:a,loading:i||r}}function Bp(){const{session:t,loading:r}=He(),{loading:n,organizationMemberships:o}=Kt(),{loading:i,workspaceMemberships:a}=So();if(r||n||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const u=s.useMemo(()=>!t||!t.signins||t.signins.length===0?null:o==null?void 0:o.find(d=>{var p;return d.id===((p=t.active_signin)==null?void 0:p.active_organization_membership_id)}),[t]),c=s.useMemo(()=>!t||!t.signins||t.signins.length===0?null:a==null?void 0:a.find(d=>{var p;return d.id===((p=t.active_signin)==null?void 0:p.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:u,workspaceMembership:c}}function Kl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),i=async a=>{o(!0);try{const u=new FormData;for(const[p,l]of Object.entries(a))l&&u.append(p,l);const c=await t("/waitlist/join",{method:"POST",body:u});return await N(c)}finally{o(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:n,joinWaitlist:i}}function Ql(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),[i,a]=s.useState(null),[u,c]=s.useState(null),[d,p]=s.useState(null),[l,f]=s.useState(!1),[m,x]=s.useState(null);s.useEffect(()=>{if(l||r)return;const $=new URLSearchParams(window.location.search),S=$.get("code"),_=$.get("state"),k=$.get("error"),P=$.get("error_description");if(!S&&!k){f(!0);const y=new Error("No OAuth callback data found.");a(y);return}if(f(!0),o(!0),k){const y=P||k,b=new Error(`OAuth Error: ${y}`);a(b),o(!1);return}if(S&&_)v(S,_);else{const y=new Error("Missing required OAuth parameters");a(y),o(!1)}},[l,r]);const v=async($,S)=>{try{let _,k;try{const b=S.split(".");if(b.length!==2)throw new Error("Invalid OAuth state format - missing signature");const C=b[0].replace(/-/g,"+").replace(/_/g,"/"),g=C.length%4?"=".repeat(4-C.length%4):"",w=atob(C+g).split("|")[0];if(w==="sign_in")_="/auth/oauth2/callback",k="GET";else if(w==="connect_social")_="/me/sso-connection-callback",k="POST";else throw new Error(`Unknown OAuth action: ${w}`)}catch(b){const C=b instanceof Error?b:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${C.message}. The authorization link may be expired or malformed. Please try signing in again.`)),o(!1);return}const P=await t(`${_}?code=${encodeURIComponent($)}&state=${encodeURIComponent(S)}`,{method:k}),y=await N(P);if("data"in y){const b=y.data.session,C=y.data.redirect_uri||null;if(c(b),p(C),b.signin_attempts&&b.signin_attempts.length>0){const g=b.signin_attempts.at(-1);g&&x(g)}}else{const b=new Error("SSO callback failed");a(b)}}catch(_){const k=_ instanceof Error?_:new Error("Unknown error occurred");a(k)}finally{o(!1)}};return{loading:n,error:i,session:u,redirectUri:d,processed:l,signinAttempt:m}}function Zl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),[i,a]=s.useState(null);return{loading:r||n,verifyMagicLink:async c=>{if(!c.token||!c.attempt)throw new Error("Invalid magic link parameters");o(!0),a(null);try{const d=new URL("/auth/verify-magic-link",window.location.origin);d.searchParams.set("token",c.token),d.searchParams.set("attempt",c.attempt),c.redirectUri&&d.searchParams.set("redirect_uri",c.redirectUri);const p=await t(d.pathname+d.search,{method:"GET"}),l=await N(p);return o(!1),a(!0),l}catch(d){throw o(!1),a(!1),d}},success:i}}function Jl(){const[t,r]=s.useState({});return s.useEffect(()=>{const n=new URLSearchParams(window.location.search);r({token:n.get("token")||void 0,attempt:n.get("attempt")||void 0,redirectUri:n.get("redirect_uri")||void 0})},[]),t}function Xl(){const{client:t,loading:r}=$e();return{loading:r,forgotPassword:async a=>{const u=new FormData;u.append("email",a);const c=await t("/auth/forgot-password",{method:"POST",body:u});return await N(c)},verifyOtp:async(a,u)=>{const c=new FormData;c.append("email",a),c.append("otp",u);const d=await t("/auth/forgot-password",{method:"POST",body:c});return await N(d)},resetPassword:async(a,u)=>{const c=new FormData;c.append("token",a),c.append("password",u);const d=await t("/auth/reset-password",{method:"POST",body:c});return await N(d)}}}const Wp=()=>{},Vp=Wp(),Bi=Object,ts=t=>t===Vp,Gp=t=>typeof t=="function",En=new WeakMap,Hp=t=>Bi.prototype.toString.call(t),Zo=(t,r)=>t===`[object ${r}]`;let qp=0;const Wi=t=>{const r=typeof t,n=Hp(t),o=Zo(n,"Date"),i=Zo(n,"RegExp"),a=Zo(n,"Object");let u,c;if(Bi(t)===t&&!o&&!i){if(u=En.get(t),u)return u;if(u=++qp+"~",En.set(t,u),Array.isArray(t)){for(u="@",c=0;c<t.length;c++)u+=Wi(t[c])+",";En.set(t,u)}if(a){u="#";const d=Bi.keys(t).sort();for(;!ts(c=d.pop());)ts(t[c])||(u+=c+":"+Wi(t[c])+",");En.set(t,u)}}else u=o?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},Yp=t=>{if(Gp(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Wi(t):"",[t,r]},Kp=t=>Yp(t?t(0,null):null)[0],Jo=Promise.resolve(),Qp=t=>(r,n,o)=>{const i=s.useRef(!1),{cache:a,initialSize:u=1,revalidateAll:c=!1,persistSize:d=!1,revalidateFirstPage:p=!0,revalidateOnMount:l=!1,parallel:f=!1}=o,[,,,m]=Pt.get(ca);let x;try{x=Kp(r),x&&(x=Vl+x)}catch{}const[v,$,S]=Xt(a,x),_=s.useCallback(()=>ye(v()._l)?u:v()._l,[a,x,u]);Ii.useSyncExternalStore(s.useCallback(j=>x?S(x,()=>{j()}):()=>{},[a,x]),_,_);const k=s.useCallback(()=>{const j=v()._l;return ye(j)?u:j},[x,u]),P=s.useRef(k());ao(()=>{if(!i.current){i.current=!0;return}x&&$({_l:d?P.current:k()})},[x,a]);const y=l&&!i.current,b=t(x,async j=>{const w=v()._i,E=v()._r;$({_r:Je});const I=[],O=k(),[z]=Xt(a,j),T=z().data,D=[];let F=null;for(let M=0;M<O;++M){const[L,A]=yn(r(M,f?null:F));if(!L)break;const[R,U]=Xt(a,L);let V=R().data;const H=c||w||ye(V)||p&&!M&&!ye(T)||y||T&&!ye(T[M])&&!o.compare(T[M],V);if(n&&(typeof E=="function"?E(V,A):H)){const ae=async()=>{if(!(L in m))V=await n(A);else{const ge=m[L];delete m[L],V=await ge}U({data:V,_k:A}),I[M]=V};f?D.push(ae):await ae()}else I[M]=V;f||(F=V)}return f&&await Promise.all(D.map(M=>M())),$({_i:Je}),I},o),C=s.useCallback(function(j,w){const E=typeof w=="boolean"?{revalidate:w}:w||{},I=E.revalidate!==!1;return x?(I&&(ye(j)?$({_i:!0,_r:E.revalidate}):$({_i:!1,_r:E.revalidate})),arguments.length?b.mutate(j,{...E,revalidate:I}):b.mutate()):Jo},[x,a]),g=s.useCallback(j=>{if(!x)return Jo;const[,w]=Xt(a,x);let E;if(vt(j)?E=j(k()):typeof j=="number"&&(E=j),typeof E!="number")return Jo;w({_l:E}),P.current=E;const I=[],[O]=Xt(a,x);let z=null;for(let T=0;T<E;++T){const[D]=yn(r(T,z)),[F]=Xt(a,D),M=D?F().data:Je;if(ye(M))return C(O().data);I.push(M),z=M}return C(I)},[x,a,C,k]);return{size:k(),setSize:g,mutate:C,get data(){return b.data},get error(){return b.error},get isValidating(){return b.isValidating},get isLoading(){return b.isLoading}}},Zp=$p(Re,Qp);function ed({enabled:t=!0,channels:r,organizationIds:n,workspaceIds:o,onNotification:i,onError:a,reconnectDelay:u=1e3,maxReconnectAttempts:c=5}={}){const{session:d,loading:p}=He(),{deployment:l,loading:f}=be(),[m,x]=s.useState(!1),[v,$]=s.useState(null),S=s.useRef(null),_=s.useRef(null),k=s.useRef(0),P=s.useRef(null),y=s.useRef(i),b=s.useRef(a),C=s.useRef(r),g=s.useRef(n),j=s.useRef(o),w=s.useRef(u),E=s.useRef(c);y.current=i,b.current=a,C.current=r,g.current=n,j.current=o,w.current=u,E.current=c;const I=s.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),P.current&&(clearInterval(P.current),P.current=null),S.current&&(S.current.close(),S.current=null)},[]),O=s.useCallback(async()=>{var L;if(!t||p||f||!d||!l)return;I();const D=new URL(l.backend_host),F=D.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${F}//${D.host}`);if(l.mode==="staging"){const A=tt();A&&M.searchParams.set("__dev_session__",A)}C.current&&C.current.length>0&&C.current.forEach(A=>M.searchParams.append("channels",A)),g.current&&g.current.length>0&&g.current.forEach(A=>M.searchParams.append("organization_ids",A.toString())),j.current&&j.current.length>0&&j.current.forEach(A=>M.searchParams.append("workspace_ids",A.toString()));try{const A=new WebSocket(M.toString());S.current=A,A.onopen=()=>{x(!0),$(null),k.current=0,P.current=setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send("ping")},3e4)},A.onmessage=R=>{var U,V;try{const H=JSON.parse(R.data);if(H.type==="notification"&&H.data)(U=y.current)==null||U.call(y,H.data);else if(H.type==="error"){const ae=H.error||"Unknown error occurred";$(ae),(V=b.current)==null||V.call(b,ae)}else H.type}catch{}},A.onerror=()=>{var R;$("Connection error occurred"),(R=b.current)==null||R.call(b,"Connection error occurred")},A.onclose=R=>{var U;if(x(!1),P.current&&(clearInterval(P.current),P.current=null),t&&R.code!==1e3&&k.current<E.current){k.current++;const V=w.current*Math.pow(2,k.current-1);_.current=setTimeout(()=>{O()},V)}else k.current>=E.current&&($("Max reconnection attempts reached"),(U=b.current)==null||U.call(b,"Max reconnection attempts reached"))}}catch{$("Failed to connect"),(L=b.current)==null||L.call(b,"Failed to connect")}},[t,p,f,d,l,I]);s.useEffect(()=>(O(),()=>{I()}),[O,I]),s.useEffect(()=>{S.current&&S.current.readyState===WebSocket.OPEN&&O()},[r,n,o,O]);const z=s.useCallback(()=>{I(),x(!1)},[I]),T=s.useCallback(()=>{k.current=0,O()},[O]);return{isConnected:m,connectionError:v,disconnect:z,reconnect:T}}function $o(t){if(!t)return"";const r=new URLSearchParams;t.limit&&r.append("limit",t.limit.toString()),t.cursor&&r.append("cursor",t.cursor),t.scope&&r.append("scope",t.scope),t.is_read!==void 0&&r.append("is_read",t.is_read.toString()),t.is_archived!==void 0&&r.append("is_archived",t.is_archived.toString()),t.is_starred!==void 0&&r.append("is_starred",t.is_starred.toString()),t.severity&&r.append("severity",t.severity);const n=r.toString();return n?"?"+n:""}async function Jp(t,r){const n=`/notifications${$o(r)}`,o=await t(n,{method:"GET"});return(await N(o)).data}async function Xp(t,r){const n=await t(`/notifications/${r}/read`,{method:"POST"});return N(n)}async function eh(t,r){const n=await t(`/notifications/${r}/unread`,{method:"POST"});return N(n)}async function th(t,r){const n=await t(`/notifications/mark-all-read${$o(r)}`,{method:"POST"});return N(n)}async function rh(t,r){const n=await t(`/notifications/archive-all-read${$o(r)}`,{method:"POST"});return N(n)}async function nh(t,r){const n=await t(`/notifications/${r}/archive`,{method:"POST"});return N(n)}async function oh(t,r){const n=await t(`/notifications/${r}/star`,{method:"POST"});return N(n)}function td(t){var b;const{client:r,loading:n}=$e(),{data:o,error:i,mutate:a,isLoading:u,size:c,setSize:d,isValidating:p}=Zp((C,g)=>{var I;if(n||C>0&&(!g||!g.has_more))return null;const j=C===0||(I=g==null?void 0:g.notifications[g.notifications.length-1])==null?void 0:I.id,{onNotification:w,...E}=t||{};return["wacht-notifications",{...E,cursor:j}]},([,C])=>Jp(r,C),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),l=s.useMemo(()=>o?o.flatMap(C=>C.notifications):[],[o]),f=o?(b=o[o.length-1])==null?void 0:b.has_more:!1;ed({enabled:!n&&!!o,onNotification:s.useCallback(C=>{a(async g=>{var I;if(!g||g.length===0||g.some(O=>O.notifications.some(z=>z.id===C.id.toString())))return g;(I=t==null?void 0:t.onNotification)==null||I.call(t,C);const w=g[0];return[{...w,notifications:[{id:C.id.toString(),user_id:C.user_id.toString(),deployment_id:C.deployment_id.toString(),title:C.title,body:C.body,severity:C.severity,ctas:C.ctas,is_read:!1,is_archived:!1,created_at:C.created_at,updated_at:C.created_at},...w.notifications]},...g.slice(1)]},!1)},[a,t]),onError:s.useCallback(()=>{},[])});const m=s.useCallback(async C=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===C?{...w,is_read:!0}:w)})),!1),await Xp(r,C),await a())},[r,n,a]),x=s.useCallback(async C=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===C?{...w,is_read:!1}:w)})),!1),await eh(r,C),await a())},[r,n,a]),v=s.useCallback(async()=>{n||(await a(async C=>C&&C.map(g=>({...g,notifications:g.notifications.map(j=>({...j,is_read:!0}))})),!1),await th(r,t),await a())},[r,t,a,n]),$=s.useCallback(async()=>{n||(await a(async C=>C&&C.map(g=>({...g,notifications:g.notifications.filter(j=>!j.is_read)})),!1),await rh(r,t),await a())},[r,t,n,a]),S=s.useCallback(async C=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:(t==null?void 0:t.is_archived)!==void 0?j.notifications.filter(w=>w.id!==C):j.notifications.map(w=>w.id===C?{...w,is_archived:!w.is_archived}:w)})),!1),await nh(r,C),await a())},[r,n,a,t==null?void 0:t.is_archived]),_=s.useCallback(async C=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===C?{...w,is_starred:!w.is_starred}:w)})),!1),await oh(r,C),await a())},[r,n,a]),k=s.useCallback(async()=>{p||!f||await d(c+1)},[p,f,d,c]),P=s.useCallback(async()=>{await a()},[a]),y=n||u||c>0&&o&&typeof o[c-1]>"u";return!o||y?{loading:!0,notifications:l,hasMore:f,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:i,refetch:P,loadMore:k}:{loading:!1,error:i,notifications:l,hasMore:f,markAsRead:m,markAllAsRead:v,archiveAllRead:$,archiveNotification:S,starNotification:_,markAsUnread:x,refetch:P,loadMore:k}}async function ih(t,r){const n=`/notifications/scope-unread${$o(r)}`,o=await t(n,{method:"GET"});return(await N(o)).data}function rd(t){const{client:r,loading:n}=$e(),{data:o,error:i,mutate:a}=Re(n?null:["wacht-notifications-unread",t],([,c])=>ih(r,c),{refreshInterval:3e4,revalidateOnFocus:!0}),u=async()=>{await a()};return!o||n?{loading:!0,count:0,error:i,refetch:u}:{loading:!1,count:o.count,error:i,refetch:u}}const zn={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Qe={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},dr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function ah(t){switch(t){case dr.IDLE:return Qe.IDLE;case dr.STARTING:return Qe.STARTING;case dr.RUNNING:return Qe.RUNNING;case dr.WAITING_FOR_INPUT:return Qe.WAITING_FOR_INPUT;case dr.COMPLETED:return Qe.COMPLETED;case dr.FAILED:case dr.CANCELLED:return Qe.FAILED;default:return Qe.IDLE}}function sh(t){return t===Qe.STARTING||t===Qe.RUNNING||t===Qe.WAITING_FOR_INPUT}function ch({contextId:t,agentName:r,platformAdapter:n}){const{deployment:o}=be(),{client:i}=$e(),[a,u]=s.useState([]),[c,d]=s.useState([]),[p,l]=s.useState(null),[f,m]=s.useState(null),[x,v]=s.useState(null),[$,S]=s.useState(!1),[_,k]=s.useState(!1),[P,y]=s.useState(Qe.IDLE),[b,C]=s.useState({status:zn.DISCONNECTED}),[g,j]=s.useState(!0),[w,E]=s.useState(!1),I=s.useRef(null),O=s.useRef(null),z=s.useRef(null),T=s.useRef(new Set),D=s.useCallback(se=>{var te;const{id:ce,content:_e}=se,me=se.message_type||((te=se.metadata)==null?void 0:te.message_type)||(_e==null?void 0:_e.type);let Ce="assistant";me==="user_message"&&(Ce="user");const q={...se,role:Ce,metadata:{...se.metadata||{},message_type:me}};if(me==="system_decision"||me==="action_execution_result"||me==="context_results"){if(l(null),m(null),v(null),T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]);return}if(me==="user_message"){if(l(null),m(null),v(null),T.current.has(ce))return;T.current.add(ce),console.log(T.current,ce),u(de=>[...de,q]);return}if(me==="assistant_acknowledgment"){if(l(null),m(null),v(null),T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]),se.further_action_required||(k(!1),y(Qe.IDLE),O.current=null);return}if(me==="agent_response"){if(T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]),k(!1),y(Qe.IDLE),O.current=null;return}if(me==="user_input_request"){if(T.current.has(ce))return;T.current.add(ce),y(Qe.WAITING_FOR_INPUT),u(de=>[...de,q]);return}if(me==="execution_status"){const de=ah(_e.status);y(de),k(sh(de));return}},[]),F=s.useCallback((se,ce)=>{var _e;(_e=n==null?void 0:n.onPlatformEvent)==null||_e.call(n,se,ce)},[n]),M=s.useRef(D),L=s.useRef(F),A=s.useRef(i),R=s.useRef(o);s.useEffect(()=>{M.current=D,L.current=F,A.current=i,R.current=o});const U=s.useRef(null),V=s.useRef(null),H=s.useRef(0),ae=10,ee=s.useCallback(async se=>{if(t)try{const ce=new URLSearchParams({limit:"100"});se&&(ce.append("before_id",se),E(!0));const _e=await i(`/api/agent/contexts/${t}/messages?${ce}`,{method:"GET"}),me=await N(_e);if(me.data){const Ce=[...me.data.data].sort((q,te)=>{const de=new Date(q.timestamp).getTime(),ie=new Date(te.timestamp).getTime();return de-ie});Ce.length>0&&(I.current=Ce[0].id),Ce.forEach(q=>{T.current.add(q.id)}),u(q=>se?[...Ce,...q]:Ce),j(me.data.has_more||!1),E(!1)}}catch(ce){console.error("Failed to fetch messages:",ce),E(!1)}},[t,i]);s.useEffect(()=>{const se=R.current;if(!se||!t)return;const ce=()=>{U.current&&(U.current.close(),U.current=null);const _e=se.backend_host.replace(/\/$/,""),me=new URL(`${_e}/realtime/agent/stream`);if(me.searchParams.append("context_id",t),se.mode==="staging"){const q=tt();q&&me.searchParams.append("__dev_session__",q)}console.log("SSE: Connecting to",me.toString());const Ce=new EventSource(me.toString(),{withCredentials:se.mode!=="staging"});U.current=Ce,Ce.onopen=()=>{console.log("SSE: Connected successfully"),S(!0),C({status:zn.CONNECTED}),H.current>0&&setTimeout(()=>{i(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async q=>{const te=await N(q);if(te.data){const de=[...te.data.data].sort((ie,Y)=>new Date(ie.timestamp).getTime()-new Date(Y.timestamp).getTime());u(de)}}).catch(q=>console.error("Failed to refetch messages:",q))},100),H.current=0},Ce.onerror=q=>{if(console.error("SSE error:",q),S(!1),C({status:zn.ERROR}),Ce.close(),U.current=null,H.current<ae){const te=Math.min(1e3*Math.pow(2,H.current),3e4);console.log(`SSE: Reconnecting in ${te}ms (attempt ${H.current+1}/${ae})`),V.current=setTimeout(()=>{H.current++,ce()},te)}else console.error("SSE: Max reconnection attempts reached"),C({status:zn.DISCONNECTED})},Ce.addEventListener("conversation_message",q=>{try{console.log("SSE received conversation_message:",q.data);const te=JSON.parse(q.data);te.ConversationMessage&&M.current(te.ConversationMessage)}catch(te){console.error("Failed to parse conversation event:",te)}}),Ce.addEventListener("platform_event",q=>{try{console.log("SSE received platform_event:",q.data);const te=JSON.parse(q.data);te.PlatformEvent&&L.current(te.PlatformEvent[0],te.PlatformEvent[1])}catch(te){console.error("Failed to parse platform event:",te)}}),Ce.addEventListener("user_input_request",q=>{try{console.log("SSE received user_input_request:",q.data);const te=JSON.parse(q.data);te.UserInputRequest&&D({id:`input-${Date.now()}`,content:te.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(te){console.error("Failed to parse user input request:",te)}})};return ce(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),V.current&&(clearTimeout(V.current),V.current=null),U.current&&(U.current.close(),U.current=null),S(!1)}},[t]);const ge=s.useCallback(async(se,ce,_e)=>{if(!(!t||!o)){l(se),ce&&ce.length>0&&m(ce),_e&&_e.length>0&&v(_e);try{const me=new FormData;me.append("agent_name",r),me.append("message",se),_e&&_e.length>0&&_e.forEach(q=>{me.append("files",q)}),(await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:me})).ok?(k(!0),y(Qe.RUNNING)):(l(null),m(null),v(null))}catch(me){console.error("Failed to send message:",me),l(null),m(null),v(null)}}},[t,r,o,i,ee]),pe=s.useCallback(async se=>{if(!(!t||P!==Qe.WAITING_FOR_INPUT))try{const ce=new FormData;ce.append("agent_name",r),ce.append("user_input",se),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ce}),y(Qe.RUNNING)}catch(ce){console.error("Failed to submit user input:",ce)}},[t,r,P,i]);s.useEffect(()=>{t&&z.current!==t&&(z.current=t,ee())},[t]);const Q=s.useCallback(async()=>{if(!(w||!g||!I.current)){E(!0);try{await ee(I.current)}finally{E(!1)}}},[w,g,ee]),he=s.useCallback(()=>{u([]),d([]),l(null),m(null),v(null)},[]),X=s.useCallback(()=>{},[]),Oe=s.useCallback(async()=>{if(!(!t||!_))try{const se=new FormData;se.append("agent_name",r),se.append("cancel","true"),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:se}),k(!1),y(Qe.IDLE)}catch(se){console.error("Failed to cancel execution:",se)}},[t,_,r,i]);return{messages:a,quickQuestions:c,pendingMessage:p,pendingImages:f,pendingFiles:x,connectionState:b,isConnected:$,isExecuting:_,executionStatus:P,isWaitingForInput:P===Qe.WAITING_FOR_INPUT,hasMoreMessages:g,isLoadingMore:w,sendMessage:ge,submitUserInput:pe,clearMessages:he,loadMoreMessages:Q,cancelExecution:Oe,connect:X,disconnect:()=>{U.current&&(U.current.close(),U.current=null,S(!1))}}}function lh(t){const{client:r}=$e(),n=s.useCallback(async()=>{if(!t)return[];const d=new URLSearchParams({agent_name:t}),p=await r(`/api/agent/integrations?${d.toString()}`,{method:"GET"});return(await N(p)).data},[r,t]),{data:o,error:i,mutate:a}=Re(t?`wacht-agent-integrations:${t}`:null,n,{revalidateOnFocus:!1}),u=s.useCallback(async d=>{const p=`/api/agent/integrations/${d}/consent-url`,l=await r(p,{method:"POST"});return(await N(l)).data},[r]),c=s.useCallback(async d=>{await r(`/api/agent/integrations/${d}/remove`,{method:"POST"}),await a(p=>p&&p.filter(l=>l.id!==d))},[r,a]);return{integrations:o||[],loading:!o&&!i,error:i,generateConsentURL:u,removeIntegration:c,refetch:async()=>{await a()}}}function dh(t){const{client:r}=$e(),n=s.useCallback(async()=>{if(!t)return[];const d=new URLSearchParams({agent_name:t}),p=await r(`/api/agent/mcp-servers?${d.toString()}`,{method:"GET"});return(await N(p)).data},[r,t]),{data:o,error:i,mutate:a}=Re(t?`wacht-agent-mcp-servers:${t}`:null,n,{revalidateOnFocus:!1}),u=s.useCallback(async d=>{if(!t)throw new Error("Agent name required");const p=new URLSearchParams({agent_name:t}),l=await r(`/api/agent/mcp-servers/${d}/connect?${p.toString()}`,{method:"POST"}),f=await N(l);return await a(),f.data},[r,t,a]),c=s.useCallback(async d=>{if(!t)throw new Error("Agent name required");const p=new URLSearchParams({agent_name:t});await r(`/api/agent/mcp-servers/${d}/disconnect?${p.toString()}`,{method:"POST"}),await a()},[r,t,a]);return{mcpServers:o||[],loading:!o&&!i,error:i,connect:u,disconnect:c,refetch:async()=>{await a()}}}function uh(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),[l,f]=s.useState(null),m=n,x=s.useCallback(async()=>{const b=await r("/api/agent/session",{method:"GET"});if(!b.ok)throw b.status===401||b.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await N(b)).data},[r]),{data:v,error:$,isLoading:S,mutate:_}=Re(m?"wacht-agent-session":null,x,{revalidateOnFocus:!1});s.useEffect(()=>{if(!t||d.current||p.current)return;(async()=>{p.current=!0,a(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(d.current=!0,o(!0)):c(new Error("Failed to exchange ticket"))}catch(C){c(C instanceof Error?C:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]),s.useEffect(()=>{!l&&(v!=null&&v.agents)&&v.agents.length>0&&f(v.agents[0])},[v,l]),s.useEffect(()=>{v!=null&&v.agents&&l&&!v.agents.some(C=>C.id===l.id)&&v.agents.length>0&&f(v.agents[0])},[v,l]);const k=!$||$.message!=="NO_SESSION",P=u||($&&$.message!=="NO_SESSION"?$:null);return{hasSession:k,sessionLoading:i||m&&S,sessionError:P,sessionId:(v==null?void 0:v.session_id)||null,contextGroup:(v==null?void 0:v.context_group)||null,agents:(v==null?void 0:v.agents)||[],activeAgent:l,setActiveAgent:f,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await _()}}}function ph(t={}){const{client:r}=$e(),{limit:n=20,offset:o=0,status:i,search:a,enabled:u=!0}=t,c=s.useCallback(async()=>{const v=new URLSearchParams({limit:String(n),offset:String(o)});i&&v.append("status",i),a&&v.append("search",a);const $=await r(`/api/agent/contexts?${v.toString()}`,{method:"GET"});return(await N($)).data},[r,n,o,i,a]),{data:d,error:p,mutate:l}=Re(u?`wacht-agent-contexts:${n}:${o}:${i}:${a}`:null,c,{revalidateOnFocus:!1}),f=s.useCallback(async v=>{const $=new FormData;$.append("title",v.title),v.system_instructions&&$.append("system_instructions",v.system_instructions);const S=await r("/api/agent/contexts",{method:"POST",body:$}),_=await N(S);return await l(k=>k&&{...k,data:[_.data,...k.data]}),_.data},[r,l]),m=s.useCallback(async v=>{await r(`/api/agent/contexts/${v}/delete`,{method:"POST"}),await l($=>$&&{...$,data:$.data.filter(S=>S.id!==v)})},[r,l]),x=s.useCallback(async(v,$)=>{const S=new FormData;if($.title&&S.append("title",$.title),!(await r(`/api/agent/contexts/${v}/update`,{method:"POST",body:S})).ok)throw new Error("Failed to update context");await l(k=>k&&{...k,data:k.data.map(P=>P.id===v?{...P,...$}:P)})},[r,l]);return{contexts:(d==null?void 0:d.data)||[],loading:!d&&!p,error:p,hasMore:(d==null?void 0:d.has_more)||!1,createContext:f,deleteContext:m,updateContext:x,refetch:async()=>{await l()}}}function hh(t){const r=new URLSearchParams;return r.append("url",t.url),t.description&&r.append("description",t.description),t.subscribed_events&&t.subscribed_events.forEach(n=>r.append("subscribed_events",n)),t.subscriptions&&t.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(t.subscriptions)),t.headers&&Object.entries(t.headers).forEach(([n,o])=>{r.append(`headers[${n}]`,o)}),t.rate_limit_config&&(r.append("rate_limit[duration_ms]",t.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",t.rate_limit_config.max_requests.toString())),r}function fh(t){const r=new URLSearchParams;return t.url&&r.append("url",t.url),t.description!==void 0&&r.append("description",t.description||""),t.subscribed_events&&t.subscribed_events.forEach(n=>r.append("subscribed_events",n)),t.subscriptions&&t.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(t.subscriptions)),t.headers&&Object.entries(t.headers).forEach(([n,o])=>{r.append(`headers[${n}]`,o)}),t.is_active!==void 0&&r.append("is_active",t.is_active.toString()),t.rate_limit_config&&(r.append("rate_limit[duration_ms]",t.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",t.rate_limit_config.max_requests.toString())),r}function gh(t){const r=new URLSearchParams;return r.append("event_name",t.event_name),r.append("payload",JSON.stringify(t.payload||{})),r}function mh(t){const r=new URLSearchParams;return(t.delivery_ids||[]).forEach(o=>r.append("delivery_ids",o)),t.start_date&&r.append("start_date",t.start_date),t.end_date&&r.append("end_date",t.end_date),t.status&&r.append("status",t.status),t.event_name&&r.append("event_name",t.event_name),t.endpoint_id&&r.append("endpoint_id",t.endpoint_id),t.idempotency_key&&r.append("idempotency_key",t.idempotency_key),r}const _n={"Content-Type":"application/x-www-form-urlencoded"};async function gt(t,r){const n=await N(t);if(!n||!("data"in n))throw new Error(r);return n.data}async function xh(t){const r=await t("/webhook/session",{method:"GET"});if(!r.ok)throw r.status===401||r.status===403?new Error("NO_SESSION"):new Error("Failed to fetch webhook app session");return gt(r,"Failed to fetch webhook app session")}async function vh(t,r){if(!(await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"})).ok)throw new Error("Failed to exchange ticket")}async function yh(t,r){const n=hh(r),o=await t("/webhook/endpoints",{method:"POST",headers:_n,body:n.toString()});return gt(o,"Failed to create webhook endpoint")}async function bh(t,r,n){const o=fh(n),i=await t(`/webhook/endpoints/${r}`,{method:"PUT",headers:_n,body:o.toString()});return gt(i,"Failed to update webhook endpoint")}async function wh(t,r){const n=await t(`/webhook/endpoints/${r}`,{method:"DELETE"});return gt(n,"Failed to delete webhook endpoint")}async function jh(t,r,n){const o=gh(n),i=await t(`/webhook/endpoints/${r}/test`,{method:"POST",headers:_n,body:o.toString()});return gt(i,"Failed to test webhook endpoint")}async function _h(t){const r=await t("/webhook/rotate-secret",{method:"POST"});return gt(r,"Failed to rotate signing secret")}async function kh(t,r){const n=new URLSearchParams;for(const i of r.failure_notification_emails)n.append("failure_notification_emails",i);const o=await t("/webhook/settings",{method:"PUT",headers:_n,body:n.toString()});return gt(o,"Failed to update webhook settings")}async function Ch(t,r){const n=mh(r),o=await t("/webhook/deliveries/replay",{method:"POST",headers:_n,body:n.toString()});return gt(o,"Failed to replay webhook delivery")}async function Sh(t,r){const n=await t(`/webhook/deliveries/${r}`,{method:"GET"});return gt(n,"Failed to fetch delivery details")}async function $h(t,{taskId:r}){const n=await t(`/webhook/deliveries/replay/${r}`,{method:"GET"});return gt(n,"Failed to fetch replay task status")}async function Eh(t,r){const n=(r==null?void 0:r.limit)??50,o=(r==null?void 0:r.offset)??0,i=await t(`/webhook/deliveries/replay?limit=${n}&offset=${o}`,{method:"GET"});return gt(i,"Failed to fetch replay tasks")}async function zh(t,{taskId:r}){const n=await t(`/webhook/deliveries/replay/${r}/cancel`,{method:"POST"});return gt(n,"Failed to cancel replay task")}function Ph(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),l=n,f=s.useCallback(async()=>xh(r),[r]),{data:m,error:x,isLoading:v,mutate:$}=Re(l?"wacht-webhook-app-session":null,f,{revalidateOnFocus:!1,shouldRetryOnError:!1});s.useEffect(()=>{if(!t||d.current||p.current)return;(async()=>{p.current=!0,a(!0);try{await vh(r,t),d.current=!0,o(!0)}catch(D){c(D instanceof Error?D:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]);const S=s.useCallback(async T=>yh(r,T),[r]),_=s.useCallback(async(T,D)=>bh(r,T,D),[r]),k=s.useCallback(async T=>wh(r,T),[r]),P=s.useCallback(async(T,D)=>jh(r,T,D),[r]),y=s.useCallback(async()=>_h(r),[r]),b=s.useCallback(async T=>Ch(r,T),[r]),C=s.useCallback(async T=>kh(r,T),[r]),g=s.useCallback(async T=>Sh(r,T),[r]),j=s.useCallback(async T=>$h(r,T),[r]),w=s.useCallback(async T=>Eh(r,T),[r]),E=s.useCallback(async T=>zh(r,T),[r]),I=!x||x.message!=="NO_SESSION",O=u||(x&&x.message!=="NO_SESSION"?x:null);return{hasSession:I,sessionLoading:i||l&&v,sessionError:O,sessionId:(m==null?void 0:m.session_id)||null,webhookApp:(m==null?void 0:m.webhook_app)||null,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await $()},createEndpoint:S,updateEndpoint:_,deleteEndpoint:k,testEndpoint:P,rotateSecret:y,updateSettings:C,replayDelivery:b,fetchReplayTaskStatus:j,fetchReplayTasks:w,cancelReplayTask:E,fetchDeliveryDetail:g}}function Rh(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/stats",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-stats",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{stats:n||null,loading:i,error:o,refetch:()=>a()}}function Ih(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/endpoints",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-endpoints",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{endpoints:n||[],loading:i,error:o,refetch:()=>a()}}function Th(){const{client:t}=$e();return{createEndpoint:s.useCallback(async n=>{const o=new URLSearchParams;o.append("url",n.url),n.description&&o.append("description",n.description),n.subscribed_events.forEach(u=>{o.append("subscribed_events",u)});const i=await t("/webhook/endpoints",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()});return(await N(i)).data},[t]),loading:!1,error:null}}function Oh(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/events",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-events",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{events:n||[],loading:i,error:o,refetch:()=>a()}}function Ah(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.status&&c.set("status",t.status),t.event_name&&c.set("event_name",t.event_name),t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor);const d=await r(`/webhook/deliveries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.endpoint_id,t.status,t.event_name,t.limit,t.cursor]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.status&&c.set("status",t.status),t.event_name&&c.set("event_name",t.event_name),t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),`wacht-webhook-deliveries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{deliveries:(o==null?void 0:o.data)||[],has_more:(o==null?void 0:o.has_more)||!1,next_cursor:o==null?void 0:o.next_cursor,loading:a,error:i,refetch:()=>u()}}function Lh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.fields&&t.fields.length>0&&c.set("fields",t.fields.join(","));const d=await r(`/webhook/analytics?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.endpoint_id,t.fields]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.fields&&t.fields.length>0&&c.set("fields",t.fields.join(",")),`wacht-webhook-analytics?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:o||null,loading:a,error:i,refetch:()=>u()}}function Mh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id);const d=await r(`/webhook/analytics/timeseries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.interval,t.endpoint_id]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),`wacht-webhook-timeseries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(o==null?void 0:o.data)||[],interval:(o==null?void 0:o.interval)||"hour",loading:a,error:i,refetch:()=>u()}}function Dh(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),l=n,f=s.useCallback(async()=>{const P=await r("/api-auth/session",{method:"GET"});if(!P.ok)throw P.status===401||P.status===403?new Error("NO_SESSION"):new Error("Failed to fetch API auth app session");return(await N(P)).data},[r]),{data:m,error:x,isLoading:v,mutate:$}=Re(l?"wacht-api-auth-app-session":null,f,{revalidateOnFocus:!1,shouldRetryOnError:!1});s.useEffect(()=>{if(!t||d.current||p.current)return;(async()=>{p.current=!0,a(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(d.current=!0,o(!0)):c(new Error("Failed to exchange ticket"))}catch(y){c(y instanceof Error?y:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]);const S=!x||x.message!=="NO_SESSION",_=u||(x&&x.message!=="NO_SESSION"?x:null);return{hasSession:S,sessionLoading:i||l&&v,sessionError:_,sessionId:(m==null?void 0:m.session_id)||null,apiAuthApp:(m==null?void 0:m.api_auth_app)||null,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await $()}}}function Fh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const l=new URLSearchParams;t.status&&l.set("status",t.status);const f=await r(`/api-auth/keys${l.toString()?`?${l.toString()}`:""}`,{method:"GET"});return(await N(f)).data},[r,t.status]),{data:o,error:i,isLoading:a,mutate:u}=Re(`wacht-api-auth-keys:${t.status||"all"}`,n,{revalidateOnFocus:!1,shouldRetryOnError:!1}),c=s.useCallback(async l=>{const f=new URLSearchParams;f.set("name",l.name),l.expires_at&&f.set("expires_at",l.expires_at);const m=await r("/api-auth/keys",{method:"POST",body:f}),x=await N(m);return await u(),x.data},[r,u]),d=s.useCallback(async l=>{const f=await r(`/api-auth/keys/${l.key_id}/rotate`,{method:"POST"}),m=await N(f);return await u(),m.data},[r,u]),p=s.useCallback(async l=>{const f=new URLSearchParams;l.reason&&f.set("reason",l.reason),await r(`/api-auth/keys/${l.key_id}/revoke`,{method:"POST",body:f}),await u()},[r,u]);return{keys:o||[],createKey:c,rotateKey:d,revokeKey:p,loading:a,error:i,refetch:()=>u()}}function Nh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),t.outcome&&c.set("outcome",t.outcome),t.key_id&&c.set("key_id",t.key_id),t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date);const d=await r(`/api-auth/audit/logs?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.limit,t.cursor,t.outcome,t.key_id,t.start_date,t.end_date]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),t.outcome&&c.set("outcome",t.outcome),t.key_id&&c.set("key_id",t.key_id),t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),`wacht-api-auth-audit-logs?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{logs:(o==null?void 0:o.data)||[],limit:(o==null?void 0:o.limit)||t.limit||0,has_more:(o==null?void 0:o.has_more)||!1,next_cursor:o==null?void 0:o.next_cursor,loading:a,error:i,refetch:()=>u()}}function Uh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.key_id&&c.set("key_id",t.key_id),t.include_top_keys&&c.set("include_top_keys","true"),t.include_top_paths&&c.set("include_top_paths","true"),t.include_blocked_reasons&&c.set("include_blocked_reasons","true"),t.include_rate_limits&&c.set("include_rate_limits","true"),t.top_limit&&c.set("top_limit",t.top_limit.toString());const d=await r(`/api-auth/audit/analytics?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.key_id,t.include_top_keys,t.include_top_paths,t.include_blocked_reasons,t.include_rate_limits,t.top_limit]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.key_id&&c.set("key_id",t.key_id),t.include_top_keys&&c.set("include_top_keys","true"),t.include_top_paths&&c.set("include_top_paths","true"),t.include_blocked_reasons&&c.set("include_blocked_reasons","true"),t.include_rate_limits&&c.set("include_rate_limits","true"),t.top_limit&&c.set("top_limit",t.top_limit.toString()),`wacht-api-auth-audit-analytics?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:o||null,loading:a,error:i,refetch:()=>u()}}function Bh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.key_id&&c.set("key_id",t.key_id);const d=await r(`/api-auth/audit/timeseries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.interval,t.key_id]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.key_id&&c.set("key_id",t.key_id),`wacht-api-auth-audit-timeseries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(o==null?void 0:o.data)||[],interval:(o==null?void 0:o.interval)||t.interval||"hour",loading:a,error:i,refetch:()=>u()}}const nd=()=>{const{client:t}=$e(),[r,n]=s.useState(!1),[o,i]=s.useState(null),[a,u]=s.useState(null),c=s.useCallback(async p=>{n(!0),i(null),u(null);try{const l=new FormData;l.append("token",p);const f=await t("/organizations/invitations/accept",{method:"POST",body:l}),x=(await N(f)).data;return u(x),x.error_code&&i(x.message||"Failed to accept invitation"),x}catch(l){const f=l.message||"Failed to accept invitation";i(f);const m={error_code:"NETWORK_ERROR",message:f};return u(m),m}finally{n(!1)}},[t]),d=s.useCallback(()=>{i(null),u(null)},[]);return{acceptInvitation:c,invitationData:a,loading:r,error:o,reset:d}},Wh=({children:t})=>{const{loading:r}=be();return r?null:e.jsx(e.Fragment,{children:t})},Vh=({children:t})=>{const{loading:r}=be();return r?e.jsx(e.Fragment,{children:t}):null};var dt=function(){return dt=Object.assign||function(r){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},dt.apply(this,arguments)};function $r(t,r,n){if(n||arguments.length===2)for(var o=0,i=r.length,a;o<i;o++)(a||!(o in r))&&(a||(a=Array.prototype.slice.call(r,0,o)),a[o]=r[o]);return t.concat(a||Array.prototype.slice.call(r))}function Gh(t){var r=Object.create(null);return function(n){return r[n]===void 0&&(r[n]=t(n)),r[n]}}var Hh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,qh=Gh(function(t){return Hh.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Be="-ms-",mn="-moz-",Ae="-webkit-",od="comm",Eo="rule",la="decl",Yh="@import",Kh="@namespace",id="@keyframes",Qh="@layer",ad=Math.abs,da=String.fromCharCode,Vi=Object.assign;function Zh(t,r){return Ze(t,0)^45?(((r<<2^Ze(t,0))<<2^Ze(t,1))<<2^Ze(t,2))<<2^Ze(t,3):0}function sd(t){return t.trim()}function Wt(t,r){return(t=r.exec(t))?t[0]:t}function ke(t,r,n){return t.replace(r,n)}function so(t,r,n){return t.indexOf(r,n)}function Ze(t,r){return t.charCodeAt(r)|0}function Er(t,r,n){return t.slice(r,n)}function xt(t){return t.length}function cd(t){return t.length}function hn(t,r){return r.push(t),t}function Jh(t,r){return t.map(r).join("")}function rs(t,r){return t.filter(function(n){return!Wt(n,r)})}var zo=1,qr=1,ld=0,ft=0,Ye=0,Xr="";function Po(t,r,n,o,i,a,u,c){return{value:t,root:r,parent:n,type:o,props:i,children:a,line:zo,column:qr,length:u,return:"",siblings:c}}function Jt(t,r){return Vi(Po("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function Or(t){for(;t.root;)t=Jt(t.root,{children:[t]});hn(t,t.siblings)}function Xh(){return Ye}function ef(){return Ye=ft>0?Ze(Xr,--ft):0,qr--,Ye===10&&(qr=1,zo--),Ye}function bt(){return Ye=ft<ld?Ze(Xr,ft++):0,qr++,Ye===10&&(qr=1,zo++),Ye}function tr(){return Ze(Xr,ft)}function co(){return ft}function Ro(t,r){return Er(Xr,t,r)}function bn(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function tf(t){return zo=qr=1,ld=xt(Xr=t),ft=0,[]}function rf(t){return Xr="",t}function Xo(t){return sd(Ro(ft-1,Gi(t===91?t+2:t===40?t+1:t)))}function nf(t){for(;(Ye=tr())&&Ye<33;)bt();return bn(t)>2||bn(Ye)>3?"":" "}function of(t,r){for(;--r&&bt()&&!(Ye<48||Ye>102||Ye>57&&Ye<65||Ye>70&&Ye<97););return Ro(t,co()+(r<6&&tr()==32&&bt()==32))}function Gi(t){for(;bt();)switch(Ye){case t:return ft;case 34:case 39:t!==34&&t!==39&&Gi(Ye);break;case 40:t===41&&Gi(t);break;case 92:bt();break}return ft}function af(t,r){for(;bt()&&t+Ye!==57;)if(t+Ye===84&&tr()===47)break;return"/*"+Ro(r,ft-1)+"*"+da(t===47?t:bt())}function sf(t){for(;!bn(tr());)bt();return Ro(t,ft)}function cf(t){return rf(lo("",null,null,null,[""],t=tf(t),0,[0],t))}function lo(t,r,n,o,i,a,u,c,d){for(var p=0,l=0,f=u,m=0,x=0,v=0,$=1,S=1,_=1,k=0,P="",y=i,b=a,C=o,g=P;S;)switch(v=k,k=bt()){case 40:if(v!=108&&Ze(g,f-1)==58){so(g+=ke(Xo(k),"&","&\f"),"&\f",ad(p?c[p-1]:0))!=-1&&(_=-1);break}case 34:case 39:case 91:g+=Xo(k);break;case 9:case 10:case 13:case 32:g+=nf(v);break;case 92:g+=of(co()-1,7);continue;case 47:switch(tr()){case 42:case 47:hn(lf(af(bt(),co()),r,n,d),d),(bn(v||1)==5||bn(tr()||1)==5)&&xt(g)&&Er(g,-1,void 0)!==" "&&(g+=" ");break;default:g+="/"}break;case 123*$:c[p++]=xt(g)*_;case 125*$:case 59:case 0:switch(k){case 0:case 125:S=0;case 59+l:_==-1&&(g=ke(g,/\f/g,"")),x>0&&(xt(g)-f||$===0&&v===47)&&hn(x>32?os(g+";",o,n,f-1,d):os(ke(g," ","")+";",o,n,f-2,d),d);break;case 59:g+=";";default:if(hn(C=ns(g,r,n,p,l,i,c,P,y=[],b=[],f,a),a),k===123)if(l===0)lo(g,r,C,C,y,a,f,c,b);else{switch(m){case 99:if(Ze(g,3)===110)break;case 108:if(Ze(g,2)===97)break;default:l=0;case 100:case 109:case 115:}l?lo(t,C,C,o&&hn(ns(t,C,C,0,0,i,c,P,i,y=[],f,b),b),i,b,f,c,o?y:b):lo(g,C,C,C,[""],b,0,c,b)}}p=l=x=0,$=_=1,P=g="",f=u;break;case 58:f=1+xt(g),x=v;default:if($<1){if(k==123)--$;else if(k==125&&$++==0&&ef()==125)continue}switch(g+=da(k),k*$){case 38:_=l>0?1:(g+="\f",-1);break;case 44:c[p++]=(xt(g)-1)*_,_=1;break;case 64:tr()===45&&(g+=Xo(bt())),m=tr(),l=f=xt(P=g+=sf(co())),k++;break;case 45:v===45&&xt(g)==2&&($=0)}}return a}function ns(t,r,n,o,i,a,u,c,d,p,l,f){for(var m=i-1,x=i===0?a:[""],v=cd(x),$=0,S=0,_=0;$<o;++$)for(var k=0,P=Er(t,m+1,m=ad(S=u[$])),y=t;k<v;++k)(y=sd(S>0?x[k]+" "+P:ke(P,/&\f/g,x[k])))&&(d[_++]=y);return Po(t,r,n,i===0?Eo:c,d,p,l,f)}function lf(t,r,n,o){return Po(t,r,n,od,da(Xh()),Er(t,2,-2),0,o)}function os(t,r,n,o,i){return Po(t,r,n,la,Er(t,0,o),Er(t,o+1,-1),o,i)}function dd(t,r,n){switch(Zh(t,r)){case 5103:return Ae+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Ae+t+t;case 4855:return Ae+t.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+t;case 4789:return mn+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Ae+t+mn+t+Be+t+t;case 5936:switch(Ze(t,r+11)){case 114:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Ae+t+Be+t+t;case 6165:return Ae+t+Be+"flex-"+t+t;case 5187:return Ae+t+ke(t,/(\w+).+(:[^]+)/,Ae+"box-$1$2"+Be+"flex-$1$2")+t;case 5443:return Ae+t+Be+"flex-item-"+ke(t,/flex-|-self/g,"")+(Wt(t,/flex-|baseline/)?"":Be+"grid-row-"+ke(t,/flex-|-self/g,""))+t;case 4675:return Ae+t+Be+"flex-line-pack"+ke(t,/align-content|flex-|-self/g,"")+t;case 5548:return Ae+t+Be+ke(t,"shrink","negative")+t;case 5292:return Ae+t+Be+ke(t,"basis","preferred-size")+t;case 6060:return Ae+"box-"+ke(t,"-grow","")+Ae+t+Be+ke(t,"grow","positive")+t;case 4554:return Ae+ke(t,/([^-])(transform)/g,"$1"+Ae+"$2")+t;case 6187:return ke(ke(ke(t,/(zoom-|grab)/,Ae+"$1"),/(image-set)/,Ae+"$1"),t,"")+t;case 5495:case 3959:return ke(t,/(image-set\([^]*)/,Ae+"$1$`$1");case 4968:return ke(ke(t,/(.+:)(flex-)?(.*)/,Ae+"box-pack:$3"+Be+"flex-pack:$3"),/space-between/,"justify")+Ae+t+t;case 4200:if(!Wt(t,/flex-|baseline/))return Be+"grid-column-align"+Er(t,r)+t;break;case 2592:case 3360:return Be+ke(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(o,i){return r=i,Wt(o.props,/grid-\w+-end/)})?~so(t+(n=n[r].value),"span",0)?t:Be+ke(t,"-start","")+t+Be+"grid-row-span:"+(~so(n,"span",0)?Wt(n,/\d+/):+Wt(n,/\d+/)-+Wt(t,/\d+/))+";":Be+ke(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(o){return Wt(o.props,/grid-\w+-start/)})?t:Be+ke(ke(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ke(t,/(.+)-inline(.+)/,Ae+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(xt(t)-1-r>6)switch(Ze(t,r+1)){case 109:if(Ze(t,r+4)!==45)break;case 102:return ke(t,/(.+:)(.+)-([^]+)/,"$1"+Ae+"$2-$3$1"+mn+(Ze(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~so(t,"stretch",0)?dd(ke(t,"stretch","fill-available"),r,n)+t:t}break;case 5152:case 5920:return ke(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(o,i,a,u,c,d,p){return Be+i+":"+a+p+(u?Be+i+"-span:"+(c?d:+d-+a)+p:"")+t});case 4949:if(Ze(t,r+6)===121)return ke(t,":",":"+Ae)+t;break;case 6444:switch(Ze(t,Ze(t,14)===45?18:11)){case 120:return ke(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ae+(Ze(t,14)===45?"inline-":"")+"box$3$1"+Ae+"$2$3$1"+Be+"$2box$3")+t;case 100:return ke(t,":",":"+Be)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ke(t,"scroll-","scroll-snap-")+t}return t}function xo(t,r){for(var n="",o=0;o<t.length;o++)n+=r(t[o],o,t,r)||"";return n}function df(t,r,n,o){switch(t.type){case Qh:if(t.children.length)break;case Yh:case Kh:case la:return t.return=t.return||t.value;case od:return"";case id:return t.return=t.value+"{"+xo(t.children,o)+"}";case Eo:if(!xt(t.value=t.props.join(",")))return""}return xt(n=xo(t.children,o))?t.return=t.value+"{"+n+"}":""}function uf(t){var r=cd(t);return function(n,o,i,a){for(var u="",c=0;c<r;c++)u+=t[c](n,o,i,a)||"";return u}}function pf(t){return function(r){r.root||(r=r.return)&&t(r)}}function hf(t,r,n,o){if(t.length>-1&&!t.return)switch(t.type){case la:t.return=dd(t.value,t.length,n);return;case id:return xo([Jt(t,{value:ke(t.value,"@","@"+Ae)})],o);case Eo:if(t.length)return Jh(n=t.props,function(i){switch(Wt(i,o=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Or(Jt(t,{props:[ke(i,/:(read-\w+)/,":"+mn+"$1")]})),Or(Jt(t,{props:[i]})),Vi(t,{props:rs(n,o)});break;case"::placeholder":Or(Jt(t,{props:[ke(i,/:(plac\w+)/,":"+Ae+"input-$1")]})),Or(Jt(t,{props:[ke(i,/:(plac\w+)/,":"+mn+"$1")]})),Or(Jt(t,{props:[ke(i,/:(plac\w+)/,Be+"input-$1")]})),Or(Jt(t,{props:[i]})),Vi(t,{props:rs(n,o)});break}return""})}}var ff={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},zr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",ud="active",pd="data-styled-version",Io="6.3.11",ua=`/*!sc*/
|
|
18
|
+
*/var qa;function tp(){return qa||(qa=1,process.env.NODE_ENV!=="production"&&(function(){function t(m,v){return m===v&&(m!==0||1/m===1/v)||m!==m&&v!==v}function r(m,v){l||i.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var C=v();if(!f){var $=v();a(C,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}$=u({inst:{value:C,getSnapshot:v}});var _=$[0].inst,k=$[1];return d(function(){_.value=C,_.getSnapshot=v,n(_)&&k({inst:_})},[m,C,v]),c(function(){return n(_)&&k({inst:_}),m(function(){n(_)&&k({inst:_})})},[m]),p(C),C}function n(m){var v=m.getSnapshot;m=m.value;try{var C=v();return!a(m,C)}catch{return!0}}function o(m,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=s,a=typeof Object.is=="function"?Object.is:t,u=i.useState,c=i.useEffect,d=i.useLayoutEffect,p=i.useDebugValue,l=!1,f=!1,x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:r;Wo.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:x,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Wo}var Ya;function rp(){return Ya||(Ya=1,process.env.NODE_ENV==="production"?Cn.exports=ep():Cn.exports=tp()),Cn.exports}var Ii=rp();const Fl=0,Nl=1,Ul=2,Ka=3;var Qa=Object.prototype.hasOwnProperty;function Ti(t,r){var n,o;if(t===r)return!0;if(t&&r&&(n=t.constructor)===r.constructor){if(n===Date)return t.getTime()===r.getTime();if(n===RegExp)return t.toString()===r.toString();if(n===Array){if((o=t.length)===r.length)for(;o--&&Ti(t[o],r[o]););return o===-1}if(!n||typeof t=="object"){o=0;for(n in t)if(Qa.call(t,n)&&++o&&!Qa.call(r,n)||!(n in r)||!Ti(t[n],r[n]))return!1;return Object.keys(r).length===o}}return t!==t&&r!==r}const Pt=new WeakMap,Gt=()=>{},Je=Gt(),Oi=Object,ye=t=>t===Je,vt=t=>typeof t=="function",nr=(t,r)=>({...t,...r}),Bl=t=>vt(t.then),Vo={},Sn={},sa="undefined",jn=typeof window!=sa,Ai=typeof document!=sa,np=jn&&"Deno"in window,op=()=>jn&&typeof window.requestAnimationFrame!=sa,Xt=(t,r)=>{const n=Pt.get(t);return[()=>!ye(r)&&t.get(r)||Vo,o=>{if(!ye(r)){const i=t.get(r);r in Sn||(Sn[r]=i),n[5](r,nr(i,o),i||Vo)}},n[6],()=>!ye(r)&&r in Sn?Sn[r]:!ye(r)&&t.get(r)||Vo]};let Li=!0;const ip=()=>Li,[Mi,Di]=jn&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Gt,Gt],ap=()=>{const t=Ai&&document.visibilityState;return ye(t)||t!=="hidden"},sp=t=>(Ai&&document.addEventListener("visibilitychange",t),Mi("focus",t),()=>{Ai&&document.removeEventListener("visibilitychange",t),Di("focus",t)}),cp=t=>{const r=()=>{Li=!0,t()},n=()=>{Li=!1};return Mi("online",r),Mi("offline",n),()=>{Di("online",r),Di("offline",n)}},lp={isOnline:ip,isVisible:ap},dp={initFocus:sp,initReconnect:cp},Za=!s.useId,Hr=!jn||np,up=t=>op()?window.requestAnimationFrame(t):setTimeout(t,1),ao=Hr?s.useEffect:s.useLayoutEffect,Go=typeof navigator<"u"&&navigator.connection,Ja=!Hr&&Go&&(["slow-2g","2g"].includes(Go.effectiveType)||Go.saveData),$n=new WeakMap,pp=t=>Oi.prototype.toString.call(t),Ho=(t,r)=>t===`[object ${r}]`;let hp=0;const Fi=t=>{const r=typeof t,n=pp(t),o=Ho(n,"Date"),i=Ho(n,"RegExp"),a=Ho(n,"Object");let u,c;if(Oi(t)===t&&!o&&!i){if(u=$n.get(t),u)return u;if(u=++hp+"~",$n.set(t,u),Array.isArray(t)){for(u="@",c=0;c<t.length;c++)u+=Fi(t[c])+",";$n.set(t,u)}if(a){u="#";const d=Oi.keys(t).sort();for(;!ye(c=d.pop());)ye(t[c])||(u+=c+":"+Fi(t[c])+",");$n.set(t,u)}}else u=o?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},yn=t=>{if(vt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Fi(t):"",[t,r]};let fp=0;const Ni=()=>++fp;async function Wl(...t){const[r,n,o,i]=t,a=nr({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let u=a.populateCache;const c=a.rollbackOnError;let d=a.optimisticData;const p=x=>typeof c=="function"?c(x):c!==!1,l=a.throwOnError;if(vt(n)){const x=n,m=[],v=r.keys();for(const C of v)!/^\$(inf|sub)\$/.test(C)&&x(r.get(C)._k)&&m.push(C);return Promise.all(m.map(f))}return f(n);async function f(x){const[m]=yn(x);if(!m)return;const[v,C]=Xt(r,m),[$,_,k,R]=Pt.get(r),y=()=>{const T=$[m];return(vt(a.revalidate)?a.revalidate(v().data,x):a.revalidate!==!1)&&(delete k[m],delete R[m],T&&T[0])?T[0](Ul).then(()=>v().data):v().data};if(t.length<3)return y();let b=o,S,g=!1;const j=Ni();_[m]=[j,0];const w=!ye(d),E=v(),I=E.data,O=E._c,z=ye(O)?I:O;if(w&&(d=vt(d)?d(z,I):d,C({data:d,_c:z})),vt(b))try{b=b(z)}catch(T){S=T,g=!0}if(b&&Bl(b))if(b=await b.catch(T=>{S=T,g=!0}),j!==_[m][0]){if(g)throw S;return b}else g&&w&&p(S)&&(u=!0,C({data:z,_c:Je}));if(u&&!g)if(vt(u)){const T=u(b,z);C({data:T,error:Je,_c:Je})}else C({data:b,error:Je,_c:Je});if(_[m][1]=Ni(),Promise.resolve(y()).then(()=>{C({_c:Je})}),g){if(l)throw S;return}return b}}const Xa=(t,r)=>{for(const n in t)t[n][0]&&t[n][0](r)},gp=(t,r)=>{if(!Pt.has(t)){const n=nr(dp,r),o=Object.create(null),i=Wl.bind(Je,t);let a=Gt;const u=Object.create(null),c=(l,f)=>{const x=u[l]||[];return u[l]=x,x.push(f),()=>x.splice(x.indexOf(f),1)},d=(l,f,x)=>{t.set(l,f);const m=u[l];if(m)for(const v of m)v(f,x)},p=()=>{if(!Pt.has(t)&&(Pt.set(t,[o,Object.create(null),Object.create(null),Object.create(null),i,d,c]),!Hr)){const l=n.initFocus(setTimeout.bind(Je,Xa.bind(Je,o,Fl))),f=n.initReconnect(setTimeout.bind(Je,Xa.bind(Je,o,Nl)));a=()=>{l&&l(),f&&f(),Pt.delete(t)}}};return p(),[t,i,p,a]}return[t,Pt.get(t)[4]]},mp=(t,r,n,o,i)=>{const a=n.errorRetryCount,u=i.retryCount,c=~~((Math.random()+.5)*(1<<(u<8?u:8)))*n.errorRetryInterval;!ye(a)&&u>a||setTimeout(o,c,i)},xp=Ti,[ca,un]=gp(new Map),vp=nr({onLoadingSlow:Gt,onSuccess:Gt,onError:Gt,onErrorRetry:mp,onDiscarded:Gt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ja?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ja?5e3:3e3,compare:xp,isPaused:()=>!1,cache:ca,mutate:un,fallback:{}},lp),yp=(t,r)=>{const n=nr(t,r);if(r){const{use:o,fallback:i}=t,{use:a,fallback:u}=r;o&&a&&(n.use=o.concat(a)),i&&u&&(n.fallback=nr(i,u))}return n},bp=s.createContext({}),Vl="$inf$",Gl=jn&&window.__SWR_DEVTOOLS_USE__,wp=Gl?window.__SWR_DEVTOOLS_USE__:[],jp=()=>{Gl&&(window.__SWR_DEVTOOLS_REACT__=s)},Hl=t=>vt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],ql=()=>{const t=s.useContext(bp);return s.useMemo(()=>nr(vp,t),[t])},_p=t=>(r,n,o)=>t(r,n&&((...a)=>{const[u]=yn(r),[,,,c]=Pt.get(ca);if(u.startsWith(Vl))return n(...a);const d=c[u];return ye(d)?n(...a):(delete c[u],d)}),o),kp=wp.concat(_p),Cp=t=>function(...n){const o=ql(),[i,a,u]=Hl(n),c=yp(o,u);let d=t;const{use:p}=c,l=(p||[]).concat(kp);for(let f=l.length;f--;)d=l[f](d);return d(i,a||c.fetcher||null,c)},Sp=(t,r,n)=>{const o=r[t]||(r[t]=[]);return o.push(n),()=>{const i=o.indexOf(n);i>=0&&(o[i]=o[o.length-1],o.pop())}},$p=(t,r)=>(...n)=>{const[o,i,a]=Hl(n),u=(a.use||[]).concat(r);return t(o,i,{...a,use:u})};jp();const qo=s.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),Yo={dedupe:!0},es=Promise.resolve(Je),Ep=()=>Gt,zp=(t,r,n)=>{const{cache:o,compare:i,suspense:a,fallbackData:u,revalidateOnMount:c,revalidateIfStale:d,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:f,keepPreviousData:x,strictServerPrefetchWarning:m}=n,[v,C,$,_]=Pt.get(o),[k,R]=yn(t),y=s.useRef(!1),b=s.useRef(!1),S=s.useRef(k),g=s.useRef(r),j=s.useRef(n),w=()=>j.current,E=()=>w().isVisible()&&w().isOnline(),[I,O,z,T]=Xt(o,k),M=s.useRef({}).current,D=ye(u)?ye(n.fallback)?Je:n.fallback[k]:u,F=(q,te)=>{for(const de in M){const ie=de;if(ie==="data"){if(!i(q[ie],te[ie])&&(!ye(q[ie])||!i(ge,te[ie])))return!1}else if(te[ie]!==q[ie])return!1}return!0},L=!y.current,A=s.useMemo(()=>{const q=I(),te=T(),de=W=>{const xe=nr(W);return delete xe._k,(()=>{if(!k||!r||w().isPaused())return!1;if(L&&!ye(c))return c;const it=ye(D)?xe.data:D;return ye(it)||d})()?{isValidating:!0,isLoading:!0,...xe}:xe},ie=de(q),Y=q===te?ie:de(te);let ve=ie;return[()=>{const W=de(I());return F(W,ve)?(ve.data=W.data,ve.isLoading=W.isLoading,ve.isValidating=W.isValidating,ve.error=W.error,ve):(ve=W,W)},()=>Y]},[o,k]),P=Ii.useSyncExternalStore(s.useCallback(q=>z(k,(te,de)=>{F(de,te)||q()}),[o,k]),A[0],A[1]),U=v[k]&&v[k].length>0,V=P.data,H=ye(V)?D&&Bl(D)?qo(D):D:V,ae=P.error,ee=s.useRef(H),ge=x?ye(V)?ye(ee.current)?H:ee.current:V:H,pe=k&&ye(H),Q=s.useRef(null);!Hr&&Ii.useSyncExternalStore(Ep,()=>(Q.current=!1,Q),()=>(Q.current=!0,Q));const he=Q.current;m&&he&&!a&&pe&&console.warn(`Missing pre-initiated data for serialized key "${k}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const X=!k||!r||w().isPaused()||U&&!ye(ae)?!1:L&&!ye(c)?c:a?ye(H)?!1:d:ye(H)||d,Oe=L&&X,se=ye(P.isValidating)?Oe:P.isValidating,ce=ye(P.isLoading)?Oe:P.isLoading,_e=s.useCallback(async q=>{const te=g.current;if(!k||!te||b.current||w().isPaused())return!1;let de,ie,Y=!0;const ve=q||{},W=!$[k]||!ve.dedupe,xe=()=>Za?!b.current&&k===S.current&&y.current:k===S.current,qe={isValidating:!1,isLoading:!1},it=()=>{O(qe)},G=()=>{const Me=$[k];Me&&Me[1]===ie&&delete $[k]},fe={isValidating:!0};ye(I().data)&&(fe.isLoading=!0);try{if(W&&(O(fe),n.loadingTimeout&&ye(I().data)&&setTimeout(()=>{Y&&xe()&&w().onLoadingSlow(k,n)},n.loadingTimeout),$[k]=[te(R),Ni()]),[de,ie]=$[k],de=await de,W&&setTimeout(G,n.dedupingInterval),!$[k]||$[k][1]!==ie)return W&&xe()&&w().onDiscarded(k),!1;qe.error=Je;const Me=C[k];if(!ye(Me)&&(ie<=Me[0]||ie<=Me[1]||Me[1]===0))return it(),W&&xe()&&w().onDiscarded(k),!1;const Ve=I().data;qe.data=i(Ve,de)?Ve:de,W&&xe()&&w().onSuccess(de,k,n)}catch(Me){G();const Ve=w(),{shouldRetryOnError:nt}=Ve;Ve.isPaused()||(qe.error=Me,W&&xe()&&(Ve.onError(Me,k,Ve),(nt===!0||vt(nt)&&nt(Me))&&(!w().revalidateOnFocus||!w().revalidateOnReconnect||E())&&Ve.onErrorRetry(Me,k,Ve,ct=>{const Xe=v[k];Xe&&Xe[0]&&Xe[0](Ka,ct)},{retryCount:(ve.retryCount||0)+1,dedupe:!0})))}return Y=!1,it(),!0},[k,o]),me=s.useCallback((...q)=>Wl(o,S.current,...q),[]);if(ao(()=>{g.current=r,j.current=n,ye(V)||(ee.current=V)}),ao(()=>{if(!k)return;const q=_e.bind(Je,Yo);let te=0;w().revalidateOnFocus&&(te=Date.now()+w().focusThrottleInterval);const ie=Sp(k,v,(Y,ve={})=>{if(Y==Fl){const W=Date.now();w().revalidateOnFocus&&W>te&&E()&&(te=W+w().focusThrottleInterval,q())}else if(Y==Nl)w().revalidateOnReconnect&&E()&&q();else{if(Y==Ul)return _e();if(Y==Ka)return _e(ve)}});return b.current=!1,S.current=k,y.current=!0,O({_k:R}),X&&($[k]||(ye(H)||Hr?q():up(q))),()=>{b.current=!0,ie()}},[k]),ao(()=>{let q;function te(){const ie=vt(p)?p(I().data):p;ie&&q!==-1&&(q=setTimeout(de,ie))}function de(){!I().error&&(l||w().isVisible())&&(f||w().isOnline())?_e(Yo).then(te):te()}return te(),()=>{q&&(clearTimeout(q),q=-1)}},[p,l,f,k]),s.useDebugValue(ge),a){if(!Za&&Hr&&pe)throw new Error("Fallback data is required when using Suspense in SSR.");pe&&(g.current=r,j.current=n,b.current=!1);const q=_[k],te=!ye(q)&&pe?me(q):es;if(qo(te),!ye(ae)&&pe)throw ae;const de=pe?_e(Yo):es;!ye(ge)&&pe&&(de.status="fulfilled",de.value=!0),qo(de)}return{mutate:me,get data(){return M.data=!0,ge},get error(){return M.error=!0,ae},get isValidating(){return M.isValidating=!0,se},get isLoading(){return M.isLoading=!0,ce}}},Re=Cp(zp),lt=()=>{const{adapter:t,deployment:r}=be(),n=t.useNavigate(),o=(d,p)=>{n?n(d,p):window.location.href=d},i=d=>{if(d)return d;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:o,navigateToSignIn:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:d=>{if(!r)return;const p=i(d),l=new URLSearchParams;l.set("redirect_uri",p),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",tt()??""),o(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function Pp(t){const r=await t("/session",{method:"GET"});return(await N(r)).data}async function Rp(t,r){const n=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return N(n)}async function Ip(t,r){const n=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",o=await t(n,{method:"POST"});return N(o)}async function Tp(t,r){const n=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return N(n)}async function Op(t,r){const n=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return N(n)}async function Ap(t,r){const n=await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return N(n)}const Ui=new Map,pn=new Map;function Rt(){Ui.clear(),pn.clear()}async function Lp(t,r){const n=await t(`/session/token${r?`?template=${r}`:""}`);return N(n)}function He(){const{client:t,loading:r}=$e(),{deployment:n}=be(),{navigate:o}=lt(),{cache:i}=ql(),{data:a,error:u,mutate:c,isLoading:d}=Re(r?null:"/session",()=>Pp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=s.useCallback(async()=>{await c(void 0,{revalidate:!0})},[c]),l=s.useCallback(async(f="default")=>{if(!a)throw new Error("no session");const x=Ui.get(f);if(x&&x.expires>Date.now())return(x==null?void 0:x.token)||"";pn.get(f)||pn.set(f,Lp(t,f));const m=await pn.get(f);return pn.delete(f),Ui.set(f,m.data),m.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||d?{loading:!0,error:u,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:p}:{loading:d,error:u,session:a,switchSignIn:async f=>{await Rp(t,f),Rt(),await un("/me/organization-memberships",void 0,{revalidate:!1}),await un("/me/workspace-memberships",void 0,{revalidate:!1}),await c(void 0,{revalidate:!0}),await un("/me/organization-memberships"),await un("/me/workspace-memberships")},signOut:async f=>{await Ip(t,f);const x=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],m=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const v=Array.from(i.keys());for(const C of v){let $=!1;(x.includes(C)||typeof C=="string"&&m.some(_=>C.startsWith(_)))&&($=!0),$&&i.delete(C)}}Rt(),await c(void 0,{revalidate:!0}),n!=null&&n.ui_settings&&(f&&n.ui_settings.after_sign_out_one_page_url?o(n.ui_settings.after_sign_out_one_page_url):!f&&n.ui_settings.after_sign_out_all_page_url&&o(n.ui_settings.after_sign_out_all_page_url))},switchOrganization:async f=>{await Tp(t,f),Rt(),await c(void 0,{revalidate:!0})},switchWorkspace:async f=>{await Op(t,f),Rt(),await c(void 0,{revalidate:!0})},exchangeTicket:async f=>{await Ap(t,f),Rt(),await c(void 0,{revalidate:!0})},getToken:l,refetch:p}}const Tt=()=>{const{organizationMemberships:t,refetch:r,loading:n}=Kt(),{client:o}=$e(),{refetch:i}=He(),a=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[o]),u=s.useCallback(async(L,A)=>{const P=new URLSearchParams;return A&&(P.set("page",A.page.toString()),P.set("limit",A.limit.toString()),A.search&&P.set("search",A.search)),(await N(await o(`/organizations/${L.id}/members?${P.toString()}`,{method:"GET"}))).data},[o]),c=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[o]),d=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[o]),p=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/members/${A.id}/remove`,{method:"POST"})},[o]),l=s.useCallback(async L=>{const A=new FormData;A.append("name",L.name),L.image&&A.append("image",L.image),L.description&&A.append("description",L.description);const P=await N(await o("/organizations",{method:"POST",body:A}));return Rt(),await r(),await i(),P},[i,r,o]),f=s.useCallback(async(L,A)=>{const P=Object.entries(A).reduce((V,[H,ae])=>(ae!=null&&(Array.isArray(ae)?ae.forEach(ee=>V.append(H,ee)):V.append(H,ae)),V),new FormData),U=await N(await o(`/organizations/${L.id}/update`,{method:"POST",body:P}));return await r(),U},[r,o]),x=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/roles/${A.id}/remove`,{method:"POST"})},[o]),m=s.useCallback(async(L,A)=>{const P=new FormData;return P.append("domain",A.fqdn),await N(await o(`/organizations/${L.id}/domains`,{method:"POST",body:P}))},[o]),v=s.useCallback(async(L,A)=>await N(await o(`/organizations/${L.id}/domains/${A.id}/verify`,{method:"POST"})),[o]),C=s.useCallback(async(L,A)=>await N(await o(`/organizations/${L.id}/domains/${A.id}/delete`,{method:"POST"})),[o]),$=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[o]),_=s.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.domain_id&&P.append("domain_id",A.domain_id),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&P.append("oidc_scopes",A.oidc_scopes),A.jit_enabled!==void 0&&P.append("jit_enabled",String(A.jit_enabled)),A.attribute_mapping&&P.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await N(await o(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:P}))).data},[o]),k=s.useCallback(async(L,A,P)=>{const U=new FormData;return P.domain_id&&U.append("domain_id",P.domain_id),P.idp_entity_id&&U.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&U.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&U.append("idp_certificate",P.idp_certificate),P.oidc_client_id&&U.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&U.append("oidc_client_secret",P.oidc_client_secret),P.oidc_issuer_url&&U.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_scopes&&U.append("oidc_scopes",P.oidc_scopes),P.attribute_mapping&&U.append("attribute_mapping",JSON.stringify(P.attribute_mapping)),(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/update`,{method:"POST",body:U}))).data},[o]),R=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/enterprise-connections/${A}/delete`,{method:"POST"})},[o]),y=s.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),(await N(await o(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:P}))).data},[o]),b=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/test`,{method:"POST"}))).data,[o]),S=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"POST"}))).data,[o]),g=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"GET"}))).data,[o]),j=s.useCallback(async(L,A)=>{await o(`/organizations/${L.id}/enterprise-connections/${A}/scim/token/revoke`,{method:"POST"})},[o]),w=s.useCallback(async(L,A)=>{const P=new FormData;return P.append("name",A.name),A.permissions&&A.permissions.forEach((V,H)=>{P.append(`permissions[${H}]`,V)}),await N(await o(`/organizations/${L.id}/roles`,{method:"POST",body:P}))},[o]),E=s.useCallback(async L=>(await N(await o(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[o]),I=s.useCallback(async L=>{const A=await N(await o(`/organizations/${L.id}/delete`,{method:"POST"}));return Rt(),await r(),await i(),A.data},[o,r,i]),O=s.useCallback(async(L,A,P)=>(await N(await o(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/add`,{method:"POST"}))).data,[o]),z=s.useCallback(async(L,A,P)=>(await N(await o(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/remove`,{method:"POST"}))).data,[o]),T=s.useCallback(async(L,A)=>{var V,H;const P=new FormData;return P.append("email",A.email),P.append("role_id",A.organizationRole.id),(V=A.workspace)!=null&&V.id&&P.append("workspace_id",A.workspace.id),(H=A.workspaceRole)!=null&&H.id&&P.append("workspace_role_id",A.workspaceRole.id),(await N(await o(`/organizations/${L.id}/invitations`,{method:"POST",body:P}))).data},[o]),M=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/invitations/${A.id}/discard`,{method:"POST"}))).data,[o]),D=s.useCallback(async(L,A)=>(await N(await o(`/organizations/${L.id}/invitations/${A.id}/resend`,{method:"POST"}))).data,[o]);return{organizations:s.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:n,error:null,refetch:r,leaveOrganization:E,getOrganizationRoles:a,getOrganizationMembers:u,removeOrganizationMember:p,createOrganization:l,getOrganizationInvitations:c,getOrganizationDomains:d,addOrganizationDomain:m,verifyOrganizationDomain:v,removeOrganizationDomain:C,addRoleToOrganizationMember:O,removeRoleFromOrganizationMember:z,inviteOrganizationMember:T,discardOrganizationInvitation:M,resendOrganizationInvitation:D,updateOrganization:f,addRole:w,removeOrganizationRoles:x,deleteOrganization:I,getEnterpriseConnections:$,createEnterpriseConnection:_,updateEnterpriseConnection:k,deleteEnterpriseConnection:R,testEnterpriseConnectionConfig:y,testEnterpriseConnection:b,generateSCIMToken:S,getSCIMToken:g,revokeSCIMToken:j}},Tr=()=>{const{loading:t,error:r,refetch:n,getOrganizationMembers:o,getOrganizationRoles:i,leaveOrganization:a,removeOrganizationMember:u,getOrganizationInvitations:c,getOrganizationDomains:d,removeOrganizationDomain:p,addOrganizationDomain:l,verifyOrganizationDomain:f,addRoleToOrganizationMember:x,removeRoleFromOrganizationMember:m,inviteOrganizationMember:v,discardOrganizationInvitation:C,resendOrganizationInvitation:$,updateOrganization:_,removeOrganizationRoles:k,getEnterpriseConnections:R,createEnterpriseConnection:y,updateEnterpriseConnection:b,deleteEnterpriseConnection:S,testEnterpriseConnectionConfig:g,testEnterpriseConnection:j,generateSCIMToken:w,getSCIMToken:E,revokeSCIMToken:I}=Tt(),{session:O,error:z,loading:T}=He(),{organizationMemberships:M}=Kt(),D=s.useMemo(()=>(M==null?void 0:M.find(W=>{var xe;return W.id===((xe=O==null?void 0:O.active_signin)==null?void 0:xe.active_organization_membership_id)}))||null,[M,O]),F=s.useMemo(()=>(D==null?void 0:D.organization)||null,[D]),L=s.useCallback(async W=>F?await _(F,W):[],[F,_]),A=s.useCallback(async()=>F?await o(F):[],[F,o]),P=s.useCallback(async()=>F?await i(F):[],[F,i]),U=s.useCallback(async W=>F?await u(F,W):[],[F,u]),V=s.useCallback(async W=>F?await k(F,W):void 0,[F,k]),H=s.useCallback(async()=>F?await d(F):[],[F,d]),ae=s.useCallback(async W=>F?await l(F,W):void 0,[F,l]),ee=s.useCallback(async W=>F?await f(F,W):void 0,[F,f]),ge=s.useCallback(async W=>F?await p(F,W):void 0,[F,p]),pe=s.useCallback(async(W,xe)=>F?await x(F,W,xe):void 0,[F,x]),Q=s.useCallback(async(W,xe)=>F?await m(F,W,xe):void 0,[F,m]),he=s.useCallback(async W=>F?await v(F,W):void 0,[F,v]),X=s.useCallback(async W=>F?await C(F,W):void 0,[F,C]),Oe=s.useCallback(async W=>F?await $(F,W):void 0,[F,$]),se=s.useCallback(async()=>{F&&await a(F)},[F,a]),ce=s.useCallback(async()=>F?await c(F):[],[F,c]),_e=s.useCallback(async()=>F?await R(F):[],[F,R]),me=s.useCallback(async W=>{if(F)return await y(F,W)},[F,y]),Ce=s.useCallback(async(W,xe)=>{if(F)return await b(F,W,xe)},[F,b]),q=s.useCallback(async W=>{F&&await S(F,W)},[F,S]),te=s.useCallback(async W=>F?await g(F,W):null,[F,g]),de=s.useCallback(async W=>F?await j(F,W):null,[F,j]),ie=s.useCallback(async W=>{if(F)return await w(F,W)},[F,w]),Y=s.useCallback(async W=>{if(F)return await E(F,W)},[F,E]),ve=s.useCallback(async W=>{F&&await I(F,W)},[F,I]);return T||t?{activeOrganization:null,activeMembership:null,loading:!0,error:z||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:F,activeMembership:D,loading:!1,refetch:n,getRoles:P,updateOrganization:L,getMembers:A,getDomains:H,addDomain:ae,verifyDomain:ee,removeDomain:ge,getInvitations:ce,removeMember:U,leave:se,removeRole:V,addMemberRole:pe,removeMemberRole:Q,inviteMember:he,discardInvitation:X,resendInvitation:Oe,getEnterpriseConnections:_e,createEnterpriseConnection:me,updateEnterpriseConnection:Ce,deleteEnterpriseConnection:q,testEnterpriseConnectionConfig:te,testEnterpriseConnection:de,generateSCIMToken:ie,getSCIMToken:Y,revokeSCIMToken:ve,error:null}};async function Mp(t){return(await N(await t("/me/organization-memberships"))).data}const Kt=()=>{const{client:t,loading:r}=$e(),{data:n,isLoading:o,error:i,mutate:a}=Re(r?null:"/me/organization-memberships",()=>Mp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=s.useCallback(async()=>{await a()},[a]);return{organizationMemberships:n,loading:r||o,error:i,refetch:u}};async function Dp(t){return(await N(await t("/me/workspace-memberships"))).data}async function Fp(t,r,n){return(await N(await t(`/workspaces/${r}/members/${n}/remove`,{method:"POST"}))).data}const So=()=>{const{client:t,loading:r}=$e(),{deployment:n}=be(),{data:o,isLoading:i,error:a,mutate:u}=Re(!r&&(n!=null&&n.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Dp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=s.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]);return{workspaceMemberships:o,loading:r||i,error:a,refetch:c}},ar=()=>{const{workspaceMemberships:t,refetch:r,loading:n,error:o}=So(),{client:i}=$e(),a=s.useMemo(()=>t==null?void 0:t.map(b=>({...b.workspace,organization:b.organization,eligibility_restriction:b.eligibility_restriction})),[t]),u=s.useCallback(async(b,S,g,j)=>{const w=new FormData;w.append("name",S),g&&w.append("image",g),j&&w.append("description",j),w.append("organization_id",b);const E=await N(await i("/workspaces",{method:"POST",body:w}));return Rt(),await r(),E.data},[i,r]),c=s.useCallback(async(b,S)=>{const g=await Fp(i,b,S);return await r(),g},[i,r]),d=s.useCallback(async(b,S)=>{const g=new FormData;S.name&&g.append("name",S.name),S.description&&g.append("description",S.description),S.image&&g.append("image",S.image),S.enforce_2fa!==void 0&&g.append("enforce_2fa",String(S.enforce_2fa)),S.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(S.enable_ip_restriction)),S.whitelisted_ips&&S.whitelisted_ips.forEach(w=>g.append("whitelisted_ips",w));const j=await N(await i(`/workspaces/${b.id}/update`,{method:"POST",body:g}));return await r(),j.data},[i,r]),p=s.useCallback(async b=>{const S=await N(await i(`/workspaces/${b.id}/delete`,{method:"POST"}));return Rt(),await r(),S.data},[i,r]),l=s.useCallback(async(b,S)=>{const g=new URLSearchParams;return S&&(g.set("page",S.page.toString()),g.set("limit",S.limit.toString()),S.search&&g.set("search",S.search)),(await N(await i(`/workspaces/${b.id}/members?${g.toString()}`,{method:"GET"}))).data},[i]),f=s.useCallback(async b=>(await N(await i(`/workspaces/${b.id}/roles`,{method:"GET"}))).data,[i]),x=s.useCallback(async(b,S,g)=>{const j=new FormData;return j.append("name",S),g.forEach(E=>j.append("permissions",E)),(await N(await i(`/workspaces/${b.id}/roles`,{method:"POST",body:j}))).data},[i]),m=s.useCallback(async(b,S)=>(await N(await i(`/workspaces/${b.id}/roles/${S.id}/delete`,{method:"POST"}))).data,[i]),v=s.useCallback(async(b,S)=>{const g=await N(await i(`/workspaces/${b.id}/members/${S}/remove`,{method:"POST"}));return await r(),g.data},[i,r]),C=s.useCallback(async(b,S,g)=>(await N(await i(`/workspaces/${b.id}/members/${S}/roles/${g}/add`,{method:"POST"}))).data,[i]),$=s.useCallback(async(b,S,g)=>(await N(await i(`/workspaces/${b.id}/members/${S}/roles/${g}/remove`,{method:"POST"}))).data,[i]),_=s.useCallback(async b=>(await N(await i(`/organizations/${b.organization.id}/invitations?workspace_id=${b.id}`,{method:"GET"}))).data,[i]),k=s.useCallback(async(b,S,g)=>{const j=new FormData;return j.append("email",S),j.append("workspace_id",b.id),g&&j.append("workspace_role_id",g),(await N(await i(`/organizations/${b.organization.id}/invitations`,{method:"POST",body:j}))).data},[i]),R=s.useCallback(async(b,S)=>(await N(await i(`/organizations/${b.organization.id}/invitations/${S}/discard`,{method:"POST"}))).data,[i]),y=s.useCallback(async(b,S)=>(await N(await i(`/organizations/${b.organization.id}/invitations/${S}/resend`,{method:"POST"}))).data,[i]);return{workspaces:a||[],loading:n,error:o,refetch:r,leaveWorkspace:c,createWorkspace:u,updateWorkspace:d,deleteWorkspace:p,getWorkspaceMembers:l,getWorkspaceRoles:f,createWorkspaceRole:x,deleteWorkspaceRole:m,removeWorkspaceMember:v,addWorkspaceMemberRole:C,removeWorkspaceMemberRole:$,getWorkspaceInvitations:_,createWorkspaceInvitation:k,discardWorkspaceInvitation:R,resendWorkspaceInvitation:y}},Qt=()=>{const{refetch:t,loading:r,error:n,workspaces:o,leaveWorkspace:i,updateWorkspace:a,deleteWorkspace:u,getWorkspaceMembers:c,getWorkspaceRoles:d,createWorkspaceRole:p,deleteWorkspaceRole:l,removeWorkspaceMember:f,addWorkspaceMemberRole:x,removeWorkspaceMemberRole:m,getWorkspaceInvitations:v,createWorkspaceInvitation:C,discardWorkspaceInvitation:$,resendWorkspaceInvitation:_}=ar(),{workspaceMemberships:k}=So(),{session:R,loading:y,error:b}=He(),S=s.useMemo(()=>(k==null?void 0:k.find(ee=>{var ge;return ee.id===((ge=R==null?void 0:R.active_signin)==null?void 0:ge.active_workspace_membership_id)}))||null,[k,R]),g=s.useMemo(()=>(S==null?void 0:S.workspace)||null,[S]),j=s.useCallback(async()=>{var ee;if(!(!g||!((ee=R==null?void 0:R.active_signin)!=null&&ee.user_id)))return await i(g.id,R.active_signin.user_id)},[g,i,R]),w=s.useCallback(async ee=>{if(g)return await a(g,ee)},[g,a]),E=s.useCallback(async()=>{if(g)return await u(g)},[g,u]),I=s.useCallback(async ee=>g?await c(g,ee):{data:[],meta:{total:0,page:1,limit:10}},[g,c]),O=s.useCallback(async()=>g?await d(g):[],[g,d]),z=s.useCallback(async(ee,ge)=>{if(g)return await p(g,ee,ge)},[g,p]),T=s.useCallback(async ee=>{if(g)return await l(g,ee)},[g,l]),M=s.useCallback(async ee=>{if(g)return await f(g,ee)},[g,f]),D=s.useCallback(async(ee,ge)=>{if(g)return await x(g,ee,ge)},[g,x]),F=s.useCallback(async(ee,ge)=>{if(g)return await m(g,ee,ge)},[g,m]),L=s.useMemo(()=>(o==null?void 0:o.find(ee=>ee.id===(g==null?void 0:g.id)))||null,[o,g]),A=s.useCallback(async()=>L?await v(L):[],[L,v]),P=s.useCallback(async ee=>{if(L)return await C(L,ee.email,ee.workspaceRoleId)},[L,C]),U=s.useCallback(async ee=>{if(L)return await $(L,ee)},[L,$]),V=s.useCallback(async ee=>{if(L)return await _(L,ee)},[L,_]),H=r||y,ae=n||b;return H?{activeWorkspace:null,activeMembership:null,loading:!0,error:ae,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:g,activeMembership:S,loading:!1,error:ae,refetch:t,leave:j,updateWorkspace:w,deleteWorkspace:E,getMembers:I,getRoles:O,createRole:z,deleteRole:T,inviteMember:P,removeMember:M,addMemberRole:D,removeMemberRole:F,getInvitations:A,discardInvitation:U,resendInvitation:V}};function Ko(t){const r=new Uint8Array(t);let n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Qo(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),n=r.padEnd(r.length+(4-r.length%4)%4,"="),o=atob(n),i=new Uint8Array(o.length);for(let a=0;a<o.length;a++)i[a]=o.charCodeAt(a);return i.buffer}const Np=async t=>(await N(await t("/me"))).data,Up=async t=>(await N(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=$e(),{data:n,error:o,isLoading:i,mutate:a}=Re(r?null:"/user",()=>Np(t)),u=async L=>{const A=new FormData;for(const[U,V]of Object.entries(L))V!=null&&V!==""&&A.append(U,String(V));const P=await N(await t("/me",{method:"POST",body:A}));return a(),P},c=async()=>await N(await t("/me/email-addresses",{method:"GET"})),d=async L=>await N(await t(`/me/email-addresses/${L}`,{method:"GET"})),p=async L=>{const A=new FormData;return A.append("email",L),await N(await t("/me/email-addresses",{method:"POST",body:A}))},l=async L=>await N(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),f=async L=>await N(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),x=async(L,A)=>await N(await t(`/me/email-addresses/${L}/attempt-verification?code=${A}`,{method:"POST"})),m=async(L,A)=>{const P=new FormData;return P.append("phone_number",L),P.append("country_code",A),await N(await t("/me/phone-numbers",{method:"POST",body:P}))},v=async L=>await N(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),C=async L=>await N(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),$=async(L,A)=>{const P=new FormData;return P.append("code",A),await N(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:P}))},_=async L=>{const A=await N(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return a(),A},k=async L=>await N(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),R=async()=>(await N(await t("/me/authenticator",{method:"POST"}))).data,y=async(L,A)=>{const P=new FormData;return P.append("authenticator_id",L),A.forEach(V=>{P.append("codes",V)}),await N(await t("/me/authenticator/attempt-verification",{method:"POST",body:P}))},b=async L=>await N(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),S=async()=>(await N(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const A=new FormData;return A.append("file",L),await N(await t("/me/profile-picture",{method:"POST",body:A}))},j=async()=>(await N(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,w=async(L,A)=>{const P=new FormData;return P.append("current_password",L),P.append("new_password",A),await N(await t("/me/update-password",{method:"POST",body:P}))},E=async L=>{const A=new FormData;A.append("current_password",L);const P=await N(await t("/me/remove-password",{method:"POST",body:A}));return a(),P},I=async L=>{const A=new FormData;return A.append("password",L),await N(await t("/me/account/delete",{method:"POST",body:A}))},O=async L=>await N(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),z=async({provider:L,redirectUri:A})=>{var V;const P=new URLSearchParams({provider:L});A&&P.append("redirect_uri",A);const U=await N(await t(`/me/init-sso-connection?${P.toString()}`,{method:"POST"}));return"data"in U&&((V=U.data)!=null&&V.oauth_url)&&window.open(U.data.oauth_url,"_blank"),U},T=async()=>await N(await t("/me/passkeys",{method:"GET"})),M=async L=>{var ge,pe;const A=await N(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in A))return A;const P=A.data.options.publicKey,U={challenge:Qo(P.challenge),rp:P.rp,user:{id:Qo(P.user.id),name:P.user.name,displayName:P.user.displayName},pubKeyCredParams:P.pubKeyCredParams,timeout:P.timeout,attestation:P.attestation,authenticatorSelection:P.authenticatorSelection,excludeCredentials:(ge=P.excludeCredentials)==null?void 0:ge.map(Q=>({type:Q.type,id:Qo(Q.id),transports:Q.transports}))},V=await navigator.credentials.create({publicKey:U});if(!V)throw new Error("Failed to create credential");const H=V.response,ae={id:V.id,rawId:Ko(V.rawId),type:V.type,response:{clientDataJSON:Ko(H.clientDataJSON),attestationObject:Ko(H.attestationObject),transports:((pe=H.getTransports)==null?void 0:pe.call(H))||[]}};return await N(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)}))},D=async L=>await N(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),F=async(L,A)=>await N(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}));return{user:{...n,refetch:a},loading:r||i,error:o||null,updateProfile:u,getEmailAddresses:c,getEmailAddress:d,createEmailAddress:p,deleteEmailAddress:l,prepareEmailVerification:f,attemptEmailVerification:x,makeEmailPrimary:k,createPhoneNumber:m,deletePhoneNumber:v,preparePhoneVerification:C,attemptPhoneVerification:$,makePhonePrimary:_,setupAuthenticator:R,verifyAuthenticator:y,deleteAuthenticator:b,generateBackupCodes:S,regenerateBackupCodes:j,updateProfilePicture:g,disconnectSocialConnection:O,connectSocialAccount:z,updatePassword:w,removePassword:E,deleteAccount:I,getPasskeys:T,registerPasskey:M,deletePasskey:D,renamePasskey:F}}function Yl(){const{client:t,loading:r}=$e(),{data:n,error:o,isLoading:i,mutate:a}=Re(r?null:"/me/signins",()=>Up(t));return{signins:n,error:o||null,removeSignin:async c=>await N(await t(`/me/signins/${c}/signout`,{method:"POST"})),refetch:a,loading:i||r}}function Bp(){const{session:t,loading:r}=He(),{loading:n,organizationMemberships:o}=Kt(),{loading:i,workspaceMemberships:a}=So();if(r||n||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const u=s.useMemo(()=>!t||!t.signins||t.signins.length===0?null:o==null?void 0:o.find(d=>{var p;return d.id===((p=t.active_signin)==null?void 0:p.active_organization_membership_id)}),[t]),c=s.useMemo(()=>!t||!t.signins||t.signins.length===0?null:a==null?void 0:a.find(d=>{var p;return d.id===((p=t.active_signin)==null?void 0:p.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:u,workspaceMembership:c}}function Kl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),i=async a=>{o(!0);try{const u=new FormData;for(const[p,l]of Object.entries(a))l&&u.append(p,l);const c=await t("/waitlist/join",{method:"POST",body:u});return await N(c)}finally{o(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:n,joinWaitlist:i}}function Ql(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),[i,a]=s.useState(null),[u,c]=s.useState(null),[d,p]=s.useState(null),[l,f]=s.useState(!1),[x,m]=s.useState(null);s.useEffect(()=>{if(l||r)return;const C=new URLSearchParams(window.location.search),$=C.get("code"),_=C.get("state"),k=C.get("error"),R=C.get("error_description");if(!$&&!k){f(!0);const y=new Error("No OAuth callback data found.");a(y);return}if(f(!0),o(!0),k){const y=R||k,b=new Error(`OAuth Error: ${y}`);a(b),o(!1);return}if($&&_)v($,_);else{const y=new Error("Missing required OAuth parameters");a(y),o(!1)}},[l,r]);const v=async(C,$)=>{try{let _,k;try{const b=$.split(".");if(b.length!==2)throw new Error("Invalid OAuth state format - missing signature");const S=b[0].replace(/-/g,"+").replace(/_/g,"/"),g=S.length%4?"=".repeat(4-S.length%4):"",w=atob(S+g).split("|")[0];if(w==="sign_in")_="/auth/oauth2/callback",k="GET";else if(w==="connect_social")_="/me/sso-connection-callback",k="POST";else throw new Error(`Unknown OAuth action: ${w}`)}catch(b){const S=b instanceof Error?b:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${S.message}. The authorization link may be expired or malformed. Please try signing in again.`)),o(!1);return}const R=await t(`${_}?code=${encodeURIComponent(C)}&state=${encodeURIComponent($)}`,{method:k}),y=await N(R);if("data"in y){const b=y.data.session,S=y.data.redirect_uri||null;if(c(b),p(S),b.signin_attempts&&b.signin_attempts.length>0){const g=b.signin_attempts.at(-1);g&&m(g)}}else{const b=new Error("SSO callback failed");a(b)}}catch(_){const k=_ instanceof Error?_:new Error("Unknown error occurred");a(k)}finally{o(!1)}};return{loading:n,error:i,session:u,redirectUri:d,processed:l,signinAttempt:x}}function Zl(){const{client:t,loading:r}=$e(),[n,o]=s.useState(!1),[i,a]=s.useState(null);return{loading:r||n,verifyMagicLink:async c=>{if(!c.token||!c.attempt)throw new Error("Invalid magic link parameters");o(!0),a(null);try{const d=new URL("/auth/verify-magic-link",window.location.origin);d.searchParams.set("token",c.token),d.searchParams.set("attempt",c.attempt),c.redirectUri&&d.searchParams.set("redirect_uri",c.redirectUri);const p=await t(d.pathname+d.search,{method:"GET"}),l=await N(p);return o(!1),a(!0),l}catch(d){throw o(!1),a(!1),d}},success:i}}function Jl(){const[t,r]=s.useState({});return s.useEffect(()=>{const n=new URLSearchParams(window.location.search);r({token:n.get("token")||void 0,attempt:n.get("attempt")||void 0,redirectUri:n.get("redirect_uri")||void 0})},[]),t}function Xl(){const{client:t,loading:r}=$e();return{loading:r,forgotPassword:async a=>{const u=new FormData;u.append("email",a);const c=await t("/auth/forgot-password",{method:"POST",body:u});return await N(c)},verifyOtp:async(a,u)=>{const c=new FormData;c.append("email",a),c.append("otp",u);const d=await t("/auth/forgot-password",{method:"POST",body:c});return await N(d)},resetPassword:async(a,u)=>{const c=new FormData;c.append("token",a),c.append("password",u);const d=await t("/auth/reset-password",{method:"POST",body:c});return await N(d)}}}const Wp=()=>{},Vp=Wp(),Bi=Object,ts=t=>t===Vp,Gp=t=>typeof t=="function",En=new WeakMap,Hp=t=>Bi.prototype.toString.call(t),Zo=(t,r)=>t===`[object ${r}]`;let qp=0;const Wi=t=>{const r=typeof t,n=Hp(t),o=Zo(n,"Date"),i=Zo(n,"RegExp"),a=Zo(n,"Object");let u,c;if(Bi(t)===t&&!o&&!i){if(u=En.get(t),u)return u;if(u=++qp+"~",En.set(t,u),Array.isArray(t)){for(u="@",c=0;c<t.length;c++)u+=Wi(t[c])+",";En.set(t,u)}if(a){u="#";const d=Bi.keys(t).sort();for(;!ts(c=d.pop());)ts(t[c])||(u+=c+":"+Wi(t[c])+",");En.set(t,u)}}else u=o?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},Yp=t=>{if(Gp(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Wi(t):"",[t,r]},Kp=t=>Yp(t?t(0,null):null)[0],Jo=Promise.resolve(),Qp=t=>(r,n,o)=>{const i=s.useRef(!1),{cache:a,initialSize:u=1,revalidateAll:c=!1,persistSize:d=!1,revalidateFirstPage:p=!0,revalidateOnMount:l=!1,parallel:f=!1}=o,[,,,x]=Pt.get(ca);let m;try{m=Kp(r),m&&(m=Vl+m)}catch{}const[v,C,$]=Xt(a,m),_=s.useCallback(()=>ye(v()._l)?u:v()._l,[a,m,u]);Ii.useSyncExternalStore(s.useCallback(j=>m?$(m,()=>{j()}):()=>{},[a,m]),_,_);const k=s.useCallback(()=>{const j=v()._l;return ye(j)?u:j},[m,u]),R=s.useRef(k());ao(()=>{if(!i.current){i.current=!0;return}m&&C({_l:d?R.current:k()})},[m,a]);const y=l&&!i.current,b=t(m,async j=>{const w=v()._i,E=v()._r;C({_r:Je});const I=[],O=k(),[z]=Xt(a,j),T=z().data,M=[];let D=null;for(let F=0;F<O;++F){const[L,A]=yn(r(F,f?null:D));if(!L)break;const[P,U]=Xt(a,L);let V=P().data;const H=c||w||ye(V)||p&&!F&&!ye(T)||y||T&&!ye(T[F])&&!o.compare(T[F],V);if(n&&(typeof E=="function"?E(V,A):H)){const ae=async()=>{if(!(L in x))V=await n(A);else{const ge=x[L];delete x[L],V=await ge}U({data:V,_k:A}),I[F]=V};f?M.push(ae):await ae()}else I[F]=V;f||(D=V)}return f&&await Promise.all(M.map(F=>F())),C({_i:Je}),I},o),S=s.useCallback(function(j,w){const E=typeof w=="boolean"?{revalidate:w}:w||{},I=E.revalidate!==!1;return m?(I&&(ye(j)?C({_i:!0,_r:E.revalidate}):C({_i:!1,_r:E.revalidate})),arguments.length?b.mutate(j,{...E,revalidate:I}):b.mutate()):Jo},[m,a]),g=s.useCallback(j=>{if(!m)return Jo;const[,w]=Xt(a,m);let E;if(vt(j)?E=j(k()):typeof j=="number"&&(E=j),typeof E!="number")return Jo;w({_l:E}),R.current=E;const I=[],[O]=Xt(a,m);let z=null;for(let T=0;T<E;++T){const[M]=yn(r(T,z)),[D]=Xt(a,M),F=M?D().data:Je;if(ye(F))return S(O().data);I.push(F),z=F}return S(I)},[m,a,S,k]);return{size:k(),setSize:g,mutate:S,get data(){return b.data},get error(){return b.error},get isValidating(){return b.isValidating},get isLoading(){return b.isLoading}}},Zp=$p(Re,Qp);function ed({enabled:t=!0,channels:r,organizationIds:n,workspaceIds:o,onNotification:i,onError:a,reconnectDelay:u=1e3,maxReconnectAttempts:c=5}={}){const{session:d,loading:p}=He(),{deployment:l,loading:f}=be(),[x,m]=s.useState(!1),[v,C]=s.useState(null),$=s.useRef(null),_=s.useRef(null),k=s.useRef(0),R=s.useRef(null),y=s.useRef(i),b=s.useRef(a),S=s.useRef(r),g=s.useRef(n),j=s.useRef(o),w=s.useRef(u),E=s.useRef(c);y.current=i,b.current=a,S.current=r,g.current=n,j.current=o,w.current=u,E.current=c;const I=s.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),R.current&&(clearInterval(R.current),R.current=null),$.current&&($.current.close(),$.current=null)},[]),O=s.useCallback(async()=>{var L;if(!t||p||f||!d||!l)return;I();const M=new URL(l.backend_host),D=M.protocol==="https:"?"wss:":"ws:",F=new URL("/realtime/notifications",`${D}//${M.host}`);if(l.mode==="staging"){const A=tt();A&&F.searchParams.set("__dev_session__",A)}S.current&&S.current.length>0&&S.current.forEach(A=>F.searchParams.append("channels",A)),g.current&&g.current.length>0&&g.current.forEach(A=>F.searchParams.append("organization_ids",A.toString())),j.current&&j.current.length>0&&j.current.forEach(A=>F.searchParams.append("workspace_ids",A.toString()));try{const A=new WebSocket(F.toString());$.current=A,A.onopen=()=>{m(!0),C(null),k.current=0,R.current=setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send("ping")},3e4)},A.onmessage=P=>{var U,V;try{const H=JSON.parse(P.data);if(H.type==="notification"&&H.data)(U=y.current)==null||U.call(y,H.data);else if(H.type==="error"){const ae=H.error||"Unknown error occurred";C(ae),(V=b.current)==null||V.call(b,ae)}else H.type}catch{}},A.onerror=()=>{var P;C("Connection error occurred"),(P=b.current)==null||P.call(b,"Connection error occurred")},A.onclose=P=>{var U;if(m(!1),R.current&&(clearInterval(R.current),R.current=null),t&&P.code!==1e3&&k.current<E.current){k.current++;const V=w.current*Math.pow(2,k.current-1);_.current=setTimeout(()=>{O()},V)}else k.current>=E.current&&(C("Max reconnection attempts reached"),(U=b.current)==null||U.call(b,"Max reconnection attempts reached"))}}catch{C("Failed to connect"),(L=b.current)==null||L.call(b,"Failed to connect")}},[t,p,f,d,l,I]);s.useEffect(()=>(O(),()=>{I()}),[O,I]),s.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&O()},[r,n,o,O]);const z=s.useCallback(()=>{I(),m(!1)},[I]),T=s.useCallback(()=>{k.current=0,O()},[O]);return{isConnected:x,connectionError:v,disconnect:z,reconnect:T}}function $o(t){if(!t)return"";const r=new URLSearchParams;t.limit&&r.append("limit",t.limit.toString()),t.cursor&&r.append("cursor",t.cursor),t.scope&&r.append("scope",t.scope),t.is_read!==void 0&&r.append("is_read",t.is_read.toString()),t.is_archived!==void 0&&r.append("is_archived",t.is_archived.toString()),t.is_starred!==void 0&&r.append("is_starred",t.is_starred.toString()),t.severity&&r.append("severity",t.severity);const n=r.toString();return n?"?"+n:""}async function Jp(t,r){const n=`/notifications${$o(r)}`,o=await t(n,{method:"GET"});return(await N(o)).data}async function Xp(t,r){const n=await t(`/notifications/${r}/read`,{method:"POST"});return N(n)}async function eh(t,r){const n=await t(`/notifications/${r}/unread`,{method:"POST"});return N(n)}async function th(t,r){const n=await t(`/notifications/mark-all-read${$o(r)}`,{method:"POST"});return N(n)}async function rh(t,r){const n=await t(`/notifications/archive-all-read${$o(r)}`,{method:"POST"});return N(n)}async function nh(t,r){const n=await t(`/notifications/${r}/archive`,{method:"POST"});return N(n)}async function oh(t,r){const n=await t(`/notifications/${r}/star`,{method:"POST"});return N(n)}function td(t){var b;const{client:r,loading:n}=$e(),{data:o,error:i,mutate:a,isLoading:u,size:c,setSize:d,isValidating:p}=Zp((S,g)=>{var I;if(n||S>0&&(!g||!g.has_more))return null;const j=S===0||(I=g==null?void 0:g.notifications[g.notifications.length-1])==null?void 0:I.id,{onNotification:w,...E}=t||{};return["wacht-notifications",{...E,cursor:j}]},([,S])=>Jp(r,S),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),l=s.useMemo(()=>o?o.flatMap(S=>S.notifications):[],[o]),f=o?(b=o[o.length-1])==null?void 0:b.has_more:!1;ed({enabled:!n&&!!o,onNotification:s.useCallback(S=>{a(async g=>{var I;if(!g||g.length===0||g.some(O=>O.notifications.some(z=>z.id===S.id.toString())))return g;(I=t==null?void 0:t.onNotification)==null||I.call(t,S);const w=g[0];return[{...w,notifications:[{id:S.id.toString(),user_id:S.user_id.toString(),deployment_id:S.deployment_id.toString(),title:S.title,body:S.body,severity:S.severity,ctas:S.ctas,is_read:!1,is_archived:!1,created_at:S.created_at,updated_at:S.created_at},...w.notifications]},...g.slice(1)]},!1)},[a,t]),onError:s.useCallback(()=>{},[])});const x=s.useCallback(async S=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===S?{...w,is_read:!0}:w)})),!1),await Xp(r,S),await a())},[r,n,a]),m=s.useCallback(async S=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===S?{...w,is_read:!1}:w)})),!1),await eh(r,S),await a())},[r,n,a]),v=s.useCallback(async()=>{n||(await a(async S=>S&&S.map(g=>({...g,notifications:g.notifications.map(j=>({...j,is_read:!0}))})),!1),await th(r,t),await a())},[r,t,a,n]),C=s.useCallback(async()=>{n||(await a(async S=>S&&S.map(g=>({...g,notifications:g.notifications.filter(j=>!j.is_read)})),!1),await rh(r,t),await a())},[r,t,n,a]),$=s.useCallback(async S=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:(t==null?void 0:t.is_archived)!==void 0?j.notifications.filter(w=>w.id!==S):j.notifications.map(w=>w.id===S?{...w,is_archived:!w.is_archived}:w)})),!1),await nh(r,S),await a())},[r,n,a,t==null?void 0:t.is_archived]),_=s.useCallback(async S=>{n||(await a(async g=>g&&g.map(j=>({...j,notifications:j.notifications.map(w=>w.id===S?{...w,is_starred:!w.is_starred}:w)})),!1),await oh(r,S),await a())},[r,n,a]),k=s.useCallback(async()=>{p||!f||await d(c+1)},[p,f,d,c]),R=s.useCallback(async()=>{await a()},[a]),y=n||u||c>0&&o&&typeof o[c-1]>"u";return!o||y?{loading:!0,notifications:l,hasMore:f,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:i,refetch:R,loadMore:k}:{loading:!1,error:i,notifications:l,hasMore:f,markAsRead:x,markAllAsRead:v,archiveAllRead:C,archiveNotification:$,starNotification:_,markAsUnread:m,refetch:R,loadMore:k}}async function ih(t,r){const n=`/notifications/scope-unread${$o(r)}`,o=await t(n,{method:"GET"});return(await N(o)).data}function rd(t){const{client:r,loading:n}=$e(),{data:o,error:i,mutate:a}=Re(n?null:["wacht-notifications-unread",t],([,c])=>ih(r,c),{refreshInterval:3e4,revalidateOnFocus:!0}),u=async()=>{await a()};return!o||n?{loading:!0,count:0,error:i,refetch:u}:{loading:!1,count:o.count,error:i,refetch:u}}const zn={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Qe={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},dr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function ah(t){switch(t){case dr.IDLE:return Qe.IDLE;case dr.STARTING:return Qe.STARTING;case dr.RUNNING:return Qe.RUNNING;case dr.WAITING_FOR_INPUT:return Qe.WAITING_FOR_INPUT;case dr.COMPLETED:return Qe.COMPLETED;case dr.FAILED:case dr.CANCELLED:return Qe.FAILED;default:return Qe.IDLE}}function sh(t){return t===Qe.STARTING||t===Qe.RUNNING||t===Qe.WAITING_FOR_INPUT}function ch({contextId:t,agentName:r,platformAdapter:n}){const{deployment:o}=be(),{client:i}=$e(),[a,u]=s.useState([]),[c,d]=s.useState([]),[p,l]=s.useState(null),[f,x]=s.useState(null),[m,v]=s.useState(null),[C,$]=s.useState(!1),[_,k]=s.useState(!1),[R,y]=s.useState(Qe.IDLE),[b,S]=s.useState({status:zn.DISCONNECTED}),[g,j]=s.useState(!0),[w,E]=s.useState(!1),I=s.useRef(null),O=s.useRef(null),z=s.useRef(null),T=s.useRef(new Set),M=s.useCallback(se=>{var te;const{id:ce,content:_e}=se,me=se.message_type||((te=se.metadata)==null?void 0:te.message_type)||(_e==null?void 0:_e.type);let Ce="assistant";me==="user_message"&&(Ce="user");const q={...se,role:Ce,metadata:{...se.metadata||{},message_type:me}};if(me==="system_decision"||me==="action_execution_result"||me==="context_results"){if(l(null),x(null),v(null),T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]);return}if(me==="user_message"){if(l(null),x(null),v(null),T.current.has(ce))return;T.current.add(ce),console.log(T.current,ce),u(de=>[...de,q]);return}if(me==="assistant_acknowledgment"){if(l(null),x(null),v(null),T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]),se.further_action_required||(k(!1),y(Qe.IDLE),O.current=null);return}if(me==="agent_response"){if(T.current.has(ce))return;T.current.add(ce),u(de=>[...de,q]),k(!1),y(Qe.IDLE),O.current=null;return}if(me==="user_input_request"){if(T.current.has(ce))return;T.current.add(ce),y(Qe.WAITING_FOR_INPUT),u(de=>[...de,q]);return}if(me==="execution_status"){const de=ah(_e.status);y(de),k(sh(de));return}},[]),D=s.useCallback((se,ce)=>{var _e;(_e=n==null?void 0:n.onPlatformEvent)==null||_e.call(n,se,ce)},[n]),F=s.useRef(M),L=s.useRef(D),A=s.useRef(i),P=s.useRef(o);s.useEffect(()=>{F.current=M,L.current=D,A.current=i,P.current=o});const U=s.useRef(null),V=s.useRef(null),H=s.useRef(0),ae=10,ee=s.useCallback(async se=>{if(t)try{const ce=new URLSearchParams({limit:"100"});se&&(ce.append("before_id",se),E(!0));const _e=await i(`/api/agent/contexts/${t}/messages?${ce}`,{method:"GET"}),me=await N(_e);if(me.data){const Ce=[...me.data.data].sort((q,te)=>{const de=new Date(q.timestamp).getTime(),ie=new Date(te.timestamp).getTime();return de-ie});Ce.length>0&&(I.current=Ce[0].id),Ce.forEach(q=>{T.current.add(q.id)}),u(q=>se?[...Ce,...q]:Ce),j(me.data.has_more||!1),E(!1)}}catch(ce){console.error("Failed to fetch messages:",ce),E(!1)}},[t,i]);s.useEffect(()=>{const se=P.current;if(!se||!t)return;const ce=()=>{U.current&&(U.current.close(),U.current=null);const _e=se.backend_host.replace(/\/$/,""),me=new URL(`${_e}/realtime/agent/stream`);if(me.searchParams.append("context_id",t),se.mode==="staging"){const q=tt();q&&me.searchParams.append("__dev_session__",q)}console.log("SSE: Connecting to",me.toString());const Ce=new EventSource(me.toString(),{withCredentials:se.mode!=="staging"});U.current=Ce,Ce.onopen=()=>{console.log("SSE: Connected successfully"),$(!0),S({status:zn.CONNECTED}),H.current>0&&setTimeout(()=>{i(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async q=>{const te=await N(q);if(te.data){const de=[...te.data.data].sort((ie,Y)=>new Date(ie.timestamp).getTime()-new Date(Y.timestamp).getTime());u(de)}}).catch(q=>console.error("Failed to refetch messages:",q))},100),H.current=0},Ce.onerror=q=>{if(console.error("SSE error:",q),$(!1),S({status:zn.ERROR}),Ce.close(),U.current=null,H.current<ae){const te=Math.min(1e3*Math.pow(2,H.current),3e4);console.log(`SSE: Reconnecting in ${te}ms (attempt ${H.current+1}/${ae})`),V.current=setTimeout(()=>{H.current++,ce()},te)}else console.error("SSE: Max reconnection attempts reached"),S({status:zn.DISCONNECTED})},Ce.addEventListener("conversation_message",q=>{try{console.log("SSE received conversation_message:",q.data);const te=JSON.parse(q.data);te.ConversationMessage&&F.current(te.ConversationMessage)}catch(te){console.error("Failed to parse conversation event:",te)}}),Ce.addEventListener("platform_event",q=>{try{console.log("SSE received platform_event:",q.data);const te=JSON.parse(q.data);te.PlatformEvent&&L.current(te.PlatformEvent[0],te.PlatformEvent[1])}catch(te){console.error("Failed to parse platform event:",te)}}),Ce.addEventListener("user_input_request",q=>{try{console.log("SSE received user_input_request:",q.data);const te=JSON.parse(q.data);te.UserInputRequest&&M({id:`input-${Date.now()}`,content:te.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(te){console.error("Failed to parse user input request:",te)}})};return ce(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),V.current&&(clearTimeout(V.current),V.current=null),U.current&&(U.current.close(),U.current=null),$(!1)}},[t]);const ge=s.useCallback(async(se,ce,_e)=>{if(!(!t||!o)){l(se),ce&&ce.length>0&&x(ce),_e&&_e.length>0&&v(_e);try{const me=new FormData;me.append("agent_name",r),me.append("message",se),_e&&_e.length>0&&_e.forEach(q=>{me.append("files",q)}),(await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:me})).ok?(k(!0),y(Qe.RUNNING)):(l(null),x(null),v(null))}catch(me){console.error("Failed to send message:",me),l(null),x(null),v(null)}}},[t,r,o,i,ee]),pe=s.useCallback(async se=>{if(!(!t||R!==Qe.WAITING_FOR_INPUT))try{const ce=new FormData;ce.append("agent_name",r),ce.append("user_input",se),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ce}),y(Qe.RUNNING)}catch(ce){console.error("Failed to submit user input:",ce)}},[t,r,R,i]);s.useEffect(()=>{t&&z.current!==t&&(z.current=t,ee())},[t]);const Q=s.useCallback(async()=>{if(!(w||!g||!I.current)){E(!0);try{await ee(I.current)}finally{E(!1)}}},[w,g,ee]),he=s.useCallback(()=>{u([]),d([]),l(null),x(null),v(null)},[]),X=s.useCallback(()=>{},[]),Oe=s.useCallback(async()=>{if(!(!t||!_))try{const se=new FormData;se.append("agent_name",r),se.append("cancel","true"),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:se}),k(!1),y(Qe.IDLE)}catch(se){console.error("Failed to cancel execution:",se)}},[t,_,r,i]);return{messages:a,quickQuestions:c,pendingMessage:p,pendingImages:f,pendingFiles:m,connectionState:b,isConnected:C,isExecuting:_,executionStatus:R,isWaitingForInput:R===Qe.WAITING_FOR_INPUT,hasMoreMessages:g,isLoadingMore:w,sendMessage:ge,submitUserInput:pe,clearMessages:he,loadMoreMessages:Q,cancelExecution:Oe,connect:X,disconnect:()=>{U.current&&(U.current.close(),U.current=null,$(!1))}}}function lh(t){const{client:r}=$e(),n=s.useCallback(async()=>{if(!t)return[];const d=new URLSearchParams({agent_name:t}),p=await r(`/api/agent/integrations?${d.toString()}`,{method:"GET"});return(await N(p)).data},[r,t]),{data:o,error:i,mutate:a}=Re(t?`wacht-agent-integrations:${t}`:null,n,{revalidateOnFocus:!1}),u=s.useCallback(async d=>{const p=`/api/agent/integrations/${d}/consent-url`,l=await r(p,{method:"POST"});return(await N(l)).data},[r]),c=s.useCallback(async d=>{await r(`/api/agent/integrations/${d}/remove`,{method:"POST"}),await a(p=>p&&p.filter(l=>l.id!==d))},[r,a]);return{integrations:o||[],loading:!o&&!i,error:i,generateConsentURL:u,removeIntegration:c,refetch:async()=>{await a()}}}function dh(t){const{client:r}=$e(),n=s.useCallback(async()=>{if(!t)return[];const d=new URLSearchParams({agent_name:t}),p=await r(`/api/agent/mcp-servers?${d.toString()}`,{method:"GET"});return(await N(p)).data},[r,t]),{data:o,error:i,mutate:a}=Re(t?`wacht-agent-mcp-servers:${t}`:null,n,{revalidateOnFocus:!1}),u=s.useCallback(async d=>{if(!t)throw new Error("Agent name required");const p=new URLSearchParams({agent_name:t}),l=await r(`/api/agent/mcp-servers/${d}/connect?${p.toString()}`,{method:"POST"}),f=await N(l);return await a(),f.data},[r,t,a]),c=s.useCallback(async d=>{if(!t)throw new Error("Agent name required");const p=new URLSearchParams({agent_name:t});await r(`/api/agent/mcp-servers/${d}/disconnect?${p.toString()}`,{method:"POST"}),await a()},[r,t,a]);return{mcpServers:o||[],loading:!o&&!i,error:i,connect:u,disconnect:c,refetch:async()=>{await a()}}}function uh(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),l=s.useRef(null),[f,x]=s.useState(null),m=n,v=s.useCallback(async()=>{const S=await r("/api/agent/session",{method:"GET"});if(!S.ok)throw S.status===401||S.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await N(S)).data},[r]),{data:C,error:$,isLoading:_,mutate:k}=Re(m?"wacht-agent-session":null,v,{revalidateOnFocus:!1});s.useEffect(()=>{if(!t||d.current||p.current||l.current===t)return;l.current=t,(async()=>{p.current=!0,a(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(d.current=!0,o(!0)):c(new Error("Failed to exchange ticket"))}catch(g){c(g instanceof Error?g:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]),s.useEffect(()=>{!f&&(C!=null&&C.agents)&&C.agents.length>0&&x(C.agents[0])},[C,f]),s.useEffect(()=>{C!=null&&C.agents&&f&&!C.agents.some(g=>g.id===f.id)&&C.agents.length>0&&x(C.agents[0])},[C,f]);const R=!$||$.message!=="NO_SESSION",y=u||($&&$.message!=="NO_SESSION"?$:null);return{hasSession:R,sessionLoading:i||m&&_,sessionError:y,sessionId:(C==null?void 0:C.session_id)||null,contextGroup:(C==null?void 0:C.context_group)||null,agents:(C==null?void 0:C.agents)||[],activeAgent:f,setActiveAgent:x,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await k()}}}function ph(t={}){const{client:r}=$e(),{limit:n=20,offset:o=0,status:i,search:a,enabled:u=!0}=t,c=s.useCallback(async()=>{const v=new URLSearchParams({limit:String(n),offset:String(o)});i&&v.append("status",i),a&&v.append("search",a);const C=await r(`/api/agent/contexts?${v.toString()}`,{method:"GET"});return(await N(C)).data},[r,n,o,i,a]),{data:d,error:p,mutate:l}=Re(u?`wacht-agent-contexts:${n}:${o}:${i}:${a}`:null,c,{revalidateOnFocus:!1}),f=s.useCallback(async v=>{const C=new FormData;C.append("title",v.title),v.system_instructions&&C.append("system_instructions",v.system_instructions);const $=await r("/api/agent/contexts",{method:"POST",body:C}),_=await N($);return await l(k=>k&&{...k,data:[_.data,...k.data]}),_.data},[r,l]),x=s.useCallback(async v=>{await r(`/api/agent/contexts/${v}/delete`,{method:"POST"}),await l(C=>C&&{...C,data:C.data.filter($=>$.id!==v)})},[r,l]),m=s.useCallback(async(v,C)=>{const $=new FormData;if(C.title&&$.append("title",C.title),!(await r(`/api/agent/contexts/${v}/update`,{method:"POST",body:$})).ok)throw new Error("Failed to update context");await l(k=>k&&{...k,data:k.data.map(R=>R.id===v?{...R,...C}:R)})},[r,l]);return{contexts:(d==null?void 0:d.data)||[],loading:!d&&!p,error:p,hasMore:(d==null?void 0:d.has_more)||!1,createContext:f,deleteContext:x,updateContext:m,refetch:async()=>{await l()}}}function hh(t){const r=new URLSearchParams;return r.append("url",t.url),t.description&&r.append("description",t.description),t.subscribed_events&&t.subscribed_events.forEach(n=>r.append("subscribed_events",n)),t.subscriptions&&t.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(t.subscriptions)),t.headers&&Object.entries(t.headers).forEach(([n,o])=>{r.append(`headers[${n}]`,o)}),t.rate_limit_config&&(r.append("rate_limit[duration_ms]",t.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",t.rate_limit_config.max_requests.toString())),r}function fh(t){const r=new URLSearchParams;return t.url&&r.append("url",t.url),t.description!==void 0&&r.append("description",t.description||""),t.subscribed_events&&t.subscribed_events.forEach(n=>r.append("subscribed_events",n)),t.subscriptions&&t.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(t.subscriptions)),t.headers&&Object.entries(t.headers).forEach(([n,o])=>{r.append(`headers[${n}]`,o)}),t.is_active!==void 0&&r.append("is_active",t.is_active.toString()),t.rate_limit_config&&(r.append("rate_limit[duration_ms]",t.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",t.rate_limit_config.max_requests.toString())),r}function gh(t){const r=new URLSearchParams;return r.append("event_name",t.event_name),r.append("payload",JSON.stringify(t.payload||{})),r}function mh(t){const r=new URLSearchParams;return(t.delivery_ids||[]).forEach(o=>r.append("delivery_ids",o)),t.start_date&&r.append("start_date",t.start_date),t.end_date&&r.append("end_date",t.end_date),t.status&&r.append("status",t.status),t.event_name&&r.append("event_name",t.event_name),t.endpoint_id&&r.append("endpoint_id",t.endpoint_id),t.idempotency_key&&r.append("idempotency_key",t.idempotency_key),r}const _n={"Content-Type":"application/x-www-form-urlencoded"};async function gt(t,r){const n=await N(t);if(!n||!("data"in n))throw new Error(r);return n.data}async function xh(t){const r=await t("/webhook/session",{method:"GET"});if(!r.ok)throw r.status===401||r.status===403?new Error("NO_SESSION"):new Error("Failed to fetch webhook app session");return gt(r,"Failed to fetch webhook app session")}async function vh(t,r){if(!(await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"})).ok)throw new Error("Failed to exchange ticket")}async function yh(t,r){const n=hh(r),o=await t("/webhook/endpoints",{method:"POST",headers:_n,body:n.toString()});return gt(o,"Failed to create webhook endpoint")}async function bh(t,r,n){const o=fh(n),i=await t(`/webhook/endpoints/${r}`,{method:"PUT",headers:_n,body:o.toString()});return gt(i,"Failed to update webhook endpoint")}async function wh(t,r){const n=await t(`/webhook/endpoints/${r}`,{method:"DELETE"});return gt(n,"Failed to delete webhook endpoint")}async function jh(t,r,n){const o=gh(n),i=await t(`/webhook/endpoints/${r}/test`,{method:"POST",headers:_n,body:o.toString()});return gt(i,"Failed to test webhook endpoint")}async function _h(t){const r=await t("/webhook/rotate-secret",{method:"POST"});return gt(r,"Failed to rotate signing secret")}async function kh(t,r){const n=new URLSearchParams;for(const i of r.failure_notification_emails)n.append("failure_notification_emails",i);const o=await t("/webhook/settings",{method:"PUT",headers:_n,body:n.toString()});return gt(o,"Failed to update webhook settings")}async function Ch(t,r){const n=mh(r),o=await t("/webhook/deliveries/replay",{method:"POST",headers:_n,body:n.toString()});return gt(o,"Failed to replay webhook delivery")}async function Sh(t,r){const n=await t(`/webhook/deliveries/${r}`,{method:"GET"});return gt(n,"Failed to fetch delivery details")}async function $h(t,{taskId:r}){const n=await t(`/webhook/deliveries/replay/${r}`,{method:"GET"});return gt(n,"Failed to fetch replay task status")}async function Eh(t,r){const n=(r==null?void 0:r.limit)??50,o=(r==null?void 0:r.offset)??0,i=await t(`/webhook/deliveries/replay?limit=${n}&offset=${o}`,{method:"GET"});return gt(i,"Failed to fetch replay tasks")}async function zh(t,{taskId:r}){const n=await t(`/webhook/deliveries/replay/${r}/cancel`,{method:"POST"});return gt(n,"Failed to cancel replay task")}function Ph(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),l=s.useRef(null),f=n,x=s.useCallback(async()=>xh(r),[r]),{data:m,error:v,isLoading:C,mutate:$}=Re(f?"wacht-webhook-app-session":null,x,{revalidateOnFocus:!1,shouldRetryOnError:!1});s.useEffect(()=>{if(!t||d.current||p.current||l.current===t)return;l.current=t,(async()=>{p.current=!0,a(!0);try{await vh(r,t),d.current=!0,o(!0)}catch(D){c(D instanceof Error?D:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]);const _=s.useCallback(async M=>yh(r,M),[r]),k=s.useCallback(async(M,D)=>bh(r,M,D),[r]),R=s.useCallback(async M=>wh(r,M),[r]),y=s.useCallback(async(M,D)=>jh(r,M,D),[r]),b=s.useCallback(async()=>_h(r),[r]),S=s.useCallback(async M=>Ch(r,M),[r]),g=s.useCallback(async M=>kh(r,M),[r]),j=s.useCallback(async M=>Sh(r,M),[r]),w=s.useCallback(async M=>$h(r,M),[r]),E=s.useCallback(async M=>Eh(r,M),[r]),I=s.useCallback(async M=>zh(r,M),[r]),O=!v||v.message!=="NO_SESSION",z=u||(v&&v.message!=="NO_SESSION"?v:null);return{hasSession:O,sessionLoading:i||f&&C,sessionError:z,sessionId:(m==null?void 0:m.session_id)||null,webhookApp:(m==null?void 0:m.webhook_app)||null,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await $()},createEndpoint:_,updateEndpoint:k,deleteEndpoint:R,testEndpoint:y,rotateSecret:b,updateSettings:g,replayDelivery:S,fetchReplayTaskStatus:w,fetchReplayTasks:E,cancelReplayTask:I,fetchDeliveryDetail:j}}function Rh(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/stats",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-stats",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{stats:n||null,loading:i,error:o,refetch:()=>a()}}function Ih(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/endpoints",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-endpoints",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{endpoints:n||[],loading:i,error:o,refetch:()=>a()}}function Th(){const{client:t}=$e();return{createEndpoint:s.useCallback(async n=>{const o=new URLSearchParams;o.append("url",n.url),n.description&&o.append("description",n.description),n.subscribed_events.forEach(u=>{o.append("subscribed_events",u)});const i=await t("/webhook/endpoints",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()});return(await N(i)).data},[t]),loading:!1,error:null}}function Oh(){const{client:t}=$e(),r=s.useCallback(async()=>{const u=await t("/webhook/events",{method:"GET"});return(await N(u)).data},[t]),{data:n,error:o,isLoading:i,mutate:a}=Re("wacht-webhook-events",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{events:n||[],loading:i,error:o,refetch:()=>a()}}function Ah(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.status&&c.set("status",t.status),t.event_name&&c.set("event_name",t.event_name),t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor);const d=await r(`/webhook/deliveries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.endpoint_id,t.status,t.event_name,t.limit,t.cursor]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.status&&c.set("status",t.status),t.event_name&&c.set("event_name",t.event_name),t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),`wacht-webhook-deliveries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{deliveries:(o==null?void 0:o.data)||[],has_more:(o==null?void 0:o.has_more)||!1,next_cursor:o==null?void 0:o.next_cursor,loading:a,error:i,refetch:()=>u()}}function Lh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.fields&&t.fields.length>0&&c.set("fields",t.fields.join(","));const d=await r(`/webhook/analytics?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.endpoint_id,t.fields]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),t.fields&&t.fields.length>0&&c.set("fields",t.fields.join(",")),`wacht-webhook-analytics?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:o||null,loading:a,error:i,refetch:()=>u()}}function Mh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id);const d=await r(`/webhook/analytics/timeseries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.interval,t.endpoint_id]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.endpoint_id&&c.set("endpoint_id",t.endpoint_id),`wacht-webhook-timeseries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(o==null?void 0:o.data)||[],interval:(o==null?void 0:o.interval)||"hour",loading:a,error:i,refetch:()=>u()}}function Dh(t){const{client:r}=$e(),[n,o]=s.useState(!t),[i,a]=s.useState(!!t),[u,c]=s.useState(null),d=s.useRef(!1),p=s.useRef(!1),l=s.useRef(null),f=n,x=s.useCallback(async()=>{const y=await r("/api-auth/session",{method:"GET"});if(!y.ok)throw y.status===401||y.status===403?new Error("NO_SESSION"):new Error("Failed to fetch API auth app session");return(await N(y)).data},[r]),{data:m,error:v,isLoading:C,mutate:$}=Re(f?"wacht-api-auth-app-session":null,x,{revalidateOnFocus:!1,shouldRetryOnError:!1});s.useEffect(()=>{if(!t||d.current||p.current||l.current===t)return;l.current=t,(async()=>{p.current=!0,a(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(d.current=!0,o(!0)):c(new Error("Failed to exchange ticket"))}catch(b){c(b instanceof Error?b:new Error("Failed to exchange ticket"))}finally{a(!1),p.current=!1}})()},[t,r]);const _=!v||v.message!=="NO_SESSION",k=u||(v&&v.message!=="NO_SESSION"?v:null);return{hasSession:_,sessionLoading:i||f&&C,sessionError:k,sessionId:(m==null?void 0:m.session_id)||null,apiAuthApp:(m==null?void 0:m.api_auth_app)||null,ticketExchanged:n,ticketLoading:i,refetch:async()=>{await $()}}}function Fh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const l=new URLSearchParams;t.status&&l.set("status",t.status);const f=await r(`/api-auth/keys${l.toString()?`?${l.toString()}`:""}`,{method:"GET"});return(await N(f)).data},[r,t.status]),{data:o,error:i,isLoading:a,mutate:u}=Re(`wacht-api-auth-keys:${t.status||"all"}`,n,{revalidateOnFocus:!1,shouldRetryOnError:!1}),c=s.useCallback(async l=>{const f=new URLSearchParams;f.set("name",l.name),l.expires_at&&f.set("expires_at",l.expires_at);const x=await r("/api-auth/keys",{method:"POST",body:f}),m=await N(x);return await u(),m.data},[r,u]),d=s.useCallback(async l=>{const f=await r(`/api-auth/keys/${l.key_id}/rotate`,{method:"POST"}),x=await N(f);return await u(),x.data},[r,u]),p=s.useCallback(async l=>{const f=new URLSearchParams;l.reason&&f.set("reason",l.reason),await r(`/api-auth/keys/${l.key_id}/revoke`,{method:"POST",body:f}),await u()},[r,u]);return{keys:o||[],createKey:c,rotateKey:d,revokeKey:p,loading:a,error:i,refetch:()=>u()}}function Nh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),t.outcome&&c.set("outcome",t.outcome),t.key_id&&c.set("key_id",t.key_id),t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date);const d=await r(`/api-auth/audit/logs?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.limit,t.cursor,t.outcome,t.key_id,t.start_date,t.end_date]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.limit&&c.set("limit",t.limit.toString()),t.cursor&&c.set("cursor",t.cursor),t.outcome&&c.set("outcome",t.outcome),t.key_id&&c.set("key_id",t.key_id),t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),`wacht-api-auth-audit-logs?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{logs:(o==null?void 0:o.data)||[],limit:(o==null?void 0:o.limit)||t.limit||0,has_more:(o==null?void 0:o.has_more)||!1,next_cursor:o==null?void 0:o.next_cursor,loading:a,error:i,refetch:()=>u()}}function Uh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.key_id&&c.set("key_id",t.key_id),t.include_top_keys&&c.set("include_top_keys","true"),t.include_top_paths&&c.set("include_top_paths","true"),t.include_blocked_reasons&&c.set("include_blocked_reasons","true"),t.include_rate_limits&&c.set("include_rate_limits","true"),t.top_limit&&c.set("top_limit",t.top_limit.toString());const d=await r(`/api-auth/audit/analytics?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.key_id,t.include_top_keys,t.include_top_paths,t.include_blocked_reasons,t.include_rate_limits,t.top_limit]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.key_id&&c.set("key_id",t.key_id),t.include_top_keys&&c.set("include_top_keys","true"),t.include_top_paths&&c.set("include_top_paths","true"),t.include_blocked_reasons&&c.set("include_blocked_reasons","true"),t.include_rate_limits&&c.set("include_rate_limits","true"),t.top_limit&&c.set("top_limit",t.top_limit.toString()),`wacht-api-auth-audit-analytics?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:o||null,loading:a,error:i,refetch:()=>u()}}function Bh(t={}){const{client:r}=$e(),n=s.useCallback(async()=>{const c=new URLSearchParams;t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.key_id&&c.set("key_id",t.key_id);const d=await r(`/api-auth/audit/timeseries?${c.toString()}`,{method:"GET"});return(await N(d)).data},[r,t.start_date,t.end_date,t.interval,t.key_id]),{data:o,error:i,isLoading:a,mutate:u}=Re(()=>{const c=new URLSearchParams;return t.start_date&&c.set("start_date",t.start_date),t.end_date&&c.set("end_date",t.end_date),t.interval&&c.set("interval",t.interval),t.key_id&&c.set("key_id",t.key_id),`wacht-api-auth-audit-timeseries?${c.toString()}`},n,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(o==null?void 0:o.data)||[],interval:(o==null?void 0:o.interval)||t.interval||"hour",loading:a,error:i,refetch:()=>u()}}const nd=()=>{const{client:t}=$e(),[r,n]=s.useState(!1),[o,i]=s.useState(null),[a,u]=s.useState(null),c=s.useCallback(async p=>{n(!0),i(null),u(null);try{const l=new FormData;l.append("token",p);const f=await t("/organizations/invitations/accept",{method:"POST",body:l}),m=(await N(f)).data;return u(m),m.error_code&&i(m.message||"Failed to accept invitation"),m}catch(l){const f=l.message||"Failed to accept invitation";i(f);const x={error_code:"NETWORK_ERROR",message:f};return u(x),x}finally{n(!1)}},[t]),d=s.useCallback(()=>{i(null),u(null)},[]);return{acceptInvitation:c,invitationData:a,loading:r,error:o,reset:d}},Wh=({children:t})=>{const{loading:r}=be();return r?null:e.jsx(e.Fragment,{children:t})},Vh=({children:t})=>{const{loading:r}=be();return r?e.jsx(e.Fragment,{children:t}):null};var dt=function(){return dt=Object.assign||function(r){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},dt.apply(this,arguments)};function $r(t,r,n){if(n||arguments.length===2)for(var o=0,i=r.length,a;o<i;o++)(a||!(o in r))&&(a||(a=Array.prototype.slice.call(r,0,o)),a[o]=r[o]);return t.concat(a||Array.prototype.slice.call(r))}function Gh(t){var r=Object.create(null);return function(n){return r[n]===void 0&&(r[n]=t(n)),r[n]}}var Hh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,qh=Gh(function(t){return Hh.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Be="-ms-",mn="-moz-",Ae="-webkit-",od="comm",Eo="rule",la="decl",Yh="@import",Kh="@namespace",id="@keyframes",Qh="@layer",ad=Math.abs,da=String.fromCharCode,Vi=Object.assign;function Zh(t,r){return Ze(t,0)^45?(((r<<2^Ze(t,0))<<2^Ze(t,1))<<2^Ze(t,2))<<2^Ze(t,3):0}function sd(t){return t.trim()}function Wt(t,r){return(t=r.exec(t))?t[0]:t}function ke(t,r,n){return t.replace(r,n)}function so(t,r,n){return t.indexOf(r,n)}function Ze(t,r){return t.charCodeAt(r)|0}function Er(t,r,n){return t.slice(r,n)}function xt(t){return t.length}function cd(t){return t.length}function hn(t,r){return r.push(t),t}function Jh(t,r){return t.map(r).join("")}function rs(t,r){return t.filter(function(n){return!Wt(n,r)})}var zo=1,qr=1,ld=0,ft=0,Ye=0,Xr="";function Po(t,r,n,o,i,a,u,c){return{value:t,root:r,parent:n,type:o,props:i,children:a,line:zo,column:qr,length:u,return:"",siblings:c}}function Jt(t,r){return Vi(Po("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function Or(t){for(;t.root;)t=Jt(t.root,{children:[t]});hn(t,t.siblings)}function Xh(){return Ye}function ef(){return Ye=ft>0?Ze(Xr,--ft):0,qr--,Ye===10&&(qr=1,zo--),Ye}function bt(){return Ye=ft<ld?Ze(Xr,ft++):0,qr++,Ye===10&&(qr=1,zo++),Ye}function tr(){return Ze(Xr,ft)}function co(){return ft}function Ro(t,r){return Er(Xr,t,r)}function bn(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function tf(t){return zo=qr=1,ld=xt(Xr=t),ft=0,[]}function rf(t){return Xr="",t}function Xo(t){return sd(Ro(ft-1,Gi(t===91?t+2:t===40?t+1:t)))}function nf(t){for(;(Ye=tr())&&Ye<33;)bt();return bn(t)>2||bn(Ye)>3?"":" "}function of(t,r){for(;--r&&bt()&&!(Ye<48||Ye>102||Ye>57&&Ye<65||Ye>70&&Ye<97););return Ro(t,co()+(r<6&&tr()==32&&bt()==32))}function Gi(t){for(;bt();)switch(Ye){case t:return ft;case 34:case 39:t!==34&&t!==39&&Gi(Ye);break;case 40:t===41&&Gi(t);break;case 92:bt();break}return ft}function af(t,r){for(;bt()&&t+Ye!==57;)if(t+Ye===84&&tr()===47)break;return"/*"+Ro(r,ft-1)+"*"+da(t===47?t:bt())}function sf(t){for(;!bn(tr());)bt();return Ro(t,ft)}function cf(t){return rf(lo("",null,null,null,[""],t=tf(t),0,[0],t))}function lo(t,r,n,o,i,a,u,c,d){for(var p=0,l=0,f=u,x=0,m=0,v=0,C=1,$=1,_=1,k=0,R="",y=i,b=a,S=o,g=R;$;)switch(v=k,k=bt()){case 40:if(v!=108&&Ze(g,f-1)==58){so(g+=ke(Xo(k),"&","&\f"),"&\f",ad(p?c[p-1]:0))!=-1&&(_=-1);break}case 34:case 39:case 91:g+=Xo(k);break;case 9:case 10:case 13:case 32:g+=nf(v);break;case 92:g+=of(co()-1,7);continue;case 47:switch(tr()){case 42:case 47:hn(lf(af(bt(),co()),r,n,d),d),(bn(v||1)==5||bn(tr()||1)==5)&&xt(g)&&Er(g,-1,void 0)!==" "&&(g+=" ");break;default:g+="/"}break;case 123*C:c[p++]=xt(g)*_;case 125*C:case 59:case 0:switch(k){case 0:case 125:$=0;case 59+l:_==-1&&(g=ke(g,/\f/g,"")),m>0&&(xt(g)-f||C===0&&v===47)&&hn(m>32?os(g+";",o,n,f-1,d):os(ke(g," ","")+";",o,n,f-2,d),d);break;case 59:g+=";";default:if(hn(S=ns(g,r,n,p,l,i,c,R,y=[],b=[],f,a),a),k===123)if(l===0)lo(g,r,S,S,y,a,f,c,b);else{switch(x){case 99:if(Ze(g,3)===110)break;case 108:if(Ze(g,2)===97)break;default:l=0;case 100:case 109:case 115:}l?lo(t,S,S,o&&hn(ns(t,S,S,0,0,i,c,R,i,y=[],f,b),b),i,b,f,c,o?y:b):lo(g,S,S,S,[""],b,0,c,b)}}p=l=m=0,C=_=1,R=g="",f=u;break;case 58:f=1+xt(g),m=v;default:if(C<1){if(k==123)--C;else if(k==125&&C++==0&&ef()==125)continue}switch(g+=da(k),k*C){case 38:_=l>0?1:(g+="\f",-1);break;case 44:c[p++]=(xt(g)-1)*_,_=1;break;case 64:tr()===45&&(g+=Xo(bt())),x=tr(),l=f=xt(R=g+=sf(co())),k++;break;case 45:v===45&&xt(g)==2&&(C=0)}}return a}function ns(t,r,n,o,i,a,u,c,d,p,l,f){for(var x=i-1,m=i===0?a:[""],v=cd(m),C=0,$=0,_=0;C<o;++C)for(var k=0,R=Er(t,x+1,x=ad($=u[C])),y=t;k<v;++k)(y=sd($>0?m[k]+" "+R:ke(R,/&\f/g,m[k])))&&(d[_++]=y);return Po(t,r,n,i===0?Eo:c,d,p,l,f)}function lf(t,r,n,o){return Po(t,r,n,od,da(Xh()),Er(t,2,-2),0,o)}function os(t,r,n,o,i){return Po(t,r,n,la,Er(t,0,o),Er(t,o+1,-1),o,i)}function dd(t,r,n){switch(Zh(t,r)){case 5103:return Ae+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Ae+t+t;case 4855:return Ae+t.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+t;case 4789:return mn+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Ae+t+mn+t+Be+t+t;case 5936:switch(Ze(t,r+11)){case 114:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Ae+t+Be+ke(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Ae+t+Be+t+t;case 6165:return Ae+t+Be+"flex-"+t+t;case 5187:return Ae+t+ke(t,/(\w+).+(:[^]+)/,Ae+"box-$1$2"+Be+"flex-$1$2")+t;case 5443:return Ae+t+Be+"flex-item-"+ke(t,/flex-|-self/g,"")+(Wt(t,/flex-|baseline/)?"":Be+"grid-row-"+ke(t,/flex-|-self/g,""))+t;case 4675:return Ae+t+Be+"flex-line-pack"+ke(t,/align-content|flex-|-self/g,"")+t;case 5548:return Ae+t+Be+ke(t,"shrink","negative")+t;case 5292:return Ae+t+Be+ke(t,"basis","preferred-size")+t;case 6060:return Ae+"box-"+ke(t,"-grow","")+Ae+t+Be+ke(t,"grow","positive")+t;case 4554:return Ae+ke(t,/([^-])(transform)/g,"$1"+Ae+"$2")+t;case 6187:return ke(ke(ke(t,/(zoom-|grab)/,Ae+"$1"),/(image-set)/,Ae+"$1"),t,"")+t;case 5495:case 3959:return ke(t,/(image-set\([^]*)/,Ae+"$1$`$1");case 4968:return ke(ke(t,/(.+:)(flex-)?(.*)/,Ae+"box-pack:$3"+Be+"flex-pack:$3"),/space-between/,"justify")+Ae+t+t;case 4200:if(!Wt(t,/flex-|baseline/))return Be+"grid-column-align"+Er(t,r)+t;break;case 2592:case 3360:return Be+ke(t,"template-","")+t;case 4384:case 3616:return n&&n.some(function(o,i){return r=i,Wt(o.props,/grid-\w+-end/)})?~so(t+(n=n[r].value),"span",0)?t:Be+ke(t,"-start","")+t+Be+"grid-row-span:"+(~so(n,"span",0)?Wt(n,/\d+/):+Wt(n,/\d+/)-+Wt(t,/\d+/))+";":Be+ke(t,"-start","")+t;case 4896:case 4128:return n&&n.some(function(o){return Wt(o.props,/grid-\w+-start/)})?t:Be+ke(ke(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ke(t,/(.+)-inline(.+)/,Ae+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(xt(t)-1-r>6)switch(Ze(t,r+1)){case 109:if(Ze(t,r+4)!==45)break;case 102:return ke(t,/(.+:)(.+)-([^]+)/,"$1"+Ae+"$2-$3$1"+mn+(Ze(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~so(t,"stretch",0)?dd(ke(t,"stretch","fill-available"),r,n)+t:t}break;case 5152:case 5920:return ke(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(o,i,a,u,c,d,p){return Be+i+":"+a+p+(u?Be+i+"-span:"+(c?d:+d-+a)+p:"")+t});case 4949:if(Ze(t,r+6)===121)return ke(t,":",":"+Ae)+t;break;case 6444:switch(Ze(t,Ze(t,14)===45?18:11)){case 120:return ke(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ae+(Ze(t,14)===45?"inline-":"")+"box$3$1"+Ae+"$2$3$1"+Be+"$2box$3")+t;case 100:return ke(t,":",":"+Be)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ke(t,"scroll-","scroll-snap-")+t}return t}function xo(t,r){for(var n="",o=0;o<t.length;o++)n+=r(t[o],o,t,r)||"";return n}function df(t,r,n,o){switch(t.type){case Qh:if(t.children.length)break;case Yh:case Kh:case la:return t.return=t.return||t.value;case od:return"";case id:return t.return=t.value+"{"+xo(t.children,o)+"}";case Eo:if(!xt(t.value=t.props.join(",")))return""}return xt(n=xo(t.children,o))?t.return=t.value+"{"+n+"}":""}function uf(t){var r=cd(t);return function(n,o,i,a){for(var u="",c=0;c<r;c++)u+=t[c](n,o,i,a)||"";return u}}function pf(t){return function(r){r.root||(r=r.return)&&t(r)}}function hf(t,r,n,o){if(t.length>-1&&!t.return)switch(t.type){case la:t.return=dd(t.value,t.length,n);return;case id:return xo([Jt(t,{value:ke(t.value,"@","@"+Ae)})],o);case Eo:if(t.length)return Jh(n=t.props,function(i){switch(Wt(i,o=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Or(Jt(t,{props:[ke(i,/:(read-\w+)/,":"+mn+"$1")]})),Or(Jt(t,{props:[i]})),Vi(t,{props:rs(n,o)});break;case"::placeholder":Or(Jt(t,{props:[ke(i,/:(plac\w+)/,":"+Ae+"input-$1")]})),Or(Jt(t,{props:[ke(i,/:(plac\w+)/,":"+mn+"$1")]})),Or(Jt(t,{props:[ke(i,/:(plac\w+)/,Be+"input-$1")]})),Or(Jt(t,{props:[i]})),Vi(t,{props:rs(n,o)});break}return""})}}var ff={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},zr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",ud="active",pd="data-styled-version",Io="6.3.11",ua=`/*!sc*/
|
|
19
19
|
`,xn=typeof window<"u"&&typeof document<"u",gf=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),mf=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
|
|
20
20
|
|
|
21
21
|
`,2:`Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
|
|
@@ -61,7 +61,7 @@ Has styled-components' style tag been unmounted or altered by another script?
|
|
|
61
61
|
`)+`You may see this warning because you've called styled inside another component.
|
|
62
62
|
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
63
63
|
See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
|
|
64
|
-
`,i=console.error;try{var a=!0;console.error=function(u){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];is.test(u)?(a=!1,Pn.delete(o)):i.apply(void 0,$r([u],c,!1))},typeof s.useState=="function"&&s.useState(null),a&&!Pn.has(o)&&(console.warn(o),Pn.add(o))}catch(u){is.test(u.message)&&Pn.delete(o)}finally{console.error=i}}},pa=Object.freeze([]),Yr=Object.freeze({});function wf(t,r,n){return n===void 0&&(n=Yr),t.theme!==n.theme&&t.theme||r||n.theme}var Hi=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]),jf=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,_f=/(^-|-$)/g;function as(t){return t.replace(jf,"-").replace(_f,"")}var kf=/(a)(d)/gi,ss=function(t){return String.fromCharCode(t+(t>25?39:97))};function qi(t){var r,n="";for(r=Math.abs(t);r>52;r=r/52|0)n=ss(r%52)+n;return(ss(r%52)+n).replace(kf,"$1-$2")}var ei,er=function(t,r){for(var n=r.length;n;)t=33*t^r.charCodeAt(--n);return t},hd=function(t){return er(5381,t)};function fd(t){return qi(hd(t)>>>0)}function gd(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function ti(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var md=typeof Symbol=="function"&&Symbol.for,xd=md?Symbol.for("react.memo"):60115,Cf=md?Symbol.for("react.forward_ref"):60112,Sf={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},$f={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},vd={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ef=((ei={})[Cf]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ei[xd]=vd,ei);function cs(t){return("type"in(r=t)&&r.type.$$typeof)===xd?vd:"$$typeof"in t?Ef[t.$$typeof]:Sf;var r}var zf=Object.defineProperty,Pf=Object.getOwnPropertyNames,ls=Object.getOwnPropertySymbols,Rf=Object.getOwnPropertyDescriptor,If=Object.getPrototypeOf,ds=Object.prototype;function yd(t,r,n){if(typeof r!="string"){if(ds){var o=If(r);o&&o!==ds&&yd(t,o,n)}var i=Pf(r);ls&&(i=i.concat(ls(r)));for(var a=cs(t),u=cs(r),c=0;c<i.length;++c){var d=i[c];if(!(d in $f||n&&n[d]||u&&d in u||a&&d in a)){var p=Rf(r,d);try{zf(t,d,p)}catch{}}}}return t}function Kr(t){return typeof t=="function"}function ha(t){return typeof t=="object"&&"styledComponentId"in t}function _r(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function Yi(t,r){return t.join("")}function Qr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function Ki(t,r,n){if(n===void 0&&(n=!1),!n&&!Qr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var o=0;o<r.length;o++)t[o]=Ki(t[o],r[o]);else if(Qr(r))for(var o in r)t[o]=Ki(t[o],r[o]);return t}function fa(t,r){Object.defineProperty(t,"toString",{value:r})}var Tf=(function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r,this._cGroup=0,this._cIndex=0}return t.prototype.indexOfGroup=function(r){if(r===this._cGroup)return this._cIndex;var n=this._cIndex;if(r>this._cGroup)for(var o=this._cGroup;o<r;o++)n+=this.groupSizes[o];else for(o=this._cGroup-1;o>=r;o--)n-=this.groupSizes[o];return this._cGroup=r,this._cIndex=n,n},t.prototype.insertRules=function(r,n){if(r>=this.groupSizes.length){for(var o=this.groupSizes,i=o.length,a=i;r>=a;)if((a<<=1)<0)throw en(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(o),this.length=a;for(var u=i;u<a;u++)this.groupSizes[u]=0}for(var c=this.indexOfGroup(r+1),d=0,p=(u=0,n.length);u<p;u++)this.tag.insertRule(c,n[u])&&(this.groupSizes[r]++,c++,d++);d>0&&this._cGroup>r&&(this._cIndex+=d)},t.prototype.clearGroup=function(r){if(r<this.length){var n=this.groupSizes[r],o=this.indexOfGroup(r),i=o+n;this.groupSizes[r]=0;for(var a=o;a<i;a++)this.tag.deleteRule(o);n>0&&this._cGroup>r&&(this._cIndex-=n)}},t.prototype.getGroup=function(r){var n="";if(r>=this.length||this.groupSizes[r]===0)return n;for(var o=this.groupSizes[r],i=this.indexOfGroup(r),a=i+o,u=i;u<a;u++)n+=this.tag.getRule(u)+ua;return n},t})(),Of="style[".concat(zr,"][").concat(pd,'="').concat(Io,'"]'),Af=new RegExp("^".concat(zr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),us=function(t){return typeof ShadowRoot<"u"&&t instanceof ShadowRoot||"host"in t&&t.nodeType===11},Qi=function(t){if(!t)return document;if(us(t))return t;if("getRootNode"in t){var r=t.getRootNode();if(us(r))return r}return document},Lf=function(t,r,n){for(var o,i=n.split(","),a=0,u=i.length;a<u;a++)(o=i[a])&&t.registerName(r,o)},Mf=function(t,r){for(var n,o=((n=r.textContent)!==null&&n!==void 0?n:"").split(ua),i=[],a=0,u=o.length;a<u;a++){var c=o[a].trim();if(c){var d=c.match(Af);if(d){var p=0|parseInt(d[1],10),l=d[2];p!==0&&(yf(l,p),Lf(t,l,d[3]),t.getTag().insertRules(p,i)),i.length=0}else i.push(c)}}},ri=function(t){for(var r=Qi(t.options.target).querySelectorAll(Of),n=0,o=r.length;n<o;n++){var i=r[n];i&&i.getAttribute(zr)!==ud&&(Mf(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function Df(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var bd=function(t){var r=document.head,n=t||r,o=document.createElement("style"),i=(function(c){var d=Array.from(c.querySelectorAll("style[".concat(zr,"]")));return d[d.length-1]})(n),a=i!==void 0?i.nextSibling:null;o.setAttribute(zr,ud),o.setAttribute(pd,Io);var u=Df();return u&&o.setAttribute("nonce",u),n.insertBefore(o,a),o},Ff=(function(){function t(r){this.element=bd(r),this.element.appendChild(document.createTextNode("")),this.sheet=(function(n){var o;if(n.sheet)return n.sheet;for(var i=(o=n.getRootNode().styleSheets)!==null&&o!==void 0?o:document.styleSheets,a=0,u=i.length;a<u;a++){var c=i[a];if(c.ownerNode===n)return c}throw en(17)})(this.element),this.length=0}return t.prototype.insertRule=function(r,n){try{return this.sheet.insertRule(n,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var n=this.sheet.cssRules[r];return n&&n.cssText?n.cssText:""},t})(),Nf=(function(){function t(r){this.element=bd(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,n){if(r<=this.length&&r>=0){var o=document.createTextNode(n);return this.element.insertBefore(o,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t})(),Uf=(function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,n){return r<=this.length&&(r===this.length?this.rules.push(n):this.rules.splice(r,0,n),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t})(),ps=xn,Bf={isServer:!xn,useCSSOMInjection:!gf},wd=(function(){function t(r,n,o){r===void 0&&(r=Yr),n===void 0&&(n={});var i=this;this.options=dt(dt({},Bf),r),this.gs=n,this.names=new Map(o),this.server=!!r.isServer,!this.server&&xn&&ps&&(ps=!1,ri(this)),fa(this,function(){return(function(a){for(var u=a.getTag(),c=u.length,d="",p=function(f){var m=(function(_){return vo.get(_)})(f);if(m===void 0)return"continue";var x=a.names.get(m);if(x===void 0||!x.size)return"continue";var v=u.getGroup(f);if(v.length===0)return"continue";var $=zr+".g"+f+'[id="'+m+'"]',S="";x.forEach(function(_){_.length>0&&(S+=_+",")}),d+=v+$+'{content:"'+S+'"}'+ua},l=0;l<c;l++)p(l);return d})(i)})}return t.registerId=function(r){return fn(r)},t.prototype.rehydrate=function(){!this.server&&xn&&ri(this)},t.prototype.reconstructWithOptions=function(r,n){n===void 0&&(n=!0);var o=new t(dt(dt({},this.options),r),this.gs,n&&this.names||void 0);return!this.server&&xn&&r.target!==this.options.target&&Qi(this.options.target)!==Qi(r.target)&&ri(o),o},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=(function(n){var o=n.useCSSOMInjection,i=n.target;return n.isServer?new Uf(i):o?new Ff(i):new Nf(i)})(this.options),new Tf(r)));var r},t.prototype.hasNameForId=function(r,n){var o,i;return(i=(o=this.names.get(r))===null||o===void 0?void 0:o.has(n))!==null&&i!==void 0&&i},t.prototype.registerName=function(r,n){fn(r);var o=this.names.get(r);o?o.add(n):this.names.set(r,new Set([n]))},t.prototype.insertRules=function(r,n,o){this.registerName(r,n),this.getTag().insertRules(fn(r),o)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(fn(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t})(),Wf=/&/g,Vt=47,wr=42;function hs(t){if(t.indexOf("}")===-1)return!1;for(var r=t.length,n=0,o=0,i=!1,a=0;a<r;a++){var u=t.charCodeAt(a);if(o!==0||i||u!==Vt||t.charCodeAt(a+1)!==wr)if(i)u===wr&&t.charCodeAt(a+1)===Vt&&(i=!1,a++);else if(u!==34&&u!==39||a!==0&&t.charCodeAt(a-1)===92){if(o===0){if(u===123)n++;else if(u===125&&--n<0)return!0}}else o===0?o=u:o===u&&(o=0);else i=!0,a++}return n!==0||o!==0}function jd(t,r){return t.map(function(n){return n.type==="rule"&&(n.value="".concat(r," ").concat(n.value),n.value=n.value.replaceAll(",",",".concat(r," ")),n.props=n.props.map(function(o){return"".concat(r," ").concat(o)})),Array.isArray(n.children)&&n.type!=="@keyframes"&&(n.children=jd(n.children,r)),n})}function Vf(t){var r,n,o,i=Yr,a=i.options,u=a===void 0?Yr:a,c=i.plugins,d=c===void 0?pa:c,p=function(v,$,S){return S.startsWith(n)&&S.endsWith(n)&&S.replaceAll(n,"").length>0?".".concat(r):v},l=d.slice();l.push(function(v){v.type===Eo&&v.value.includes("&")&&(o||(o=new RegExp("\\".concat(n,"\\b"),"g")),v.props[0]=v.props[0].replace(Wf,n).replace(o,p))}),u.prefix&&l.push(hf),l.push(df);var f=[],m=uf(l.concat(pf(function(v){return f.push(v)}))),x=function(v,$,S,_){$===void 0&&($=""),S===void 0&&(S=""),_===void 0&&(_="&"),r=_,n=$,o=void 0;var k=(function(y){if(!hs(y))return y;for(var b=y.length,C="",g=0,j=0,w=0,E=!1,I=0;I<b;I++){var O=y.charCodeAt(I);if(w!==0||E||O!==Vt||y.charCodeAt(I+1)!==wr)if(E)O===wr&&y.charCodeAt(I+1)===Vt&&(E=!1,I++);else if(O!==34&&O!==39||I!==0&&y.charCodeAt(I-1)===92){if(w===0)if(O===123)j++;else if(O===125){if(--j<0){for(var z=I+1;z<b;){var T=y.charCodeAt(z);if(T===59||T===10)break;z++}z<b&&y.charCodeAt(z)===59&&z++,j=0,I=z-1,g=z;continue}j===0&&(C+=y.substring(g,I+1),g=I+1)}else O===59&&j===0&&(C+=y.substring(g,I+1),g=I+1)}else w===0?w=O:w===O&&(w=0);else E=!0,I++}if(g<b){var D=y.substring(g);hs(D)||(C+=D)}return C})((function(y){if(y.indexOf("//")===-1)return y;for(var b=y.length,C=[],g=0,j=0,w=0,E=0;j<b;){var I=y.charCodeAt(j);if(I!==34&&I!==39||j!==0&&y.charCodeAt(j-1)===92)if(w===0)if(I===Vt&&j+1<b&&y.charCodeAt(j+1)===wr){for(j+=2;j+1<b&&(y.charCodeAt(j)!==wr||y.charCodeAt(j+1)!==Vt);)j++;j+=2}else if(I===40&&j>=3&&(32|y.charCodeAt(j-1))==108&&(32|y.charCodeAt(j-2))==114&&(32|y.charCodeAt(j-3))==117)E=1,j++;else if(E>0)I===41?E--:I===40&&E++,j++;else if(I===wr&&j+1<b&&y.charCodeAt(j+1)===Vt)j>g&&C.push(y.substring(g,j)),g=j+=2;else if(I===Vt&&j+1<b&&y.charCodeAt(j+1)===Vt){for(j>g&&C.push(y.substring(g,j));j<b&&y.charCodeAt(j)!==10;)j++;g=j}else j++;else j++;else w===0?w=I:w===I&&(w=0),j++}return g===0?y:(g<b&&C.push(y.substring(g)),C.join(""))})(v)),P=cf(S||$?"".concat(S," ").concat($," { ").concat(k," }"):k);return u.namespace&&(P=jd(P,u.namespace)),f=[],xo(P,m),f};return x.hash=d.length?d.reduce(function(v,$){return $.name||en(15),er(v,$.name)},5381).toString():"",x}var Gf=new wd,Zi=Vf(),_d=s.createContext({shouldForwardProp:void 0,styleSheet:Gf,stylis:Zi});_d.Consumer;s.createContext(void 0);function fs(){return s.useContext(_d)}var Ji=(function(){function t(r,n){var o=this;this.inject=function(i,a){a===void 0&&(a=Zi);var u=o.name+a.hash;i.hasNameForId(o.id,u)||i.insertRules(o.id,u,a(o.rules,u,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=n,fa(this,function(){throw en(12,String(o.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=Zi),this.name+r.hash},t})();function Hf(t,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||t in ff||t.startsWith("--")?String(r).trim():"".concat(r,"px")}var qf=function(t){return t>="A"&&t<="Z"};function gs(t){for(var r="",n=0;n<t.length;n++){var o=t[n];if(n===1&&o==="-"&&t[0]==="-")return t;qf(o)?r+="-"+o.toLowerCase():r+=o}return r.startsWith("ms-")?"-"+r:r}var kd=function(t){return t==null||t===!1||t===""},Cd=function(t){var r=[];for(var n in t){var o=t[n];t.hasOwnProperty(n)&&!kd(o)&&(Array.isArray(o)&&o.isCss||Kr(o)?r.push("".concat(gs(n),":"),o,";"):Qr(o)?r.push.apply(r,$r($r(["".concat(n," {")],Cd(o),!1),["}"],!1)):r.push("".concat(gs(n),": ").concat(Hf(n,o),";")))}return r};function kr(t,r,n,o,i){if(i===void 0&&(i=[]),typeof t=="string")return t&&i.push(t),i;if(kd(t))return i;if(ha(t))return i.push(".".concat(t.styledComponentId)),i;if(Kr(t)){if(!Kr(u=t)||u.prototype&&u.prototype.isReactComponent||!r)return i.push(t),i;var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof Ji||Qr(a)||a===null||console.error("".concat(gd(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),kr(a,r,n,o,i)}var u;if(t instanceof Ji)return n?(t.inject(n,o),i.push(t.getName(o))):i.push(t),i;if(Qr(t)){for(var c=Cd(t),d=0;d<c.length;d++)i.push(c[d]);return i}if(!Array.isArray(t))return i.push(t.toString()),i;for(d=0;d<t.length;d++)kr(t[d],r,n,o,i);return i}function Yf(t){for(var r=0;r<t.length;r+=1){var n=t[r];if(Kr(n)&&!ha(n))return!1}return!0}var Kf=hd(Io),Qf=(function(){function t(r,n,o){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(o===void 0||o.isStatic)&&Yf(r),this.componentId=n,this.baseHash=er(Kf,n),this.baseStyle=o,wd.registerId(n)}return t.prototype.generateAndInjectStyles=function(r,n,o){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,n,o).className:"";if(this.isStatic&&!o.hash)if(this.staticRulesId&&n.hasNameForId(this.componentId,this.staticRulesId))i=_r(i,this.staticRulesId);else{var a=Yi(kr(this.rules,r,n,o)),u=qi(er(this.baseHash,a)>>>0);if(!n.hasNameForId(this.componentId,u)){var c=o(a,".".concat(u),void 0,this.componentId);n.insertRules(this.componentId,u,c)}i=_r(i,u),this.staticRulesId=u}else{for(var d=er(this.baseHash,o.hash),p="",l=0;l<this.rules.length;l++){var f=this.rules[l];if(typeof f=="string")p+=f,process.env.NODE_ENV!=="production"&&(d=er(d,f));else if(f){var m=Yi(kr(f,r,n,o));d=er(er(d,String(l)),m),p+=m}}if(p){var x=qi(d>>>0);if(!n.hasNameForId(this.componentId,x)){var v=o(p,".".concat(x),void 0,this.componentId);n.insertRules(this.componentId,x,v)}i=_r(i,x)}}return{className:i,css:typeof window>"u"?n.getTag().getGroup(fn(this.componentId)):""}},t})(),Sd=s.createContext(void 0);Sd.Consumer;var ni={},ms=new Set;function Zf(t,r,n){var o=ha(t),i=t,a=!ti(t),u=r.attrs,c=u===void 0?pa:u,d=r.componentId,p=d===void 0?(function(y,b){var C=typeof y!="string"?"sc":as(y);ni[C]=(ni[C]||0)+1;var g="".concat(C,"-").concat(fd(Io+C+ni[C]));return b?"".concat(b,"-").concat(g):g})(r.displayName,r.parentComponentId):d,l=r.displayName,f=l===void 0?(function(y){return ti(y)?"styled.".concat(y):"Styled(".concat(gd(y),")")})(t):l,m=r.displayName&&r.componentId?"".concat(as(r.displayName),"-").concat(r.componentId):r.componentId||p,x=o&&i.attrs?i.attrs.concat(c).filter(Boolean):c,v=r.shouldForwardProp;if(o&&i.shouldForwardProp){var $=i.shouldForwardProp;if(r.shouldForwardProp){var S=r.shouldForwardProp;v=function(y,b){return $(y,b)&&S(y,b)}}else v=$}var _=new Qf(n,m,o?i.componentStyle:void 0);function k(y,b){return(function(C,g,j){var w=C.attrs,E=C.componentStyle,I=C.defaultProps,O=C.foldedComponentIds,z=C.styledComponentId,T=C.target,D=s.useContext(Sd),F=fs(),M=C.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&s.useDebugValue&&s.useDebugValue(z);var L=wf(g,D,I)||Yr,A=(function(ge,pe,Q){for(var he,X=dt(dt({},pe),{className:void 0,theme:Q}),Oe=0;Oe<ge.length;Oe+=1){var se=Kr(he=ge[Oe])?he(X):he;for(var ce in se)ce==="className"?X.className=_r(X.className,se[ce]):ce==="style"?X.style=dt(dt({},X.style),se[ce]):X[ce]=se[ce]}return"className"in pe&&typeof pe.className=="string"&&(X.className=_r(X.className,pe.className)),X})(w,g,L),R=A.as||T,U={};for(var V in A)A[V]===void 0||V[0]==="$"||V==="as"||V==="theme"&&A.theme===L||(V==="forwardedAs"?U.as=A.forwardedAs:M&&!M(V,R)||(U[V]=A[V],M||process.env.NODE_ENV!=="development"||qh(V)||ms.has(V)||!Hi.has(R)||(ms.add(V),console.warn('styled-components: it looks like an unknown prop "'.concat(V,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var H=(function(ge,pe){var Q=fs(),he=ge.generateAndInjectStyles(pe,Q.styleSheet,Q.stylis);return process.env.NODE_ENV!=="production"&&s.useDebugValue&&s.useDebugValue(he.className),he})(E,A),ae=H.className;process.env.NODE_ENV!=="production"&&C.warnTooManyClasses&&C.warnTooManyClasses(ae);var ee=_r(O,z);return ae&&(ee+=" "+ae),A.className&&(ee+=" "+A.className),U[ti(R)&&!Hi.has(R)?"class":"className"]=ee,j&&(U.ref=j),s.createElement(R,U)})(P,y,b)}k.displayName=f;var P=s.forwardRef(k);return P.attrs=x,P.componentStyle=_,P.displayName=f,P.shouldForwardProp=v,P.foldedComponentIds=o?_r(i.foldedComponentIds,i.styledComponentId):"",P.styledComponentId=m,P.target=o?i.target:t,Object.defineProperty(P,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(y){this._foldedDefaultProps=o?(function(b){for(var C=[],g=1;g<arguments.length;g++)C[g-1]=arguments[g];for(var j=0,w=C;j<w.length;j++)Ki(b,w[j],!0);return b})({},i.defaultProps,y):y}}),process.env.NODE_ENV!=="production"&&(bf(f,m),P.warnTooManyClasses=(function(y,b){var C={},g=!1;return function(j){if(!g&&(C[j]=!0,Object.keys(C).length>=200)){var w=b?' with the id of "'.concat(b,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(y).concat(w,`.
|
|
64
|
+
`,i=console.error;try{var a=!0;console.error=function(u){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];is.test(u)?(a=!1,Pn.delete(o)):i.apply(void 0,$r([u],c,!1))},typeof s.useState=="function"&&s.useState(null),a&&!Pn.has(o)&&(console.warn(o),Pn.add(o))}catch(u){is.test(u.message)&&Pn.delete(o)}finally{console.error=i}}},pa=Object.freeze([]),Yr=Object.freeze({});function wf(t,r,n){return n===void 0&&(n=Yr),t.theme!==n.theme&&t.theme||r||n.theme}var Hi=new Set(["a","abbr","address","area","article","aside","audio","b","bdi","bdo","blockquote","body","button","br","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","slot","small","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","tspan","use"]),jf=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,_f=/(^-|-$)/g;function as(t){return t.replace(jf,"-").replace(_f,"")}var kf=/(a)(d)/gi,ss=function(t){return String.fromCharCode(t+(t>25?39:97))};function qi(t){var r,n="";for(r=Math.abs(t);r>52;r=r/52|0)n=ss(r%52)+n;return(ss(r%52)+n).replace(kf,"$1-$2")}var ei,er=function(t,r){for(var n=r.length;n;)t=33*t^r.charCodeAt(--n);return t},hd=function(t){return er(5381,t)};function fd(t){return qi(hd(t)>>>0)}function gd(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function ti(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var md=typeof Symbol=="function"&&Symbol.for,xd=md?Symbol.for("react.memo"):60115,Cf=md?Symbol.for("react.forward_ref"):60112,Sf={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},$f={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},vd={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ef=((ei={})[Cf]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},ei[xd]=vd,ei);function cs(t){return("type"in(r=t)&&r.type.$$typeof)===xd?vd:"$$typeof"in t?Ef[t.$$typeof]:Sf;var r}var zf=Object.defineProperty,Pf=Object.getOwnPropertyNames,ls=Object.getOwnPropertySymbols,Rf=Object.getOwnPropertyDescriptor,If=Object.getPrototypeOf,ds=Object.prototype;function yd(t,r,n){if(typeof r!="string"){if(ds){var o=If(r);o&&o!==ds&&yd(t,o,n)}var i=Pf(r);ls&&(i=i.concat(ls(r)));for(var a=cs(t),u=cs(r),c=0;c<i.length;++c){var d=i[c];if(!(d in $f||n&&n[d]||u&&d in u||a&&d in a)){var p=Rf(r,d);try{zf(t,d,p)}catch{}}}}return t}function Kr(t){return typeof t=="function"}function ha(t){return typeof t=="object"&&"styledComponentId"in t}function _r(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function Yi(t,r){return t.join("")}function Qr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function Ki(t,r,n){if(n===void 0&&(n=!1),!n&&!Qr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var o=0;o<r.length;o++)t[o]=Ki(t[o],r[o]);else if(Qr(r))for(var o in r)t[o]=Ki(t[o],r[o]);return t}function fa(t,r){Object.defineProperty(t,"toString",{value:r})}var Tf=(function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r,this._cGroup=0,this._cIndex=0}return t.prototype.indexOfGroup=function(r){if(r===this._cGroup)return this._cIndex;var n=this._cIndex;if(r>this._cGroup)for(var o=this._cGroup;o<r;o++)n+=this.groupSizes[o];else for(o=this._cGroup-1;o>=r;o--)n-=this.groupSizes[o];return this._cGroup=r,this._cIndex=n,n},t.prototype.insertRules=function(r,n){if(r>=this.groupSizes.length){for(var o=this.groupSizes,i=o.length,a=i;r>=a;)if((a<<=1)<0)throw en(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(o),this.length=a;for(var u=i;u<a;u++)this.groupSizes[u]=0}for(var c=this.indexOfGroup(r+1),d=0,p=(u=0,n.length);u<p;u++)this.tag.insertRule(c,n[u])&&(this.groupSizes[r]++,c++,d++);d>0&&this._cGroup>r&&(this._cIndex+=d)},t.prototype.clearGroup=function(r){if(r<this.length){var n=this.groupSizes[r],o=this.indexOfGroup(r),i=o+n;this.groupSizes[r]=0;for(var a=o;a<i;a++)this.tag.deleteRule(o);n>0&&this._cGroup>r&&(this._cIndex-=n)}},t.prototype.getGroup=function(r){var n="";if(r>=this.length||this.groupSizes[r]===0)return n;for(var o=this.groupSizes[r],i=this.indexOfGroup(r),a=i+o,u=i;u<a;u++)n+=this.tag.getRule(u)+ua;return n},t})(),Of="style[".concat(zr,"][").concat(pd,'="').concat(Io,'"]'),Af=new RegExp("^".concat(zr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),us=function(t){return typeof ShadowRoot<"u"&&t instanceof ShadowRoot||"host"in t&&t.nodeType===11},Qi=function(t){if(!t)return document;if(us(t))return t;if("getRootNode"in t){var r=t.getRootNode();if(us(r))return r}return document},Lf=function(t,r,n){for(var o,i=n.split(","),a=0,u=i.length;a<u;a++)(o=i[a])&&t.registerName(r,o)},Mf=function(t,r){for(var n,o=((n=r.textContent)!==null&&n!==void 0?n:"").split(ua),i=[],a=0,u=o.length;a<u;a++){var c=o[a].trim();if(c){var d=c.match(Af);if(d){var p=0|parseInt(d[1],10),l=d[2];p!==0&&(yf(l,p),Lf(t,l,d[3]),t.getTag().insertRules(p,i)),i.length=0}else i.push(c)}}},ri=function(t){for(var r=Qi(t.options.target).querySelectorAll(Of),n=0,o=r.length;n<o;n++){var i=r[n];i&&i.getAttribute(zr)!==ud&&(Mf(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function Df(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var bd=function(t){var r=document.head,n=t||r,o=document.createElement("style"),i=(function(c){var d=Array.from(c.querySelectorAll("style[".concat(zr,"]")));return d[d.length-1]})(n),a=i!==void 0?i.nextSibling:null;o.setAttribute(zr,ud),o.setAttribute(pd,Io);var u=Df();return u&&o.setAttribute("nonce",u),n.insertBefore(o,a),o},Ff=(function(){function t(r){this.element=bd(r),this.element.appendChild(document.createTextNode("")),this.sheet=(function(n){var o;if(n.sheet)return n.sheet;for(var i=(o=n.getRootNode().styleSheets)!==null&&o!==void 0?o:document.styleSheets,a=0,u=i.length;a<u;a++){var c=i[a];if(c.ownerNode===n)return c}throw en(17)})(this.element),this.length=0}return t.prototype.insertRule=function(r,n){try{return this.sheet.insertRule(n,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var n=this.sheet.cssRules[r];return n&&n.cssText?n.cssText:""},t})(),Nf=(function(){function t(r){this.element=bd(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,n){if(r<=this.length&&r>=0){var o=document.createTextNode(n);return this.element.insertBefore(o,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t})(),Uf=(function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,n){return r<=this.length&&(r===this.length?this.rules.push(n):this.rules.splice(r,0,n),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t})(),ps=xn,Bf={isServer:!xn,useCSSOMInjection:!gf},wd=(function(){function t(r,n,o){r===void 0&&(r=Yr),n===void 0&&(n={});var i=this;this.options=dt(dt({},Bf),r),this.gs=n,this.names=new Map(o),this.server=!!r.isServer,!this.server&&xn&&ps&&(ps=!1,ri(this)),fa(this,function(){return(function(a){for(var u=a.getTag(),c=u.length,d="",p=function(f){var x=(function(_){return vo.get(_)})(f);if(x===void 0)return"continue";var m=a.names.get(x);if(m===void 0||!m.size)return"continue";var v=u.getGroup(f);if(v.length===0)return"continue";var C=zr+".g"+f+'[id="'+x+'"]',$="";m.forEach(function(_){_.length>0&&($+=_+",")}),d+=v+C+'{content:"'+$+'"}'+ua},l=0;l<c;l++)p(l);return d})(i)})}return t.registerId=function(r){return fn(r)},t.prototype.rehydrate=function(){!this.server&&xn&&ri(this)},t.prototype.reconstructWithOptions=function(r,n){n===void 0&&(n=!0);var o=new t(dt(dt({},this.options),r),this.gs,n&&this.names||void 0);return!this.server&&xn&&r.target!==this.options.target&&Qi(this.options.target)!==Qi(r.target)&&ri(o),o},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=(function(n){var o=n.useCSSOMInjection,i=n.target;return n.isServer?new Uf(i):o?new Ff(i):new Nf(i)})(this.options),new Tf(r)));var r},t.prototype.hasNameForId=function(r,n){var o,i;return(i=(o=this.names.get(r))===null||o===void 0?void 0:o.has(n))!==null&&i!==void 0&&i},t.prototype.registerName=function(r,n){fn(r);var o=this.names.get(r);o?o.add(n):this.names.set(r,new Set([n]))},t.prototype.insertRules=function(r,n,o){this.registerName(r,n),this.getTag().insertRules(fn(r),o)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(fn(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t})(),Wf=/&/g,Vt=47,wr=42;function hs(t){if(t.indexOf("}")===-1)return!1;for(var r=t.length,n=0,o=0,i=!1,a=0;a<r;a++){var u=t.charCodeAt(a);if(o!==0||i||u!==Vt||t.charCodeAt(a+1)!==wr)if(i)u===wr&&t.charCodeAt(a+1)===Vt&&(i=!1,a++);else if(u!==34&&u!==39||a!==0&&t.charCodeAt(a-1)===92){if(o===0){if(u===123)n++;else if(u===125&&--n<0)return!0}}else o===0?o=u:o===u&&(o=0);else i=!0,a++}return n!==0||o!==0}function jd(t,r){return t.map(function(n){return n.type==="rule"&&(n.value="".concat(r," ").concat(n.value),n.value=n.value.replaceAll(",",",".concat(r," ")),n.props=n.props.map(function(o){return"".concat(r," ").concat(o)})),Array.isArray(n.children)&&n.type!=="@keyframes"&&(n.children=jd(n.children,r)),n})}function Vf(t){var r,n,o,i=Yr,a=i.options,u=a===void 0?Yr:a,c=i.plugins,d=c===void 0?pa:c,p=function(v,C,$){return $.startsWith(n)&&$.endsWith(n)&&$.replaceAll(n,"").length>0?".".concat(r):v},l=d.slice();l.push(function(v){v.type===Eo&&v.value.includes("&")&&(o||(o=new RegExp("\\".concat(n,"\\b"),"g")),v.props[0]=v.props[0].replace(Wf,n).replace(o,p))}),u.prefix&&l.push(hf),l.push(df);var f=[],x=uf(l.concat(pf(function(v){return f.push(v)}))),m=function(v,C,$,_){C===void 0&&(C=""),$===void 0&&($=""),_===void 0&&(_="&"),r=_,n=C,o=void 0;var k=(function(y){if(!hs(y))return y;for(var b=y.length,S="",g=0,j=0,w=0,E=!1,I=0;I<b;I++){var O=y.charCodeAt(I);if(w!==0||E||O!==Vt||y.charCodeAt(I+1)!==wr)if(E)O===wr&&y.charCodeAt(I+1)===Vt&&(E=!1,I++);else if(O!==34&&O!==39||I!==0&&y.charCodeAt(I-1)===92){if(w===0)if(O===123)j++;else if(O===125){if(--j<0){for(var z=I+1;z<b;){var T=y.charCodeAt(z);if(T===59||T===10)break;z++}z<b&&y.charCodeAt(z)===59&&z++,j=0,I=z-1,g=z;continue}j===0&&(S+=y.substring(g,I+1),g=I+1)}else O===59&&j===0&&(S+=y.substring(g,I+1),g=I+1)}else w===0?w=O:w===O&&(w=0);else E=!0,I++}if(g<b){var M=y.substring(g);hs(M)||(S+=M)}return S})((function(y){if(y.indexOf("//")===-1)return y;for(var b=y.length,S=[],g=0,j=0,w=0,E=0;j<b;){var I=y.charCodeAt(j);if(I!==34&&I!==39||j!==0&&y.charCodeAt(j-1)===92)if(w===0)if(I===Vt&&j+1<b&&y.charCodeAt(j+1)===wr){for(j+=2;j+1<b&&(y.charCodeAt(j)!==wr||y.charCodeAt(j+1)!==Vt);)j++;j+=2}else if(I===40&&j>=3&&(32|y.charCodeAt(j-1))==108&&(32|y.charCodeAt(j-2))==114&&(32|y.charCodeAt(j-3))==117)E=1,j++;else if(E>0)I===41?E--:I===40&&E++,j++;else if(I===wr&&j+1<b&&y.charCodeAt(j+1)===Vt)j>g&&S.push(y.substring(g,j)),g=j+=2;else if(I===Vt&&j+1<b&&y.charCodeAt(j+1)===Vt){for(j>g&&S.push(y.substring(g,j));j<b&&y.charCodeAt(j)!==10;)j++;g=j}else j++;else j++;else w===0?w=I:w===I&&(w=0),j++}return g===0?y:(g<b&&S.push(y.substring(g)),S.join(""))})(v)),R=cf($||C?"".concat($," ").concat(C," { ").concat(k," }"):k);return u.namespace&&(R=jd(R,u.namespace)),f=[],xo(R,x),f};return m.hash=d.length?d.reduce(function(v,C){return C.name||en(15),er(v,C.name)},5381).toString():"",m}var Gf=new wd,Zi=Vf(),_d=s.createContext({shouldForwardProp:void 0,styleSheet:Gf,stylis:Zi});_d.Consumer;s.createContext(void 0);function fs(){return s.useContext(_d)}var Ji=(function(){function t(r,n){var o=this;this.inject=function(i,a){a===void 0&&(a=Zi);var u=o.name+a.hash;i.hasNameForId(o.id,u)||i.insertRules(o.id,u,a(o.rules,u,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=n,fa(this,function(){throw en(12,String(o.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=Zi),this.name+r.hash},t})();function Hf(t,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||t in ff||t.startsWith("--")?String(r).trim():"".concat(r,"px")}var qf=function(t){return t>="A"&&t<="Z"};function gs(t){for(var r="",n=0;n<t.length;n++){var o=t[n];if(n===1&&o==="-"&&t[0]==="-")return t;qf(o)?r+="-"+o.toLowerCase():r+=o}return r.startsWith("ms-")?"-"+r:r}var kd=function(t){return t==null||t===!1||t===""},Cd=function(t){var r=[];for(var n in t){var o=t[n];t.hasOwnProperty(n)&&!kd(o)&&(Array.isArray(o)&&o.isCss||Kr(o)?r.push("".concat(gs(n),":"),o,";"):Qr(o)?r.push.apply(r,$r($r(["".concat(n," {")],Cd(o),!1),["}"],!1)):r.push("".concat(gs(n),": ").concat(Hf(n,o),";")))}return r};function kr(t,r,n,o,i){if(i===void 0&&(i=[]),typeof t=="string")return t&&i.push(t),i;if(kd(t))return i;if(ha(t))return i.push(".".concat(t.styledComponentId)),i;if(Kr(t)){if(!Kr(u=t)||u.prototype&&u.prototype.isReactComponent||!r)return i.push(t),i;var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof Ji||Qr(a)||a===null||console.error("".concat(gd(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),kr(a,r,n,o,i)}var u;if(t instanceof Ji)return n?(t.inject(n,o),i.push(t.getName(o))):i.push(t),i;if(Qr(t)){for(var c=Cd(t),d=0;d<c.length;d++)i.push(c[d]);return i}if(!Array.isArray(t))return i.push(t.toString()),i;for(d=0;d<t.length;d++)kr(t[d],r,n,o,i);return i}function Yf(t){for(var r=0;r<t.length;r+=1){var n=t[r];if(Kr(n)&&!ha(n))return!1}return!0}var Kf=hd(Io),Qf=(function(){function t(r,n,o){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(o===void 0||o.isStatic)&&Yf(r),this.componentId=n,this.baseHash=er(Kf,n),this.baseStyle=o,wd.registerId(n)}return t.prototype.generateAndInjectStyles=function(r,n,o){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,n,o).className:"";if(this.isStatic&&!o.hash)if(this.staticRulesId&&n.hasNameForId(this.componentId,this.staticRulesId))i=_r(i,this.staticRulesId);else{var a=Yi(kr(this.rules,r,n,o)),u=qi(er(this.baseHash,a)>>>0);if(!n.hasNameForId(this.componentId,u)){var c=o(a,".".concat(u),void 0,this.componentId);n.insertRules(this.componentId,u,c)}i=_r(i,u),this.staticRulesId=u}else{for(var d=er(this.baseHash,o.hash),p="",l=0;l<this.rules.length;l++){var f=this.rules[l];if(typeof f=="string")p+=f,process.env.NODE_ENV!=="production"&&(d=er(d,f));else if(f){var x=Yi(kr(f,r,n,o));d=er(er(d,String(l)),x),p+=x}}if(p){var m=qi(d>>>0);if(!n.hasNameForId(this.componentId,m)){var v=o(p,".".concat(m),void 0,this.componentId);n.insertRules(this.componentId,m,v)}i=_r(i,m)}}return{className:i,css:typeof window>"u"?n.getTag().getGroup(fn(this.componentId)):""}},t})(),Sd=s.createContext(void 0);Sd.Consumer;var ni={},ms=new Set;function Zf(t,r,n){var o=ha(t),i=t,a=!ti(t),u=r.attrs,c=u===void 0?pa:u,d=r.componentId,p=d===void 0?(function(y,b){var S=typeof y!="string"?"sc":as(y);ni[S]=(ni[S]||0)+1;var g="".concat(S,"-").concat(fd(Io+S+ni[S]));return b?"".concat(b,"-").concat(g):g})(r.displayName,r.parentComponentId):d,l=r.displayName,f=l===void 0?(function(y){return ti(y)?"styled.".concat(y):"Styled(".concat(gd(y),")")})(t):l,x=r.displayName&&r.componentId?"".concat(as(r.displayName),"-").concat(r.componentId):r.componentId||p,m=o&&i.attrs?i.attrs.concat(c).filter(Boolean):c,v=r.shouldForwardProp;if(o&&i.shouldForwardProp){var C=i.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;v=function(y,b){return C(y,b)&&$(y,b)}}else v=C}var _=new Qf(n,x,o?i.componentStyle:void 0);function k(y,b){return(function(S,g,j){var w=S.attrs,E=S.componentStyle,I=S.defaultProps,O=S.foldedComponentIds,z=S.styledComponentId,T=S.target,M=s.useContext(Sd),D=fs(),F=S.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&s.useDebugValue&&s.useDebugValue(z);var L=wf(g,M,I)||Yr,A=(function(ge,pe,Q){for(var he,X=dt(dt({},pe),{className:void 0,theme:Q}),Oe=0;Oe<ge.length;Oe+=1){var se=Kr(he=ge[Oe])?he(X):he;for(var ce in se)ce==="className"?X.className=_r(X.className,se[ce]):ce==="style"?X.style=dt(dt({},X.style),se[ce]):X[ce]=se[ce]}return"className"in pe&&typeof pe.className=="string"&&(X.className=_r(X.className,pe.className)),X})(w,g,L),P=A.as||T,U={};for(var V in A)A[V]===void 0||V[0]==="$"||V==="as"||V==="theme"&&A.theme===L||(V==="forwardedAs"?U.as=A.forwardedAs:F&&!F(V,P)||(U[V]=A[V],F||process.env.NODE_ENV!=="development"||qh(V)||ms.has(V)||!Hi.has(P)||(ms.add(V),console.warn('styled-components: it looks like an unknown prop "'.concat(V,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var H=(function(ge,pe){var Q=fs(),he=ge.generateAndInjectStyles(pe,Q.styleSheet,Q.stylis);return process.env.NODE_ENV!=="production"&&s.useDebugValue&&s.useDebugValue(he.className),he})(E,A),ae=H.className;process.env.NODE_ENV!=="production"&&S.warnTooManyClasses&&S.warnTooManyClasses(ae);var ee=_r(O,z);return ae&&(ee+=" "+ae),A.className&&(ee+=" "+A.className),U[ti(P)&&!Hi.has(P)?"class":"className"]=ee,j&&(U.ref=j),s.createElement(P,U)})(R,y,b)}k.displayName=f;var R=s.forwardRef(k);return R.attrs=m,R.componentStyle=_,R.displayName=f,R.shouldForwardProp=v,R.foldedComponentIds=o?_r(i.foldedComponentIds,i.styledComponentId):"",R.styledComponentId=x,R.target=o?i.target:t,Object.defineProperty(R,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(y){this._foldedDefaultProps=o?(function(b){for(var S=[],g=1;g<arguments.length;g++)S[g-1]=arguments[g];for(var j=0,w=S;j<w.length;j++)Ki(b,w[j],!0);return b})({},i.defaultProps,y):y}}),process.env.NODE_ENV!=="production"&&(bf(f,x),R.warnTooManyClasses=(function(y,b){var S={},g=!1;return function(j){if(!g&&(S[j]=!0,Object.keys(S).length>=200)){var w=b?' with the id of "'.concat(b,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(y).concat(w,`.
|
|
65
65
|
`)+`Consider using the attrs method, together with a style object for frequently changed styles.
|
|
66
66
|
Example:
|
|
67
67
|
const Component = styled.div.attrs(props => ({
|
|
@@ -70,7 +70,7 @@ Example:
|
|
|
70
70
|
},
|
|
71
71
|
}))\`width: 100%;\`
|
|
72
72
|
|
|
73
|
-
<Component />`),g=!0,
|
|
73
|
+
<Component />`),g=!0,S={}}}})(f,x)),fa(R,function(){return".".concat(R.styledComponentId)}),a&&yd(R,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),R}function xs(t,r){for(var n=[t[0]],o=0,i=r.length;o<i;o+=1)n.push(r[o],t[o+1]);return n}var vs=function(t){return Object.assign(t,{isCss:!0})};function rr(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if(Kr(t)||Qr(t))return vs(kr(xs(pa,$r([t],r,!0))));var o=t;return r.length===0&&o.length===1&&typeof o[0]=="string"?kr(o):vs(kr(xs(o,r)))}function Xi(t,r,n){if(n===void 0&&(n=Yr),!r)throw en(1,r);var o=function(i){for(var a=[],u=1;u<arguments.length;u++)a[u-1]=arguments[u];return t(r,n,rr.apply(void 0,$r([i],a,!1)))};return o.attrs=function(i){return Xi(t,r,dt(dt({},n),{attrs:Array.prototype.concat(n.attrs,i).filter(Boolean)}))},o.withConfig=function(i){return Xi(t,r,dt(dt({},n),i))},o}var $d=function(t){return Xi(Zf,t)},h=$d;Hi.forEach(function(t){h[t]=$d(t)});function _t(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var o=Yi(rr.apply(void 0,$r([t],r,!1))),i=fd(o);return new Ji(i,o)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
|
|
74
74
|
Perhaps you're looking to import 'styled-components/native'?
|
|
75
75
|
Read more about this at https://www.styled-components.com/docs/basics#react-native`);var Rn="__sc-".concat(zr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[Rn]||(window[Rn]=0),window[Rn]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
|
|
76
76
|
|
|
@@ -512,7 +512,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
512
512
|
font-size: var(--font-xs);
|
|
513
513
|
display: block;
|
|
514
514
|
text-align: center;
|
|
515
|
-
`;function cr({length:t=6,onComplete:r,onResend:n,error:o,isSubmitting:i=!1}){const[a,u]=s.useState(new Array(t).fill("")),[c,d]=s.useState(60),[p,l]=s.useState(!1),f=s.useRef([]),
|
|
515
|
+
`;function cr({length:t=6,onComplete:r,onResend:n,error:o,isSubmitting:i=!1}){const[a,u]=s.useState(new Array(t).fill("")),[c,d]=s.useState(60),[p,l]=s.useState(!1),f=s.useRef([]),x=s.useCallback(()=>{const _=setInterval(()=>{d(k=>k<=1?(l(!0),clearInterval(_),0):k-1)},1e3);return _},[]);s.useEffect(()=>{const _=x();return()=>clearInterval(_)},[x]);const m=async()=>{var _;!p||i||!n||(await n(),l(!1),d(60),u(new Array(t).fill("")),(_=f.current[0])==null||_.focus(),x())},v=(_,k)=>{var S;if(i)return;const R=_.value,y=[...a];y[k]=R.replace(/[^0-9]/g,""),u(y);const b=y.join("");b.length===t&&r(b),R&&k<t-1&&((S=f.current[k+1])==null||S.focus())},C=(_,k)=>{var R;i||_.key==="Backspace"&&!a[k]&&k>0&&((R=f.current[k-1])==null||R.focus())},$=(_,k)=>{var g,j,w;if(i)return;_.preventDefault();const y=_.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(y.length===0)return;const b=[...a];for(let E=0;E<y.length&&k+E<t;E++)b[k+E]=y[E];if(k===0&&y.length===t)for(let E=0;E<t;E++)b[E]=y[E];u(b);const S=b.join("");if(S.length===t)r(S),(g=f.current[t-1])==null||g.focus();else{const E=b.findIndex((I,O)=>O>=k&&!I);if(E!==-1)(j=f.current[E])==null||j.focus();else{const I=b.map((O,z)=>O?z:-1).filter(O=>O!==-1).pop();I!==void 0&&I<t-1&&((w=f.current[I+1])==null||w.focus())}}};return e.jsxs(tm,{children:[e.jsx(rm,{children:a.map((_,k)=>e.jsx(nm,{type:"text",maxLength:1,value:_,onChange:R=>v(R.target,k),onKeyDown:R=>C(R,k),onPaste:R=>$(R,k),ref:R=>{f.current[k]=R},disabled:i,autoFocus:k===0},k))}),o&&e.jsx(om,{children:o}),n&&e.jsx("div",{children:p?e.jsx(im,{type:"button",onClick:m,disabled:i,children:"Didn't receive a code? Resend"}):e.jsxs(am,{children:["Resend code in ",c,"s"]})})]})}const Od=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Ad=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Ld=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),sm=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Md=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Dd=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),cm=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Fd=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),ai={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(Ad,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(Od,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(Ld,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(sm,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(Md,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(Dd,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(cm,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(Fd,{})}},lm=h.div`
|
|
516
516
|
display: flex;
|
|
517
517
|
flex-direction: column;
|
|
518
518
|
gap: var(--space-xs);
|
|
@@ -718,7 +718,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
718
718
|
}
|
|
719
719
|
`,bm=h(ne)`
|
|
720
720
|
flex: 1;
|
|
721
|
-
`,kn=({value:t,onChange:r,error:n,countryCode:o,setCountryCode:i})=>{const[a,u]=s.useState(!1),[c,d]=s.useState(ho.find(v=>v.code===o)||ho[0]),p=s.useRef(null),[l,f]=s.useState(""),
|
|
721
|
+
`,kn=({value:t,onChange:r,error:n,countryCode:o,setCountryCode:i})=>{const[a,u]=s.useState(!1),[c,d]=s.useState(ho.find(v=>v.code===o)||ho[0]),p=s.useRef(null),[l,f]=s.useState(""),x=s.useRef(null);s.useEffect(()=>{function v(C){p.current&&!p.current.contains(C.target)&&u(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const m=ho.filter(v=>v.name.toLowerCase().includes(l.toLowerCase())||v.dialCode.includes(l));return s.useEffect(()=>{i(c.dialCode)},[c,i]),e.jsxs(hm,{children:[e.jsxs(fm,{ref:p,children:[e.jsxs(gm,{type:"button",onClick:()=>u(v=>!v),children:[e.jsx("span",{children:c.flag}),e.jsx("span",{children:c.dialCode})]}),e.jsxs(mm,{$isOpen:a,children:[e.jsx(xm,{type:"text",placeholder:"Search country...",value:l,onChange:v=>f(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(vm,{children:m.map(v=>e.jsxs(ym,{onClick:C=>{var $;C.stopPropagation(),C.preventDefault(),d(v),u(!1),($=x.current)==null||$.focus()},children:[e.jsx("span",{children:v.flag}),e.jsx("span",{children:v.name}),e.jsx("span",{className:"country-code",children:v.dialCode})]},v.code))})]})]}),e.jsx(bm,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:x,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!n,pattern:"^\\d{7,15}$"})]})},wm=h.div`
|
|
722
722
|
display: flex;
|
|
723
723
|
justify-content: center;
|
|
724
724
|
`,jm=h.div`
|
|
@@ -925,7 +925,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
925
925
|
`,Mr=h.span`
|
|
926
926
|
color: var(--color-danger);
|
|
927
927
|
margin-left: 2px;
|
|
928
|
-
`;function Om(){var H,ae,ee,ge,pe,Q,he,X,Oe,se,ce,_e,me,Ce,q,te,de;const{loading:t,signUp:r,signupAttempt:n,discardSignupAttempt:o}=Dl(),{signIn:i}=Gr("oauth"),{deployment:a}=be(),{navigate:u}=lt(),{session:c,refetch:d,loading:p}=He(),[l,f]=s.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=s.useState({}),[v,$]=s.useState(!1),[S,_]=s.useState(void 0),[k,P]=s.useState(null),[y,b]=s.useState(null),[C,g]=s.useState(!1),j=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="restricted",w=((ae=a==null?void 0:a.restrictions)==null?void 0:ae.sign_up_mode)==="waitlist",E=((ge=(ee=a==null?void 0:a.auth_settings)==null?void 0:ee.multi_session_support)==null?void 0:ge.enabled)??!1;s.useEffect(()=>{var ie;if(!p&&(c!=null&&c.active_signin)&&!E&&!C){g(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");Y||(Y=((ie=a==null?void 0:a.ui_settings)==null?void 0:ie.after_signin_redirect_url)||null),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),Y&&u(Y)}},[c,p,E,a,u,C]),s.useEffect(()=>{var ve;if(!a)return;const Y=new URLSearchParams(window.location.search).get("invite_token");if(w&&!Y){g(!0);const W=((ve=a.ui_settings)==null?void 0:ve.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;u(W);return}Y&&!k&&r&&(b(Y),r.validateDeploymentInvitation(Y).then(W=>{P(W),W.valid&&f(xe=>({...xe,first_name:W.first_name||xe.first_name,last_name:W.last_name||xe.last_name,email:W.email||xe.email}))}).catch(W=>{console.error("Failed to validate invitation:",W)}))},[a,w,u,k,r]);const[I,O]=s.useState(!1),[z,T]=s.useState(""),D=ie=>{let{name:Y,value:ve}=ie.target;Y==="phone_number"?ve=ve.replace(/[^0-9-]/g,""):Y==="email"&&(ve=ve.toLowerCase()),f(W=>({...W,[Y]:ve})),x(W=>({...W,[Y]:""}))},F=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),O(!1),T(""),o()},M=async ie=>{if(ie.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",R),console.log("Form data:",l),t||v)return;const Y={},ve=/^[a-zA-Z]{3,30}$/,W=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,xe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,qe=/^\d{7,15}$/,it=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(R!=null&&R.first_name.enabled&&(R!=null&&R.first_name.required&&!l.first_name?Y.first_name="First name is required":l.first_name&&!ve.test(l.first_name)&&(Y.first_name="Invalid name")),R!=null&&R.last_name.enabled&&(R!=null&&R.last_name.required&&!l.last_name?Y.last_name="Last name is required":l.last_name&&!ve.test(l.last_name)&&(Y.last_name="Invalid last name")),R!=null&&R.username.enabled&&(R!=null&&R.username.required&&!l.username?Y.username="Username is required":l.username&&!W.test(l.username)&&(Y.username="Username must be 3-20 characters")),R!=null&&R.email_address.enabled&&(R!=null&&R.email_address.required&&!l.email?Y.email="Email address is required":l.email&&!xe.test(l.email)&&(Y.email="Invalid email address")),R!=null&&R.phone_number.enabled&&(R!=null&&R.phone_number.required&&!l.phone_number?Y.phone_number="Phone number is required":l.phone_number&&!qe.test(l.phone_number)&&(Y.phone_number="Phone number must contain 7-15 digits")),R!=null&&R.password.enabled&&(l.password?it.test(l.password)||(Y.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):Y.password="Password is required"),x(Y),Object.keys(Y).length>0){console.log("Signup validation failed. Errors:",Y);return}console.log("Signup validation passed"),$(!0);try{const G={...l};l.phone_number&&S&&(G.phone_country_code=S),y&&(G.invite_token=y),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){x({submit:G.message})}finally{$(!1)}},L=async ie=>{if(!(t||v)){$(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:W}=await i.create({provider:ie.provider,redirectUri:ve});W&&typeof W=="object"&&"oauth_url"in W&&(window.location.href=W.oauth_url)}catch(Y){x({submit:Y.message})}finally{$(!1)}}},A=(a==null?void 0:a.social_connections.filter(ie=>ie.enabled))||[],R=a==null?void 0:a.auth_settings,U=!!((pe=R==null?void 0:R.first_name)!=null&&pe.enabled&&((Q=R==null?void 0:R.last_name)!=null&&Q.enabled)),V=async ie=>{var ve;if(ie.preventDefault(),t||v)return;$(!0);const Y={};if(!z){Y.otp="OTP code is required",x(Y),$(!1);return}x(Y);try{const W=await r.completeVerification(z);"data"in W&&((ve=W.data)!=null&&ve.active_signin)&&await d()}catch(W){console.error("Verification failed:",W)}finally{$(!1)}};return s.useEffect(()=>{var ie;if(n){if(n.completed){let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((ie=a==null?void 0:a.ui_settings)==null?void 0:ie.after_signup_redirect_url)||null),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),Y){let ve;try{ve=new URL(Y)}catch{ve=new URL(Y,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ve.searchParams.set("__dev_session__",tt()||""),u(ve.toString())}return}if(!I){switch(n.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}O(!0)}}},[n,r,I,a,c,u]),p?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(bs,{children:e.jsx(qt,{size:32})})]})}):C?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(bs,{children:e.jsx(qt,{size:32})})]})}):j?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(si,{children:e.jsx(ci,{children:"Sign up Restricted!"})}),e.jsx(zm,{children:e.jsx(Pm,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Rm,{children:e.jsxs(Im,{children:["Need assistance?"," ",e.jsx(Tm,{href:(he=a==null?void 0:a.ui_settings)!=null&&he.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(In,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(si,{children:[e.jsxs(ci,{children:["Check your"," ",(n==null?void 0:n.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ws,{children:(n==null?void 0:n.current_step)==="verify_email"?`${l.email} to continue to ${(X=a==null?void 0:a.ui_settings)==null?void 0:X.app_name}`:`${l.phone_number} to continue to ${(Oe=a==null?void 0:a.ui_settings)==null?void 0:Oe.app_name}`})]}),e.jsxs(js,{style:{gap:"15px"},onSubmit:V,noValidate:!0,children:[e.jsx(cr,{onComplete:async ie=>{T(ie)},onResend:async()=>{const ie=(n==null?void 0:n.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ie})},error:m.otp,isSubmitting:v}),e.jsx(_s,{type:"submit",disabled:v||t||!z,children:v?"Verifying...":`Continue to ${(se=a==null?void 0:a.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(ks,{children:["Having trouble?"," ",e.jsx(li,{children:e.jsx(jt,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(li,{onClick:()=>{F()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsxs(si,{children:[e.jsx(ci,{children:"Create your account"}),e.jsx(ws,{children:k!=null&&k.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),A.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(xa,{connections:A,callback:L}),e.jsx(Cm,{children:e.jsx(Sm,{children:"or"})})]}),e.jsxs(js,{onSubmit:M,noValidate:!0,children:[(((ce=R==null?void 0:R.first_name)==null?void 0:ce.enabled)||((_e=R==null?void 0:R.last_name)==null?void 0:_e.enabled))&&e.jsxs($m,{$isBothEnabled:U,children:[((me=R==null?void 0:R.first_name)==null?void 0:me.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"first_name",children:["First name",((Ce=R==null?void 0:R.first_name)==null?void 0:Ce.required)&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:D,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(ur,{children:m.first_name})]}),((q=R==null?void 0:R.last_name)==null?void 0:q.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"last_name",children:["Last name",((te=R==null?void 0:R.last_name)==null?void 0:te.required)&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:D,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(ur,{children:m.last_name})]})]}),(R==null?void 0:R.username.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"username",children:["Username",R.username.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:D,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(ur,{children:m.username})]}),(R==null?void 0:R.email_address.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"email",children:["Email address",R.email_address.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:D,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(k==null?void 0:k.valid)&&!!(k!=null&&k.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(ur,{children:m.email})]}),(R==null?void 0:R.phone_number.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"phone_number",children:["Phone number",R.phone_number.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(kn,{value:l.phone_number,onChange:D,error:m.phone_number,countryCode:S,setCountryCode:_}),m.phone_number&&e.jsx(ur,{children:m.phone_number})]}),(R==null?void 0:R.password.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"password",children:["Password",R.password.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(Em,{children:e.jsx(ne,{type:"password",id:"password",name:"password",value:l.password,onChange:D,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(ur,{children:m.password})]}),m.submit&&e.jsx(ur,{children:m.submit}),e.jsx(_s,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(ks,{children:["Already have an account?"," ",e.jsx(li,{children:e.jsx(jt,{to:`${(de=a.ui_settings)==null?void 0:de.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Nd=s.createContext(void 0),Ud=()=>{const t=s.useContext(Nd);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Am=h.div`
|
|
928
|
+
`;function Om(){var H,ae,ee,ge,pe,Q,he,X,Oe,se,ce,_e,me,Ce,q,te,de;const{loading:t,signUp:r,signupAttempt:n,discardSignupAttempt:o}=Dl(),{signIn:i}=Gr("oauth"),{deployment:a}=be(),{navigate:u}=lt(),{session:c,refetch:d,loading:p}=He(),[l,f]=s.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[x,m]=s.useState({}),[v,C]=s.useState(!1),[$,_]=s.useState(void 0),[k,R]=s.useState(null),[y,b]=s.useState(null),[S,g]=s.useState(!1),j=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="restricted",w=((ae=a==null?void 0:a.restrictions)==null?void 0:ae.sign_up_mode)==="waitlist",E=((ge=(ee=a==null?void 0:a.auth_settings)==null?void 0:ee.multi_session_support)==null?void 0:ge.enabled)??!1;s.useEffect(()=>{var ie;if(!p&&(c!=null&&c.active_signin)&&!E&&!S){g(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");Y||(Y=((ie=a==null?void 0:a.ui_settings)==null?void 0:ie.after_signin_redirect_url)||null),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),Y&&u(Y)}},[c,p,E,a,u,S]),s.useEffect(()=>{var ve;if(!a)return;const Y=new URLSearchParams(window.location.search).get("invite_token");if(w&&!Y){g(!0);const W=((ve=a.ui_settings)==null?void 0:ve.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;u(W);return}Y&&!k&&r&&(b(Y),r.validateDeploymentInvitation(Y).then(W=>{R(W),W.valid&&f(xe=>({...xe,first_name:W.first_name||xe.first_name,last_name:W.last_name||xe.last_name,email:W.email||xe.email}))}).catch(W=>{console.error("Failed to validate invitation:",W)}))},[a,w,u,k,r]);const[I,O]=s.useState(!1),[z,T]=s.useState(""),M=ie=>{let{name:Y,value:ve}=ie.target;Y==="phone_number"?ve=ve.replace(/[^0-9-]/g,""):Y==="email"&&(ve=ve.toLowerCase()),f(W=>({...W,[Y]:ve})),m(W=>({...W,[Y]:""}))},D=()=>{f({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),m({}),O(!1),T(""),o()},F=async ie=>{if(ie.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",P),console.log("Form data:",l),t||v)return;const Y={},ve=/^[a-zA-Z]{3,30}$/,W=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,xe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,qe=/^\d{7,15}$/,it=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(P!=null&&P.first_name.enabled&&(P!=null&&P.first_name.required&&!l.first_name?Y.first_name="First name is required":l.first_name&&!ve.test(l.first_name)&&(Y.first_name="Invalid name")),P!=null&&P.last_name.enabled&&(P!=null&&P.last_name.required&&!l.last_name?Y.last_name="Last name is required":l.last_name&&!ve.test(l.last_name)&&(Y.last_name="Invalid last name")),P!=null&&P.username.enabled&&(P!=null&&P.username.required&&!l.username?Y.username="Username is required":l.username&&!W.test(l.username)&&(Y.username="Username must be 3-20 characters")),P!=null&&P.email_address.enabled&&(P!=null&&P.email_address.required&&!l.email?Y.email="Email address is required":l.email&&!xe.test(l.email)&&(Y.email="Invalid email address")),P!=null&&P.phone_number.enabled&&(P!=null&&P.phone_number.required&&!l.phone_number?Y.phone_number="Phone number is required":l.phone_number&&!qe.test(l.phone_number)&&(Y.phone_number="Phone number must contain 7-15 digits")),P!=null&&P.password.enabled&&(l.password?it.test(l.password)||(Y.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):Y.password="Password is required"),m(Y),Object.keys(Y).length>0){console.log("Signup validation failed. Errors:",Y);return}console.log("Signup validation passed"),C(!0);try{const G={...l};l.phone_number&&$&&(G.phone_country_code=$),y&&(G.invite_token=y),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){m({submit:G.message})}finally{C(!1)}},L=async ie=>{if(!(t||v)){C(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:W}=await i.create({provider:ie.provider,redirectUri:ve});W&&typeof W=="object"&&"oauth_url"in W&&(window.location.href=W.oauth_url)}catch(Y){m({submit:Y.message})}finally{C(!1)}}},A=(a==null?void 0:a.social_connections.filter(ie=>ie.enabled))||[],P=a==null?void 0:a.auth_settings,U=!!((pe=P==null?void 0:P.first_name)!=null&&pe.enabled&&((Q=P==null?void 0:P.last_name)!=null&&Q.enabled)),V=async ie=>{var ve;if(ie.preventDefault(),t||v)return;C(!0);const Y={};if(!z){Y.otp="OTP code is required",m(Y),C(!1);return}m(Y);try{const W=await r.completeVerification(z);"data"in W&&((ve=W.data)!=null&&ve.active_signin)&&await d()}catch(W){console.error("Verification failed:",W)}finally{C(!1)}};return s.useEffect(()=>{var ie;if(n){if(n.completed){let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((ie=a==null?void 0:a.ui_settings)==null?void 0:ie.after_signup_redirect_url)||null),!Y&&(a!=null&&a.frontend_host)&&(Y=`https://${a.frontend_host}`),Y){let ve;try{ve=new URL(Y)}catch{ve=new URL(Y,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ve.searchParams.set("__dev_session__",tt()||""),u(ve.toString())}return}if(!I){switch(n.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}O(!0)}}},[n,r,I,a,c,u]),p?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(bs,{children:e.jsx(qt,{size:32})})]})}):S?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(bs,{children:e.jsx(qt,{size:32})})]})}):j?e.jsx(le,{children:e.jsxs(In,{children:[e.jsx(Fe,{}),e.jsx(si,{children:e.jsx(ci,{children:"Sign up Restricted!"})}),e.jsx(zm,{children:e.jsx(Pm,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Rm,{children:e.jsxs(Im,{children:["Need assistance?"," ",e.jsx(Tm,{href:(he=a==null?void 0:a.ui_settings)!=null&&he.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(In,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(si,{children:[e.jsxs(ci,{children:["Check your"," ",(n==null?void 0:n.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ws,{children:(n==null?void 0:n.current_step)==="verify_email"?`${l.email} to continue to ${(X=a==null?void 0:a.ui_settings)==null?void 0:X.app_name}`:`${l.phone_number} to continue to ${(Oe=a==null?void 0:a.ui_settings)==null?void 0:Oe.app_name}`})]}),e.jsxs(js,{style:{gap:"15px"},onSubmit:V,noValidate:!0,children:[e.jsx(cr,{onComplete:async ie=>{T(ie)},onResend:async()=>{const ie=(n==null?void 0:n.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ie})},error:x.otp,isSubmitting:v}),e.jsx(_s,{type:"submit",disabled:v||t||!z,children:v?"Verifying...":`Continue to ${(se=a==null?void 0:a.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(ks,{children:["Having trouble?"," ",e.jsx(li,{children:e.jsx(jt,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(li,{onClick:()=>{D()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsxs(si,{children:[e.jsx(ci,{children:"Create your account"}),e.jsx(ws,{children:k!=null&&k.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),A.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(xa,{connections:A,callback:L}),e.jsx(Cm,{children:e.jsx(Sm,{children:"or"})})]}),e.jsxs(js,{onSubmit:F,noValidate:!0,children:[(((ce=P==null?void 0:P.first_name)==null?void 0:ce.enabled)||((_e=P==null?void 0:P.last_name)==null?void 0:_e.enabled))&&e.jsxs($m,{$isBothEnabled:U,children:[((me=P==null?void 0:P.first_name)==null?void 0:me.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"first_name",children:["First name",((Ce=P==null?void 0:P.first_name)==null?void 0:Ce.required)&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!x.first_name,pattern:"^[a-zA-Z]{3,30}$"}),x.first_name&&e.jsx(ur,{children:x.first_name})]}),((q=P==null?void 0:P.last_name)==null?void 0:q.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"last_name",children:["Last name",((te=P==null?void 0:P.last_name)==null?void 0:te.required)&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!x.last_name,pattern:"^[a-zA-Z]{3,30}$"}),x.last_name&&e.jsx(ur,{children:x.last_name})]})]}),(P==null?void 0:P.username.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"username",children:["Username",P.username.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!x.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),x.username&&e.jsx(ur,{children:x.username})]}),(P==null?void 0:P.email_address.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"email",children:["Email address",P.email_address.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(ne,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!x.email,required:!0,readOnly:(k==null?void 0:k.valid)&&!!(k!=null&&k.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),x.email&&e.jsx(ur,{children:x.email})]}),(P==null?void 0:P.phone_number.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"phone_number",children:["Phone number",P.phone_number.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(kn,{value:l.phone_number,onChange:M,error:x.phone_number,countryCode:$,setCountryCode:_}),x.phone_number&&e.jsx(ur,{children:x.phone_number})]}),(P==null?void 0:P.password.enabled)&&e.jsxs(Ar,{children:[e.jsxs(Lr,{htmlFor:"password",children:["Password",P.password.required&&e.jsx(Mr,{children:"*"})]}),e.jsx(Em,{children:e.jsx(ne,{type:"password",id:"password",name:"password",value:l.password,onChange:M,placeholder:"Enter your password","aria-invalid":!!x.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),x.password&&e.jsx(ur,{children:x.password})]}),x.submit&&e.jsx(ur,{children:x.submit}),e.jsx(_s,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(ks,{children:["Already have an account?"," ",e.jsx(li,{children:e.jsx(jt,{to:`${(de=a.ui_settings)==null?void 0:de.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Nd=s.createContext(void 0),Ud=()=>{const t=s.useContext(Nd);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Am=h.div`
|
|
929
929
|
position: fixed;
|
|
930
930
|
inset: 0;
|
|
931
931
|
background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
|
|
@@ -988,7 +988,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
988
988
|
display: grid;
|
|
989
989
|
`,Zm=h.div`
|
|
990
990
|
width: fit-content;
|
|
991
|
-
`,Bd=s.createContext(void 0),Wd=()=>{const t=s.useContext(Bd);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ut=({children:t,open:r,openChange:n,style:o})=>{const i=s.useRef(null),[a,u]=s.useState(!1);return s.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&u(!1)};return a&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[a,n]),s.useEffect(()=>{n==null||n(a)},[a]),s.useEffect(()=>{u(!!r)},[r]),e.jsx(Bd.Provider,{value:{open:a,openChange:c=>u(c)},children:e.jsx(Zm,{style:o,ref:i,children:t})})},pt=({children:t,style:r})=>{const{open:n}=Wd(),[o,i]=s.useState({top:0,left:0}),[a,u]=s.useState(!1),c=s.useRef(null);return s.useEffect(()=>{n&&c.current?(u(!1),requestAnimationFrame(()=>{var l,f;const d=(l=c.current)==null?void 0:l.parentElement;if(!d)return;const p=d.querySelector("[data-dropdown-trigger]")||d.firstElementChild;if(p&&p!==c.current){const
|
|
991
|
+
`,Bd=s.createContext(void 0),Wd=()=>{const t=s.useContext(Bd);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ut=({children:t,open:r,openChange:n,style:o})=>{const i=s.useRef(null),[a,u]=s.useState(!1);return s.useEffect(()=>{const c=d=>{i.current&&!i.current.contains(d.target)&&u(!1)};return a&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[a,n]),s.useEffect(()=>{n==null||n(a)},[a]),s.useEffect(()=>{u(!!r)},[r]),e.jsx(Bd.Provider,{value:{open:a,openChange:c=>u(c)},children:e.jsx(Zm,{style:o,ref:i,children:t})})},pt=({children:t,style:r})=>{const{open:n}=Wd(),[o,i]=s.useState({top:0,left:0}),[a,u]=s.useState(!1),c=s.useRef(null);return s.useEffect(()=>{n&&c.current?(u(!1),requestAnimationFrame(()=>{var l,f;const d=(l=c.current)==null?void 0:l.parentElement;if(!d)return;const p=d.querySelector("[data-dropdown-trigger]")||d.firstElementChild;if(p&&p!==c.current){const x=p.getBoundingClientRect(),m=(f=c.current)==null?void 0:f.getBoundingClientRect(),v=window.innerWidth,C=window.innerHeight;let $=x.bottom+4,_=x.right-((m==null?void 0:m.width)||200);_<8&&(_=x.left),_+((m==null?void 0:m.width)||200)>v-8&&(_=v-((m==null?void 0:m.width)||200)-8),m&&$+m.height>C-8&&($=x.top-(m.height+4)),i({top:$,left:_}),u(!0)}})):u(!1)},[n]),n?e.jsx(Qm,{ref:c,style:{...r,top:`${o.top}px`,left:`${o.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},ht=({children:t})=>{const{openChange:r,open:n}=Wd(),o=s.useCallback(()=>{r(!n)},[n,r]);return e.jsx("div",{style:{position:"relative"},onClick:o,"data-dropdown-trigger":!0,children:t})},Le=h.button`
|
|
992
992
|
width: 100%;
|
|
993
993
|
padding: 8px 12px;
|
|
994
994
|
background: none;
|
|
@@ -1214,7 +1214,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1214
1214
|
text-transform: uppercase;
|
|
1215
1215
|
color: var(--color-muted);
|
|
1216
1216
|
background: var(--color-background-hover);
|
|
1217
|
-
`,Ao=({options:t,value:r,onChange:n,placeholder:o="Select an option",disabled:i=!1,searchable:a=!1,width:u,name:c,id:d,groupsEnabled:p=!1,className:l})=>{const[f,
|
|
1217
|
+
`,Ao=({options:t,value:r,onChange:n,placeholder:o="Select an option",disabled:i=!1,searchable:a=!1,width:u,name:c,id:d,groupsEnabled:p=!1,className:l})=>{const[f,x]=s.useState(!1),[m,v]=s.useState(""),C=s.useRef(null),$=s.useRef(null),_=p&&"options"in t[0],R=(_?t.flatMap(g=>g.options):t).find(g=>g.value===r),y=m?_?t.map(g=>({...g,options:g.options.filter(j=>j.label.toLowerCase().includes(m.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(m.toLowerCase())):t,b=(g,j=!1)=>{j||(n(g),x(!1),v(""))},S=()=>{i||x(!f)};return s.useEffect(()=>{f&&a&&$.current&&setTimeout(()=>{var g;(g=$.current)==null||g.focus()},10)},[f,a]),s.useEffect(()=>{const g=j=>{C.current&&!C.current.contains(j.target)&&(x(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Vd,{ref:C,style:{width:u},className:l,children:[e.jsxs(Gd,{type:"button",onClick:S,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[R?R.label:e.jsx(Yd,{children:o}),f?e.jsx(Pd,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(Hd,{isOpen:f,role:"listbox",children:[a&&e.jsx(qd,{ref:$,type:"text",placeholder:"Search...",value:m,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),_?y.map((g,j)=>e.jsxs(s.Fragment,{children:[e.jsx(Kd,{children:g.label}),g.options.length===0?e.jsx(_o,{children:"No options available"}):g.options.map(w=>e.jsxs(jo,{isSelected:w.value===r,disabled:w.disabled,onClick:()=>b(w.value,w.disabled),role:"option","aria-selected":w.value===r,children:[w.label,w.value===r&&e.jsx(st,{size:16})]},w.value))]},`group-${j}`)):e.jsx(e.Fragment,{children:y.length===0?e.jsx(_o,{children:"No options available"}):y.map(g=>e.jsxs(jo,{isSelected:g.value===r,disabled:g.disabled,onClick:()=>b(g.value,g.disabled),role:"option","aria-selected":g.value===r,children:[g.label,g.value===r&&e.jsx(st,{size:16})]},g.value))})]}),c&&e.jsx("input",{type:"hidden",name:c,value:r||""})]})},Qd=({options:t,value:r,onChange:n,placeholder:o="Select options",disabled:i=!1,searchable:a=!1,width:u,name:c,id:d,groupsEnabled:p=!1,className:l})=>{const[f,x]=s.useState(!1),[m,v]=s.useState(""),C=s.useRef(null),$=s.useRef(null),_=p&&"options"in t[0],R=(_?t.flatMap(g=>g.options):t).filter(g=>r.includes(g.value)),y=m?_?t.map(g=>({...g,options:g.options.filter(j=>j.label.toLowerCase().includes(m.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(m.toLowerCase())):t,b=(g,j=!1)=>{j||(r.includes(g)?n(r.filter(w=>w!==g)):n([...r,g]))},S=()=>{i||x(!f)};return s.useEffect(()=>{f&&a&&$.current&&setTimeout(()=>{var g;(g=$.current)==null||g.focus()},10)},[f,a]),s.useEffect(()=>{const g=j=>{C.current&&!C.current.contains(j.target)&&(x(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Vd,{ref:C,style:{width:u},className:l,children:[e.jsxs(Gd,{type:"button",onClick:S,disabled:i,"aria-haspopup":"listbox","aria-expanded":f,id:d,children:[R.length>0?R.map(g=>g.label).join(", "):e.jsx(Yd,{children:o}),f?e.jsx(Pd,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(Hd,{isOpen:f,role:"listbox",children:[a&&e.jsx(qd,{ref:$,type:"text",placeholder:"Search...",value:m,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),_?y.map((g,j)=>e.jsxs(s.Fragment,{children:[e.jsx(Kd,{children:g.label}),g.options.length===0?e.jsx(_o,{children:"No options available"}):g.options.map(w=>e.jsxs(jo,{isSelected:r.includes(w.value),disabled:w.disabled,onClick:()=>b(w.value,w.disabled),role:"option","aria-selected":r.includes(w.value),children:[w.label,r.includes(w.value)&&e.jsx(st,{size:16})]},w.value))]},`group-${j}`)):e.jsx(e.Fragment,{children:y.length===0?e.jsx(_o,{children:"No options available"}):y.map(g=>e.jsxs(jo,{isSelected:r.includes(g.value),disabled:g.disabled,onClick:()=>b(g.value,g.disabled),role:"option","aria-selected":r.includes(g.value),children:[g.label,r.includes(g.value)&&e.jsx(st,{size:16})]},g.value))})]}),c&&e.jsx("input",{type:"hidden",name:c,value:r.join(",")})]})},Zd=s.createContext(void 0);function Jd(){const t=s.useContext(Zd);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function ox({children:t}){var _;const{deployment:r}=be(),[n,o]=s.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),i=s.useRef(!!(r!=null&&r.auth_settings.first_factor)),[a,u]=s.useState(""),[c,d]=s.useState(!1),[p,l]=s.useState(!1),[f,x]=s.useState(!1),[m,v]=s.useState("identifier"),C=(r==null?void 0:r.social_connections.filter(k=>k.enabled))||[],$=r==null?void 0:r.auth_settings;return s.useEffect(()=>{var R;const k=(R=r==null?void 0:r.auth_settings)==null?void 0:R.first_factor;!i.current&&k&&(o(k),i.current=!0)},[(_=r==null?void 0:r.auth_settings)==null?void 0:_.first_factor]),e.jsx(Zd.Provider,{value:{email:a,showOtherOptions:c,showForgotPassword:p,otpSent:f,setFirstFactor:o,setEmail:u,setShowOtherOptions:d,setShowForgotPassword:l,setOtpSent:x,enabledSocialsProviders:C,authSettings:$,firstFactor:n,signInStep:m,setSignInStep:v},children:t})}const on=h.button`
|
|
1218
1218
|
width: 100%;
|
|
1219
1219
|
padding: var(--space-sm) var(--space-md);
|
|
1220
1220
|
background: var(--color-input-background);
|
|
@@ -1237,7 +1237,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1237
1237
|
opacity: 0.7;
|
|
1238
1238
|
cursor: not-allowed;
|
|
1239
1239
|
}
|
|
1240
|
-
`;function Xd(){const{deployment:t}=be(),{signIn:r}=Gr("oauth"),{setFirstFactor:n,firstFactor:o,setShowOtherOptions:i,setShowForgotPassword:a}=Jd(),[u,c]=s.useState(!1),d=t==null?void 0:t.auth_settings,p=(t==null?void 0:t.social_connections.filter(
|
|
1240
|
+
`;function Xd(){const{deployment:t}=be(),{signIn:r}=Gr("oauth"),{setFirstFactor:n,firstFactor:o,setShowOtherOptions:i,setShowForgotPassword:a}=Jd(),[u,c]=s.useState(!1),d=t==null?void 0:t.auth_settings,p=(t==null?void 0:t.social_connections.filter(x=>x.enabled))||[],l=async x=>{if(!u){c(!0);try{const{data:m}=await r.create({provider:x.provider});m&&typeof m=="object"&&"oauth_url"in m&&(window.location.href=m.oauth_url)}catch{}finally{c(!1)}}},f=()=>{a(!1),i(!1)};return e.jsxs(e.Fragment,{children:[p.length>0&&e.jsx(xa,{connections:p,callback:l}),e.jsxs("div",{children:[o!=="email_magic_link"&&(d==null?void 0:d.auth_factors_enabled.email_magic_link)&&e.jsx(on,{onClick:()=>{n("email_magic_link"),f()},children:"Get a magic link on your email"}),o!=="email_password"&&(d==null?void 0:d.auth_factors_enabled.email_password)&&e.jsx(on,{onClick:()=>{n("email_password"),f()},children:"Sign in with email and password"}),o!=="email_otp"&&(d==null?void 0:d.auth_factors_enabled.email_otp)&&e.jsx(on,{onClick:()=>{n("email_otp"),f()},children:"Sign in with email and OTP"}),o!=="phone_otp"&&(d==null?void 0:d.auth_factors_enabled.phone_otp)&&e.jsx(on,{onClick:()=>{n("phone_otp"),f()},children:"Sign in with phone number"}),o!=="username_password"&&(d==null?void 0:d.auth_factors_enabled.username_password)&&e.jsx(on,{onClick:()=>{n("username_password"),f()},children:"Sign in with username and password"})]})]})}const ix=h.div`
|
|
1241
1241
|
max-width: 380px;
|
|
1242
1242
|
width: 380px;
|
|
1243
1243
|
padding: var(--space-3xl);
|
|
@@ -1301,7 +1301,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1301
1301
|
&:hover {
|
|
1302
1302
|
text-decoration: underline;
|
|
1303
1303
|
}
|
|
1304
|
-
`;function lx({onBack:t}){const{deployment:r}=be(),{navigate:n}=lt(),[o,i]=s.useState("start"),[a,u]=s.useState(""),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,
|
|
1304
|
+
`;function lx({onBack:t}){const{deployment:r}=be(),{navigate:n}=lt(),[o,i]=s.useState("start"),[a,u]=s.useState(""),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,x]=s.useState(""),[m,v]=s.useState(""),{forgotPassword:C,verifyOtp:$,resetPassword:_}=Xl(),[k,R]=s.useState(!1),[y,b]=s.useState(null),S=async E=>{if(E.preventDefault(),!!a){R(!0),b(null);try{await C(a),i("otp")}catch(I){b(I)}finally{R(!1)}}},g=async E=>{if(E.preventDefault(),c.length===6){R(!0),b(null);try{const I=await $(a,c);I.data&&(l(I.data.token),i("reset"))}catch(I){b(I)}finally{R(!1)}}},j=async E=>{var I,O;if(E.preventDefault(),f===m&&!(f.length<8)){R(!0),b(null);try{const z=await _(p,f);if(z.data){const T=z.data,M=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(M&&!M.completed){const D=(I=r==null?void 0:r.ui_settings)==null?void 0:I.sign_in_page_url;if(D){const F=new URL(D,window.location.origin);F.searchParams.set("signin_attempt_id",M.id),n(F.toString())}else t()}else{const D=((O=r==null?void 0:r.ui_settings)==null?void 0:O.after_signin_redirect_url)||"/";n(D)}}}catch(z){b(z)}finally{R(!1)}}},w=()=>e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsx(Tn,{children:e.jsx(On,{children:"Forgot Password"})}),e.jsx(ax,{onClick:()=>i("email"),disabled:k,children:"Reset your password"}),e.jsx(sx,{children:e.jsx(cx,{children:"Or, sign in with another method"})}),e.jsx(Xd,{}),e.jsxs(An,{children:[e.jsxs(an,{children:["Unable to reset password? ",e.jsx(sn,{href:"/contact",children:"Get help"})]}),e.jsx(an,{style:{marginTop:"var(--space-sm)"},children:e.jsx(sn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(ix,{children:[o==="start"&&w(),o==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsxs(Tn,{children:[e.jsx(On,{children:"Forgot Password"}),e.jsx(di,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(It,{onSubmit:S,noValidate:!0,children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"email",children:"Email Address"}),e.jsx(ne,{type:"email",id:"email",value:a,onChange:E=>u(E.target.value),placeholder:"Enter your email",required:!0})]}),y&&e.jsx(ui,{children:y.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:k,style:{marginTop:"var(--space-md)"},children:k?"Sending...":"Send Code"})]}),e.jsx(An,{children:e.jsx(an,{style:{marginTop:"var(--space-sm)"},children:e.jsx(sn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),o==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsxs(Tn,{children:[e.jsx(On,{children:"Enter Verification Code"}),e.jsxs(di,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(It,{onSubmit:g,noValidate:!0,children:[e.jsx(cr,{onComplete:E=>d(E),isSubmitting:k,error:y==null?void 0:y.message,onResend:async()=>{await C(a)}}),y&&e.jsx(ui,{children:y.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:k||c.length!==6,style:{marginTop:"var(--space-md)"},children:k?"Verifying...":"Verify"})]}),e.jsx(An,{children:e.jsx(an,{style:{marginTop:"var(--space-sm)"},children:e.jsx(sn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),o==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{}),e.jsxs(Tn,{children:[e.jsx(On,{children:"Reset Password"}),e.jsx(di,{children:"Create a new password for your account."})]}),e.jsxs(It,{onSubmit:j,noValidate:!0,children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"password",children:"New Password"}),e.jsx(ne,{type:"password",id:"password",value:f,onChange:E=>x(E.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(ne,{type:"password",id:"confirmPassword",value:m,onChange:E=>v(E.target.value),placeholder:"Confirm new password",required:!0})]}),y&&e.jsx(ui,{children:y.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:k,style:{marginTop:"var(--space-md)"},children:k?"Resetting...":"Reset Password"})]}),e.jsx(An,{children:e.jsx(an,{style:{marginTop:"var(--space-sm)"},children:e.jsx(sn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const dx=h.div`
|
|
1305
1305
|
max-width: 360px;
|
|
1306
1306
|
width: 360px;
|
|
1307
1307
|
padding: var(--space-2xl);
|
|
@@ -1534,7 +1534,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1534
1534
|
}
|
|
1535
1535
|
`,Bx=h(ne)`
|
|
1536
1536
|
padding: var(--space-sm) var(--space-md);
|
|
1537
|
-
`;function ru({onBack:t,attempt:r,completeVerification:n,prepareVerification:o}){const{deployment:i}=be(),[a,u]=s.useState(""),[c,d]=s.useState({}),[p,l]=s.useState(!1),[f,
|
|
1537
|
+
`;function ru({onBack:t,attempt:r,completeVerification:n,prepareVerification:o}){const{deployment:i}=be(),[a,u]=s.useState(""),[c,d]=s.useState({}),[p,l]=s.useState(!1),[f,x]=s.useState(null),[m,v]=s.useState(!0),[C,$]=s.useState(!1),[_,k]=s.useState(""),[R,y]=s.useState(!1),{navigate:b}=lt(),S=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Lx,{}),available:S.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Mx,{}),available:S.includes("phone_otp"),phoneNumber:_},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Dx,{}),available:S.includes("backup_code")}].filter(O=>O.available),j=async O=>{x(O),v(!1),O==="phone_otp"&&$(!0)},w=async O=>{var z,T;if(r){l(!0);try{const M=await o({strategy:"phone_otp",lastDigits:O});M&&"data"in M&&((z=M.data)!=null&&z.otp_sent)?((T=M.data)!=null&&T.masked_phone&&k(M.data.masked_phone),$(!1)):d({phone:"Phone number verification failed"})}catch(M){d({phone:M.message})}finally{l(!1)}}},E=async(O,z)=>{if(O.preventDefault(),p)return;const T=z||a,M={};if(T?f==="authenticator"&&T.length!==6?M.code="Authentication code must be 6 digits":f==="phone_otp"&&T.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",d(M),!(Object.keys(M).length>0)){l(!0);try{await n(T)}catch(D){d({submit:D.message})}finally{l(!1)}}},I=O=>{let z=O.target.value;f!=="backup_code"&&(z=z.replace(/\D/g,"").slice(0,6)),u(z),d(T=>({...T,code:""}))};return s.useEffect(()=>{var O;if(r.completed){y(!0);let z=new URLSearchParams(window.location.search).get("redirect_uri");if(z||(z=((O=i==null?void 0:i.ui_settings)==null?void 0:O.after_signin_redirect_url)||null),!z&&(i!=null&&i.frontend_host)&&(z=`https://${i.frontend_host}`),z){let T;try{T=new URL(z)}catch{T=new URL(z,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&T.searchParams.set("__dev_session__",tt()||""),b(T.toString())}return}},[r,i]),R?e.jsx(le,{children:e.jsxs(pi,{children:[e.jsx(Fe,{}),e.jsx(Nx,{children:e.jsx(qt,{size:32})})]})}):m?g.length===0?e.jsx(le,{children:e.jsxs(pi,{children:[e.jsx(Fe,{}),e.jsxs($s,{children:[e.jsx(Es,{children:"Set Up Two-Factor Authentication"}),e.jsx(zs,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(Rs,{children:[t&&e.jsx("div",{children:e.jsx(cn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(cn,{children:e.jsx(jt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(eu,{methods:g,onSelectMethod:j,onBack:t}):C&&f==="phone_otp"?e.jsx(tu,{onVerify:w,onBack:()=>{$(!1),v(!0),x(null)},loading:p}):e.jsx(le,{children:e.jsxs(pi,{children:[e.jsx(Fe,{}),e.jsxs($s,{children:[e.jsx(Es,{children:"Two-factor authentication"}),e.jsxs(zs,{children:[f==="authenticator"&&"Enter the 6-digit code from your authenticator app",f==="phone_otp"&&`Enter the 6-digit code sent to your phone ${_}`,f==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(It,{onSubmit:E,noValidate:!0,children:[f==="backup_code"?e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"code",children:"Backup code"}),e.jsx(Bx,{type:"text",id:"code",name:"code",value:a,onChange:I,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!c.code,autoFocus:!0}),c.code&&e.jsx(Ps,{children:c.code})]}):e.jsx(cr,{onComplete:async O=>{if(u(O),f!=="backup_code"){const z=new Event("submit",{bubbles:!0,cancelable:!0});await E(z,O)}},onResend:f==="phone_otp"?async()=>{try{await o({strategy:"phone_otp",lastDigits:_.slice(-4)})}catch(O){d({submit:O.message})}}:void 0,error:c.code,isSubmitting:p}),e.jsxs("div",{children:[c.submit&&e.jsx(Ps,{children:c.submit}),e.jsx(Ux,{type:"submit",disabled:p||!a,children:p?"Verifying...":"Verify"})]})]}),e.jsxs(Rs,{children:[e.jsx(cn,{onClick:()=>{v(!0),x(null),u(""),d({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(cn,{children:e.jsx(jt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(cn,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const hi=h.div`
|
|
1538
1538
|
max-width: 380px;
|
|
1539
1539
|
width: 380px;
|
|
1540
1540
|
padding: var(--space-3xl);
|
|
@@ -1599,7 +1599,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1599
1599
|
transform: rotate(360deg);
|
|
1600
1600
|
}
|
|
1601
1601
|
}
|
|
1602
|
-
`;function nu({attempt:t,onBack:r,completeProfile:n,completeVerification:o,prepareVerification:i}){var L,A,
|
|
1602
|
+
`;function nu({attempt:t,onBack:r,completeProfile:n,completeVerification:o,prepareVerification:i}){var L,A,P,U,V,H,ae,ee,ge;const{deployment:a}=be(),{navigate:u}=lt(),[c,d]=s.useState({}),[p,l]=s.useState({}),[f,x]=s.useState("US"),[m,v]=s.useState(!1),[C,$]=s.useState(!1),[_,k]=s.useState(null),[R,y]=s.useState(!1),b=_,S=C,g=async pe=>{var Q;$(!0),k(null);try{if(await n(pe)){y(!0);let X=new URLSearchParams(window.location.search).get("redirect_uri");if(X||(X=((Q=a==null?void 0:a.ui_settings)==null?void 0:Q.after_signin_redirect_url)||null),!X&&(a!=null&&a.frontend_host)&&(X=`https://${a.frontend_host}`),X){let Oe;try{Oe=new URL(X)}catch{Oe=new URL(X,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&Oe.searchParams.set("__dev_session__",tt()||""),u(Oe.toString())}}}catch(he){const X=he;throw k(X),X}finally{$(!1)}},j=async pe=>{var Q;$(!0),k(null);try{if(await o(pe)){y(!0);let X=new URLSearchParams(window.location.search).get("redirect_uri");if(X||(X=((Q=a==null?void 0:a.ui_settings)==null?void 0:Q.after_signin_redirect_url)||null),!X&&(a!=null&&a.frontend_host)&&(X=`https://${a.frontend_host}`),X){let Oe;try{Oe=new URL(X)}catch{Oe=new URL(X,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&Oe.searchParams.set("__dev_session__",tt()||""),u(Oe.toString())}}return!0}catch(he){return k(he),!1}finally{$(!1)}};if(R||!t)return e.jsx(le,{children:e.jsxs(hi,{children:[e.jsx(Fe,{}),e.jsx(Gx,{children:e.jsx(qt,{size:32})})]})});const w=t.missing_fields||[],E="Complete Your Profile",I="Please provide the following information to continue",O=a==null?void 0:a.auth_settings,z=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||m,T=pe=>{const{name:Q,value:he}=pe.target;d(X=>({...X,[Q]:he})),p[Q]&&l(X=>({...X,[Q]:""}))},M=()=>{const pe={};return w.forEach(Q=>{var Oe,se,ce,_e,me;const he=c[Q];let X=!1;switch(Q){case"first_name":X=((Oe=O==null?void 0:O.first_name)==null?void 0:Oe.enabled)||!1;break;case"last_name":X=((se=O==null?void 0:O.last_name)==null?void 0:se.enabled)||!1;break;case"username":X=((ce=O==null?void 0:O.username)==null?void 0:ce.enabled)||!1;break;case"phone_number":X=((_e=O==null?void 0:O.phone_number)==null?void 0:_e.enabled)||!1;break;case"email_address":X=((me=O==null?void 0:O.email_address)==null?void 0:me.enabled)||!1;break;default:X=!0}if(X&&(!he||he.trim()==="")){const Ce=Q.replace("_"," ").replace(/\b\w/g,q=>q.toUpperCase());pe[Q]=`${Ce} is required`}}),c.username&&w.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(c.username)||(pe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),c.phone_number&&w.includes("phone_number")&&(/^\d{7,15}$/.test(c.phone_number)||(pe.phone_number="Phone number must contain 7-15 digits")),c.email&&w.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(c.email)||(pe.email_address="Please enter a valid email address")),l(pe),Object.keys(pe).length===0},D=async pe=>{if(pe.preventDefault(),!M())return;const Q={...c};c.phone_number&&f&&(Q.phone_country_code=f),await g(Q)},F=pe=>{const Q=pe.target.value;d(he=>({...he,phone_number:Q})),p.phone_number&&l(he=>({...he,phone_number:""}))};if(z){const pe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",Q=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",he=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(hi,{children:[e.jsx(Fe,{}),e.jsxs(Is,{children:[e.jsx(Ts,{children:pe}),e.jsx(Os,{children:Q})]}),e.jsxs(It,{onSubmit:X=>X.preventDefault(),noValidate:!0,children:[e.jsx(cr,{onComplete:j,onResend:async()=>{await i({strategy:he})},error:b==null?void 0:b.message,isSubmitting:S}),b&&e.jsx(pr,{style:{marginBottom:"var(--space-md)"},children:b.message})]}),e.jsxs(As,{children:[e.jsx("div",{children:e.jsx(Ln,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Ln,{children:e.jsx(jt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(hi,{children:[e.jsx(Fe,{}),e.jsxs(Is,{children:[e.jsx(Ts,{children:E}),e.jsx(Os,{children:I})]}),e.jsxs(It,{onSubmit:D,noValidate:!0,children:[(w.includes("first_name")||w.includes("last_name"))&&(((L=O==null?void 0:O.first_name)==null?void 0:L.enabled)||((A=O==null?void 0:O.last_name)==null?void 0:A.enabled))&&e.jsxs(Wx,{$isBothEnabled:!!((P=O==null?void 0:O.first_name)!=null&&P.enabled&&((U=O==null?void 0:O.last_name)!=null&&U.enabled)&&w.includes("first_name")&&w.includes("last_name")),children:[w.includes("first_name")&&((V=O==null?void 0:O.first_name)==null?void 0:V.enabled)&&e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"first_name",children:["First name ",O.first_name.required&&"*"]}),e.jsx(ne,{type:"text",id:"first_name",name:"first_name",value:c.first_name||"",onChange:T,placeholder:"Enter your first name","aria-invalid":!!p.first_name,disabled:S,autoComplete:"given-name"}),p.first_name&&e.jsx(pr,{children:p.first_name})]}),w.includes("last_name")&&((H=O==null?void 0:O.last_name)==null?void 0:H.enabled)&&e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"last_name",children:["Last name ",O.last_name.required&&"*"]}),e.jsx(ne,{type:"text",id:"last_name",name:"last_name",value:c.last_name||"",onChange:T,placeholder:"Enter your last name","aria-invalid":!!p.last_name,disabled:S,autoComplete:"family-name"}),p.last_name&&e.jsx(pr,{children:p.last_name})]})]}),w.includes("username")&&((ae=O==null?void 0:O.username)==null?void 0:ae.enabled)&&e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"username",children:["Username ",O.username.required&&"*"]}),e.jsx(ne,{type:"text",id:"username",name:"username",value:c.username||"",onChange:T,placeholder:"Choose a username","aria-invalid":!!p.username,disabled:S,autoComplete:"username"}),p.username&&e.jsx(pr,{children:p.username})]}),w.includes("phone_number")&&((ee=O==null?void 0:O.phone_number)==null?void 0:ee.enabled)&&e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"phone_number",children:["Phone number ",O.phone_number.required&&"*"]}),e.jsx(kn,{value:c.phone_number||"",onChange:F,error:p.phone_number,countryCode:f,setCountryCode:x}),p.phone_number&&e.jsx(pr,{children:p.phone_number})]}),w.includes("email_address")&&((ge=O==null?void 0:O.email_address)==null?void 0:ge.enabled)&&e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"email",children:["Email address ",O.email_address.required&&"*"]}),e.jsx(ne,{type:"email",id:"email",name:"email",value:c.email||"",onChange:T,placeholder:"Enter your email address","aria-invalid":!!p.email_address,disabled:S,autoComplete:"email"}),p.email_address&&e.jsx(pr,{children:p.email_address})]}),b&&e.jsx(pr,{style:{marginBottom:"var(--space-md)"},children:b.message}),e.jsx(Vx,{type:"submit",disabled:S,children:S?"Completing...":"Continue"})]}),e.jsxs(As,{children:[r&&e.jsx("div",{children:e.jsx(Ln,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Ln,{children:e.jsx(jt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const Hx=h.div`
|
|
1603
1603
|
text-align: center;
|
|
1604
1604
|
margin-bottom: var(--space-2xl);
|
|
1605
1605
|
`,qx=h.div`
|
|
@@ -1757,6 +1757,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1757
1757
|
display: flex;
|
|
1758
1758
|
gap: var(--space-sm);
|
|
1759
1759
|
flex-wrap: wrap;
|
|
1760
|
+
width: 100%;
|
|
1760
1761
|
`,Us=h(B).withConfig({shouldForwardProp:t=>!["$size","$secondary"].includes(t)})`
|
|
1761
1762
|
display: inline-flex;
|
|
1762
1763
|
align-items: center;
|
|
@@ -1848,7 +1849,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1848
1849
|
&:hover {
|
|
1849
1850
|
color: var(--color-primary-hover);
|
|
1850
1851
|
}
|
|
1851
|
-
`;function h0(){return e.jsx(ox,{children:e.jsx(f0,{})})}function f0(){var qe,it,G,fe,Me,Ve,nt,ct,Xe,Ct,St,mt,We,ot,$t,Et,et,zt;const{deployment:t}=be(),{navigate:r}=lt(),{session:n,loading:o,refetch:i,exchangeTicket:a,switchSignIn:u}=He(),c=((it=(qe=t==null?void 0:t.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:it.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:l,showForgotPassword:f,setShowForgotPassword:m,showOtherOptions:x,setShowOtherOptions:v,enabledSocialsProviders:$,firstFactor:S,signInStep:_,setSignInStep:k}=Jd(),{loading:P,signIn:y,signinAttempt:b,discardSignInAttempt:C,setSignInAttempt:g}=Gr("generic"),{signIn:j}=Gr("oauth"),{signIn:w}=Gr("passkey"),[E,I]=s.useState({email:"",username:"",password:"",phone:""}),[O,z]=s.useState({}),[T,D]=s.useState(!1),[F,M]=s.useState(""),[L,A]=s.useState("US"),[R,U]=s.useState(!1),[V,H]=s.useState(null),[ae,ee]=s.useState(!1),[ge,pe]=s.useState(null),Q=[...(n==null?void 0:n.signins)||[]].sort((Z,K)=>{var ue,we;return Z.id===((ue=n==null?void 0:n.active_signin)==null?void 0:ue.id)?-1:K.id===((we=n==null?void 0:n.active_signin)==null?void 0:we.id)?1:0});s.useEffect(()=>{const Z=new URLSearchParams(window.location.search),K=Z.get("error"),ue=Z.get("error_description");if(K==="access_denied"&&ue){H(ue),Z.delete("error"),Z.delete("error_description");const we=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",we)}},[]),s.useEffect(()=>{var Z,K,ue,we;if(!o&&(n!=null&&n.active_signin)&&!c&&!R&&!ae){let Ee=new URLSearchParams(window.location.search).get("redirect_uri");Ee||(Ee=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`);const Ue=(K=t==null?void 0:t.auth_settings)==null?void 0:K.passkey;(Ue==null?void 0:Ue.enabled)&&(Ue==null?void 0:Ue.prompt_registration_on_auth)&&!((we=(ue=n.active_signin)==null?void 0:ue.user)!=null&&we.has_passkeys)?(pe(Ee),ee(!0)):Ee&&(U(!0),r(Ee))}},[n,o,c,t,r,R]);const he=Z=>{let{name:K,value:ue}=Z.target;K==="phone"?ue=ue.replace(/[^0-9]/g,""):K==="email"&&(d(ue),ue=ue.toLowerCase()),I(we=>({...we,[K]:ue})),z(we=>({...we,[K]:""}))},X=()=>{I({email:"",username:"",password:"",phone:""}),z({}),A("US"),k("identifier")},Oe=async Z=>{if(!Z){z({email:"Email address is required"});return}D(!0),z({});try{const K=await y.identify(Z);if(K.strategy==="sso"&&K.connection_id){const we=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ee=await y.initEnterpriseSso(K.connection_id,we);if(Ee&&Ee.sso_url){U(!0),window.location.href=Ee.sso_url;return}}else if(K.strategy==="social"&&K.provider){const ue=$.find(we=>we.provider===K.provider);if(ue){const Ee=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ue}=await j.create({provider:ue.provider,redirectUri:Ee});if(Ue&&typeof Ue=="object"&&"oauth_url"in Ue){U(!0),window.location.href=Ue.oauth_url;return}}else k("password")}else k("password")}catch(K){z({submit:K.message})}finally{R||D(!1)}},se=async Z=>{if(Z.preventDefault(),P||T)return;C();const K={};if(_==="identifier"&&S==="email_password"){if(!E.email){z({email:"Email address is required"});return}await Oe(E.email);return}if(S==="email_password"?(E.email||(K.email="Email address is required"),E.password||(K.password="Password is required")):S==="username_password"?(E.username||(K.username="Username is required"),E.password||(K.password="Password is required")):S==="email_otp"||S==="email_magic_link"?E.email||(K.email="Email address is required"):S==="phone_otp"&&(E.phone?/^\d{7,15}$/.test(E.phone)||(K.phone="Phone number must contain 7-15 digits"):K.phone="Phone number is required"),z(K),Object.keys(K).length>0)return;let ue="";switch(S){case"email_password":ue="plain_email";break;case"username_password":ue="plain_username";break;case"email_otp":ue="email_otp";break;case"email_magic_link":ue="magic_link";break;case"phone_otp":ue="phone_otp";break}D(!0);try{const we={...E,strategy:ue};S==="phone_otp"&&L&&(we.phone_country_code=L),await y.create(we)}catch(we){z({submit:we.message})}finally{D(!1)}},ce=async Z=>{if(Z.preventDefault(),P||T)return;const K={};if(!F){K.otp="OTP code is required",z(K);return}D(!0),z({});try{await y.completeVerification(F),l(!1),M("")}catch(ue){z({otp:ue.message||"Verification failed"})}finally{D(!1)}},_e=async Z=>{if(!(P||T)){D(!0);try{const ue=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:we}=await j.create({provider:Z.provider,redirectUri:ue});we&&typeof we=="object"&&"oauth_url"in we&&(window.location.href=we.oauth_url)}catch(K){z({submit:K.message})}finally{D(!1)}}},me=async()=>{var Z;if(!(P||T)){D(!0),z({});try{const K=await w.create();if("data"in K&&K.data){await i();let ue=new URLSearchParams(window.location.search).get("redirect_uri");ue||(ue=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!ue&&(t!=null&&t.frontend_host)&&(ue=`https://${t.frontend_host}`),U(!0),ue&&r(ue)}}catch(K){z({submit:K.message||"Passkey sign-in failed"})}finally{D(!1)}}},Ce=()=>{var ue;let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((ue=t==null?void 0:t.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!Z&&(t!=null&&t.frontend_host)&&(Z=`https://${t.frontend_host}`),!Z)return null;let K;try{K=new URL(Z)}catch{K=new URL(Z,window.location.origin)}return(t==null?void 0:t.mode)==="staging"&&K.searchParams.set("__dev_session__",tt()||""),K.toString()},q=()=>{if(!(t!=null&&t.frontend_host))return null;const Z=new URL(`https://${t.frontend_host}`);return(t==null?void 0:t.mode)==="staging"&&Z.searchParams.set("__dev_session__",tt()||""),Z.toString()},te=async Z=>{if(!(P||T)){z({}),D(!0);try{await u(Z);const K=Ce();K&&(U(!0),r(K))}catch(K){z({submit:K.message||"Failed to continue with selected account"})}finally{D(!1)}}},de=()=>{const Z=q();Z&&(U(!0),r(Z))},ie=(Z,K)=>`${Z||""} ${K||""}`.trim().split(" ").filter(Boolean).map(ue=>ue[0]).join("").toUpperCase().slice(0,2)||"?",Y=s.useRef(!1);if(s.useEffect(()=>{if(o)return;const Z=new URLSearchParams(window.location.search),K=Z.get("ticket");if(K&&!Y.current&&!P){Y.current=!0,Z.delete("ticket");const we=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",we),(async()=>{var Ue;try{D(!0),await a(K),U(!0);let J=new URLSearchParams(window.location.search).get("redirect_uri");if(J||(J=((Ue=t==null?void 0:t.ui_settings)==null?void 0:Ue.after_signin_redirect_url)||null),!J&&(t!=null&&t.frontend_host)&&(J=`https://${t.frontend_host}`),J){let Te;try{Te=new URL(J)}catch{Te=new URL(J,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Te.searchParams.set("__dev_session__",tt()||""),r(Te.toString())}return}catch(J){z({submit:J.message||"Failed to exchange ticket"}),Y.current=!1}finally{D(!1)}})();return}const ue=Z.get("signin_attempt_id");if(ue&&(n!=null&&n.signin_attempts)&&!b){const we=n.signin_attempts.find(Ee=>Ee.id===ue);if(we){g(we),Z.delete("signin_attempt_id");const Ee=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",Ee)}}},[n,o,b,g,P]),s.useEffect(()=>{var we;if(!b)return;if(b.completed){U(!0);let Ee=new URLSearchParams(window.location.search).get("redirect_uri");if(Ee||(Ee=((we=t==null?void 0:t.ui_settings)==null?void 0:we.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`),Ee){let Ue;try{Ue=new URL(Ee)}catch{Ue=new URL(Ee,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ue.searchParams.set("__dev_session__",tt()||""),r(Ue.toString())}return}if(!y||p)return;const K={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[b.current_step];if(!K)return;(async()=>{try{await y.prepareVerification({strategy:K}),l(!0)}catch(Ee){console.error("Failed to prepare verification:",Ee),z({submit:"Failed to send verification. Please try again."})}finally{D(!1)}})()},[b,y,p,l,r,t]),x)return e.jsx(gx,{onBack:()=>v(!1)});if(f)return e.jsx(lx,{onBack:()=>m(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(ru,{attempt:b,completeVerification:y.completeVerification,prepareVerification:y.prepareVerification,onBack:()=>{C(),X(),l(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(nu,{attempt:b,completeProfile:y.completeProfile,completeVerification:y.completeVerification,prepareVerification:y.prepareVerification,onBack:()=>{C(),X(),l(!1)}});if(ae){const Z=()=>{ee(!1),ge&&(U(!0),r(ge))},K=()=>{ee(!1),ge&&(U(!0),r(ge))};return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(ou,{onComplete:Z,onSkip:K})]})})}if(o)return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(Ls,{children:e.jsx(qt,{size:32})})]})});if(R)return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(Ls,{children:e.jsx(qt,{size:32})})]})});const W=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&p,xe=c&&!W&&Q.length>0;return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),W?e.jsx(e.Fragment,{children:e.jsxs(Ms,{children:[e.jsx(Ds,{children:S==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Fs,{children:S==="email_magic_link"?`If ${E.email} exists in our records, you will receive a magic link. Click the link to sign in.`:S==="phone_otp"?`If ${E.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${E.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ms,{children:[e.jsx(Ds,{children:"Sign in to your account"}),e.jsxs(Fs,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),V&&e.jsxs(l0,{children:[e.jsx(d0,{children:"Access Denied"}),e.jsx(u0,{children:V}),e.jsx(p0,{onClick:()=>H(null),children:"Try again"})]}),xe&&e.jsx(i0,{children:e.jsxs(a0,{children:[e.jsxs(Us,{type:"button",$size:"sm",onClick:()=>te(Q[0].id),disabled:T||P,children:[e.jsx(au,{children:Q[0].user.has_profile_picture?e.jsx("img",{src:Q[0].user.profile_picture_url,alt:((G=Q[0].user.primary_email_address)==null?void 0:G.email)||"account"}):ie(Q[0].user.first_name,Q[0].user.last_name)}),e.jsxs(Bs,{children:["Continue as"," ",((fe=Q[0].user.primary_email_address)==null?void 0:fe.email)||Q[0].user.first_name||"account"]}),e.jsx(Ws,{})]}),Q.length>1&&e.jsxs(Us,{type:"button",$size:"sm",onClick:de,disabled:T||P,children:[e.jsx(c0,{children:Q.slice(0,3).map((Z,K)=>e.jsx(s0,{style:{marginLeft:K===0?0:-14,zIndex:K+1}},Z.id))}),e.jsxs(Bs,{children:["+",Q.length-1," existing signins"]}),e.jsx(Ws,{})]})]})}),W?S==="email_magic_link"?e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(hr,{children:e.jsx(jt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(hr,{onClick:()=>{l(!1),C(),X()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(It,{style:{gap:"15px"},onSubmit:ce,noValidate:!0,children:[e.jsx(cr,{onComplete:async Z=>{if(M(Z),Z&&Z.length===6){D(!0),z({});try{await y.completeVerification(Z),l(!1)}catch(K){z({otp:K.message||"Verification failed"})}finally{D(!1)}}},onResend:async()=>{const Z=S==="email_otp"?"email_otp":"phone_otp";await y.prepareVerification({strategy:Z})},error:O.otp,isSubmitting:T}),e.jsx(Ns,{type:"submit",$fullWidth:!0,$size:"sm",disabled:T||P||!F,style:{margin:0},children:T?"Verifying...":`Continue to ${(zt=t==null?void 0:t.ui_settings)==null?void 0:zt.app_name}`})]}),e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(hr,{children:e.jsx(jt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(hr,{onClick:()=>{l(!1),C(),X()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[$.length>0&&e.jsx(e.Fragment,{children:e.jsx(xa,{connections:$,callback:_e})}),((Ve=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.passkey)==null?void 0:Ve.enabled)&&e.jsxs(o0,{type:"button",onClick:me,disabled:T,children:[e.jsx(ea,{size:16}),"Sign in with Passkey"]}),($.length>0||((ct=(nt=t==null?void 0:t.auth_settings)==null?void 0:nt.passkey)==null?void 0:ct.enabled))&&e.jsx(e0,{children:e.jsx(t0,{children:"or"})}),e.jsxs(It,{onSubmit:se,noValidate:!0,children:[(S==="email_password"||S==="email_otp"||S==="email_magic_link")&&((Ct=(Xe=t==null?void 0:t.auth_settings)==null?void 0:Xe.email_address)==null?void 0:Ct.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"email",children:"Email address"}),e.jsx(ne,{type:"email",id:"email",name:"email",value:E.email,onChange:he,placeholder:"Enter your email address","aria-invalid":!!O.email}),O.email&&e.jsx(ln,{children:O.email})]}),S==="username_password"&&((mt=(St=t==null?void 0:t.auth_settings)==null?void 0:St.username)==null?void 0:mt.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"username",children:"Username"}),e.jsx(ne,{type:"text",id:"username",name:"username",value:E.username,onChange:he,placeholder:"Enter your username","aria-invalid":!!O.username}),O.username&&e.jsx(ln,{children:O.username})]}),S==="phone_otp"&&((ot=(We=t==null?void 0:t.auth_settings)==null?void 0:We.phone_number)==null?void 0:ot.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"phone",children:"Phone number"}),e.jsx(kn,{value:E.phone,onChange:he,error:O.phone,countryCode:L,setCountryCode:A}),O.phone&&e.jsx(ln,{children:O.phone})]}),_==="password"&&(S==="email_password"||S==="username_password")&&((Et=($t=t==null?void 0:t.auth_settings)==null?void 0:$t.password)==null?void 0:Et.enabled)&&e.jsxs(oe,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(re,{htmlFor:"password",children:"Password"}),e.jsx(hr,{style:{fontSize:"12px"},onClick:()=>m(!0),children:"Forgot password?"})]}),e.jsx(r0,{children:e.jsx(ne,{type:"password",id:"password",name:"password",value:E.password,onChange:he,placeholder:"Enter your password","aria-invalid":!!O.password})}),O.password&&e.jsx(ln,{children:O.password})]}),e.jsxs("div",{children:[O.submit&&e.jsx(ln,{children:O.submit}),e.jsx(Ns,{type:"submit",$fullWidth:!0,$size:"sm",disabled:T||P,children:T?e.jsx(n0,{size:16}):_==="identifier"?"Continue":"Sign in"})]}),e.jsx(hr,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>v(!0),children:"Use other methods"})]}),e.jsxs(fi,{children:["Don't have an account?"," ",e.jsx(hr,{children:e.jsx(jt,{to:`${(et=t.ui_settings)==null?void 0:et.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Vs=h.div`
|
|
1852
|
+
`;function h0(){return e.jsx(ox,{children:e.jsx(f0,{})})}function f0(){var qe,it,G,fe,Me,Ve,nt,ct,Xe,Ct,St,mt,We,ot,$t,Et,et,zt;const{deployment:t}=be(),{navigate:r}=lt(),{session:n,loading:o,refetch:i,exchangeTicket:a,switchSignIn:u}=He(),c=((it=(qe=t==null?void 0:t.auth_settings)==null?void 0:qe.multi_session_support)==null?void 0:it.enabled)??!1,{setEmail:d,otpSent:p,setOtpSent:l,showForgotPassword:f,setShowForgotPassword:x,showOtherOptions:m,setShowOtherOptions:v,enabledSocialsProviders:C,firstFactor:$,signInStep:_,setSignInStep:k}=Jd(),{loading:R,signIn:y,signinAttempt:b,discardSignInAttempt:S,setSignInAttempt:g}=Gr("generic"),{signIn:j}=Gr("oauth"),{signIn:w}=Gr("passkey"),[E,I]=s.useState({email:"",username:"",password:"",phone:""}),[O,z]=s.useState({}),[T,M]=s.useState(!1),[D,F]=s.useState(""),[L,A]=s.useState("US"),[P,U]=s.useState(!1),[V,H]=s.useState(null),[ae,ee]=s.useState(!1),[ge,pe]=s.useState(null),Q=[...(n==null?void 0:n.signins)||[]].sort((Z,K)=>{var ue,we;return Z.id===((ue=n==null?void 0:n.active_signin)==null?void 0:ue.id)?-1:K.id===((we=n==null?void 0:n.active_signin)==null?void 0:we.id)?1:0});s.useEffect(()=>{const Z=new URLSearchParams(window.location.search),K=Z.get("error"),ue=Z.get("error_description");if(K==="access_denied"&&ue){H(ue),Z.delete("error"),Z.delete("error_description");const we=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",we)}},[]),s.useEffect(()=>{var Z,K,ue,we;if(!o&&(n!=null&&n.active_signin)&&!c&&!P&&!ae){let Ee=new URLSearchParams(window.location.search).get("redirect_uri");Ee||(Ee=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`);const Ue=(K=t==null?void 0:t.auth_settings)==null?void 0:K.passkey;(Ue==null?void 0:Ue.enabled)&&(Ue==null?void 0:Ue.prompt_registration_on_auth)&&!((we=(ue=n.active_signin)==null?void 0:ue.user)!=null&&we.has_passkeys)?(pe(Ee),ee(!0)):Ee&&(U(!0),r(Ee))}},[n,o,c,t,r,P]);const he=Z=>{let{name:K,value:ue}=Z.target;K==="phone"?ue=ue.replace(/[^0-9]/g,""):K==="email"&&(d(ue),ue=ue.toLowerCase()),I(we=>({...we,[K]:ue})),z(we=>({...we,[K]:""}))},X=()=>{I({email:"",username:"",password:"",phone:""}),z({}),A("US"),k("identifier")},Oe=async Z=>{if(!Z){z({email:"Email address is required"});return}M(!0),z({});try{const K=await y.identify(Z);if(K.strategy==="sso"&&K.connection_id){const we=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ee=await y.initEnterpriseSso(K.connection_id,we);if(Ee&&Ee.sso_url){U(!0),window.location.href=Ee.sso_url;return}}else if(K.strategy==="social"&&K.provider){const ue=C.find(we=>we.provider===K.provider);if(ue){const Ee=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ue}=await j.create({provider:ue.provider,redirectUri:Ee});if(Ue&&typeof Ue=="object"&&"oauth_url"in Ue){U(!0),window.location.href=Ue.oauth_url;return}}else k("password")}else k("password")}catch(K){z({submit:K.message})}finally{P||M(!1)}},se=async Z=>{if(Z.preventDefault(),R||T)return;S();const K={};if(_==="identifier"&&$==="email_password"){if(!E.email){z({email:"Email address is required"});return}await Oe(E.email);return}if($==="email_password"?(E.email||(K.email="Email address is required"),E.password||(K.password="Password is required")):$==="username_password"?(E.username||(K.username="Username is required"),E.password||(K.password="Password is required")):$==="email_otp"||$==="email_magic_link"?E.email||(K.email="Email address is required"):$==="phone_otp"&&(E.phone?/^\d{7,15}$/.test(E.phone)||(K.phone="Phone number must contain 7-15 digits"):K.phone="Phone number is required"),z(K),Object.keys(K).length>0)return;let ue="";switch($){case"email_password":ue="plain_email";break;case"username_password":ue="plain_username";break;case"email_otp":ue="email_otp";break;case"email_magic_link":ue="magic_link";break;case"phone_otp":ue="phone_otp";break}M(!0);try{const we={...E,strategy:ue};$==="phone_otp"&&L&&(we.phone_country_code=L),await y.create(we)}catch(we){z({submit:we.message})}finally{M(!1)}},ce=async Z=>{if(Z.preventDefault(),R||T)return;const K={};if(!D){K.otp="OTP code is required",z(K);return}M(!0),z({});try{await y.completeVerification(D),l(!1),F("")}catch(ue){z({otp:ue.message||"Verification failed"})}finally{M(!1)}},_e=async Z=>{if(!(R||T)){M(!0);try{const ue=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:we}=await j.create({provider:Z.provider,redirectUri:ue});we&&typeof we=="object"&&"oauth_url"in we&&(window.location.href=we.oauth_url)}catch(K){z({submit:K.message})}finally{M(!1)}}},me=async()=>{var Z;if(!(R||T)){M(!0),z({});try{const K=await w.create();if("data"in K&&K.data){await i();let ue=new URLSearchParams(window.location.search).get("redirect_uri");ue||(ue=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!ue&&(t!=null&&t.frontend_host)&&(ue=`https://${t.frontend_host}`),U(!0),ue&&r(ue)}}catch(K){z({submit:K.message||"Passkey sign-in failed"})}finally{M(!1)}}},Ce=()=>{var ue;let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((ue=t==null?void 0:t.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!Z&&(t!=null&&t.frontend_host)&&(Z=`https://${t.frontend_host}`),!Z)return null;let K;try{K=new URL(Z)}catch{K=new URL(Z,window.location.origin)}return(t==null?void 0:t.mode)==="staging"&&K.searchParams.set("__dev_session__",tt()||""),K.toString()},q=()=>{if(!(t!=null&&t.frontend_host))return null;const Z=new URL(`https://${t.frontend_host}`);return(t==null?void 0:t.mode)==="staging"&&Z.searchParams.set("__dev_session__",tt()||""),Z.toString()},te=async Z=>{if(!(R||T)){z({}),M(!0);try{await u(Z);const K=Ce();K&&(U(!0),r(K))}catch(K){z({submit:K.message||"Failed to continue with selected account"})}finally{M(!1)}}},de=()=>{const Z=q();Z&&(U(!0),r(Z))},ie=(Z,K)=>`${Z||""} ${K||""}`.trim().split(" ").filter(Boolean).map(ue=>ue[0]).join("").toUpperCase().slice(0,2)||"?",Y=s.useRef(!1);if(s.useEffect(()=>{if(o)return;const Z=new URLSearchParams(window.location.search),K=Z.get("ticket");if(K&&!Y.current&&!R){Y.current=!0,Z.delete("ticket");const we=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",we),(async()=>{var Ue;try{M(!0),await a(K),U(!0);let J=new URLSearchParams(window.location.search).get("redirect_uri");if(J||(J=((Ue=t==null?void 0:t.ui_settings)==null?void 0:Ue.after_signin_redirect_url)||null),!J&&(t!=null&&t.frontend_host)&&(J=`https://${t.frontend_host}`),J){let Te;try{Te=new URL(J)}catch{Te=new URL(J,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Te.searchParams.set("__dev_session__",tt()||""),r(Te.toString())}return}catch(J){z({submit:J.message||"Failed to exchange ticket"}),Y.current=!1}finally{M(!1)}})();return}const ue=Z.get("signin_attempt_id");if(ue&&(n!=null&&n.signin_attempts)&&!b){const we=n.signin_attempts.find(Ee=>Ee.id===ue);if(we){g(we),Z.delete("signin_attempt_id");const Ee=Z.toString()?`${window.location.pathname}?${Z.toString()}`:window.location.pathname;window.history.replaceState({},"",Ee)}}},[n,o,b,g,R]),s.useEffect(()=>{var we;if(!b)return;if(b.completed){U(!0);let Ee=new URLSearchParams(window.location.search).get("redirect_uri");if(Ee||(Ee=((we=t==null?void 0:t.ui_settings)==null?void 0:we.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`),Ee){let Ue;try{Ue=new URL(Ee)}catch{Ue=new URL(Ee,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ue.searchParams.set("__dev_session__",tt()||""),r(Ue.toString())}return}if(!y||p)return;const K={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[b.current_step];if(!K)return;(async()=>{try{await y.prepareVerification({strategy:K}),l(!0)}catch(Ee){console.error("Failed to prepare verification:",Ee),z({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[b,y,p,l,r,t]),m)return e.jsx(gx,{onBack:()=>v(!1)});if(f)return e.jsx(lx,{onBack:()=>x(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(ru,{attempt:b,completeVerification:y.completeVerification,prepareVerification:y.prepareVerification,onBack:()=>{S(),X(),l(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(nu,{attempt:b,completeProfile:y.completeProfile,completeVerification:y.completeVerification,prepareVerification:y.prepareVerification,onBack:()=>{S(),X(),l(!1)}});if(ae){const Z=()=>{ee(!1),ge&&(U(!0),r(ge))},K=()=>{ee(!1),ge&&(U(!0),r(ge))};return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(ou,{onComplete:Z,onSkip:K})]})})}if(o)return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(Ls,{children:e.jsx(qt,{size:32})})]})});if(P)return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),e.jsx(Ls,{children:e.jsx(qt,{size:32})})]})});const W=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&p,xe=c&&!W&&Q.length>0;return e.jsx(le,{children:e.jsxs(Mn,{children:[e.jsx(Fe,{}),W?e.jsx(e.Fragment,{children:e.jsxs(Ms,{children:[e.jsx(Ds,{children:$==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Fs,{children:$==="email_magic_link"?`If ${E.email} exists in our records, you will receive a magic link. Click the link to sign in.`:$==="phone_otp"?`If ${E.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${E.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ms,{children:[e.jsx(Ds,{children:"Sign in to your account"}),e.jsxs(Fs,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),V&&e.jsxs(l0,{children:[e.jsx(d0,{children:"Access Denied"}),e.jsx(u0,{children:V}),e.jsx(p0,{onClick:()=>H(null),children:"Try again"})]}),xe&&e.jsx(i0,{children:e.jsxs(a0,{children:[e.jsxs(Us,{type:"button",$size:"sm",onClick:()=>te(Q[0].id),disabled:T||R,children:[e.jsx(au,{children:Q[0].user.has_profile_picture?e.jsx("img",{src:Q[0].user.profile_picture_url,alt:((G=Q[0].user.primary_email_address)==null?void 0:G.email)||"account"}):ie(Q[0].user.first_name,Q[0].user.last_name)}),e.jsxs(Bs,{children:["Continue as"," ",((fe=Q[0].user.primary_email_address)==null?void 0:fe.email)||Q[0].user.first_name||"account"]}),e.jsx(Ws,{})]}),Q.length>1&&e.jsxs(Us,{type:"button",$size:"sm",onClick:de,disabled:T||R,children:[e.jsx(c0,{children:Q.slice(0,3).map((Z,K)=>e.jsx(s0,{style:{marginLeft:K===0?0:-14,zIndex:K+1}},Z.id))}),e.jsxs(Bs,{children:["+",Q.length-1," existing signins"]}),e.jsx(Ws,{})]})]})}),W?$==="email_magic_link"?e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(hr,{children:e.jsx(jt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(hr,{onClick:()=>{l(!1),S(),X()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(It,{style:{gap:"15px"},onSubmit:ce,noValidate:!0,children:[e.jsx(cr,{onComplete:async Z=>{if(F(Z),Z&&Z.length===6){M(!0),z({});try{await y.completeVerification(Z),l(!1)}catch(K){z({otp:K.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const Z=$==="email_otp"?"email_otp":"phone_otp";await y.prepareVerification({strategy:Z})},error:O.otp,isSubmitting:T}),e.jsx(Ns,{type:"submit",$fullWidth:!0,$size:"sm",disabled:T||R||!D,style:{margin:0},children:T?"Verifying...":`Continue to ${(zt=t==null?void 0:t.ui_settings)==null?void 0:zt.app_name}`})]}),e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(hr,{children:e.jsx(jt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(hr,{onClick:()=>{l(!1),S(),X()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[C.length>0&&e.jsx(e.Fragment,{children:e.jsx(xa,{connections:C,callback:_e})}),((Ve=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.passkey)==null?void 0:Ve.enabled)&&e.jsxs(o0,{type:"button",onClick:me,disabled:T,children:[e.jsx(ea,{size:16}),"Sign in with Passkey"]}),(C.length>0||((ct=(nt=t==null?void 0:t.auth_settings)==null?void 0:nt.passkey)==null?void 0:ct.enabled))&&e.jsx(e0,{children:e.jsx(t0,{children:"or"})}),e.jsxs(It,{onSubmit:se,noValidate:!0,children:[($==="email_password"||$==="email_otp"||$==="email_magic_link")&&((Ct=(Xe=t==null?void 0:t.auth_settings)==null?void 0:Xe.email_address)==null?void 0:Ct.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"email",children:"Email address"}),e.jsx(ne,{type:"email",id:"email",name:"email",value:E.email,onChange:he,placeholder:"Enter your email address","aria-invalid":!!O.email}),O.email&&e.jsx(ln,{children:O.email})]}),$==="username_password"&&((mt=(St=t==null?void 0:t.auth_settings)==null?void 0:St.username)==null?void 0:mt.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"username",children:"Username"}),e.jsx(ne,{type:"text",id:"username",name:"username",value:E.username,onChange:he,placeholder:"Enter your username","aria-invalid":!!O.username}),O.username&&e.jsx(ln,{children:O.username})]}),$==="phone_otp"&&((ot=(We=t==null?void 0:t.auth_settings)==null?void 0:We.phone_number)==null?void 0:ot.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"phone",children:"Phone number"}),e.jsx(kn,{value:E.phone,onChange:he,error:O.phone,countryCode:L,setCountryCode:A}),O.phone&&e.jsx(ln,{children:O.phone})]}),_==="password"&&($==="email_password"||$==="username_password")&&((Et=($t=t==null?void 0:t.auth_settings)==null?void 0:$t.password)==null?void 0:Et.enabled)&&e.jsxs(oe,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(re,{htmlFor:"password",children:"Password"}),e.jsx(hr,{style:{fontSize:"12px"},onClick:()=>x(!0),children:"Forgot password?"})]}),e.jsx(r0,{children:e.jsx(ne,{type:"password",id:"password",name:"password",value:E.password,onChange:he,placeholder:"Enter your password","aria-invalid":!!O.password})}),O.password&&e.jsx(ln,{children:O.password})]}),e.jsxs("div",{children:[O.submit&&e.jsx(ln,{children:O.submit}),e.jsx(Ns,{type:"submit",$fullWidth:!0,$size:"sm",disabled:T||R,children:T?e.jsx(n0,{size:16}):_==="identifier"?"Continue":"Sign in"})]}),e.jsx(hr,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>v(!0),children:"Use other methods"})]}),e.jsxs(fi,{children:["Don't have an account?"," ",e.jsx(hr,{children:e.jsx(jt,{to:`${(et=t.ui_settings)==null?void 0:et.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Vs=h.div`
|
|
1852
1853
|
max-width: 380px;
|
|
1853
1854
|
width: 380px;
|
|
1854
1855
|
padding: var(--space-3xl);
|
|
@@ -1927,7 +1928,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1927
1928
|
color: var(--color-primary);
|
|
1928
1929
|
text-decoration: none;
|
|
1929
1930
|
cursor: pointer;
|
|
1930
|
-
`;function $0(){var
|
|
1931
|
+
`;function $0(){var $,_,k,R,y,b,S,g,j,w,E,I;const{deployment:t}=be(),{loading:r,joinWaitlist:n}=Kl(),[o,i]=s.useState({first_name:"",last_name:"",email:""}),[a,u]=s.useState(!1),[c,d]=s.useState(!1),[p,l]=s.useState(null),f=O=>{if(p)return p.message},x=t==null?void 0:t.auth_settings,m=!!(($=x==null?void 0:x.first_name)!=null&&$.enabled&&((_=x==null?void 0:x.last_name)!=null&&_.enabled)),v=O=>{const{name:z,value:T}=O.target;i(M=>({...M,[z]:T}))},C=async O=>{if(O.preventDefault(),!!x){d(!0),l(null);try{(await n(o)).data&&u(!0)}catch(z){l(z)}finally{d(!1)}}};return a?e.jsx(le,{children:e.jsx(Vs,{children:e.jsxs(b0,{children:[e.jsx(w0,{children:e.jsx(st,{size:32})}),e.jsx(j0,{children:"You're on the waitlist!"}),e.jsxs(_0,{children:["Thanks for your interest! We'll notify you at ",o.email," ","when we're ready for you to join."]})]})})}):e.jsx(le,{children:e.jsxs(Vs,{children:[e.jsx(Fe,{}),e.jsxs(g0,{children:[e.jsx(m0,{children:"Join the waitlist"}),e.jsx(x0,{children:"Be the first to know when we launch!"})]}),e.jsxs(v0,{onSubmit:C,noValidate:!0,children:[(((k=x==null?void 0:x.first_name)==null?void 0:k.enabled)||((R=x==null?void 0:x.last_name)==null?void 0:R.enabled))&&e.jsxs(y0,{$isBothEnabled:m,children:[((y=x==null?void 0:x.first_name)==null?void 0:y.enabled)&&e.jsxs(gi,{children:[e.jsxs(mi,{htmlFor:"first_name",children:["First name",((b=x==null?void 0:x.first_name)==null?void 0:b.required)&&e.jsx(xi,{children:"*"})]}),e.jsx(ne,{type:"text",id:"first_name",name:"first_name",required:(S=x==null?void 0:x.first_name)==null?void 0:S.required,minLength:2,maxLength:50,value:o.first_name,onChange:v,placeholder:"First name","aria-invalid":!!f()}),f()&&e.jsx(Dn,{children:f()})]}),((g=x==null?void 0:x.last_name)==null?void 0:g.enabled)&&e.jsxs(gi,{children:[e.jsxs(mi,{htmlFor:"last_name",children:["Last name",((j=x==null?void 0:x.last_name)==null?void 0:j.required)&&e.jsx(xi,{children:"*"})]}),e.jsx(ne,{type:"text",id:"last_name",name:"last_name",required:(w=x==null?void 0:x.last_name)==null?void 0:w.required,minLength:2,maxLength:50,value:o.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!f()}),f()&&e.jsx(Dn,{children:f()})]})]}),e.jsxs(gi,{children:[e.jsxs(mi,{htmlFor:"email",children:["Email address",((E=x==null?void 0:x.email_address)==null?void 0:E.required)&&e.jsx(xi,{children:"*"})]}),e.jsx(ne,{type:"email",id:"email",name:"email",required:(I=x==null?void 0:x.email_address)==null?void 0:I.required,value:o.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!f()}),f()&&e.jsx(Dn,{children:f()})]}),f()&&e.jsx(Dn,{children:f()}),e.jsx(B,{type:"submit",$primary:!0,$fullWidth:!0,$size:"sm",disabled:c||r,children:c||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(k0,{children:e.jsxs(C0,{children:["Need assistance? ",e.jsx(S0,{href:"/contact",children:"Get help"})]})})]})})}const dn=h.div`
|
|
1931
1932
|
max-width: 380px;
|
|
1932
1933
|
width: 380px;
|
|
1933
1934
|
padding: var(--space-3xl);
|
|
@@ -2014,7 +2015,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2014
2015
|
color: var(--color-primary-hover);
|
|
2015
2016
|
text-decoration: underline;
|
|
2016
2017
|
}
|
|
2017
|
-
`;function I0(){const{deployment:t}=be(),{navigate:r}=lt(),{error:n,session:o,processed:i,signinAttempt:a,redirectUri:u,loading:c}=Ql(),[d,p]=s.useState(!1),[l,f]=s.useState(null),
|
|
2018
|
+
`;function I0(){const{deployment:t}=be(),{navigate:r}=lt(),{error:n,session:o,processed:i,signinAttempt:a,redirectUri:u,loading:c}=Ql(),[d,p]=s.useState(!1),[l,f]=s.useState(null),x=()=>{window.location.reload()},m=()=>{var _;const $=((_=t==null?void 0:t.ui_settings)==null?void 0:_.sign_in_page_url)||"/sign-in";r($)},v=()=>{p(!1),l&&r(l)},C=()=>{p(!1),l&&r(l)};if(s.useEffect(()=>{var $,_,k,R,y;if(!(!i||c||d)){if(a&&!a.completed){const b=($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url;if(b){const S=new URL(b,window.location.origin);S.searchParams.set("signin_attempt_id",a.id),u&&S.searchParams.set("redirect_uri",u),r(S.toString())}return}if(a!=null&&a.completed){const b=u||((_=t==null?void 0:t.ui_settings)==null?void 0:_.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let S;try{S=new URL(b)}catch{S=new URL(b,window.location.origin)}if(S){(t==null?void 0:t.mode)==="staging"&&S.searchParams.set("__dev_session__",tt()||"");const g=(k=t==null?void 0:t.auth_settings)==null?void 0:k.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!((y=(R=o==null?void 0:o.active_signin)==null?void 0:R.user)!=null&&y.has_passkeys)?(f(S.toString()),p(!0)):r(S.toString())}}}},[o,i,c,u,t,a,r]),s.useEffect(()=>{n&&n.message.includes("No OAuth callback data found")&&setTimeout(()=>{var _;const $=((_=t==null?void 0:t.ui_settings)==null?void 0:_.sign_in_page_url)||(t==null?void 0:t.frontend_host);$&&r($)},2e3)},[n,t,r]),c&&!i)return e.jsx(le,{children:e.jsxs(dn,{children:[e.jsxs(Fn,{children:[e.jsx(Nn,{children:"Completing sign in"}),e.jsx(Un,{children:"Please wait while we authenticate you"})]}),e.jsxs(Bn,{children:[e.jsx(Gs,{}),e.jsx(Wn,{children:"Verifying your credentials..."}),e.jsx(Vn,{children:"This will only take a moment."})]})]})});if(d)return e.jsx(le,{children:e.jsxs(dn,{children:[e.jsx(Fe,{}),e.jsx(ou,{onComplete:v,onSkip:C})]})});if(o&&i&&!n)return e.jsx(le,{children:e.jsxs(dn,{children:[e.jsxs(Fn,{children:[e.jsx(Nn,{children:"Success!"}),e.jsx(Un,{children:"Authentication completed successfully"})]}),e.jsxs(Bn,{children:[e.jsx(z0,{children:"✓"}),e.jsx(Wn,{children:"Redirecting you now..."}),e.jsx(Vn,{children:"You'll be redirected to your destination shortly."})]})]})});if(n){const $=n.message.includes("No OAuth callback data found");return e.jsx(le,{children:e.jsxs(dn,{children:[e.jsxs(Fn,{children:[e.jsx(Nn,{children:"Something went wrong"}),e.jsx(Un,{children:"We couldn't complete your sign in"})]}),e.jsxs(Bn,{children:[e.jsx(E0,{children:"✗"}),e.jsx(Wn,{children:"Authentication Failed"}),e.jsx(Vn,{children:n.message||"An unexpected error occurred during authentication."}),!$&&e.jsx(B,{onClick:x,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!$&&e.jsx(P0,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(R0,{onClick:m,children:"Return to sign in"})]})})]})})}return e.jsx(le,{children:e.jsxs(dn,{children:[e.jsxs(Fn,{children:[e.jsx(Nn,{children:"Completing sign in"}),e.jsx(Un,{children:"Please wait while we authenticate you"})]}),e.jsxs(Bn,{children:[e.jsx(Gs,{}),e.jsx(Wn,{children:"Verifying your credentials..."}),e.jsx(Vn,{children:"This will only take a moment."})]})]})})}const T0=h.div`
|
|
2018
2019
|
max-width: 380px;
|
|
2019
2020
|
width: 380px;
|
|
2020
2021
|
padding: var(--space-3xl);
|
|
@@ -2079,7 +2080,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2079
2080
|
`,vi=h.p`
|
|
2080
2081
|
font-size: var(--font-xs);
|
|
2081
2082
|
color: var(--color-secondary-text);
|
|
2082
|
-
`;function U0({onSuccess:t,onError:r}={}){const[n,o]=s.useState("loading"),[i,a]=s.useState(""),{token:u,attempt:c,redirectUri:d}=Jl(),{verifyMagicLink:p}=Zl(),{navigate:l}=lt(),{deployment:f}=be(),
|
|
2083
|
+
`;function U0({onSuccess:t,onError:r}={}){const[n,o]=s.useState("loading"),[i,a]=s.useState(""),{token:u,attempt:c,redirectUri:d}=Jl(),{verifyMagicLink:p}=Zl(),{navigate:l}=lt(),{deployment:f}=be(),x=s.useRef(!1);s.useEffect(()=>{(async()=>{if(!x.current){if(!u||!c){o("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}x.current=!0,o("loading"),a("Please wait while we verify your magic link.");try{await p({token:u,attempt:c,redirectUri:d}),o("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let C=d;if(C||(C=($=f==null?void 0:f.ui_settings)==null?void 0:$.after_signin_redirect_url),!C&&(f!=null&&f.frontend_host)&&(C=`https://${f.frontend_host}`),C){const _=new URL(C);(f==null?void 0:f.mode)==="staging"&&_.searchParams.set("__dev_session__",tt()||""),l(_.toString())}},2e3)}catch(C){o("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(C.message)}}})()},[u,c]);const m=()=>{var v;(v=f==null?void 0:f.ui_settings)!=null&&v.sign_in_page_url&&l(f.ui_settings.sign_in_page_url)};return e.jsx(le,{children:e.jsxs(T0,{children:[e.jsxs(O0,{children:[e.jsx(A0,{children:"Magic Link Verification"}),e.jsx(L0,{children:"Verifying your magic link"})]}),e.jsxs(M0,{children:[n==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(N0,{}),e.jsx(vi,{children:i})]}),n==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(D0,{children:"✓"}),e.jsx(vi,{children:i})]}),n==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(F0,{children:"✗"}),e.jsx(vi,{children:i}),e.jsx(B,{onClick:m,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function B0(t){var o,i;return t?((o=t.signin_attempts)==null?void 0:o.find(a=>a.requires_completion&&!a.completed))?!0:!!((i=t.signup_attempts)==null?void 0:i.find(a=>{var u,c;return((u=a.missing_fields)==null?void 0:u.length)>0||((c=a.remaining_steps)==null?void 0:c.length)>0&&!a.completed})):!1}function W0(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const fr=h.div`
|
|
2083
2084
|
max-width: 380px;
|
|
2084
2085
|
width: 380px;
|
|
2085
2086
|
padding: var(--space-3xl);
|
|
@@ -2179,7 +2180,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2179
2180
|
&:hover {
|
|
2180
2181
|
color: var(--color-primary-hover);
|
|
2181
2182
|
}
|
|
2182
|
-
`;function Y0({token:t,onSuccess:r,onError:n}){var
|
|
2183
|
+
`;function Y0({token:t,onSuccess:r,onError:n}){var C;const{acceptInvitation:o,invitationData:i,loading:a,error:u}=nd(),{navigate:c}=lt(),{deployment:d}=be(),p=s.useRef(!1),l=()=>{var _;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((_=d==null?void 0:d.ui_settings)==null?void 0:_.after_signin_redirect_url)||"/"}};s.useEffect(()=>{if(p.current)return;const{token:$}=l();$&&(p.current=!0,o($))},[o]),s.useEffect(()=>{var $;i&&(i.organization&&!i.requires_signin&&r&&r(i.organization.id,($=i.workspace)==null?void 0:$.id),i.error_code&&n&&n(i.message||"Failed to accept invitation"))},[i,r,n]);const f=()=>{const{redirectUri:$}=l();c($)},x=()=>{var g,j;const{token:$}=l(),_=((g=d==null?void 0:d.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",k=((j=d==null?void 0:d.ui_settings)==null?void 0:j.sign_up_page_url)||"/sign-up",R=new URLSearchParams;$&&R.set("invite_token",$),i!=null&&i.invited_email&&R.set("invited_email",i.invited_email);const b=`${window.location.pathname}?token=${$}`;R.set("redirect_uri",b),i!=null&&i.message&&R.set("message",i.message);const S=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";c(`${S?k:_}?${R.toString()}`)},m=()=>{const{token:$}=l();$&&(p.current=!1,o($))},{token:v}=l();if(!v&&!a)return e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Invalid Invitation"}),e.jsx(xr,{children:"No invitation token found"})]}),e.jsxs(vr,{children:[e.jsx(yi,{children:"✗"}),e.jsx(yr,{children:"Missing Invitation Token"}),e.jsx(br,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(B,{onClick:()=>c("/"),$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Processing Invitation"}),e.jsx(xr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(vr,{children:[e.jsx(G0,{}),e.jsx(yr,{children:"Verifying invitation..."}),e.jsx(br,{children:"This will only take a moment."})]})]})});if(i!=null&&i.organization&&!i.requires_signin)return e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Invitation Accepted!"}),e.jsx(xr,{children:"You've successfully joined the organization"})]}),e.jsxs(vr,{children:[e.jsx(V0,{children:"✓"}),e.jsxs(yr,{children:["Welcome to ",i.organization.name,"!"]}),i.workspace&&e.jsxs(br,{children:["You've been added to the ",i.workspace.name," workspace."]}),e.jsx(B,{onClick:f,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.already_member)return e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Already a Member"}),e.jsx(xr,{children:"You're already part of this organization"})]}),e.jsxs(vr,{children:[e.jsx(Hs,{children:"ℹ"}),e.jsxs(yr,{children:["You're already a member of ",((C=i.organization)==null?void 0:C.name)||"this organization"]}),e.jsx(br,{children:"No action needed - you already have access."}),e.jsx(B,{onClick:f,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.requires_signin){const $=i.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(xr,{children:"To accept this invitation"})]}),e.jsxs(vr,{children:[e.jsx(Hs,{children:"ℹ"}),e.jsxs(yr,{children:["This invitation is for ",e.jsx(qs,{children:i.invited_email})]}),e.jsx(br,{children:$?"You need to create an account with this email address to accept the invitation.":i.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(B,{onClick:x,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Invitation Expired"}),e.jsx(xr,{children:"This invitation is no longer valid"})]}),e.jsxs(vr,{children:[e.jsx(yi,{children:"⏱"}),e.jsxs(yr,{children:["Invitation for ",e.jsx(qs,{children:i.invited_email})," has expired"]}),e.jsx(br,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):u||i!=null&&i.error_code?e.jsx(le,{children:e.jsxs(fr,{children:[e.jsxs(gr,{children:[e.jsx(mr,{children:"Invitation Error"}),e.jsx(xr,{children:"Unable to process invitation"})]}),e.jsxs(vr,{children:[e.jsx(yi,{children:"✗"}),e.jsx(yr,{children:"Something went wrong"}),e.jsx(br,{children:(i==null?void 0:i.message)||u||"Failed to accept invitation"}),e.jsx(B,{onClick:m,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(H0,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(q0,{onClick:x,children:"Sign in manually"})]})})]})]})}):null}const va=s.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),rt=()=>{const t=s.useContext(va);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},K0=h.div`
|
|
2183
2184
|
display: flex;
|
|
2184
2185
|
height: 100%;
|
|
2185
2186
|
min-height: 400px;
|
|
@@ -2384,7 +2385,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2384
2385
|
color: white;
|
|
2385
2386
|
font-size: 12px;
|
|
2386
2387
|
font-weight: 400;
|
|
2387
|
-
`,Lo=({onSuccess:t,onCancel:r})=>{const[n,o]=s.useState(""),[i,a]=s.useState(""),[u,c]=s.useState(),[d,p]=s.useState(null),[l,f]=s.useState(!1),
|
|
2388
|
+
`,Lo=({onSuccess:t,onCancel:r})=>{const[n,o]=s.useState(""),[i,a]=s.useState(""),[u,c]=s.useState(),[d,p]=s.useState(null),[l,f]=s.useState(!1),x=s.useRef(null),{createOrganization:m}=Tt(),{refetch:v}=He(),{toast:C}=rt(),$=g=>{o(g)},_=g=>{if(g.target.files&&g.target.files[0]){const j=g.target.files[0];if(j.size>2*1024*1024){C("File size cannot exceed 2MB","error");return}if(!j.type.startsWith("image/")){C("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),c(j),p(URL.createObjectURL(j))}},k=()=>{var g;(g=x.current)==null||g.click()},R=g=>g.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2)||"O";s.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]);const y=g=>g.trim().replace(/[<>\"'&]/g,""),b=g=>g.length>=2&&g.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(g),S=async()=>{const g=y(n),j=y(i);if(!g){C("Please enter an organization name","error");return}if(!b(g)){C("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(j.length>500){C("Description must be less than 500 characters","error");return}f(!0);try{const w=await m({name:g,description:j,image:u});await v(),t==null||t(w)}catch(w){const E=w.message||"Failed to create organization. Please try again.";C(E,"error")}finally{f(!1)}};return e.jsx(le,{children:e.jsxs(K0,{children:[e.jsxs(Q0,{children:[e.jsxs(su,{hasImage:!!d,onClick:k,children:[d?e.jsx(J0,{src:d,alt:"Organization logo"}):e.jsx(X0,{children:R(n||"O")}),e.jsx(p1,{children:e.jsx(h1,{children:"Upload Logo"})})]}),e.jsx(u1,{type:"file",ref:x,onChange:_,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(e1,{children:"Create new organization"}),e.jsx(t1,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(Z0,{children:[e.jsxs(r1,{children:[e.jsx(n1,{children:"Choose your organization name"}),e.jsx(o1,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(i1,{children:[e.jsxs(Ys,{children:[e.jsx(Ks,{children:"Organization name"}),e.jsx(a1,{type:"text",value:n,onChange:g=>$(g.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Ys,{children:[e.jsx(Ks,{children:"Description (optional)"}),e.jsx(s1,{value:i,onChange:g=>a(g.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(c1,{children:[r?e.jsxs(l1,{onClick:r,disabled:l,children:[e.jsx(ma,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(d1,{onClick:S,disabled:l||!n.trim(),children:l?"Creating...":"Create"})]})]})]})})},Qs=({isOpen:t,onClose:r,onCreated:n})=>{const o=()=>{n==null||n(),r==null||r()};return e.jsx(le,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Lo,{onSuccess:o,onCancel:r})})})})})})},f1=h.div`
|
|
2388
2389
|
text-align: left;
|
|
2389
2390
|
position: fixed;
|
|
2390
2391
|
background: var(--color-background);
|
|
@@ -2534,7 +2535,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2534
2535
|
outline: none;
|
|
2535
2536
|
border-color: var(--color-primary);
|
|
2536
2537
|
}
|
|
2537
|
-
`,k1=({organization:t})=>{const{getEnterpriseConnections:r,createEnterpriseConnection:n,deleteEnterpriseConnection:o,testEnterpriseConnection:i,generateSCIMToken:a,getSCIMToken:u,revokeSCIMToken:c}=Tt(),{toast:d}=rt(),[p,l]=s.useState(!1),[f,
|
|
2538
|
+
`,k1=({organization:t})=>{const{getEnterpriseConnections:r,createEnterpriseConnection:n,deleteEnterpriseConnection:o,testEnterpriseConnection:i,generateSCIMToken:a,getSCIMToken:u,revokeSCIMToken:c}=Tt(),{toast:d}=rt(),[p,l]=s.useState(!1),[f,x]=s.useState(null),{data:m=[],isLoading:v,mutate:C}=Re(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(r==null?void 0:r(t))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),$=async _=>{try{await(o==null?void 0:o(t,_)),C(),d("SSO connection deleted","info")}catch(k){d(k.message||"Failed to delete connection","error")}x(null)};return v?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ie,{})}):p?e.jsx(z1,{organization:t,onClose:()=>l(!1),onCreate:async _=>{try{await(n==null?void 0:n(t,_)),C(),l(!1),d("SSO connection created","info")}catch(k){d(k.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:m.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(wt,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(B,{onClick:()=>l(!0),style:{width:"auto"},children:[e.jsx(yt,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(v1,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),m.map(_=>e.jsx(E1,{connection:_,onDelete:k=>x(k),connectionToDelete:f,onConfirmDelete:$,onCancelDelete:()=>x(null),testConnection:k=>i(t,k),generateSCIMToken:k=>a(t,k),getSCIMToken:k=>u(t,k),revokeSCIMToken:k=>c(t,k),toast:d},_.id))]})})},C1=h.div`
|
|
2538
2539
|
margin-top: 16px;
|
|
2539
2540
|
padding-top: 16px;
|
|
2540
2541
|
border-top: 1px solid var(--color-border);
|
|
@@ -2550,14 +2551,14 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2550
2551
|
display: flex;
|
|
2551
2552
|
gap: 8px;
|
|
2552
2553
|
flex-wrap: wrap;
|
|
2553
|
-
`,E1=({connection:t,onDelete:r,connectionToDelete:n,onConfirmDelete:o,onCancelDelete:i,testConnection:a,generateSCIMToken:u,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var E,I,O,z,T;const[l,f]=s.useState(null),[m
|
|
2554
|
+
`,E1=({connection:t,onDelete:r,connectionToDelete:n,onConfirmDelete:o,onCancelDelete:i,testConnection:a,generateSCIMToken:u,getSCIMToken:c,revokeSCIMToken:d,toast:p})=>{var E,I,O,z,T;const[l,f]=s.useState(null),[x,m]=s.useState(!1),[v,C]=s.useState(null),[$,_]=s.useState(null),[k,R]=s.useState(!1),[y,b]=s.useState(null);s.useEffect(()=>{c&&t.id&&c(t.id).then(f).catch(()=>{})},[t.id,c]);const S=async()=>{if(a){R(!0),b(null);try{const M=await a(t.id);b(M)}catch(M){b({success:!1,checks:{},errors:{general:M.message||"Test failed"}})}finally{R(!1)}}},g=async()=>{if(u){m(!0);try{const M=await u(t.id);C(M.token),f({exists:!0,token:M}),p("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(M){p(M.message||"Failed to generate token","error")}finally{m(!1)}}},j=async()=>{if(d){m(!0);try{await d(t.id),f({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),C(null),p("SCIM token revoked","info")}catch(M){p(M.message||"Failed to revoke token","error")}finally{m(!1)}}},w=(M,D)=>{navigator.clipboard.writeText(M),_(D),setTimeout(()=>_(null),2e3)};return e.jsxs(y1,{children:[e.jsxs(b1,{children:[e.jsxs(w1,{children:[e.jsx(wt,{size:16}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(j1,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(B,{onClick:S,disabled:k,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:k?e.jsx(Ie,{size:14}):"Test"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{$outline:!0,onClick:()=>r(t.id),style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),n===t.id&&e.jsx(Zr,{title:"Delete this SSO connection?",onConfirm:()=>o(t.id),onCancel:i})]})]})]}),y&&e.jsxs("div",{style:{marginBottom:"12px",padding:"8px 12px",background:y.success?"var(--color-success-background, rgba(34, 197, 94, 0.1))":"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"6px",fontSize:"12px",color:y.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:[y.success?"✓ Connection is valid":"✗ Connection failed",y.errors&&Object.entries(y.errors).map(([M,D])=>e.jsxs("div",{style:{fontWeight:400,marginTop:"4px"},children:[M.replace(/_/g," "),": ",D]},M))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:"12px",marginBottom:"16px"},children:[t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_entity_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_sso_url})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.oidc_issuer_url}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_client_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_scopes||"openid profile email"})]}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(t.created_at).toLocaleDateString()})]}),e.jsxs(C1,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs(S1,{style:{marginBottom:0},children:[e.jsx(wt,{size:14}),"SCIM Provisioning"]}),e.jsx($1,{children:!(l!=null&&l.exists)||!((E=l==null?void 0:l.token)!=null&&E.enabled)?e.jsx(B,{onClick:g,disabled:x,style:{fontSize:"12px",padding:"6px 14px",width:"130px"},children:x?e.jsx(Ie,{size:14}):"Generate Token"}):e.jsxs(e.Fragment,{children:[e.jsx(B,{onClick:g,disabled:x,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:x?e.jsx(Ie,{size:14}):"Rotate"}),e.jsx(B,{$outline:!0,onClick:j,disabled:x,style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((I=l==null?void 0:l.token)==null?void 0:I.scim_base_url)||v)&&e.jsx("div",{style:{marginBottom:"8px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Base URL:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((O=l==null?void 0:l.token)==null?void 0:O.scim_base_url)||"Loading..."}),((z=l==null?void 0:l.token)==null?void 0:z.scim_base_url)&&e.jsx(vn,{onClick:()=>w(l.token.scim_base_url,"scim-url"),children:$==="scim-url"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]})}),v&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Token:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:v}),e.jsx(vn,{onClick:()=>w(v,"scim-token"),children:$==="scim-token"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginTop:"6px"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(l==null?void 0:l.exists)&&((T=l==null?void 0:l.token)==null?void 0:T.enabled)&&!v&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-muted)"},children:["Token: ",e.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-alt)",padding:"2px 6px",borderRadius:"4px"},children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]})]})]})},wi=h.h3`
|
|
2554
2555
|
margin: 0 0 12px 0;
|
|
2555
2556
|
font-size: 13px;
|
|
2556
2557
|
font-weight: 600;
|
|
2557
2558
|
color: var(--color-foreground);
|
|
2558
2559
|
text-transform: uppercase;
|
|
2559
2560
|
letter-spacing: 0.5px;
|
|
2560
|
-
`,z1=({onCreate:t,onClose:r,organization:n})=>{const{getOrganizationDomains:o,testEnterpriseConnectionConfig:i}=Tt(),{deployment:a}=be(),{toast:u}=rt(),[c,d]=s.useState(!1),[p,l]=s.useState(null),[f,m]=s.useState("saml"),[x,v]=s.useState(null),[$,S]=s.useState(!1),[_,k]=s.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[P,y]=s.useState(!1),[b,C]=s.useState(null),{data:g=[],isLoading:j}=Re("wacht-org-verified-domains-for-sso-screen",async()=>(await(o==null?void 0:o(n))||[]).filter(M=>M.verified),{revalidateOnFocus:!1}),w=F=>{l(F),m(F.protocol),F.protocol==="saml"?k(M=>{var L,A,R;return{...M,idp_entity_id:F.placeholders.entityId||"",idp_sso_url:F.placeholders.ssoUrl||"",attr_first_name:((L=F.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=F.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((R=F.attributeMapping)==null?void 0:R.email)||""}}):k(M=>{var L,A,R;return{...M,oidc_issuer_url:F.placeholders.issuerUrl||"",oidc_scopes:F.placeholders.scopes||"openid profile email",attr_first_name:((L=F.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=F.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((R=F.attributeMapping)==null?void 0:R.email)||""}})},E=a!=null&&a.backend_host?`${a.backend_host.startsWith("https://")?"":"https://"}${a.backend_host}/auth/sso/oidc/callback`:"",I=a!=null&&a.backend_host?`https://${a.backend_host}/auth/sso/metadata`:"",O=a!=null&&a.backend_host?`https://${a.backend_host}/auth/sso/callback`:"",z=(F,M)=>{navigator.clipboard.writeText(F),v(M),setTimeout(()=>v(null),2e3)},T=async F=>{F.preventDefault();const M=L=>L.includes("{")||L.includes("}");if(f==="saml"){if(!_.idp_entity_id||M(_.idp_entity_id)){u("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!_.idp_sso_url||M(_.idp_sso_url)){u("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!_.idp_certificate){u("Please provide the X.509 Certificate","error");return}}else{if(!_.oidc_issuer_url||M(_.oidc_issuer_url)){u("Please enter a valid Issuer URL (no placeholders)","error");return}if(!_.oidc_client_id||M(_.oidc_client_id)){u("Please enter a valid Client ID (no placeholders)","error");return}if(!_.oidc_client_secret){u("Please enter the Client Secret","error");return}}d(!0);try{const L={};_.attr_first_name&&(L.first_name=_.attr_first_name),_.attr_last_name&&(L.last_name=_.attr_last_name),_.attr_email&&(L.email=_.attr_email);const A=Object.keys(L).length>0;f==="saml"?await t({protocol:"saml",domain_id:_.domain_id||void 0,idp_entity_id:_.idp_entity_id,idp_sso_url:_.idp_sso_url,idp_certificate:_.idp_certificate,jit_enabled:_.jit_enabled,...A&&{attribute_mapping:L}}):await t({protocol:"oidc",domain_id:_.domain_id||void 0,oidc_issuer_url:_.oidc_issuer_url,oidc_client_id:_.oidc_client_id,oidc_client_secret:_.oidc_client_secret,oidc_scopes:_.oidc_scopes,jit_enabled:_.jit_enabled,...A&&{attribute_mapping:L}})}finally{d(!1)}},D=async()=>{y(!0),C(null);const F=A=>A.includes("{")||A.includes("}"),M={},L={};if(f==="saml"?(_.idp_entity_id?F(_.idp_entity_id)?(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID is required"),_.idp_sso_url?F(_.idp_sso_url)?(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL is required"),_.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,M.certificate_provided="X.509 Certificate is required")):(_.oidc_issuer_url?F(_.oidc_issuer_url)?(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL is required"),_.oidc_client_id?F(_.oidc_client_id)?(L.client_id_valid=!1,M.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,M.client_id_valid="Client ID is required")),Object.keys(M).length>0){C({success:!1,checks:L,errors:M}),y(!1);return}try{const A=f==="saml"?{protocol:"saml",idp_entity_id:_.idp_entity_id,idp_sso_url:_.idp_sso_url,idp_certificate:_.idp_certificate}:{protocol:"oidc",oidc_issuer_url:_.oidc_issuer_url,oidc_client_id:_.oidc_client_id,oidc_client_secret:_.oidc_client_secret},R=await(i==null?void 0:i(n,A));R&&C(R)}catch(A){C({success:!1,checks:{},errors:{general:"Test failed: "+A.message}})}finally{y(!1)}};return e.jsxs("form",{onSubmit:T,autoComplete:"off",children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(bi,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>l(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(wi,{children:"SAML Providers"}),e.jsx(Xs,{children:Js.filter(F=>F.protocol==="saml").map(F=>e.jsxs(ec,{type:"button",$selected:!1,onClick:()=>w(F),children:[F.logo?e.jsx(bi,{src:F.logo,alt:F.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsx(tc,{children:F.name})]},F.id))}),e.jsx(wi,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Xs,{children:Js.filter(F=>F.protocol==="oidc").map(F=>e.jsxs(ec,{type:"button",$selected:!1,onClick:()=>w(F),children:[F.logo?e.jsx(bi,{src:F.logo,alt:F.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsx(tc,{children:F.name})]},F.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Zs,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:f==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:O}),e.jsx(vn,{onClick:()=>z(O,"acs"),children:x==="acs"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:I}),e.jsx(vn,{onClick:()=>z(I,"metadata"),children:x==="metadata"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(vn,{onClick:()=>z(E,"callback"),children:x==="callback"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(wi,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Id,{size:12})," Docs"]}),e.jsx(B,{type:"button",onClick:D,disabled:P||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:P?e.jsx(Ie,{size:16}):"Test Connection"}),e.jsx(B,{type:"submit",disabled:c||g.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:c?e.jsx(Ie,{size:16}):"Create Connection"})]})]}),b&&(()=>{const F={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:b.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${b.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:b.success?"#10b981":"#ef4444"},children:b.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(b.checks).map(([M,L])=>{var A;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:L?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:L?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:F[M]||M.replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase())}),((A=b.errors)==null?void 0:A[M])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:b.errors[M]})]})]},M)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(oe,{children:[e.jsx(re,{children:"Protocol *"}),e.jsxs(rc,{value:f,onChange:F=>m(F.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(oe,{style:{gridColumn:"1 / -1"},children:[e.jsx(re,{children:"Domain *"}),j?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):g.length===0?e.jsx(Zs,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(rc,{value:_.domain_id,onChange:F=>k({..._,domain_id:F.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),g.map(F=>e.jsx("option",{value:F.id,children:F.fqdn},F.id))]})]}),f==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:"IdP Entity ID *"}),e.jsx(ne,{type:"text",value:_.idp_entity_id,onChange:F=>k({..._,idp_entity_id:F.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"IdP SSO URL *"}),e.jsx(ne,{type:"url",value:_.idp_sso_url,onChange:F=>k({..._,idp_sso_url:F.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(oe,{style:{gridColumn:"1 / -1"},children:[e.jsx(re,{children:"X.509 Certificate *"}),e.jsx(_1,{value:_.idp_certificate,onChange:F=>k({..._,idp_certificate:F.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Issuer URL *"}),e.jsx(ne,{type:"url",value:_.oidc_issuer_url,onChange:F=>k({..._,oidc_issuer_url:F.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Client ID *"}),e.jsx(ne,{type:"text",value:_.oidc_client_id,onChange:F=>k({..._,oidc_client_id:F.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Client Secret *"}),e.jsx(ne,{type:"password",value:_.oidc_client_secret,onChange:F=>k({..._,oidc_client_secret:F.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Scopes"}),e.jsx(ne,{type:"text",value:_.oidc_scopes,onChange:F=>k({..._,oidc_scopes:F.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(oe,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(Pr,{checked:_.jit_enabled,onChange:()=>k({..._,jit_enabled:!_.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>S(!$),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:$?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:$?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),$&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"First Name Attribute"}),e.jsx(ne,{type:"text",value:_.attr_first_name,onChange:F=>k({..._,attr_first_name:F.target.value}),placeholder:f==="saml"?"givenName":"given_name"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Last Name Attribute"}),e.jsx(ne,{type:"text",value:_.attr_last_name,onChange:F=>k({..._,attr_last_name:F.target.value}),placeholder:f==="saml"?"surname":"family_name"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Email Attribute"}),e.jsx(ne,{type:"text",value:_.attr_email,onChange:F=>k({..._,attr_email:F.target.value}),placeholder:"email"})]})]})]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[e.jsx(B,{type:"button",onClick:r,style:{background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)",padding:"8px 16px",borderRadius:"6px"},children:"Cancel"}),e.jsx(B,{type:"submit",disabled:c,style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px"},children:c?"Saving...":"Create Connection"})]})]})]})]})]})};_t`
|
|
2561
|
+
`,z1=({onCreate:t,onClose:r,organization:n})=>{const{getOrganizationDomains:o,testEnterpriseConnectionConfig:i}=Tt(),{deployment:a}=be(),{toast:u}=rt(),[c,d]=s.useState(!1),[p,l]=s.useState(null),[f,x]=s.useState("saml"),[m,v]=s.useState(null),[C,$]=s.useState(!1),[_,k]=s.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[R,y]=s.useState(!1),[b,S]=s.useState(null),{data:g=[],isLoading:j}=Re("wacht-org-verified-domains-for-sso-screen",async()=>(await(o==null?void 0:o(n))||[]).filter(F=>F.verified),{revalidateOnFocus:!1}),w=D=>{l(D),x(D.protocol),D.protocol==="saml"?k(F=>{var L,A,P;return{...F,idp_entity_id:D.placeholders.entityId||"",idp_sso_url:D.placeholders.ssoUrl||"",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}}):k(F=>{var L,A,P;return{...F,oidc_issuer_url:D.placeholders.issuerUrl||"",oidc_scopes:D.placeholders.scopes||"openid profile email",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}})},E=a!=null&&a.backend_host?`${a.backend_host.startsWith("https://")?"":"https://"}${a.backend_host}/auth/sso/oidc/callback`:"",I=a!=null&&a.backend_host?`https://${a.backend_host}/auth/sso/metadata`:"",O=a!=null&&a.backend_host?`https://${a.backend_host}/auth/sso/callback`:"",z=(D,F)=>{navigator.clipboard.writeText(D),v(F),setTimeout(()=>v(null),2e3)},T=async D=>{D.preventDefault();const F=L=>L.includes("{")||L.includes("}");if(f==="saml"){if(!_.idp_entity_id||F(_.idp_entity_id)){u("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!_.idp_sso_url||F(_.idp_sso_url)){u("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!_.idp_certificate){u("Please provide the X.509 Certificate","error");return}}else{if(!_.oidc_issuer_url||F(_.oidc_issuer_url)){u("Please enter a valid Issuer URL (no placeholders)","error");return}if(!_.oidc_client_id||F(_.oidc_client_id)){u("Please enter a valid Client ID (no placeholders)","error");return}if(!_.oidc_client_secret){u("Please enter the Client Secret","error");return}}d(!0);try{const L={};_.attr_first_name&&(L.first_name=_.attr_first_name),_.attr_last_name&&(L.last_name=_.attr_last_name),_.attr_email&&(L.email=_.attr_email);const A=Object.keys(L).length>0;f==="saml"?await t({protocol:"saml",domain_id:_.domain_id||void 0,idp_entity_id:_.idp_entity_id,idp_sso_url:_.idp_sso_url,idp_certificate:_.idp_certificate,jit_enabled:_.jit_enabled,...A&&{attribute_mapping:L}}):await t({protocol:"oidc",domain_id:_.domain_id||void 0,oidc_issuer_url:_.oidc_issuer_url,oidc_client_id:_.oidc_client_id,oidc_client_secret:_.oidc_client_secret,oidc_scopes:_.oidc_scopes,jit_enabled:_.jit_enabled,...A&&{attribute_mapping:L}})}finally{d(!1)}},M=async()=>{y(!0),S(null);const D=A=>A.includes("{")||A.includes("}"),F={},L={};if(f==="saml"?(_.idp_entity_id?D(_.idp_entity_id)?(L.entity_id_valid=!1,F.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,F.entity_id_valid="IdP Entity ID is required"),_.idp_sso_url?D(_.idp_sso_url)?(L.sso_url_valid=!1,F.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,F.sso_url_valid="IdP SSO URL is required"),_.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,F.certificate_provided="X.509 Certificate is required")):(_.oidc_issuer_url?D(_.oidc_issuer_url)?(L.issuer_url_valid=!1,F.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,F.issuer_url_valid="Issuer URL is required"),_.oidc_client_id?D(_.oidc_client_id)?(L.client_id_valid=!1,F.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,F.client_id_valid="Client ID is required")),Object.keys(F).length>0){S({success:!1,checks:L,errors:F}),y(!1);return}try{const A=f==="saml"?{protocol:"saml",idp_entity_id:_.idp_entity_id,idp_sso_url:_.idp_sso_url,idp_certificate:_.idp_certificate}:{protocol:"oidc",oidc_issuer_url:_.oidc_issuer_url,oidc_client_id:_.oidc_client_id,oidc_client_secret:_.oidc_client_secret},P=await(i==null?void 0:i(n,A));P&&S(P)}catch(A){S({success:!1,checks:{},errors:{general:"Test failed: "+A.message}})}finally{y(!1)}};return e.jsxs("form",{onSubmit:T,autoComplete:"off",children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(bi,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>l(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(wi,{children:"SAML Providers"}),e.jsx(Xs,{children:Js.filter(D=>D.protocol==="saml").map(D=>e.jsxs(ec,{type:"button",$selected:!1,onClick:()=>w(D),children:[D.logo?e.jsx(bi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsx(tc,{children:D.name})]},D.id))}),e.jsx(wi,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Xs,{children:Js.filter(D=>D.protocol==="oidc").map(D=>e.jsxs(ec,{type:"button",$selected:!1,onClick:()=>w(D),children:[D.logo?e.jsx(bi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(wt,{size:18,color:"#666"})}),e.jsx(tc,{children:D.name})]},D.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Zs,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:f==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:O}),e.jsx(vn,{onClick:()=>z(O,"acs"),children:m==="acs"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:I}),e.jsx(vn,{onClick:()=>z(I,"metadata"),children:m==="metadata"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(vn,{onClick:()=>z(E,"callback"),children:m==="callback"?e.jsx(st,{size:12}):e.jsx(Cr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(wi,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Id,{size:12})," Docs"]}),e.jsx(B,{type:"button",onClick:M,disabled:R||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:R?e.jsx(Ie,{size:16}):"Test Connection"}),e.jsx(B,{type:"submit",disabled:c||g.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:c?e.jsx(Ie,{size:16}):"Create Connection"})]})]}),b&&(()=>{const D={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:b.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${b.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:b.success?"#10b981":"#ef4444"},children:b.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(b.checks).map(([F,L])=>{var A;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:L?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:L?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:D[F]||F.replace(/_/g," ").replace(/\b\w/g,P=>P.toUpperCase())}),((A=b.errors)==null?void 0:A[F])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:b.errors[F]})]})]},F)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(oe,{children:[e.jsx(re,{children:"Protocol *"}),e.jsxs(rc,{value:f,onChange:D=>x(D.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(oe,{style:{gridColumn:"1 / -1"},children:[e.jsx(re,{children:"Domain *"}),j?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):g.length===0?e.jsx(Zs,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(rc,{value:_.domain_id,onChange:D=>k({..._,domain_id:D.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),g.map(D=>e.jsx("option",{value:D.id,children:D.fqdn},D.id))]})]}),f==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:"IdP Entity ID *"}),e.jsx(ne,{type:"text",value:_.idp_entity_id,onChange:D=>k({..._,idp_entity_id:D.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"IdP SSO URL *"}),e.jsx(ne,{type:"url",value:_.idp_sso_url,onChange:D=>k({..._,idp_sso_url:D.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(oe,{style:{gridColumn:"1 / -1"},children:[e.jsx(re,{children:"X.509 Certificate *"}),e.jsx(_1,{value:_.idp_certificate,onChange:D=>k({..._,idp_certificate:D.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Issuer URL *"}),e.jsx(ne,{type:"url",value:_.oidc_issuer_url,onChange:D=>k({..._,oidc_issuer_url:D.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Client ID *"}),e.jsx(ne,{type:"text",value:_.oidc_client_id,onChange:D=>k({..._,oidc_client_id:D.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Client Secret *"}),e.jsx(ne,{type:"password",value:_.oidc_client_secret,onChange:D=>k({..._,oidc_client_secret:D.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Scopes"}),e.jsx(ne,{type:"text",value:_.oidc_scopes,onChange:D=>k({..._,oidc_scopes:D.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(oe,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(Pr,{checked:_.jit_enabled,onChange:()=>k({..._,jit_enabled:!_.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>$(!C),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:C?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:C?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),C&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"First Name Attribute"}),e.jsx(ne,{type:"text",value:_.attr_first_name,onChange:D=>k({..._,attr_first_name:D.target.value}),placeholder:f==="saml"?"givenName":"given_name"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Last Name Attribute"}),e.jsx(ne,{type:"text",value:_.attr_last_name,onChange:D=>k({..._,attr_last_name:D.target.value}),placeholder:f==="saml"?"surname":"family_name"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Email Attribute"}),e.jsx(ne,{type:"text",value:_.attr_email,onChange:D=>k({..._,attr_email:D.target.value}),placeholder:"email"})]})]})]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[e.jsx(B,{type:"button",onClick:r,style:{background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)",padding:"8px 16px",borderRadius:"6px"},children:"Cancel"}),e.jsx(B,{type:"submit",disabled:c,style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px"},children:c?"Saving...":"Create Connection"})]})]})]})]})]})};_t`
|
|
2561
2562
|
0% { transform: rotate(0deg); }
|
|
2562
2563
|
100% { transform: rotate(360deg); }
|
|
2563
2564
|
`;const nc=h.div`
|
|
@@ -2821,12 +2822,12 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2821
2822
|
flex-shrink: 0;
|
|
2822
2823
|
display: block;
|
|
2823
2824
|
}
|
|
2824
|
-
`;const L1=({organization:t})=>{var F,
|
|
2825
|
-
`).filter(U=>U.trim()),enable_ip_restriction:
|
|
2826
|
-
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const z=s.useMemo(()=>o.filter(U=>U.organization.id===(t==null?void 0:t.id)),[o,t==null?void 0:t.id]),T=async()=>{if(!(!t||
|
|
2827
|
-
`).filter(ae=>ae.trim()),enable_ip_restriction:H.security.ip_restrictions,enforce_mfa:H.security.mfa_required,auto_assigned_workspace_id:H.security.default_workspace_id||"0"}),c("Logo updated","info")}catch(H){c(H.message||"Failed to update logo","error")}finally{
|
|
2828
|
-
`).filter(U=>U.trim()),enable_ip_restriction:
|
|
2829
|
-
10.0.0.0/24`,style:{minHeight:"80px",fontFamily:"monospace"}})]})]}),((L=i==null?void 0:i.b2b_settings)==null?void 0:L.workspaces_enabled)&&z.length>0&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Ao,{options:z.map(
|
|
2825
|
+
`;const L1=({organization:t})=>{var D,F,L,A;const{switchOrganization:r,refetch:n}=He(),{workspaces:o}=ar(),{deployment:i}=be(),{deleteOrganization:a,updateOrganization:u}=Tt(),{toast:c}=rt(),[d,p]=s.useState((t==null?void 0:t.name)||""),[l,f]=s.useState((t==null?void 0:t.description)||""),[x,m]=s.useState((t==null?void 0:t.image_url)||null),v=s.useRef(null),[C,$]=s.useState(!1),[_,k]=s.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[R,y]=s.useState(""),[b,S]=s.useState(!1),[g,j]=s.useState(!1),[w,E]=s.useState(null),I=s.useRef({name:d,description:l,security:_,imageFile:w,isSaving:C});s.useEffect(()=>{I.current={name:d,description:l,security:_,imageFile:w,isSaving:C}},[d,l,_,w,C]);const O=s.useCallback(async()=>{if(!t||I.current.isSaving)return;const P=I.current;try{$(!0),await u(t,{name:P.name,description:P.description,image:P.imageFile,whitelisted_ips:P.security.allowed_ips.split(`
|
|
2826
|
+
`).filter(U=>U.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),c("Changes saved","info")}catch(U){const V=U.message||"Failed to save changes. Please try again.";c(V,"error")}finally{$(!1)}},[t,u,c]);s.useEffect(()=>{var P;t&&(p(t.name||""),f(t.description||""),m(t.image_url||null),k({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
|
|
2827
|
+
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const z=s.useMemo(()=>o.filter(U=>U.organization.id===(t==null?void 0:t.id)),[o,t==null?void 0:t.id]),T=async()=>{if(!(!t||R!==t.name))try{S(!0),await r(""),await a(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{S(!1),y("")}};s.useEffect(()=>()=>{x&&x.startsWith("blob:")&&URL.revokeObjectURL(x)},[x]);const M=async P=>{var U;if((U=P.target.files)!=null&&U[0]){const V=P.target.files[0];if(V.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!V.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&x.startsWith("blob:")&&URL.revokeObjectURL(x),E(V),m(URL.createObjectURL(V));try{$(!0);const H=I.current;await u(t,{name:H.name,description:H.description,image:V,whitelisted_ips:H.security.allowed_ips.split(`
|
|
2828
|
+
`).filter(ae=>ae.trim()),enable_ip_restriction:H.security.ip_restrictions,enforce_mfa:H.security.mfa_required,auto_assigned_workspace_id:H.security.default_workspace_id||"0"}),c("Logo updated","info")}catch(H){c(H.message||"Failed to update logo","error")}finally{$(!1)}}};return t?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)",paddingBottom:"40px"},children:[e.jsxs(T1,{children:[e.jsx(O1,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",boxShadow:"0 2px 8px var(--color-shadow)"},onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},children:[x?e.jsx("img",{src:x,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(ga,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:v,style:{display:"none"},accept:"image/*",onChange:M})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 0",fontWeight:"400"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs(A1,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},children:x?"Change":"Upload"}),x&&e.jsxs(B,{$outline:!0,$size:"sm",onClick:async()=>{m(null),E(null);try{$(!0);const P=I.current;await u(t,{name:P.name,description:P.description,image:"null",whitelisted_ips:P.security.allowed_ips.split(`
|
|
2829
|
+
`).filter(U=>U.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),c("Logo removed","info")}catch(P){c(P.message||"Failed to remove logo","error")}finally{$(!1)}},children:[e.jsx(Ot,{size:14,style:{marginRight:"4px"}})," Remove"]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)",textAlign:"inherit"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"name",children:"Organization Name"}),e.jsx(ne,{id:"name",value:d,onChange:P=>p(P.target.value),onBlur:O,placeholder:"Enter organization name",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"description",children:"Description"}),e.jsx(ne,{id:"description",as:"textarea",value:l,onChange:P=>f(P.target.value),onBlur:O,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical"}})]}),((D=i==null?void 0:i.b2b_settings)==null?void 0:D.enforce_mfa_per_org_enabled)&&e.jsxs(oc,{style:{padding:"0"},children:[e.jsxs(ic,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"Multi-Factor Authentication"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Require all members to set up MFA for added security"})]}),e.jsx(ac,{children:e.jsx(Pr,{checked:_.mfa_required,onChange:()=>{const P=!_.mfa_required;k(U=>({...U,mfa_required:P})),setTimeout(()=>O(),0)}})})]}),((F=i==null?void 0:i.b2b_settings)==null?void 0:F.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs(oc,{style:{padding:"0"},children:[e.jsxs(ic,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"IP Restrictions"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Only allow access from specific IP addresses"})]}),e.jsx(ac,{children:e.jsx(Pr,{checked:_.ip_restrictions,onChange:()=>{const P=!_.ip_restrictions;k(U=>({...U,ip_restrictions:P})),setTimeout(()=>O(),0)}})})]}),_.ip_restrictions&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ne,{id:"allowed_ips",as:"textarea",value:_.allowed_ips,onChange:P=>k(U=>({...U,allowed_ips:P.target.value})),onBlur:O,placeholder:`192.168.1.1
|
|
2830
|
+
10.0.0.0/24`,style:{minHeight:"80px",fontFamily:"monospace"}})]})]}),((L=i==null?void 0:i.b2b_settings)==null?void 0:L.workspaces_enabled)&&z.length>0&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Ao,{options:z.map(P=>({value:P.id,label:P.name})),value:_.default_workspace_id,onChange:P=>{k(U=>({...U,default_workspace_id:P})),setTimeout(()=>O(),0)},placeholder:"Select default workspace"})]})]})]}),((A=i==null?void 0:i.b2b_settings)==null?void 0:A.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:g?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete an organization, there is no going back. Please be certain."})]}),e.jsx(B,{onClick:()=>{g?(j(!1),y("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:g?"Cancel":"Delete"})]}),g&&e.jsxs("div",{style:{width:"100%",marginTop:"16px"},children:[e.jsxs(oe,{children:[e.jsxs(re,{htmlFor:"confirm_org_name",children:["Type ",e.jsx("strong",{children:t.name})," to confirm"]}),e.jsx(ne,{id:"confirm_org_name",type:"text",value:R,onChange:P=>y(P.target.value),placeholder:"Organization name",style:{width:"100%"}})]}),e.jsx(B,{onClick:T,disabled:R!==t.name||b,style:{background:R===t.name?"var(--color-error)":"transparent",color:R===t.name?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:R===t.name?"pointer":"not-allowed",width:"100%"},children:b?e.jsx(Ie,{size:12}):"Delete Forever"})]})]})]})]})]}):e.jsx(Ie,{})},Lt=h.table`
|
|
2830
2831
|
width: 100%;
|
|
2831
2832
|
border-collapse: separate;
|
|
2832
2833
|
border-spacing: 0;
|
|
@@ -2955,7 +2956,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2955
2956
|
color: var(--color-foreground);
|
|
2956
2957
|
background: var(--color-input-background);
|
|
2957
2958
|
}
|
|
2958
|
-
`,pc=({onClose:t,domain:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(),[u,c]=s.useState(""),[d,p]=s.useState(!1),[l,f]=s.useState(!1),[m
|
|
2959
|
+
`,pc=({onClose:t,domain:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(),[u,c]=s.useState(""),[d,p]=s.useState(!1),[l,f]=s.useState(!1),[x,m]=s.useState({top:0,left:0}),{addDomain:v,verifyDomain:C}=Tr(),{toast:$}=rt(),_=b=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(b),k=b=>b.trim().toLowerCase().replace(/^https?:\/\//,""),R=async()=>{const b=k(u);if(!b){$("Please enter a domain name","error");return}if(!_(b)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(b.length>253){$("Domain name is too long","error");return}try{const S=await v({fqdn:b});$("Domain added successfully","info"),a(S.data)}catch(S){const g=S.message||"Failed to add domain. Please try again.";$(g,"error")}},y=async()=>{if(!(!i||d)){p(!0);try{await C(i),t==null||t(),$("Domain verified successfully","info")}catch(b){const S=b.message||"Failed to verify domain. Please check DNS records and try again.";$(S,"error")}finally{p(!1)}}};return s.useEffect(()=>{f(!0);const b=setTimeout(()=>{if(!o.current)return;const j=n==null?void 0:n.current,w=360,E=250,I=8;let O=0,z=0;if(!j){const F=o.current.getBoundingClientRect(),L=F.width||w,A=F.height||E;O=Math.max(I,(window.innerHeight-A)/2),z=Math.max(I,(window.innerWidth-L)/2),m({top:O,left:z});return}const T=j.getBoundingClientRect(),M=window.innerHeight-T.bottom,D=T.top;M>=E+I?(O=T.bottom+I,z=T.right-w,z<I&&(z=T.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):D>=E+I?(O=T.top-E-I,z=T.right-w,z<I&&(z=T.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):(O=T.bottom+I,z=T.right-w,z<I&&(z=T.left)),m({top:O,left:z})},10),S=j=>{o.current&&!o.current.contains(j.target)&&(t==null||t())},g=j=>{j.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",S),document.addEventListener("keydown",g),()=>{clearTimeout(b),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",g)}},[t,n]),s.useEffect(()=>{r&&a(r)},[r]),l?e.jsx(N1,{ref:o,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:i?e.jsxs(e.Fragment,{children:[e.jsxs(sc,{children:[e.jsx(cc,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(uc,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Yt,{size:16})})]}),e.jsxs(lc,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Record Type"}),e.jsx(ne,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Record Name"}),e.jsx(ne,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Record Data"}),e.jsx(ne,{type:"text",value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(dc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:y,disabled:d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(sc,{children:[e.jsx(cc,{id:"add-domain-title",children:"Add Domain"}),e.jsx(uc,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Yt,{size:16})})]}),e.jsx(lc,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(oe,{children:[e.jsx(re,{children:"Enter FQDN"}),e.jsx(ne,{type:"text",placeholder:"Enter your domain",value:u,onChange:b=>c(b.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(dc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:R,disabled:!u||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Gn=h.span`
|
|
2959
2960
|
background: ${t=>t.$type==="success"?"var(--color-primary-background)":"var(--color-warning-background)"};
|
|
2960
2961
|
color: ${t=>t.$type==="success"?"var(--color-primary)":"var(--color-warning)"};
|
|
2961
2962
|
padding: 4px 8px;
|
|
@@ -2988,7 +2989,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
2988
2989
|
display: flex;
|
|
2989
2990
|
flex-direction: column;
|
|
2990
2991
|
gap: 12px;
|
|
2991
|
-
`,V1=({organization:t})=>{const{getOrganizationDomains:r,removeOrganizationDomain:n}=Tt(),[o,i]=s.useState(null),{data:a=[],isLoading:u,mutate:c}=Re(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(r==null?void 0:r(t))||[]).map(b=>({...b,verified:b.verified!==void 0?b.verified:!1}))),[d,p]=s.useState(!1),[l,f]=s.useState(null),[m
|
|
2992
|
+
`,V1=({organization:t})=>{const{getOrganizationDomains:r,removeOrganizationDomain:n}=Tt(),[o,i]=s.useState(null),{data:a=[],isLoading:u,mutate:c}=Re(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(r==null?void 0:r(t))||[]).map(b=>({...b,verified:b.verified!==void 0?b.verified:!1}))),[d,p]=s.useState(!1),[l,f]=s.useState(null),[x,m]=s.useState(""),[v,C]=s.useState(null),$=s.useRef(null),_=s.useRef({}),k=s.useMemo(()=>{if(!x.trim())return a;const y=x.toLowerCase();return a.filter(b=>b.fqdn.toLowerCase().includes(y))},[a,x]),R=async y=>{await n(t,y),c(),i(null)};return u?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Mo,{children:[e.jsx(Zt,{value:x,onChange:m,placeholder:"Search domains..."}),e.jsx(B,{$size:"sm",ref:$,onClick:()=>p(!0),children:"Add Domain"}),d&&e.jsx(pc,{onClose:()=>{p(!1),c()},triggerRef:$})]}),(k==null?void 0:k.length)>0&&e.jsxs(U1,{children:[e.jsx(Ig,{size:18,color:"var(--color-primary)",style:{flexShrink:0,marginTop:"2px"}}),e.jsxs(B1,{children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and will be auto-assigned to the default workspace.",". This helps streamline onboarding for your team."]})]}),k!=null&&k.length?e.jsxs(e.Fragment,{children:[e.jsx(Do,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Domain"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{children:"Date Added"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:k.map(y=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:y.fqdn}),e.jsx(Ne,{children:y.verified?e.jsx(Gn,{$type:"success",children:"✓ Verified"}):e.jsxs(Gn,{$type:"warning",children:[e.jsx(ir,{size:12})," Pending"]})}),e.jsx(Ne,{children:new Date(y.created_at).toLocaleDateString()}),e.jsx(Ft,{children:e.jsx(hc,{domain:y,selectedAction:v,setSelectedAction:C,onVerify:()=>f(y.id),onDelete:()=>i(y.id),actionButtonRefs:_})})]},y.id))})]})}),e.jsx(Fo,{children:k.map(y=>e.jsxs(W1,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:400,fontSize:"14px",marginBottom:"4px"},children:y.fqdn}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:["Added on ",new Date(y.created_at).toLocaleDateString()]})]}),e.jsx(hc,{domain:y,selectedAction:v,setSelectedAction:C,onVerify:()=>f(y.id),onDelete:()=>i(y.id),actionButtonRefs:_})]}),e.jsx("div",{children:y.verified?e.jsx(Gn,{$type:"success",children:"✓ Verified"}):e.jsxs(Gn,{$type:"warning",children:[e.jsx(ir,{size:12})," Pending Verification"]})})]},y.id))})]}):e.jsx(kt,{title:x?"No domains match your search":"No domains added",description:x?"Try a different search term.":"Manage your corporate domains to streamline onboarding for your team."}),o&&e.jsx(Zr,{title:"Delete domain?",description:"Are you sure you want to remove this domain? Active users won't be affected but new ones won't auto-join.",onConfirm:()=>{const y=a.find(b=>b.id===o);y&&R(y)},onCancel:()=>i(null)}),l&&e.jsx(pc,{domain:a.find(y=>y.id===l),onClose:()=>f(null),triggerRef:{current:_.current[l]}})]})},hc=({domain:t,selectedAction:r,setSelectedAction:n,onVerify:o,onDelete:i,actionButtonRefs:a})=>e.jsx("div",{style:{position:"relative"},children:e.jsxs(ut,{open:r===t.id,openChange:u=>n(u?t.id:null),children:[e.jsx(ht,{children:e.jsx(ya,{ref:u=>{a.current[t.id]=u},children:"•••"})}),e.jsxs(pt,{children:[e.jsx(Le,{onClick:()=>{o(),n(null)},children:t.verified?"📋 View DNS Record":"✓ Verify Domain"}),e.jsxs(Le,{onClick:()=>{navigator.clipboard.writeText(t.fqdn),n(null)},children:[e.jsx(Cr,{size:16})," Copy Domain"]}),e.jsxs(Le,{onClick:()=>{window.open(`https://${t.fqdn}`,"_blank"),n(null)},children:[e.jsx(Id,{size:16})," Visit Domain"]}),e.jsx(Oo,{}),e.jsxs(Le,{$destructive:!0,onClick:()=>{i(),n(null)},children:[e.jsx(Ot,{size:16})," Remove Domain"]})]})]})}),G1=h.div`
|
|
2992
2993
|
position: fixed;
|
|
2993
2994
|
width: 360px;
|
|
2994
2995
|
max-width: calc(100vw - 48px);
|
|
@@ -3037,7 +3038,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3037
3038
|
color: var(--color-foreground);
|
|
3038
3039
|
background: var(--color-input-background);
|
|
3039
3040
|
}
|
|
3040
|
-
`,cu=({onClose:t,onSuccess:r,roles:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState(""),[c,d]=s.useState(null),[p,l]=s.useState(!1),[f,
|
|
3041
|
+
`,cu=({onClose:t,onSuccess:r,roles:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState(""),[c,d]=s.useState(null),[p,l]=s.useState(!1),[f,x]=s.useState(!1),[m,v]=s.useState({top:0,left:0}),{inviteMember:C}=Tr(),{toast:$}=rt(),_=n.map(y=>({value:y.id,label:y.name})),k=y=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y),R=async()=>{const y=a.trim().toLowerCase();if(!(!y||!c)){if(!k(y)){$("Please enter a valid email address","error");return}if(y.length>320){$("Email address is too long","error");return}l(!0);try{await C({email:y,organizationRole:c}),r==null||r()}catch(b){const S=b.message||"Failed to send invitation. Please try again.";$(S,"error")}finally{l(!1)}}};return s.useEffect(()=>{x(!0);const y=setTimeout(()=>{if(!i.current||!(o!=null&&o.current))return;const g=o.current;if(g){const j=g.getBoundingClientRect(),w=360,E=250,I=8;let O=0,z=0;const T=window.innerHeight-j.bottom,M=j.top;T>=E+I?(O=j.bottom+I,z=j.right-w,z<I&&(z=j.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):M>=E+I?(O=j.top-E-I,z=j.right-w,z<I&&(z=j.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):(O=j.bottom+I,z=j.right-w,z<I&&(z=j.left)),v({top:O,left:z})}},10),b=g=>{i.current&&!i.current.contains(g.target)&&(t==null||t())},S=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",S),()=>{clearTimeout(y),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",S)}},[t,o]),f?e.jsxs(G1,{ref:i,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(H1,{children:[e.jsx(q1,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Q1,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Yt,{size:16})})]}),e.jsx(Y1,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Email Address"}),e.jsx(ne,{type:"email",placeholder:"colleague@company.com",value:a,onChange:y=>u(y.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Role"}),e.jsx(Ao,{options:_,value:c==null?void 0:c.id,onChange:y=>d(n.find(b=>b.id===y)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(K1,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:R,disabled:!a||!c||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Z1=h.div`
|
|
3041
3042
|
width: 40px;
|
|
3042
3043
|
height: 40px;
|
|
3043
3044
|
border-radius: 50%;
|
|
@@ -3049,7 +3050,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3049
3050
|
font-weight: 400;
|
|
3050
3051
|
font-size: 14px;
|
|
3051
3052
|
overflow: hidden;
|
|
3052
|
-
`,J1=({organization:t})=>{const{getOrganizationMembers:r,getOrganizationRoles:n,addRoleToOrganizationMember:o,removeRoleFromOrganizationMember:i,removeOrganizationMember:a}=Tt(),{session:u}=He(),{toast:c}=rt(),[d,p]=s.useState(""),[l,f]=s.useState(1),[
|
|
3053
|
+
`,J1=({organization:t})=>{const{getOrganizationMembers:r,getOrganizationRoles:n,addRoleToOrganizationMember:o,removeRoleFromOrganizationMember:i,removeOrganizationMember:a}=Tt(),{session:u}=He(),{toast:c}=rt(),[d,p]=s.useState(""),[l,f]=s.useState(1),[x]=s.useState(10),[m,v]=s.useState(!1),C=s.useRef(null),[$,_]=s.useState(d);s.useEffect(()=>{const z=setTimeout(()=>{_(d),f(1)},500);return()=>clearTimeout(z)},[d]);const{data:k,isLoading:R,mutate:y}=Re(t?`wacht-api-organizations:${t.id}:members:${l}:${x}:${$}`:null,()=>r==null?void 0:r(t,{page:l,limit:x,search:$})),b=(k==null?void 0:k.data)||[],S=(k==null?void 0:k.meta)||{total:0,limit:10},g=Math.ceil(S.total/(S.limit||10)),{data:j=[],isLoading:w}=Re(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n(t))||[]),E=j,I=async(z,T,M)=>{try{M?(await i(t,z,T),c("Role removed successfully","info")):(await o(t,z,T),c("Role added successfully","info")),y()}catch(D){c(D.message||"Failed to update role","error")}},O=async z=>{try{await a(t,z),y(),c("Member removed successfully","info")}catch(T){c(T.message||"Failed to remove member","error")}};return R||w?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Mo,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Zt,{value:d,onChange:p,placeholder:"Search members..."})}),e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[S.total>0&&e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)"},children:[S.total," member",S.total!==1?"s":""]}),e.jsx(B,{$size:"sm",ref:C,onClick:()=>v(!0),children:"Invite"})]})]}),m&&e.jsx(cu,{onClose:()=>v(!1),onSuccess:()=>{y(),v(!1)},roles:E,triggerRef:C}),b.length===0?e.jsx(kt,{title:d?"No members match":"No members yet",description:"Members with corporate domains will automatically join."}):e.jsxs(e.Fragment,{children:[e.jsx(Do,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Member"}),e.jsx(Pe,{children:"Joined"}),e.jsx(Pe,{children:"Roles"})]})}),e.jsx(Dt,{children:b.map(z=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsx(fc,{member:z,session:u})}),e.jsx(Ne,{children:new Date(z.created_at).toLocaleDateString()}),e.jsx(Ft,{children:e.jsx(gc,{member:z,roles:E,onToggle:I,onRemove:O})})]},z.id))})]})}),e.jsx(Fo,{children:b.map(z=>e.jsx(ba,{children:e.jsxs(wa,{children:[e.jsx(fc,{member:z,session:u,subtitle:`Joined ${new Date(z.created_at).toLocaleDateString()}`}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(gc,{member:z,roles:E,onToggle:I,onRemove:O})})]})},z.id))})]}),g>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px",marginTop:"24px"},children:[e.jsx(B,{onClick:()=>f(z=>Math.max(1,z-1)),disabled:l===1,$size:"sm",children:"Previous"}),e.jsxs("span",{style:{fontSize:"13px"},children:[l," / ",g]}),e.jsx(B,{onClick:()=>f(z=>Math.min(g,z+1)),disabled:l===g,$size:"sm",children:"Next"})]})]})},fc=({member:t,session:r,subtitle:n})=>{var u,c,d;const o=t.user,i=(o==null?void 0:o.id)===((u=r==null?void 0:r.active_signin)==null?void 0:u.user_id),a=(p="",l="")=>`${p[0]||""}${l[0]||""}`.toUpperCase();return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx(Z1,{children:o!=null&&o.profile_picture_url?e.jsx("img",{src:o.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):a(o==null?void 0:o.first_name,o==null?void 0:o.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:"400"},children:o?`${o.first_name||""} ${o.last_name||""}`.trim()||((c=o.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&e.jsx("span",{style:{fontSize:"10px",padding:"1px 4px",background:"var(--color-background-alt)",color:"var(--color-muted)",borderRadius:"3px",fontWeight:"400"},children:"You"})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"4px 8px"},children:[e.jsx("span",{children:(d=o==null?void 0:o.primary_email_address)==null?void 0:d.email}),n&&e.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",n]})]})]})]})},gc=({member:t,roles:r,onToggle:n,onRemove:o})=>{const i=t.roles||[],a=u=>i.some(c=>c.id===u);return e.jsxs(ut,{children:[e.jsx(ht,{children:e.jsxs(B,{$outline:!0,$size:"sm",style:{color:"var(--color-foreground)"},children:[i.length>0?i[0].name:"No role"," ",e.jsx(or,{size:14,style:{marginLeft:"4px"}})]})}),e.jsxs(pt,{children:[r.map(u=>{const c=a(u.id);return e.jsx(Le,{onClick:()=>n(t,u,c),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"12px"},children:[e.jsx("span",{children:u.name}),c&&e.jsx(st,{size:14,color:"var(--color-success)"})]})},u.id)}),e.jsx(Oo,{}),e.jsx(Le,{$destructive:!0,onClick:()=>o(t),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14})," Remove Member"]})})]})]})},X1=({organization:t})=>{const{getOrganizationInvitations:r,getOrganizationRoles:n,discardOrganizationInvitation:o,resendOrganizationInvitation:i}=Tt(),{toast:a}=rt(),[u,c]=s.useState(!1),[d,p]=s.useState(""),l=s.useRef(null),{data:f=[],isLoading:x,mutate:m}=Re(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(r==null?void 0:r(t))||[]),{data:v=[],isLoading:C}=Re(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n(t))||[]),$=v,_=s.useMemo(()=>{if(!d)return f;const y=d.toLowerCase();return f.filter(b=>b.email.toLowerCase().includes(y))},[f,d]),k=async y=>{try{await o(t,y),m(),a("Invitation cancelled","info")}catch(b){a(b.message||"Failed to cancel invitation","error")}},R=async y=>{try{await i(t,y),a("Invitation resent","info")}catch(b){a(b.message||"Failed to resend invitation","error")}};return x||C?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Mo,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Zt,{value:d,onChange:p,placeholder:"Search invitations..."})}),e.jsx(B,{$size:"sm",ref:l,onClick:()=>c(!0),children:"Invite"})]}),u&&e.jsx(cu,{onClose:()=>c(!1),onSuccess:()=>{m(),c(!1)},roles:$,triggerRef:l}),_.length===0?e.jsx(kt,{title:d?"No invitations match":"No pending invitations",description:"Invite members to collaborate."}):e.jsxs(e.Fragment,{children:[e.jsx(Do,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Email"}),e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Invited"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:_.map(y=>{var b;return e.jsxs(Ke,{children:[e.jsx(Ne,{children:y.email}),e.jsx(Ne,{children:((b=y.initial_organization_role)==null?void 0:b.name)||"No role"}),e.jsx(Ne,{children:new Date(y.created_at).toLocaleDateString()}),e.jsx(Ft,{children:e.jsx(mc,{invitation:y,onResend:R,onCancel:k})})]},y.id)})})]})}),e.jsx(Fo,{children:_.map(y=>{var b;return e.jsx(ba,{children:e.jsxs(wa,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:y.email}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[((b=y.initial_organization_role)==null?void 0:b.name)||"No role"," • ",new Date(y.created_at).toLocaleDateString()]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(mc,{invitation:y,onResend:R,onCancel:k})})]})},y.id)})})]})]})},mc=({invitation:t,onResend:r,onCancel:n})=>e.jsxs(ut,{children:[e.jsx(ht,{children:e.jsx(ya,{children:"•••"})}),e.jsxs(pt,{children:[e.jsxs(Le,{onClick:()=>r(t),children:[e.jsx(To,{size:16})," Resend"]}),e.jsxs(Le,{$destructive:!0,onClick:()=>n(t),children:[e.jsx(Ot,{size:16})," Cancel"]})]})]}),ev=h.div`
|
|
3053
3054
|
position: fixed;
|
|
3054
3055
|
width: 400px;
|
|
3055
3056
|
max-width: calc(100vw - 48px);
|
|
@@ -3100,7 +3101,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3100
3101
|
color: var(--color-foreground);
|
|
3101
3102
|
background: var(--color-input-background);
|
|
3102
3103
|
}
|
|
3103
|
-
`,xc=({onClose:t,onSuccess:r,role:n,triggerRef:o})=>{var
|
|
3104
|
+
`,xc=({onClose:t,onSuccess:r,role:n,triggerRef:o})=>{var S;const i=s.useRef(null),[a,u]=s.useState((n==null?void 0:n.name)||""),[c,d]=s.useState((n==null?void 0:n.permissions)||[]);Tr();const[p,l]=s.useState(!1),[f,x]=s.useState(!1),[m,v]=s.useState({top:0,left:0}),{deployment:C}=be(),{toast:$}=rt(),_=!!n,k=Array.isArray((S=C==null?void 0:C.b2b_settings)==null?void 0:S.organization_permissions)?C.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];s.useEffect(()=>{x(!0);const g=setTimeout(()=>{if(!i.current)return;let I=null;if(o!=null&&o.current)I=o.current;else if(_){const O=document.querySelectorAll("[data-role-dropdown-trigger]");for(let z=0;z<O.length;z++){const T=O[z];if(T.offsetParent!==null){I=T;break}}}else{const O=document.querySelectorAll("button");for(let z=0;z<O.length;z++){const T=O[z];if(T.textContent==="Add role"&&T.offsetParent!==null){I=T;break}}}if(I){const O=I.getBoundingClientRect(),z=400;let T=O.bottom+8,M=O.right-z;M<10&&(M=O.left),T+300>window.innerHeight&&(T=O.top-300-8),v({top:T,left:M})}},10),j=I=>{i.current&&!i.current.contains(I.target)&&(t==null||t())},w=I=>{I.key==="Escape"&&(t==null||t())},E=setTimeout(()=>{document.addEventListener("mousedown",j),document.addEventListener("keydown",w)},100);return()=>{clearTimeout(g),clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",w)}},[t,_,o]);const R=g=>g.trim().replace(/[<>\"'&]/g,""),y=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),b=async()=>{const g=R(a);if(!g){$("Please enter a role name","error");return}if(!y(g)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(c.length===0){$("Please select at least one permission","error");return}l(!0);try{const j={id:n==null?void 0:n.id,name:g,permissions:c||[]};r==null||r(j)}catch(j){const w=j.message||`Failed to ${_?"update":"create"} role. Please try again.`;$(w,"error")}finally{l(!1)}};return f?e.jsxs(ev,{ref:i,$isInTable:_,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(tv,{children:[e.jsx(rv,{id:"role-dialog-title",children:_?"Edit Role":"Create New Role"}),e.jsx(iv,{onClick:t,"aria-label":`Close ${_?"edit":"create"} role dialog`,children:e.jsx(Yt,{size:16})})]}),e.jsx(nv,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Role Name"}),e.jsx(ne,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:g=>u(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Permissions"}),e.jsx(Qd,{options:k,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(ov,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:b,disabled:!a||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," ",_?"Updating...":"Creating..."]}):_?"Update Role":"Create Role"})]})]}):null},av=({organization:t})=>{var R;const{getOrganizationRoles:r,removeOrganizationRoles:n}=Tt(),{deployment:o}=be(),[i,a]=s.useState({isOpen:!1}),[u,c]=s.useState(null),[d,p]=s.useState(""),[l,f]=s.useState(null),x=s.useRef(null),{data:m=[],isLoading:v,mutate:C}=Re(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(r==null?void 0:r(t))||[]),$=s.useMemo(()=>d?m.filter(y=>y.name.toLowerCase().includes(d.toLowerCase())):m,[m,d]),_=async y=>{try{await new Promise(b=>setTimeout(b,500)),c({text:`Role ${y.id?"updated":"created"} successfully`,type:"success"}),a({isOpen:!1}),C()}catch(b){c({text:b.message||"Failed to save role",type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async y=>{try{await n(t,y),C(),f(null)}catch{}};return v&&m.length===0?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[u&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:u.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:u.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px",fontSize:"14px"},children:[u.type==="success"?"✓":e.jsx(ir,{size:16}),u.text]}),e.jsxs(Mo,{children:[e.jsx(Zt,{placeholder:"Search roles...",onChange:p,value:d}),((R=o==null?void 0:o.b2b_settings)==null?void 0:R.custom_org_role_enabled)&&e.jsx(B,{$size:"sm",ref:x,onClick:()=>a({isOpen:!0}),children:"Add Role"})]}),i.isOpen&&!i.role&&e.jsx(xc,{onClose:()=>a({isOpen:!1}),onSuccess:_,triggerRef:x}),$.length===0?e.jsx(kt,{title:d?"No roles match":"No roles yet",description:"Define custom roles to manage granular permissions."}):e.jsxs(e.Fragment,{children:[e.jsx(Do,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Permissions"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:$.map(y=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsx("div",{style:{fontWeight:500},children:y.name})}),e.jsx(Ne,{style:{color:"var(--color-secondary-text)"},children:y.permissions.join(", ")}),e.jsx(Ft,{children:e.jsx(vc,{role:y,onEdit:()=>a({isOpen:!0,role:y}),onDelete:()=>f(y.id)})})]},y.id))})]})}),e.jsx(Fo,{children:$.map(y=>e.jsx(ba,{children:e.jsxs(wa,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:y.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)",lineHeight:1.4},children:y.permissions.join(", ")})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(vc,{role:y,onEdit:()=>a({isOpen:!0,role:y}),onDelete:()=>f(y.id)})})]})},y.id))})]}),l&&e.jsx(Zr,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const y=m.find(b=>b.id===l);y&&k(y)},onCancel:()=>f(null)}),i.isOpen&&i.role&&e.jsx(xc,{role:i.role,onClose:()=>a({isOpen:!1}),onSuccess:_})]})},vc=({role:t,onEdit:r,onDelete:n})=>e.jsxs(ut,{children:[e.jsx(ht,{children:e.jsx(ya,{disabled:!t.organization_id,children:"•••"})}),e.jsxs(pt,{children:[e.jsx(Le,{onClick:r,children:"Edit Role"}),e.jsxs(Le,{$destructive:!0,onClick:n,children:[e.jsx(Ot,{size:16})," Remove Role"]})]})]}),sv=()=>{const{activeOrganization:t,loading:r}=Tr(),[n,o]=s.useState(null);return s.useEffect(()=>{t?o(t):!r&&!t&&n&&o(null)},[t,r,n]),{activeOrganization:n||t,loading:r}},lu=()=>{var l,f;const{loading:t,activeOrganization:r}=sv(),{deployment:n}=be(),[o,i]=s.useState("general"),[a,u]=s.useState(null),[c,d]=s.useState("info"),p=s.useCallback((x,m="info")=>{u(x),d(m),setTimeout(()=>u(null),3e3)},[]);return t&&!r?e.jsx(le,{children:e.jsx(ji,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})}):r?e.jsx(le,{children:e.jsx(nc,{children:e.jsx(va.Provider,{value:{screen:null,setScreen:()=>{},toast:p},children:e.jsxs(ji,{children:[e.jsx(P1,{children:e.jsxs(R1,{children:[e.jsx(Dr,{$isActive:o==="general",onClick:()=>i("general"),children:e.jsxs(Fr,{children:[e.jsx(Sr,{size:16})," General"]})}),e.jsx(Dr,{$isActive:o==="domains",onClick:()=>i("domains"),children:e.jsxs(Fr,{children:[e.jsx(Pg,{size:16})," Domains"]})}),e.jsx(Dr,{$isActive:o==="members",onClick:()=>i("members"),children:e.jsxs(Fr,{children:[e.jsx(wo,{size:16})," Members"]})}),e.jsx(Dr,{$isActive:o==="invitations",onClick:()=>i("invitations"),children:e.jsxs(Fr,{children:[e.jsx(To,{size:16})," Invitations"]})}),((l=n==null?void 0:n.b2b_settings)==null?void 0:l.custom_org_role_enabled)&&e.jsx(Dr,{$isActive:o==="roles",onClick:()=>i("roles"),children:e.jsxs(Fr,{children:[e.jsx(wt,{size:16})," Roles"]})}),((f=n==null?void 0:n.b2b_settings)==null?void 0:f.enterprise_sso_enabled)&&e.jsx(Dr,{$isActive:o==="sso",onClick:()=>i("sso"),children:e.jsxs(Fr,{children:[e.jsx(wt,{size:16})," SSO"]})})]})}),e.jsxs(I1,{children:[o==="general"&&e.jsx(L1,{organization:r}),o==="domains"&&e.jsx(V1,{organization:r}),o==="members"&&e.jsx(J1,{organization:r}),o==="invitations"&&e.jsx(X1,{organization:r}),o==="roles"&&e.jsx(av,{organization:r}),o==="sso"&&e.jsx(k1,{organization:r})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideDown 0.3s ease-out",zIndex:100},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[c==="error"?e.jsx(ir,{size:16,color:"var(--color-error)"}):e.jsx(st,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})}):e.jsx(le,{children:e.jsx(nc,{children:e.jsx(ji,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(ga,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(yu,{})]})})})})},yc=({isOpen:t,onClose:r,title:n,showHeader:o,headerContent:i,footerContent:a,customContent:u,children:c,showCloseButton:d})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:[o&&e.jsx(ze.Header,{showCloseButton:d,children:i||n}),u||c||e.jsx(lu,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),cv=h.div`
|
|
3104
3105
|
display: flex;
|
|
3105
3106
|
height: 100%;
|
|
3106
3107
|
min-height: 400px;
|
|
@@ -3407,7 +3408,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3407
3408
|
align-items: center;
|
|
3408
3409
|
justify-content: center;
|
|
3409
3410
|
color: var(--color-primary);
|
|
3410
|
-
`,ja=({organizationId:t,onSuccess:r,onCancel:n,onCreateOrganization:o})=>{var
|
|
3411
|
+
`,ja=({organizationId:t,onSuccess:r,onCancel:n,onCreateOrganization:o})=>{var M;const[i,a]=s.useState(""),[u,c]=s.useState(""),[d,p]=s.useState(),[l,f]=s.useState(null),[x,m]=s.useState(!1),[v,C]=s.useState(!1),[$,_]=s.useState(t),k=s.useRef(null),R=s.useRef(null),{toast:y}=rt(),{createWorkspace:b}=ar(),{refetch:S}=He(),{organizationMemberships:g}=Kt(),j=(M=g==null?void 0:g.find(D=>D.organization.id===$))==null?void 0:M.organization,w=D=>{if(D.target.files&&D.target.files[0]){const F=D.target.files[0];if(F.size>2*1024*1024){y("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){y("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),p(F),f(URL.createObjectURL(F))}},E=()=>{var D;(D=k.current)==null||D.click()},I=D=>D.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",O=D=>D.trim().replace(/[<>\"'&]/g,""),z=D=>D.length>=2&&D.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(D),T=async()=>{const D=O(i),F=O(u);if(!D||!$){y("Please enter a workspace name","error");return}if(!z(D)){y("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){y("Description must be less than 500 characters","error");return}m(!0);try{const L=await b($,D,d,F);await S(),r==null||r(L)}catch(L){const A=L.message||"Failed to create workspace. Please try again.";y(A,"error")}finally{m(!1)}};return s.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),s.useEffect(()=>{const D=F=>{R.current&&!R.current.contains(F.target)&&C(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]),e.jsx(le,{children:e.jsxs(cv,{children:[e.jsxs(lv,{children:[e.jsxs(du,{hasImage:!!l,onClick:E,children:[l?e.jsx(uv,{src:l,alt:"Workspace logo"}):e.jsx(pv,{children:I(i||"W")}),e.jsx(Cv,{children:e.jsx(Sv,{children:"Upload Logo"})})]}),e.jsx(kv,{type:"file",ref:k,onChange:w,accept:"image/png, image/jpeg, image/gif",disabled:x}),e.jsx(hv,{children:"Create new workspace"}),e.jsx(fv,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(dv,{children:[e.jsxs(gv,{children:[e.jsx(mv,{children:"Choose your workspace name"}),e.jsx(xv,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(vv,{children:[e.jsxs(_i,{children:[e.jsx(ki,{children:"Organization"}),e.jsxs($v,{ref:R,children:[e.jsxs(Ev,{type:"button",onClick:()=>C(!v),disabled:x,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(bc,{children:j!=null&&j.image_url?e.jsx(wc,{src:j.image_url,alt:j.name}):I((j==null?void 0:j.name)||"O").charAt(0)}),e.jsx("span",{children:(j==null?void 0:j.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(zv,{children:[g==null?void 0:g.map(D=>{var L,A,P;const F=((L=D.eligibility_restriction)==null?void 0:L.type)&&((A=D.eligibility_restriction)==null?void 0:A.type)!=="none";return e.jsxs(uu,{onClick:()=>{F||(_(D.organization.id),C(!1))},disabled:F,style:{opacity:F?.6:1,cursor:F?"not-allowed":"pointer"},title:F?(P=D.eligibility_restriction)==null?void 0:P.message:void 0,children:[e.jsx(bc,{children:D.organization.image_url?e.jsx(wc,{src:D.organization.image_url,alt:D.organization.name}):I(D.organization.name).charAt(0)}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{children:D.organization.name}),F&&e.jsx("span",{style:{fontSize:"10px",color:"var(--color-error)"},children:"Restricted"})]})]},D.organization.id)}),e.jsxs(Pv,{onClick:()=>{C(!1),o==null||o()},children:[e.jsx(Rv,{children:e.jsx(yt,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(_i,{children:[e.jsx(ki,{children:"Workspace name"}),e.jsx(yv,{type:"text",value:i,onChange:D=>a(D.target.value),placeholder:"Workspace Name",disabled:x})]}),e.jsxs(_i,{children:[e.jsx(ki,{children:"Description (optional)"}),e.jsx(bv,{value:u,onChange:D=>c(D.target.value),placeholder:"What is this workspace for?",disabled:x})]})]}),e.jsxs(wv,{children:[n?e.jsxs(jv,{onClick:n,disabled:x,children:[e.jsx(ma,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(_v,{onClick:T,disabled:x||!i.trim(),children:x?"Creating...":"Create"})]})]})]})})},ta=({isOpen:t,onClose:r,onCreated:n,organizationId:o})=>{const[i,a]=s.useState(!1),[u,c]=s.useState(o),{refetch:d,organizationMemberships:p}=Kt(),l=()=>{n==null||n(),r==null||r()},f=()=>{a(!0)},x=async()=>{await d(),setTimeout(()=>{if(p&&p.length>0){const m=p[p.length-1];c(m.organization.id)}a(!1)},500)};return e.jsx(le,{children:e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsx(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ze.Body,{style:{padding:0},children:i?e.jsx(Lo,{onSuccess:x,onCancel:()=>a(!1)}):e.jsx(ja,{organizationId:u||o,onSuccess:l,onCancel:r,onCreateOrganization:f})})})})})})};_t`
|
|
3411
3412
|
0% { transform: rotate(0deg); }
|
|
3412
3413
|
100% { transform: rotate(360deg); }
|
|
3413
3414
|
`;const Iv=h.div`
|
|
@@ -3671,11 +3672,11 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3671
3672
|
flex-shrink: 0;
|
|
3672
3673
|
display: block;
|
|
3673
3674
|
}
|
|
3674
|
-
`;const Fv=()=>{var O,z;const{activeWorkspace:t,loading:r,updateWorkspace:n}=Qt(),{deleteWorkspace:o}=ar(),{deployment:i}=be(),{toast:a}=rt(),[u,c]=s.useState((t==null?void 0:t.name)||""),[d,p]=s.useState((t==null?void 0:t.description)||""),[l,f]=s.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m
|
|
3675
|
-
`))||""}))},[t]);const w=async()=>{if(!(!t
|
|
3676
|
-
`).filter(T=>T.trim())}),a("Changes saved","info")}catch(T){a(T.message||"Failed to save changes","error")}finally{_(!1)}},E=async T=>{var
|
|
3677
|
-
`).filter(
|
|
3678
|
-
`).filter(T=>T.trim())}),a("Logo removed","info")}catch(T){a(T.message||"Failed to remove logo","error")}finally{_(!1)}},children:[e.jsx(Ot,{size:14,style:{marginRight:"4px"}})," Remove"]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic settings for this workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"name",children:"Workspace Name"}),e.jsx(ne,{id:"name",value:u,onChange:T=>c(T.target.value),onBlur:w,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"description",children:"Description"}),e.jsx(ne,{id:"description",as:"textarea",value:d,onChange:T=>p(T.target.value),onBlur:w,placeholder:"Enter workspace description",style:{minHeight:"80px",resize:"vertical"}})]}),((O=i==null?void 0:i.b2b_settings)==null?void 0:O.enforce_mfa_per_workspace_enabled)&&e.jsxs(_c,{children:[e.jsxs(kc,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"Multi-Factor Authentication"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Require MFA for all workspace members"})]}),e.jsx(Cc,{children:e.jsx(Pr,{checked:l.mfa_required,onChange:()=>{f(T=>({...T,mfa_required:!T.mfa_required})),setTimeout(()=>w(),0)}})})]}),((z=i==null?void 0:i.b2b_settings)==null?void 0:z.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs(_c,{children:[e.jsxs(kc,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"IP Restrictions"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Limit workspace access to trusted IP addresses"})]}),e.jsx(Cc,{children:e.jsx(Pr,{checked:l.ip_restrictions,onChange:()=>{f(T=>({...T,ip_restrictions:!T.ip_restrictions})),setTimeout(()=>w(),0)}})})]}),l.ip_restrictions&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ne,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:T=>f(
|
|
3675
|
+
`;const Fv=()=>{var O,z;const{activeWorkspace:t,loading:r,updateWorkspace:n}=Qt(),{deleteWorkspace:o}=ar(),{deployment:i}=be(),{toast:a}=rt(),[u,c]=s.useState((t==null?void 0:t.name)||""),[d,p]=s.useState((t==null?void 0:t.description)||""),[l,f]=s.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[x,m]=s.useState((t==null?void 0:t.image_url)||null),[v,C]=s.useState(null),[$,_]=s.useState(!1),[k,R]=s.useState(""),[y,b]=s.useState(!1),[S,g]=s.useState(!1),j=s.useRef(null);s.useEffect(()=>{var T;t&&(c(t.name||""),p(t.description||""),m(t.image_url||null),f({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((T=t.whitelisted_ips)==null?void 0:T.join(`
|
|
3676
|
+
`))||""}))},[t]);const w=async()=>{if(!(!t||$))try{_(!0),await n({name:u,description:d,image:v,enforce_2fa:l.mfa_required,enable_ip_restriction:l.ip_restrictions,whitelisted_ips:l.allowed_ips.split(`
|
|
3677
|
+
`).filter(T=>T.trim())}),a("Changes saved","info")}catch(T){a(T.message||"Failed to save changes","error")}finally{_(!1)}},E=async T=>{var M;if((M=T.target.files)!=null&&M[0]){const D=T.target.files[0];if(D.size>2*1024*1024){a("File size cannot exceed 2MB","error");return}C(D),m(URL.createObjectURL(D));try{_(!0),await n({name:u,description:d,image:D,enforce_2fa:l.mfa_required,enable_ip_restriction:l.ip_restrictions,whitelisted_ips:l.allowed_ips.split(`
|
|
3678
|
+
`).filter(F=>F.trim())}),a("Logo updated","info")}catch(F){a(F.message||"Failed to update logo","error")}finally{_(!1)}}},I=async()=>{if(!(!t||k!==t.name))try{b(!0),await o(t),a("Workspace deleted","info")}catch{a("Failed to delete workspace","error")}finally{b(!1)}};return r&&!t?e.jsx(Ie,{}):t?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)",paddingBottom:"40px"},children:[e.jsxs(Mv,{children:[e.jsx(Dv,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",boxShadow:"0 2px 8px var(--color-shadow)"},onClick:()=>{var T;return(T=j.current)==null?void 0:T.click()},children:[x?e.jsx("img",{src:x,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(ga,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:E})]})}),e.jsxs("div",{style:{flex:1,textAlign:"inherit"},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Customise your workspace identity"})]}),e.jsxs(Av,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var T;return(T=j.current)==null?void 0:T.click()},children:x?"Change":"Upload"}),x&&e.jsxs(B,{$outline:!0,$size:"sm",onClick:async()=>{m(null),C(null);try{_(!0),await n({name:u,description:d,image:"null",enforce_2fa:l.mfa_required,enable_ip_restriction:l.ip_restrictions,whitelisted_ips:l.allowed_ips.split(`
|
|
3679
|
+
`).filter(T=>T.trim())}),a("Logo removed","info")}catch(T){a(T.message||"Failed to remove logo","error")}finally{_(!1)}},children:[e.jsx(Ot,{size:14,style:{marginRight:"4px"}})," Remove"]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic settings for this workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"name",children:"Workspace Name"}),e.jsx(ne,{id:"name",value:u,onChange:T=>c(T.target.value),onBlur:w,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"description",children:"Description"}),e.jsx(ne,{id:"description",as:"textarea",value:d,onChange:T=>p(T.target.value),onBlur:w,placeholder:"Enter workspace description",style:{minHeight:"80px",resize:"vertical"}})]}),((O=i==null?void 0:i.b2b_settings)==null?void 0:O.enforce_mfa_per_workspace_enabled)&&e.jsxs(_c,{children:[e.jsxs(kc,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"Multi-Factor Authentication"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Require MFA for all workspace members"})]}),e.jsx(Cc,{children:e.jsx(Pr,{checked:l.mfa_required,onChange:()=>{f(T=>({...T,mfa_required:!T.mfa_required})),setTimeout(()=>w(),0)}})})]}),((z=i==null?void 0:i.b2b_settings)==null?void 0:z.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs(_c,{children:[e.jsxs(kc,{children:[e.jsx(re,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"IP Restrictions"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Limit workspace access to trusted IP addresses"})]}),e.jsx(Cc,{children:e.jsx(Pr,{checked:l.ip_restrictions,onChange:()=>{f(T=>({...T,ip_restrictions:!T.ip_restrictions})),setTimeout(()=>w(),0)}})})]}),l.ip_restrictions&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ne,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:T=>f(M=>({...M,allowed_ips:T.target.value})),onBlur:w,placeholder:"One IP per line...",style:{minHeight:"80px",fontFamily:"monospace"}})]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{style:{padding:"24px",border:"1px solid var(--color-error)",borderRadius:"16px",background:"transparent",textAlign:"inherit"},children:[e.jsx("h3",{style:{color:"var(--color-error)",fontSize:"15px",fontWeight:"400",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{color:"var(--color-secondary-text)",fontSize:"13px",margin:"0 0 20px 0"},children:"Destructive actions for this workspace"}),S?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs(re,{children:["Type ",e.jsx("strong",{children:t.name})," to confirm"]}),e.jsx(ne,{value:k,onChange:T=>R(T.target.value),placeholder:"Workspace name"}),e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsx(B,{$destructive:!0,$size:"sm",onClick:I,disabled:k!==t.name||y,style:{flex:1},children:y?e.jsx(Ie,{size:12}):"Delete Workspace"}),e.jsx(B,{$outline:!0,$size:"sm",onClick:()=>{g(!1),R("")},style:{flex:1},children:"Cancel"})]})]}):e.jsx(B,{$destructive:!0,$size:"sm",onClick:()=>g(!0),children:"Delete Workspace"})]})]}):e.jsx("div",{style:{padding:"24px",color:"var(--color-muted)"},children:"Workspace not found"})},Nv=h.div`
|
|
3679
3680
|
position: fixed;
|
|
3680
3681
|
width: 360px;
|
|
3681
3682
|
max-width: calc(100vw - 48px);
|
|
@@ -3724,7 +3725,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3724
3725
|
color: var(--color-foreground);
|
|
3725
3726
|
background: var(--color-input-background);
|
|
3726
3727
|
}
|
|
3727
|
-
`,Hv=({onClose:t,onSuccess:r,roles:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState(""),[c,d]=s.useState(null),[p,l]=s.useState(!1),[f,
|
|
3728
|
+
`,Hv=({onClose:t,onSuccess:r,roles:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState(""),[c,d]=s.useState(null),[p,l]=s.useState(!1),[f,x]=s.useState(!1),[m,v]=s.useState({top:0,left:0}),{toast:C}=rt(),{inviteMember:$}=Qt(),_=n.map(y=>({value:y.id,label:y.name}));s.useEffect(()=>{x(!0);const y=setTimeout(()=>{if(!i.current||!(o!=null&&o.current))return;const j=o.current;if(j){const w=j.getBoundingClientRect(),E=360,I=250,O=8;let z=0,T=0;const M=window.innerHeight-w.bottom,D=w.top;M>=I+O?(z=w.bottom+O,T=w.right-E,T<O&&(T=w.left,T+E>window.innerWidth-O&&(T=(window.innerWidth-E)/2))):D>=I+O?(z=w.top-I-O,T=w.right-E,T<O&&(T=w.left,T+E>window.innerWidth-O&&(T=(window.innerWidth-E)/2))):(z=w.bottom+O,T=w.right-E,T<O&&(T=w.left)),v({top:z,left:T})}},10),b=j=>{i.current&&!i.current.contains(j.target)&&(t==null||t())},S=j=>{j.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",S)},100);return()=>{clearTimeout(y),clearTimeout(g),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",S)}},[t,o]);const k=y=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y),R=async()=>{const y=a.trim().toLowerCase();if(!(!y||!c)){if(!k(y)){C("Please enter a valid email address","error");return}if(y.length>320){C("Email address is too long","error");return}l(!0);try{await $({email:y,workspaceRoleId:c.id}),r==null||r()}catch(b){const S=b.message||"Failed to send invitation. Please try again.";C(S,"error")}finally{l(!1)}}};return f?e.jsxs(Nv,{ref:i,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Uv,{children:[e.jsx(Bv,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(Gv,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Yt,{size:16})})]}),e.jsx(Wv,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Email Address"}),e.jsx(ne,{type:"email",placeholder:"colleague@company.com",value:a,onChange:y=>u(y.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Role"}),e.jsx(Ao,{options:_,value:c==null?void 0:c.id,onChange:y=>d(n.find(b=>b.id===y)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(Vv,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:R,disabled:!a||!c||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},qv=h.div`
|
|
3728
3729
|
width: 40px;
|
|
3729
3730
|
height: 40px;
|
|
3730
3731
|
border-radius: 50%;
|
|
@@ -3736,7 +3737,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3736
3737
|
font-weight: 400;
|
|
3737
3738
|
font-size: 14px;
|
|
3738
3739
|
overflow: hidden;
|
|
3739
|
-
`,Yv=()=>{const{activeWorkspace:t,getMembers:r,getRoles:n,removeMember:o,addMemberRole:i,removeMemberRole:a}=Qt(),{session:u}=He(),{toast:c}=rt(),[d,p]=s.useState(""),[l,f]=s.useState(1),[
|
|
3740
|
+
`,Yv=()=>{const{activeWorkspace:t,getMembers:r,getRoles:n,removeMember:o,addMemberRole:i,removeMemberRole:a}=Qt(),{session:u}=He(),{toast:c}=rt(),[d,p]=s.useState(""),[l,f]=s.useState(1),[x]=s.useState(10),[m,v]=s.useState(""),[C,$]=s.useState(!1),_=s.useRef(null);s.useEffect(()=>{const z=setTimeout(()=>{v(d),f(1)},500);return()=>clearTimeout(z)},[d]);const{data:k,isLoading:R,mutate:y}=Re(t?`wacht - api - workspaces:${t.id}: members:${l}:${x}:${m} `:null,()=>r==null?void 0:r({page:l,limit:x,search:m})),b=(k==null?void 0:k.data)||[],S=(k==null?void 0:k.meta)||{total:0,limit:10},g=Math.ceil(S.total/(S.limit||10)),{data:j=[],isLoading:w}=Re(t?`wacht - api - workspaces:${t.id}: roles`:null,()=>n()||[]),E=j,I=async(z,T,M)=>{try{M?(await a(z,T),c("Role removed","info")):(await i(z,T),c("Role added","info")),y()}catch{c("Failed to update role","error")}},O=async z=>{try{await o(z),c("Member removed","info"),y()}catch{c("Failed to remove member","error")}};return R||w?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(_a,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Zt,{value:d,onChange:p,placeholder:"Search members..."})}),e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[S.total>0&&e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)"},children:[S.total," member",S.total!==1?"s":""]}),e.jsx(B,{$size:"sm",ref:_,onClick:()=>$(!0),children:"Invite"})]})]}),C&&e.jsx(Hv,{onClose:()=>$(!1),onSuccess:()=>{y(),$(!1)},roles:E,triggerRef:_}),b.length===0?e.jsx(kt,{title:d?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Member"}),e.jsx(Pe,{children:"Joined"}),e.jsx(Pe,{children:"Role"})]})}),e.jsx(Dt,{children:b.map(z=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsx(Sc,{member:z,session:u})}),e.jsx(Ne,{children:new Date(z.created_at).toLocaleDateString()}),e.jsx(Ft,{children:e.jsx($c,{member:z,roles:E,onToggle:(T,M)=>I(z.id,T,M),onRemove:()=>O(z.id)})})]},z.id))})]})}),e.jsx(Ca,{children:b.map(z=>e.jsx(Sa,{children:e.jsxs($a,{children:[e.jsx(Sc,{member:z,session:u,subtitle:`Joined ${new Date(z.created_at).toLocaleDateString()}`}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx($c,{member:z,roles:E,onToggle:(T,M)=>I(z.id,T,M),onRemove:()=>O(z.id)})})]})},z.id))})]}),g>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px",marginTop:"24px"},children:[e.jsx(B,{onClick:()=>f(z=>Math.max(1,z-1)),disabled:l===1,$size:"sm",children:"Previous"}),e.jsxs("span",{style:{fontSize:"13px"},children:[l," / ",g]}),e.jsx(B,{onClick:()=>f(z=>Math.min(g,z+1)),disabled:l===g,$size:"sm",children:"Next"})]})]})},Sc=({member:t,session:r,subtitle:n})=>{var u,c,d;const o=t.public_user_data||t.user,i=(o==null?void 0:o.id)===((u=r==null?void 0:r.active_signin)==null?void 0:u.user_id),a=(p="",l="")=>`${p[0]||""}${l[0]||""} `.toUpperCase();return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx(qv,{children:o!=null&&o.profile_picture_url?e.jsx("img",{src:o.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):a(o==null?void 0:o.first_name,o==null?void 0:o.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:"400"},children:o?`${o.first_name||""} ${o.last_name||""} `.trim()||((c=o.primary_email_address)==null?void 0:c.email):"Unknown"}),i&&e.jsx("span",{style:{fontSize:"10px",padding:"1px 4px",background:"var(--color-background-alt)",color:"var(--color-muted)",borderRadius:"3px",fontWeight:"400"},children:"You"})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"4px 8px"},children:[e.jsx("span",{children:(d=o==null?void 0:o.primary_email_address)==null?void 0:d.email}),n&&e.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",n]})]})]})]})},$c=({member:t,roles:r,onToggle:n,onRemove:o})=>{const i=t.roles||[],a=u=>i.some(c=>c.id===u);return e.jsxs(ut,{children:[e.jsx(ht,{children:e.jsxs(B,{$outline:!0,$size:"sm",style:{color:"var(--color-foreground)"},children:[i.length>0?i[0].name:"No role"," ",e.jsx(or,{size:14,style:{marginLeft:"4px"}})]})}),e.jsxs(pt,{children:[r.map(u=>{const c=a(u.id);return e.jsx(Le,{onClick:()=>n(u.id,c),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"12px"},children:[e.jsx("span",{children:u.name}),c&&e.jsx(st,{size:14,color:"var(--color-success)"})]})},u.id)}),e.jsx(Oo,{}),e.jsx(Le,{$destructive:!0,onClick:o,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14})," Remove Member"]})})]})]})},Kv=h.div`
|
|
3740
3741
|
position: fixed;
|
|
3741
3742
|
width: 360px;
|
|
3742
3743
|
max-width: calc(100vw - 48px);
|
|
@@ -3785,7 +3786,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3785
3786
|
color: var(--color-foreground);
|
|
3786
3787
|
background: var(--color-input-background);
|
|
3787
3788
|
}
|
|
3788
|
-
`,ty=({onClose:t,onSuccess:r,roles:n,createInvitation:o,triggerRef:i})=>{const a=s.useRef(null),[u,c]=s.useState(""),[d,p]=s.useState(n[0]||null),[l,f]=s.useState(!1),[m
|
|
3789
|
+
`,ty=({onClose:t,onSuccess:r,roles:n,createInvitation:o,triggerRef:i})=>{const a=s.useRef(null),[u,c]=s.useState(""),[d,p]=s.useState(n[0]||null),[l,f]=s.useState(!1),[x,m]=s.useState(!1),[v,C]=s.useState({top:0,left:0}),{toast:$}=rt(),_=n.map(y=>({value:y.id,label:y.name})),k=y=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y),R=async()=>{const y=u.trim().toLowerCase();if(!(!y||!d)){if(!k(y)){$("Please enter a valid email address","error");return}if(y.length>320){$("Email address is too long","error");return}f(!0);try{await o({email:y,role_id:d.id}),r()}catch(b){const S=b.message||"Failed to send invitation. Please try again.";$(S,"error")}finally{f(!1)}}};return s.useEffect(()=>{m(!0);const y=setTimeout(()=>{if(!a.current||!(i!=null&&i.current))return;const g=i.current;if(g){const j=g.getBoundingClientRect(),w=360,E=250,I=8;let O=0,z=0;const T=window.innerHeight-j.bottom,M=j.top;T>=E+I?(O=j.bottom+I,z=j.right-w,z<I&&(z=j.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):M>=E+I?(O=j.top-E-I,z=j.right-w,z<I&&(z=j.left,z+w>window.innerWidth-I&&(z=(window.innerWidth-w)/2))):(O=j.bottom+I,z=j.right-w,z<I&&(z=j.left)),C({top:O,left:z})}},10),b=g=>{a.current&&!a.current.contains(g.target)&&(t==null||t())},S=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",S),()=>{clearTimeout(y),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",S)}},[t,i]),x?e.jsxs(Kv,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Qv,{children:[e.jsx(Zv,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ey,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Yt,{size:16})})]}),e.jsx(Jv,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Email Address"}),e.jsx(ne,{type:"email",placeholder:"colleague@company.com",value:u,onChange:y=>c(y.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Role"}),e.jsx(Ao,{options:_,value:d==null?void 0:d.id,onChange:y=>p(n.find(b=>b.id===y)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Xv,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:R,disabled:!u||!d||l,style:{width:"auto"},children:l?e.jsx(Ie,{size:16}):"Send Invitation"})]})]}):null},ry=()=>{const{activeWorkspace:t,loading:r,getRoles:n,getInvitations:o,inviteMember:i,discardInvitation:a,resendInvitation:u}=Qt(),{toast:c}=rt(),[d,p]=s.useState(!0),[l,f]=s.useState(!0),[x,m]=s.useState(""),[v,C]=s.useState([]),[$,_]=s.useState([]),[k,R]=s.useState(!1),y=s.useRef(null),b=async()=>{if(t){p(!0),f(!0);try{const[w,E]=await Promise.all([n(),o()]);_(w),C(E)}catch{}finally{p(!1),f(!1)}}};s.useEffect(()=>{b()},[t==null?void 0:t.id]);const S=async w=>{try{await a(w),b(),c("Invitation cancelled","info")}catch{c("Failed to cancel invitation","error")}},g=async w=>{try{await u(w),b(),c("Invitation resent","info")}catch{c("Failed to resend invitation","error")}},j=s.useMemo(()=>{if(!x)return v;const w=x.toLowerCase();return v.filter(E=>{var I;return(I=E.email)==null?void 0:I.toLowerCase().includes(w)})},[v,x]);return r||d||l?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(_a,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Zt,{value:x,onChange:m,placeholder:"Search invitations..."})}),e.jsx(B,{$size:"sm",ref:y,onClick:()=>R(!0),children:"Invite"})]}),k&&e.jsx(ty,{onClose:()=>R(!1),onSuccess:()=>{b(),R(!1),c("Invitation sent","info")},roles:$,createInvitation:w=>i({email:w.email,workspaceRoleId:w.role_id}),triggerRef:y}),j.length===0?e.jsx(kt,{title:x?"No invitations match":"No pending invitations",description:"Invite members to your workspace."}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Email"}),e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Invited"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:j.map(w=>{var E,I;return e.jsxs(Ke,{children:[e.jsx(Ne,{children:w.email}),e.jsx(Ne,{children:((E=w.initial_workspace_role)==null?void 0:E.name)||((I=w.initial_organization_role)==null?void 0:I.name)||"No role"}),e.jsx(Ne,{children:new Date(w.created_at).toLocaleDateString()}),e.jsx(Ft,{children:e.jsx(Ec,{onResend:()=>g(w.id),onCancel:()=>S(w.id)})})]},w.id)})})]})}),e.jsx(Ca,{children:j.map(w=>{var E;return e.jsx(Sa,{children:e.jsxs($a,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:w.email}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[((E=w.initial_workspace_role)==null?void 0:E.name)||"No role"," • ",new Date(w.created_at).toLocaleDateString()]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Ec,{onResend:()=>g(w.id),onCancel:()=>S(w.id)})})]})},w.id)})})]})]})},Ec=({onResend:t,onCancel:r})=>e.jsxs(ut,{children:[e.jsx(ht,{children:e.jsx(pu,{children:"•••"})}),e.jsxs(pt,{children:[e.jsxs(Le,{onClick:t,children:[e.jsx(Td,{size:16})," Resend"]}),e.jsxs(Le,{$destructive:!0,onClick:r,children:[e.jsx(Ot,{size:16})," Cancel"]})]})]}),ny=h.div`
|
|
3789
3790
|
position: fixed;
|
|
3790
3791
|
width: 400px;
|
|
3791
3792
|
max-width: calc(100vw - 48px);
|
|
@@ -3836,7 +3837,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
3836
3837
|
color: var(--color-foreground);
|
|
3837
3838
|
background: var(--color-input-background);
|
|
3838
3839
|
}
|
|
3839
|
-
`,zc=({onClose:t,onSuccess:r,role:n,triggerRef:o})=>{var g,j;const i=s.useRef(null),[a,u]=s.useState((n==null?void 0:n.name)||""),[c,d]=s.useState((n==null?void 0:n.permissions)||[]),[p,l]=s.useState(!1),[f,
|
|
3840
|
+
`,zc=({onClose:t,onSuccess:r,role:n,triggerRef:o})=>{var g,j;const i=s.useRef(null),[a,u]=s.useState((n==null?void 0:n.name)||""),[c,d]=s.useState((n==null?void 0:n.permissions)||[]),[p,l]=s.useState(!1),[f,x]=s.useState(!1),[m,v]=s.useState({top:0,left:0}),{deployment:C}=be(),{toast:$}=rt(),_=!!n,k=((g=C==null?void 0:C.b2b_settings)==null?void 0:g.workspace_permissions)||((j=C==null?void 0:C.b2b_settings)==null?void 0:j.organization_permissions)||[],R=Array.isArray(k)?k.map(w=>({value:w,label:w})):[];s.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!i.current)return;let z=null;if(o!=null&&o.current&&(z=o.current),o!=null&&o.current&&(z=o.current),z){const T=z.getBoundingClientRect(),M=400;let D=T.bottom+8,F=T.right-M;F<10&&(F=T.left),D+300>window.innerHeight&&(D=T.top-300-8),v({top:D,left:F})}else v({top:window.innerHeight/2-200,left:window.innerWidth/2-200})},10),E=z=>{i.current&&!i.current.contains(z.target)&&(t==null||t())},I=z=>{z.key==="Escape"&&(t==null||t())},O=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",I)},100);return()=>{clearTimeout(w),clearTimeout(O),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",I)}},[t,_,o]);const y=w=>w.trim().replace(/[<>\"'&]/g,""),b=w=>w.length>=2&&w.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(w),S=async()=>{const w=y(a);if(!w){$("Please enter a role name","error");return}if(!b(w)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(c.length===0){$("Please select at least one permission","error");return}l(!0);try{const E={id:n==null?void 0:n.id,name:w,permissions:c||[]};r==null||r(E)}catch(E){const I=E.message||`Failed to ${_?"update":"create"} role. Please try again.`;$(I,"error")}finally{l(!1)}};return f?e.jsxs(ny,{ref:i,$isInTable:_,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(oy,{children:[e.jsx(iy,{id:"role-dialog-title",children:_?"Edit Role":"Create New Role"}),e.jsx(cy,{onClick:t,"aria-label":`Close ${_?"edit":"create"} role dialog`,children:e.jsx(Yt,{size:16})})]}),e.jsx(ay,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(oe,{children:[e.jsx(re,{children:"Role Name"}),e.jsx(ne,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:w=>u(w.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(oe,{children:[e.jsx(re,{children:"Permissions"}),e.jsx(Qd,{options:R,value:c,onChange:d,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(sy,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:S,disabled:!a||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," ",_?"Updating...":"Creating..."]}):_?"Update Role":"Create Role"})]})]}):null},ly=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:n,createRole:o,deleteRole:i}=Qt(),{deployment:a}=be(),{toast:u}=rt(),[c,d]=s.useState(""),[p,l]=s.useState({isOpen:!1}),[f,x]=s.useState(null),[m,v]=s.useState(null),C=s.useRef(null),$=s.useRef(new Map),{data:_=[],isLoading:k,mutate:R}=Re(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),y=s.useMemo(()=>c?_.filter(j=>j.name.toLowerCase().includes(c.toLowerCase())):_,[_,c]),b=async j=>{try{await o(j.name,j.permissions||[]),u("Role saved successfully","info"),l({isOpen:!1}),R()}catch{u("Failed to save role","error")}},S=async j=>{try{await i(j),u("Role deleted","info"),x(null),R()}catch{u("Failed to delete role","error")}};return r||k?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(_a,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Zt,{placeholder:"Search roles...",onChange:d,value:c})}),((g=a==null?void 0:a.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(B,{$size:"sm",ref:C,onClick:()=>l({isOpen:!0,triggerElement:C.current}),children:"Add Role"})]}),p.isOpen&&!p.role&&e.jsx(zc,{triggerRef:{current:p.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:b}),y.length===0?e.jsx(kt,{title:c?"No roles match":"No roles yet",description:"Create workspace-specific roles to manage access."}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Permissions"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:y.map(j=>{var w;return e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsx("div",{style:{fontWeight:500},children:j.name})}),e.jsx(Ne,{style:{color:"var(--color-secondary-text)"},children:(w=j.permissions)==null?void 0:w.join(", ")}),e.jsx(Ft,{children:e.jsx(Pc,{role:j,onEdit:E=>l({isOpen:!0,role:j,triggerElement:E}),onDelete:()=>x(j.id),open:m===j.id,onOpenChange:E=>v(E?j.id:null),dropdownButtonRefs:$})})]},j.id)})})]})}),e.jsx(Ca,{children:y.map(j=>{var w;return e.jsx(Sa,{children:e.jsxs($a,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:j.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:(w=j.permissions)==null?void 0:w.join(", ")})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Pc,{role:j,onEdit:E=>l({isOpen:!0,role:j,triggerElement:E}),onDelete:()=>x(j.id),open:m===j.id,onOpenChange:E=>v(E?j.id:null),dropdownButtonRefs:$})})]})},j.id)})})]}),f&&e.jsx(Zr,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const j=_.find(w=>w.id===f);j&&S(j)},onCancel:()=>x(null)}),p.isOpen&&p.role&&e.jsx(zc,{role:p.role,triggerRef:{current:p.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:b})]})},Pc=({role:t,onEdit:r,onDelete:n,open:o,onOpenChange:i,dropdownButtonRefs:a})=>e.jsxs(ut,{open:o,openChange:i,children:[e.jsx(ht,{children:e.jsx(pu,{ref:u=>{u&&a.current.set(t.id,u)},disabled:!t.workspace_id,children:"•••"})}),e.jsxs(pt,{children:[e.jsx(Le,{onClick:()=>r(a.current.get(t.id)),children:"Edit Role"}),e.jsxs(Le,{$destructive:!0,onClick:n,children:[e.jsx(Ot,{size:16})," Remove Role"]})]})]}),hu=()=>{var l;const{activeWorkspace:t,loading:r}=Qt(),{deployment:n}=be(),[o,i]=s.useState("general"),[a,u]=s.useState(null),[c,d]=s.useState("info"),p=s.useCallback((f,x="info")=>{u(f),d(x),setTimeout(()=>u(null),3e3)},[]);return r&&!t?e.jsx(le,{children:e.jsx(jc,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})}):t?e.jsx(le,{children:e.jsx(Iv,{children:e.jsx(va.Provider,{value:{screen:null,setScreen:()=>{},toast:p},children:e.jsxs(jc,{children:[e.jsx(Tv,{children:e.jsxs(Ov,{children:[e.jsx(Hn,{$isActive:o==="general",onClick:()=>i("general"),children:e.jsxs(qn,{children:[e.jsx(Sr,{size:16})," General"]})}),e.jsx(Hn,{$isActive:o==="members",onClick:()=>i("members"),children:e.jsxs(qn,{children:[e.jsx(wo,{size:16})," Members"]})}),e.jsx(Hn,{$isActive:o==="invitations",onClick:()=>i("invitations"),children:e.jsxs(qn,{children:[e.jsx(Td,{size:16})," Invitations"]})}),((l=n==null?void 0:n.b2b_settings)==null?void 0:l.custom_workspace_role_enabled)&&e.jsx(Hn,{$isActive:o==="roles",onClick:()=>i("roles"),children:e.jsxs(qn,{children:[e.jsx(wt,{size:16})," Roles"]})})]})}),e.jsxs(Lv,{children:[o==="general"&&e.jsx(Fv,{}),o==="members"&&e.jsx(Yv,{}),o==="invitations"&&e.jsx(ry,{}),o==="roles"&&e.jsx(ly,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideDown 0.3s ease-out",zIndex:100},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[c==="error"?e.jsx(ir,{size:16,color:"var(--color-error)"}):e.jsx(st,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})}):null},ra=({isOpen:t,onClose:r,title:n,showHeader:o,headerContent:i,footerContent:a,customContent:u,children:c,showCloseButton:d})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:[o&&e.jsx(ze.Header,{showCloseButton:d,children:i||n}),u||c||e.jsx(hu,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),Ea=({triggerRef:t,isOpen:r,minWidth:n=300,defaultMaxHeight:o=400,offset:i=8})=>{const[a,u]=s.useState();return s.useEffect(()=>{if(!r||!t.current){u(void 0);return}const c=()=>{if(!t.current)return;const d=t.current.getBoundingClientRect(),p=window.innerWidth,l=window.innerHeight,f=l-d.bottom,x=d.top;let m={};f>=x?(m.top=d.bottom+i,m.maxHeight=Math.min(o,f-i*2)):(m.bottom=l-d.top+i,m.maxHeight=Math.min(o,x-i*2));const v=p-d.left,C=d.right;v>=C?m.left=Math.max(i,Math.min(p-n-i,d.left)):m.left=Math.max(i,Math.min(p-n-i,d.right-n)),u(m)};return c(),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[r,n,o,i]),a},fu=["organization:admin"],gu=["organization:admin","organization:manage"],mu=["workspace:admin"],xu=["workspace:admin","workspace:manage"];function za(t,r){return t!=null&&t.roles?t.roles.some(n=>{var o;return(o=n.permissions)==null?void 0:o.some(i=>r.includes(i))}):!1}function vu(t){return za(t,gu)}function dy(t){return za(t,fu)}function Pa(t,r){return t!=null&&t.roles?t.roles.some(n=>{var o;return(o=n.permissions)==null?void 0:o.some(i=>r.includes(i))}):!1}function na(t){return Pa(t,xu)}function uy(t){return Pa(t,mu)}const Rc=h.div`
|
|
3840
3841
|
position: relative;
|
|
3841
3842
|
display: inline-block;
|
|
3842
3843
|
width: 100%;
|
|
@@ -4187,7 +4188,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4187
4188
|
height: 16px;
|
|
4188
4189
|
background: var(--color-border);
|
|
4189
4190
|
border-radius: 2px;
|
|
4190
|
-
`,yu=({showPersonal:t=!0})=>{var se,ce,_e,me,Ce,q,te,de,ie,Y,ve,W,xe,qe,it;const[r,n]=s.useState(!1),[o,i]=s.useState(!1),[a,u]=s.useState(new Set),c=s.useRef(null),d=s.useRef(null),p=Ea({triggerRef:c,isOpen:r,minWidth:300}),l=gn(!1),f=gn(!1),m=gn(!1),x=gn(!1),[v,$]=s.useState(null),[S,_]=s.useState(!1),[k,P]=s.useState(null),{organizationMemberships:y,loading:b,refetch:C}=Kt(),{activeOrganization:g,activeMembership:j,leave:w}=Tr(),{activeWorkspace:E,activeMembership:I,leave:O}=Qt(),{workspaces:z,loading:T}=ar(),{session:D,switchOrganization:F,switchWorkspace:M}=He(),{deployment:L}=be(),{toast:A}=rt(),R=L==null?void 0:L.b2b_settings.organizations_enabled,U=L==null?void 0:L.b2b_settings.workspaces_enabled,V=L==null?void 0:L.b2b_settings.allow_users_to_create_orgs,H=!j,ae=s.useMemo(()=>{var fe,Me;if(H)return{name:"Personal account",image_url:(Me=(fe=D==null?void 0:D.active_signin)==null?void 0:fe.user)==null?void 0:Me.profile_picture_url,isPersonal:!0};let G=(g==null?void 0:g.name)||"";return U&&E&&(G=`${g==null?void 0:g.name} / ${E.name}`),{name:G,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,E,D,U]);s.useEffect(()=>{if(!r)return;let G=null;const fe=setTimeout(()=>{const Me=Ve=>{var ct,Xe;const nt=Ve.target;(ct=c.current)!=null&&ct.contains(nt)||(Xe=d.current)!=null&&Xe.contains(nt)||(n(!1),P(null))};document.addEventListener("mousedown",Me),G=()=>{document.removeEventListener("mousedown",Me)}},50);return()=>{clearTimeout(fe),G==null||G()}},[r]),s.useEffect(()=>{if(k){const G=setTimeout(()=>{P(null)},5e3);return()=>clearTimeout(G)}},[k]);const ee=()=>{C()};if(!R)return null;const ge=G=>{i(!0),F(G).finally(()=>{i(!1)})},pe=G=>{i(!0),M(G).finally(()=>{i(!1)})},Q=G=>{const fe=new Set(a);fe.has(G)?fe.delete(G):fe.add(G),u(fe)},he=G=>G.split(" ").map(fe=>fe[0]).join("").toUpperCase().slice(0,2);return!!!D||b||U&&T?e.jsx(le,{children:e.jsxs(Rc,{children:[e.jsxs(wy,{children:[e.jsxs(Ic,{children:[e.jsx(jy,{}),e.jsx(_y,{})]}),e.jsx(ky,{})]}),R&&V&&e.jsx(Qs,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(yc,{isOpen:f.isOpen,onClose:f.close}),e.jsx(ra,{isOpen:x.isOpen,onClose:x.close}),e.jsx(ta,{isOpen:m.isOpen,onClose:()=>{m.close(),$(null)},organizationId:v||void 0})]})}):e.jsx(le,{children:e.jsxs(Rc,{children:[e.jsxs(py,{ref:c,onClick:()=>{n(!r),r||P(null)},disabled:o,children:[e.jsxs(Ic,{children:[e.jsx(hy,{children:ae.image_url?e.jsx(fy,{src:ae.image_url,alt:ae.name}):ae.isPersonal?e.jsx(bo,{size:12}):he(ae.name)}),e.jsx(gy,{children:ae.name})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(((se=j==null?void 0:j.eligibility_restriction)==null?void 0:se.type)&&((ce=j==null?void 0:j.eligibility_restriction)==null?void 0:ce.type)!=="none"||((_e=I==null?void 0:I.eligibility_restriction)==null?void 0:_e.type)&&((me=I==null?void 0:I.eligibility_restriction)==null?void 0:me.type)!=="none")&&e.jsx("div",{title:((Ce=I==null?void 0:I.eligibility_restriction)==null?void 0:Ce.message)||((q=j==null?void 0:j.eligibility_restriction)==null?void 0:q.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),e.jsx(vg,{size:16})]})]}),typeof window<"u"&&Co.createPortal(e.jsx(le,{children:e.jsx(my,{ref:d,$isOpen:r,$position:p,children:b||T?e.jsxs(by,{children:[e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsxs(eo,{children:[e.jsx(to,{width:"120px"}),e.jsx(Dc,{width:"80px"})]})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsx(eo,{children:e.jsx(to,{width:"100px"})})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsxs(eo,{children:[e.jsx(to,{width:"140px"}),e.jsx(Dc,{width:"60px"})]})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsx(eo,{children:e.jsx(to,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(fo,{as:"button",$isActive:H,onClick:G=>{G.stopPropagation(),H||ge()},disabled:o||H,children:[H&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(xy,{children:(de=(te=D==null?void 0:D.active_signin)==null?void 0:te.user)!=null&&de.profile_picture_url?e.jsx(vy,{src:D.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(bo,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Personal account"})})]}),!H&&e.jsx(Yn,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(Nr,{})]}),!H&&g&&e.jsxs(fo,{$isActive:!0,onClick:()=>{U&&Q(g.id)},style:{...o?{pointerEvents:"none",opacity:.7}:{},...((ie=j==null?void 0:j.eligibility_restriction)==null?void 0:ie.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{}},title:(Y=j==null?void 0:j.eligibility_restriction)==null?void 0:Y.message,children:[e.jsx(Qn,{}),e.jsxs(Nt,{children:[U&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:a.has(g.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Tc,{children:g.image_url?e.jsx(Oc,{src:g.image_url,alt:g.name}):he(g.name)}),e.jsx(Ut,{children:e.jsx(Bt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((ve=j==null?void 0:j.eligibility_restriction)==null?void 0:ve.type)&&((W=j==null?void 0:j.eligibility_restriction)==null?void 0:W.type)!=="none"&&e.jsx("div",{title:(xe=j==null?void 0:j.eligibility_restriction)==null?void 0:xe.message,style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),((qe=j==null?void 0:j.eligibility_restriction)==null?void 0:qe.type)==="none"&&vu(j)&&e.jsx(go,{onClick:G=>{G.stopPropagation(),f.open()},title:"Manage organization",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async G=>{G.stopPropagation(),_(!0),P(null);try{await w(),await C(),setTimeout(()=>{_(!1)},500)}catch(fe){P(fe instanceof Error?fe.message:"Failed to leave organization"),_(!1)}},disabled:S,title:"Leave organization",children:e.jsx(Ht,{size:12})})]})]}),g&&U&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[z==null?void 0:z.filter(G=>G.organization.id===g.id).map(G=>{var Me,Ve,nt,ct,Xe,Ct,St,mt,We,ot,$t,Et;const fe=(E==null?void 0:E.id)===G.id;return e.jsxs(Zn,{as:fe?void 0:"button",$isActive:fe,onClick:fe?void 0:()=>pe(G.id),...fe?{style:o?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:o},style:{...((Me=G.eligibility_restriction)==null?void 0:Me.type)!=="none"||((Ve=j==null?void 0:j.eligibility_restriction)==null?void 0:Ve.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...fe&&o?{pointerEvents:"none",opacity:.7}:{}},title:((nt=G.eligibility_restriction)==null?void 0:nt.message)||((ct=j==null?void 0:j.eligibility_restriction)==null?void 0:ct.message),children:[fe&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(Lc,{children:G.image_url?e.jsx("img",{src:G.image_url,alt:G.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):he(G.name).charAt(0)}),e.jsx(Ut,{children:e.jsx(Bt,{children:G.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((Xe=G.eligibility_restriction)==null?void 0:Xe.type)&&((Ct=G.eligibility_restriction)==null?void 0:Ct.type)!=="none"||((St=j==null?void 0:j.eligibility_restriction)==null?void 0:St.type)&&((mt=j==null?void 0:j.eligibility_restriction)==null?void 0:mt.type)!=="none")&&e.jsx("div",{title:((We=G.eligibility_restriction)==null?void 0:We.message)||((ot=j==null?void 0:j.eligibility_restriction)==null?void 0:ot.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),fe?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(($t=I==null?void 0:I.eligibility_restriction)==null?void 0:$t.type)==="none"&&((Et=j==null?void 0:j.eligibility_restriction)==null?void 0:Et.type)==="none"&&na(I)&&e.jsx(go,{onClick:et=>{et.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async et=>{et.stopPropagation();try{O&&await O()}catch(zt){const Z=zt.message||"Failed to leave workspace. Please try again.";A(Z,"error")}},title:"Leave workspace",children:e.jsx(Ht,{size:12})})]}):e.jsx(Yn,{className:"hover-arrow",size:14})]})]},G.id)}),((it=j==null?void 0:j.eligibility_restriction)==null?void 0:it.type)==="none"&&e.jsx(Zn,{as:"button",onClick:()=>{$(g.id),m.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{style:{width:"14px",height:"14px"},children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})})]}),(S||k)&&e.jsxs(e.Fragment,{children:[S&&e.jsxs(Mc,{children:[e.jsx(yy,{}),"Leaving organization..."]}),k&&e.jsxs(Mc,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),k]})]}),e.jsx(Nr,{}),y&&y.length>0&&e.jsx(e.Fragment,{children:y.filter(G=>G.organization.id!==(g==null?void 0:g.id)).map(G=>{var nt,ct,Xe,Ct,St,mt;const fe=G.organization,Me=(z==null?void 0:z.filter(We=>We.organization.id===fe.id))||[],Ve=a.has(fe.id);return e.jsxs(s.Fragment,{children:[e.jsxs(fo,{as:"button",$isActive:!1,onClick:()=>{U?Q(fe.id):ge(fe.id)},disabled:o,style:((nt=G.eligibility_restriction)==null?void 0:nt.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:void 0,title:(ct=G.eligibility_restriction)==null?void 0:ct.message,children:[e.jsxs(Nt,{children:[U&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:Ve?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Tc,{children:fe.image_url?e.jsx(Oc,{src:fe.image_url,alt:fe.name}):he(fe.name)}),e.jsx(Ut,{children:e.jsx(Bt,{children:fe.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((Xe=G.eligibility_restriction)==null?void 0:Xe.type)&&((Ct=G.eligibility_restriction)==null?void 0:Ct.type)!=="none"&&e.jsx("div",{title:(St=G.eligibility_restriction)==null?void 0:St.message,style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),e.jsx(Yn,{className:"hover-arrow",size:14})]})]}),U&&Ve&&e.jsxs(e.Fragment,{children:[Me.map(We=>{var $t,Et,et,zt,Z,K,ue,we,Ee,Ue;const ot=(E==null?void 0:E.id)===We.id;return e.jsxs(Zn,{as:ot?void 0:"button",$isActive:ot,onClick:ot?void 0:()=>pe(We.id),...ot?{style:o?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:o},style:{...(($t=We.eligibility_restriction)==null?void 0:$t.type)!=="none"||((Et=G.eligibility_restriction)==null?void 0:Et.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...ot&&o?{pointerEvents:"none",opacity:.7}:{}},title:((et=We.eligibility_restriction)==null?void 0:et.message)||((zt=G.eligibility_restriction)==null?void 0:zt.message),children:[ot&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(Lc,{children:We.image_url?e.jsx("img",{src:We.image_url,alt:We.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):he(We.name).charAt(0)}),e.jsx(Ut,{children:e.jsx(Bt,{children:We.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((Z=We.eligibility_restriction)==null?void 0:Z.type)&&((K=We.eligibility_restriction)==null?void 0:K.type)!=="none"||((ue=G.eligibility_restriction)==null?void 0:ue.type)&&((we=G.eligibility_restriction)==null?void 0:we.type)!=="none")&&e.jsx("div",{title:((Ee=We.eligibility_restriction)==null?void 0:Ee.message)||((Ue=G.eligibility_restriction)==null?void 0:Ue.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),ot?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[na(I)&&e.jsx(go,{onClick:J=>{J.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async J=>{J.stopPropagation();try{O&&await O()}catch(Te){const De=Te.message||"Failed to leave workspace. Please try again.";A(De,"error")}},title:"Leave workspace",children:e.jsx(Ht,{size:12})})]}):e.jsx(Yn,{className:"hover-arrow",size:16})]})]},We.id)}),((mt=G.eligibility_restriction)==null?void 0:mt.type)==="none"&&e.jsx(Zn,{as:"button",onClick:()=>{$(fe.id),m.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{style:{width:"14px",height:"14px"},children:e.jsx(yt,{size:10})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})})]}),e.jsx(Nr,{})]},fe.id)})}),U&&e.jsx(Ac,{onClick:()=>{var G,fe;g&&(!((G=j==null?void 0:j.eligibility_restriction)!=null&&G.type)||((fe=j==null?void 0:j.eligibility_restriction)==null?void 0:fe.type)==="none")?$(g.id):$(null),m.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})}),!U&&V&&e.jsx(Ac,{onClick:()=>{l.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create organization"})})]})})]})})}),document.body),R&&V&&e.jsx(Qs,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(yc,{isOpen:f.isOpen,onClose:f.close}),e.jsx(ra,{isOpen:x.isOpen,onClose:x.close}),e.jsx(ta,{isOpen:m.isOpen,onClose:()=>{m.close(),$(null)},organizationId:v||void 0})]})})},bu=s.createContext(void 0),lr=()=>{const t=s.useContext(bu);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Cy=_t`
|
|
4191
|
+
`,yu=({showPersonal:t=!0})=>{var se,ce,_e,me,Ce,q,te,de,ie,Y,ve,W,xe,qe,it;const[r,n]=s.useState(!1),[o,i]=s.useState(!1),[a,u]=s.useState(new Set),c=s.useRef(null),d=s.useRef(null),p=Ea({triggerRef:c,isOpen:r,minWidth:300}),l=gn(!1),f=gn(!1),x=gn(!1),m=gn(!1),[v,C]=s.useState(null),[$,_]=s.useState(!1),[k,R]=s.useState(null),{organizationMemberships:y,loading:b,refetch:S}=Kt(),{activeOrganization:g,activeMembership:j,leave:w}=Tr(),{activeWorkspace:E,activeMembership:I,leave:O}=Qt(),{workspaces:z,loading:T}=ar(),{session:M,switchOrganization:D,switchWorkspace:F}=He(),{deployment:L}=be(),{toast:A}=rt(),P=L==null?void 0:L.b2b_settings.organizations_enabled,U=L==null?void 0:L.b2b_settings.workspaces_enabled,V=L==null?void 0:L.b2b_settings.allow_users_to_create_orgs,H=!j,ae=s.useMemo(()=>{var fe,Me;if(H)return{name:"Personal account",image_url:(Me=(fe=M==null?void 0:M.active_signin)==null?void 0:fe.user)==null?void 0:Me.profile_picture_url,isPersonal:!0};let G=(g==null?void 0:g.name)||"";return U&&E&&(G=`${g==null?void 0:g.name} / ${E.name}`),{name:G,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,E,M,U]);s.useEffect(()=>{if(!r)return;let G=null;const fe=setTimeout(()=>{const Me=Ve=>{var ct,Xe;const nt=Ve.target;(ct=c.current)!=null&&ct.contains(nt)||(Xe=d.current)!=null&&Xe.contains(nt)||(n(!1),R(null))};document.addEventListener("mousedown",Me),G=()=>{document.removeEventListener("mousedown",Me)}},50);return()=>{clearTimeout(fe),G==null||G()}},[r]),s.useEffect(()=>{if(k){const G=setTimeout(()=>{R(null)},5e3);return()=>clearTimeout(G)}},[k]);const ee=()=>{S()};if(!P)return null;const ge=G=>{i(!0),D(G).finally(()=>{i(!1)})},pe=G=>{i(!0),F(G).finally(()=>{i(!1)})},Q=G=>{const fe=new Set(a);fe.has(G)?fe.delete(G):fe.add(G),u(fe)},he=G=>G.split(" ").map(fe=>fe[0]).join("").toUpperCase().slice(0,2);return!!!M||b||U&&T?e.jsx(le,{children:e.jsxs(Rc,{children:[e.jsxs(wy,{children:[e.jsxs(Ic,{children:[e.jsx(jy,{}),e.jsx(_y,{})]}),e.jsx(ky,{})]}),P&&V&&e.jsx(Qs,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(yc,{isOpen:f.isOpen,onClose:f.close}),e.jsx(ra,{isOpen:m.isOpen,onClose:m.close}),e.jsx(ta,{isOpen:x.isOpen,onClose:()=>{x.close(),C(null)},organizationId:v||void 0})]})}):e.jsx(le,{children:e.jsxs(Rc,{children:[e.jsxs(py,{ref:c,onClick:()=>{n(!r),r||R(null)},disabled:o,children:[e.jsxs(Ic,{children:[e.jsx(hy,{children:ae.image_url?e.jsx(fy,{src:ae.image_url,alt:ae.name}):ae.isPersonal?e.jsx(bo,{size:12}):he(ae.name)}),e.jsx(gy,{children:ae.name})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(((se=j==null?void 0:j.eligibility_restriction)==null?void 0:se.type)&&((ce=j==null?void 0:j.eligibility_restriction)==null?void 0:ce.type)!=="none"||((_e=I==null?void 0:I.eligibility_restriction)==null?void 0:_e.type)&&((me=I==null?void 0:I.eligibility_restriction)==null?void 0:me.type)!=="none")&&e.jsx("div",{title:((Ce=I==null?void 0:I.eligibility_restriction)==null?void 0:Ce.message)||((q=j==null?void 0:j.eligibility_restriction)==null?void 0:q.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),e.jsx(vg,{size:16})]})]}),typeof window<"u"&&Co.createPortal(e.jsx(le,{children:e.jsx(my,{ref:d,$isOpen:r,$position:p,children:b||T?e.jsxs(by,{children:[e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsxs(eo,{children:[e.jsx(to,{width:"120px"}),e.jsx(Dc,{width:"80px"})]})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsx(eo,{children:e.jsx(to,{width:"100px"})})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsxs(eo,{children:[e.jsx(to,{width:"140px"}),e.jsx(Dc,{width:"60px"})]})]}),e.jsx(Nr,{}),e.jsxs(Jn,{children:[e.jsx(Xn,{}),e.jsx(eo,{children:e.jsx(to,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(fo,{as:"button",$isActive:H,onClick:G=>{G.stopPropagation(),H||ge()},disabled:o||H,children:[H&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(xy,{children:(de=(te=M==null?void 0:M.active_signin)==null?void 0:te.user)!=null&&de.profile_picture_url?e.jsx(vy,{src:M.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(bo,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Personal account"})})]}),!H&&e.jsx(Yn,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(Nr,{})]}),!H&&g&&e.jsxs(fo,{$isActive:!0,onClick:()=>{U&&Q(g.id)},style:{...o?{pointerEvents:"none",opacity:.7}:{},...((ie=j==null?void 0:j.eligibility_restriction)==null?void 0:ie.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{}},title:(Y=j==null?void 0:j.eligibility_restriction)==null?void 0:Y.message,children:[e.jsx(Qn,{}),e.jsxs(Nt,{children:[U&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:a.has(g.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Tc,{children:g.image_url?e.jsx(Oc,{src:g.image_url,alt:g.name}):he(g.name)}),e.jsx(Ut,{children:e.jsx(Bt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((ve=j==null?void 0:j.eligibility_restriction)==null?void 0:ve.type)&&((W=j==null?void 0:j.eligibility_restriction)==null?void 0:W.type)!=="none"&&e.jsx("div",{title:(xe=j==null?void 0:j.eligibility_restriction)==null?void 0:xe.message,style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),((qe=j==null?void 0:j.eligibility_restriction)==null?void 0:qe.type)==="none"&&vu(j)&&e.jsx(go,{onClick:G=>{G.stopPropagation(),f.open()},title:"Manage organization",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async G=>{G.stopPropagation(),_(!0),R(null);try{await w(),await S(),setTimeout(()=>{_(!1)},500)}catch(fe){R(fe instanceof Error?fe.message:"Failed to leave organization"),_(!1)}},disabled:$,title:"Leave organization",children:e.jsx(Ht,{size:12})})]})]}),g&&U&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[z==null?void 0:z.filter(G=>G.organization.id===g.id).map(G=>{var Me,Ve,nt,ct,Xe,Ct,St,mt,We,ot,$t,Et;const fe=(E==null?void 0:E.id)===G.id;return e.jsxs(Zn,{as:fe?void 0:"button",$isActive:fe,onClick:fe?void 0:()=>pe(G.id),...fe?{style:o?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:o},style:{...((Me=G.eligibility_restriction)==null?void 0:Me.type)!=="none"||((Ve=j==null?void 0:j.eligibility_restriction)==null?void 0:Ve.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...fe&&o?{pointerEvents:"none",opacity:.7}:{}},title:((nt=G.eligibility_restriction)==null?void 0:nt.message)||((ct=j==null?void 0:j.eligibility_restriction)==null?void 0:ct.message),children:[fe&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(Lc,{children:G.image_url?e.jsx("img",{src:G.image_url,alt:G.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):he(G.name).charAt(0)}),e.jsx(Ut,{children:e.jsx(Bt,{children:G.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((Xe=G.eligibility_restriction)==null?void 0:Xe.type)&&((Ct=G.eligibility_restriction)==null?void 0:Ct.type)!=="none"||((St=j==null?void 0:j.eligibility_restriction)==null?void 0:St.type)&&((mt=j==null?void 0:j.eligibility_restriction)==null?void 0:mt.type)!=="none")&&e.jsx("div",{title:((We=G.eligibility_restriction)==null?void 0:We.message)||((ot=j==null?void 0:j.eligibility_restriction)==null?void 0:ot.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),fe?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(($t=I==null?void 0:I.eligibility_restriction)==null?void 0:$t.type)==="none"&&((Et=j==null?void 0:j.eligibility_restriction)==null?void 0:Et.type)==="none"&&na(I)&&e.jsx(go,{onClick:et=>{et.stopPropagation(),m.open()},title:"Manage workspace",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async et=>{et.stopPropagation();try{O&&await O()}catch(zt){const Z=zt.message||"Failed to leave workspace. Please try again.";A(Z,"error")}},title:"Leave workspace",children:e.jsx(Ht,{size:12})})]}):e.jsx(Yn,{className:"hover-arrow",size:14})]})]},G.id)}),((it=j==null?void 0:j.eligibility_restriction)==null?void 0:it.type)==="none"&&e.jsx(Zn,{as:"button",onClick:()=>{C(g.id),x.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{style:{width:"14px",height:"14px"},children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})})]}),($||k)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(Mc,{children:[e.jsx(yy,{}),"Leaving organization..."]}),k&&e.jsxs(Mc,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),k]})]}),e.jsx(Nr,{}),y&&y.length>0&&e.jsx(e.Fragment,{children:y.filter(G=>G.organization.id!==(g==null?void 0:g.id)).map(G=>{var nt,ct,Xe,Ct,St,mt;const fe=G.organization,Me=(z==null?void 0:z.filter(We=>We.organization.id===fe.id))||[],Ve=a.has(fe.id);return e.jsxs(s.Fragment,{children:[e.jsxs(fo,{as:"button",$isActive:!1,onClick:()=>{U?Q(fe.id):ge(fe.id)},disabled:o,style:((nt=G.eligibility_restriction)==null?void 0:nt.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:void 0,title:(ct=G.eligibility_restriction)==null?void 0:ct.message,children:[e.jsxs(Nt,{children:[U&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:Ve?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Tc,{children:fe.image_url?e.jsx(Oc,{src:fe.image_url,alt:fe.name}):he(fe.name)}),e.jsx(Ut,{children:e.jsx(Bt,{children:fe.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((Xe=G.eligibility_restriction)==null?void 0:Xe.type)&&((Ct=G.eligibility_restriction)==null?void 0:Ct.type)!=="none"&&e.jsx("div",{title:(St=G.eligibility_restriction)==null?void 0:St.message,style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),e.jsx(Yn,{className:"hover-arrow",size:14})]})]}),U&&Ve&&e.jsxs(e.Fragment,{children:[Me.map(We=>{var $t,Et,et,zt,Z,K,ue,we,Ee,Ue;const ot=(E==null?void 0:E.id)===We.id;return e.jsxs(Zn,{as:ot?void 0:"button",$isActive:ot,onClick:ot?void 0:()=>pe(We.id),...ot?{style:o?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:o},style:{...(($t=We.eligibility_restriction)==null?void 0:$t.type)!=="none"||((Et=G.eligibility_restriction)==null?void 0:Et.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...ot&&o?{pointerEvents:"none",opacity:.7}:{}},title:((et=We.eligibility_restriction)==null?void 0:et.message)||((zt=G.eligibility_restriction)==null?void 0:zt.message),children:[ot&&e.jsx(Qn,{}),e.jsxs(Nt,{children:[e.jsx(Lc,{children:We.image_url?e.jsx("img",{src:We.image_url,alt:We.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):he(We.name).charAt(0)}),e.jsx(Ut,{children:e.jsx(Bt,{children:We.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((Z=We.eligibility_restriction)==null?void 0:Z.type)&&((K=We.eligibility_restriction)==null?void 0:K.type)!=="none"||((ue=G.eligibility_restriction)==null?void 0:ue.type)&&((we=G.eligibility_restriction)==null?void 0:we.type)!=="none")&&e.jsx("div",{title:((Ee=We.eligibility_restriction)==null?void 0:Ee.message)||((Ue=G.eligibility_restriction)==null?void 0:Ue.message),style:{display:"flex",alignItems:"center"},children:e.jsx(jr,{size:14,color:"var(--color-error)"})}),ot?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[na(I)&&e.jsx(go,{onClick:J=>{J.stopPropagation(),m.open()},title:"Manage workspace",children:e.jsx(Sr,{size:12})}),e.jsx(Ci,{onClick:async J=>{J.stopPropagation();try{O&&await O()}catch(Te){const De=Te.message||"Failed to leave workspace. Please try again.";A(De,"error")}},title:"Leave workspace",children:e.jsx(Ht,{size:12})})]}):e.jsx(Yn,{className:"hover-arrow",size:16})]})]},We.id)}),((mt=G.eligibility_restriction)==null?void 0:mt.type)==="none"&&e.jsx(Zn,{as:"button",onClick:()=>{C(fe.id),x.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{style:{width:"14px",height:"14px"},children:e.jsx(yt,{size:10})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})})]}),e.jsx(Nr,{})]},fe.id)})}),U&&e.jsx(Ac,{onClick:()=>{var G,fe;g&&(!((G=j==null?void 0:j.eligibility_restriction)!=null&&G.type)||((fe=j==null?void 0:j.eligibility_restriction)==null?void 0:fe.type)==="none")?C(g.id):C(null),x.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create workspace"})})]})}),!U&&V&&e.jsx(Ac,{onClick:()=>{l.open()},disabled:o,children:e.jsxs(Nt,{children:[e.jsx(Kn,{children:e.jsx(yt,{size:12})}),e.jsx(Ut,{children:e.jsx(Bt,{children:"Create organization"})})]})})]})})}),document.body),P&&V&&e.jsx(Qs,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(yc,{isOpen:f.isOpen,onClose:f.close}),e.jsx(ra,{isOpen:m.isOpen,onClose:m.close}),e.jsx(ta,{isOpen:x.isOpen,onClose:()=>{x.close(),C(null)},organizationId:v||void 0})]})})},bu=s.createContext(void 0),lr=()=>{const t=s.useContext(bu);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Cy=_t`
|
|
4191
4192
|
0% { transform: rotate(0deg); }
|
|
4192
4193
|
100% { transform: rotate(360deg); }
|
|
4193
4194
|
`,Sy=h.div`
|
|
@@ -4459,7 +4460,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4459
4460
|
@media (max-width: 768px) {
|
|
4460
4461
|
justify-content: center;
|
|
4461
4462
|
}
|
|
4462
|
-
`,Dy=t=>{const[r,n]=s.useState(!1);return s.useEffect(()=>{const o=window.matchMedia(t);o.matches!==r&&n(o.matches);const i=()=>n(o.matches);return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[t]),r},Fy=()=>{var L,A;const{deployment:t}=be(),{refetch:r}=He(),{user:n,updateProfile:o,updateProfilePicture:i,deleteAccount:a}=sr(),{toast:u}=lr(),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,
|
|
4463
|
+
`,Dy=t=>{const[r,n]=s.useState(!1);return s.useEffect(()=>{const o=window.matchMedia(t);o.matches!==r&&n(o.matches);const i=()=>n(o.matches);return o.addEventListener("change",i),()=>o.removeEventListener("change",i)},[t]),r},Fy=()=>{var L,A;const{deployment:t}=be(),{refetch:r}=He(),{user:n,updateProfile:o,updateProfilePicture:i,deleteAccount:a}=sr(),{toast:u}=lr(),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,x]=s.useState(""),[m,v]=s.useState(!1),[C,$]=s.useState(!1),[_,k]=s.useState(!1),[R,y]=s.useState(""),[b,S]=s.useState((n==null?void 0:n.profile_picture_url)||null),g=s.useRef(null);s.useEffect(()=>{n&&!m&&(d(n.first_name||""),l(n.last_name||""),x(n.username||""),S(n.profile_picture_url||null),v(!0))},[n,m]);const j=s.useCallback(async()=>{if(n)try{const P={};c!==n.first_name&&(P.first_name=c),p!==n.last_name&&(P.last_name=p),f!==n.username&&(P.username=f),Object.keys(P).length>0&&await o(P)}catch(P){u(P.message||"Failed to save profile changes","error")}},[n,o,c,p,f,u]),w=P=>{d(P.target.value)},E=P=>{l(P.target.value)},I=P=>{x(P.target.value)},O=()=>{j()},z=()=>{j()},T=()=>{j()},M=P=>{var U;if((U=P.target.files)!=null&&U[0]){const V=P.target.files[0];S(URL.createObjectURL(V)),setTimeout(async()=>{try{await i(V),n.refetch(),u("Profile picture updated successfully","info")}catch(H){u(H.message||"Failed to update profile picture","error"),S((n==null?void 0:n.profile_picture_url)||null)}},100)}},D=()=>{g.current&&g.current.click()};if(!n)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ie,{})});const F=async()=>{if(!(!n||R!=="delete this account")){k(!0);try{await a(""),u("Account deleted successfully","info"),await r()}catch(P){u(P.message||"Failed to delete account","error")}finally{k(!1),y(""),$(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs(Py,{children:[e.jsx(Ry,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:b?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",margin:"0 auto"},onClick:D,onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--color-primary)",P.currentTarget.style.transform="scale(1.02)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--color-border)",P.currentTarget.style.transform="scale(1)"},children:[b?e.jsx("img",{src:b,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(bo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:g,style:{display:"none"},accept:"image/*",onChange:M})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs(My,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var P;return(P=g.current)==null?void 0:P.click()},children:b?"Change":"Upload"}),e.jsxs(B,{$size:"sm",$outline:!0,onClick:async()=>{S(null),g.current&&(g.current.value="");try{await o({remove_profile_picture:!0}),await n.refetch(),u("Profile picture removed successfully","info")}catch(P){u(P.message||"Failed to remove profile picture","error"),S((n==null?void 0:n.profile_picture_url)||null)}},children:[e.jsx(Ot,{size:14,style:{marginRight:"4px"}}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(Ay,{children:[e.jsxs(oe,{style:{flex:1},children:[e.jsx(re,{htmlFor:"firstName",children:"First Name"}),e.jsx(ne,{id:"firstName",type:"text",value:c,onChange:w,onBlur:O,placeholder:"Enter your first name",required:!0})]}),e.jsxs(oe,{style:{flex:1},children:[e.jsx(re,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ne,{id:"lastName",type:"text",value:p,onChange:E,onBlur:z,placeholder:"Enter your last name",required:!0})]})]}),((A=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:A.enabled)&&e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"username",children:"Username"}),e.jsx(ne,{id:"username",type:"text",value:f,onChange:I,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:C?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(B,{onClick:()=>{C?($(!1),y("")):$(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:C?"Cancel":"Delete"})]}),C&&e.jsxs("div",{style:{width:"100%",marginTop:"16px"},children:[e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),e.jsx(ne,{id:"confirm_username",type:"text",value:R,onChange:P=>y(P.target.value),placeholder:"delete this account",style:{width:"100%"}})]}),e.jsx(B,{onClick:F,disabled:R!=="delete this account"||_,style:{background:R==="delete this account"?"var(--color-error)":"transparent",color:R==="delete this account"?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:R==="delete this account"?"pointer":"not-allowed",opacity:R==="delete this account"?1:.6,marginTop:"12px",width:"100%"},children:_?e.jsx(Ie,{size:12}):"Delete Forever"})]})]})]})]})})},Ny=h.div`
|
|
4463
4464
|
position: fixed;
|
|
4464
4465
|
background: var(--color-background);
|
|
4465
4466
|
border-radius: var(--radius-md);
|
|
@@ -4498,7 +4499,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4498
4499
|
justify-content: center;
|
|
4499
4500
|
color: var(--color-muted);
|
|
4500
4501
|
flex-shrink: 0;
|
|
4501
|
-
`,Wc=({onClose:t,onAddEmail:r,onAttemptVerification:n,onPrepareVerification:o,existingEmail:i,triggerRef:a})=>{const u=s.useRef(null),[c,d]=s.useState(!1),[p,l]=s.useState({top:0,left:0}),{toast:f}=lr();s.useEffect(()=>{d(!0);const
|
|
4502
|
+
`,Wc=({onClose:t,onAddEmail:r,onAttemptVerification:n,onPrepareVerification:o,existingEmail:i,triggerRef:a})=>{const u=s.useRef(null),[c,d]=s.useState(!1),[p,l]=s.useState({top:0,left:0}),{toast:f}=lr();s.useEffect(()=>{d(!0);const S=setTimeout(()=>{if(!u.current||!(a!=null&&a.current))return;const w=a.current;if(w){const E=w.getBoundingClientRect(),I=380,O=300,z=8;let T=0,M=0;const D=window.innerHeight-E.bottom,F=E.top;D>=O+z?(T=E.bottom+z,M=E.right-I,M<z&&(M=E.left,M+I>window.innerWidth-z&&(M=(window.innerWidth-I)/2))):F>=O+z?(T=E.top-O-z,M=E.right-I,M<z&&(M=E.left,M+I>window.innerWidth-z&&(M=(window.innerWidth-I)/2))):(T=E.bottom+z,M=E.right-I,M<z&&(M=E.left)),l({top:T,left:M})}},10),g=w=>{u.current&&!u.current.contains(w.target)&&t()},j=w=>{w.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",j),()=>{clearTimeout(S),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",j)}},[t,a]);const[x,m]=s.useState(i?"otp":"email"),[v,C]=s.useState(i||""),[$,_]=s.useState(""),[k,R]=s.useState(!1),y=async()=>{if(!(!v||k)){R(!0);try{await r(v),m("otp")}catch(S){const g=S.message||"Failed to add email address. Please try again.";f(g,"error")}finally{R(!1)}}},b=async()=>{R(!0);try{await n($),t()}catch(S){const g=S.message||"Failed to verify email. Please check the code and try again.";f(g,"error")}finally{R(!1)}};return c?e.jsx(Ny,{ref:u,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:x==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Bc,{children:"Add email address"}),e.jsx(oe,{children:e.jsxs(Uy,{children:[e.jsx(By,{children:e.jsx(To,{size:16})}),e.jsx(ne,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:S=>C(S.target.value),style:{flex:1}})]})}),e.jsxs(Uc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:y,disabled:!v||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bc,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(cr,{onComplete:async S=>_(S),onResend:o,isSubmitting:k}),e.jsxs(Uc,{children:[e.jsx(B,{$outline:!0,onClick:()=>m("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(B,{onClick:b,disabled:$.length<6||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Verifying...":"Verify"})]})]})}):null},Wy=()=>{var S,g,j,w;const{deployment:t}=be(),{toast:r}=lr(),[n,o]=s.useState(null),[i,a]=s.useState(""),[u,c]=s.useState(!1),[d,p]=s.useState(null),[l,f]=s.useState(""),x=s.useRef(null),m=s.useRef({}),{user:v,createEmailAddress:C,deleteEmailAddress:$,prepareEmailVerification:_,attemptEmailVerification:k,makeEmailPrimary:R}=sr();if(!((g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.email_address)!=null&&g.enabled))return null;const y=async E=>{try{if(E===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(E),v.refetch(),r("Email address deleted successfully","info")}catch(I){r(I.message||"Failed to delete email address. Please try again.","error")}},b=s.useMemo(()=>v!=null&&v.user_email_addresses?l.trim()?v.user_email_addresses.filter(E=>E.email.toLowerCase().includes(l.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(wu,{children:[e.jsx("div",{style:{flex:1,minWidth:"200px"},children:e.jsx(Zt,{value:l,onChange:f,placeholder:"Search Email"})}),e.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e.jsx(B,{ref:x,onClick:()=>c(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px",width:"100%"},children:"Add Email"}),u&&e.jsx(Wc,{triggerRef:x,onClose:()=>c(!1),onAddEmail:async E=>{const I=await C(E);a(I.data.id),await _(I.data.id),v.refetch()},onPrepareVerification:async()=>{await _(i),v.refetch()},onAttemptVerification:async E=>{await k(i,E),v.refetch(),c(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),b!=null&&b.length?e.jsxs(e.Fragment,{children:[e.jsx(Ra,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Email Address"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:b.map(E=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:E.email}),e.jsx(Ne,{children:E.id===(v==null?void 0:v.primary_email_address_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx(Ft,{children:E.id!==(v==null?void 0:v.primary_email_address_id)||!E.verified?e.jsxs(ut,{open:n===E.id,openChange:I=>o(I?E.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{ref:I=>{I&&(m.current[E.id]=I)},children:e.jsx(wn,{size:16})})}),e.jsxs(pt,{children:[E.id!==(v==null?void 0:v.primary_email_address_id)&&E.verified&&e.jsx(Le,{onClick:async()=>{try{await R(E.id),v.refetch(),o(null),r("Primary email updated successfully","info")}catch(I){r(I.message||"Failed to update primary email","error")}},children:"Make primary"}),!E.verified&&e.jsx(Le,{onClick:async()=>{o(null),await _(E.id),p(E.id)},children:"Verify email"}),E.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Le,{$destructive:!0,onClick:()=>{y(E.id),o(null)},children:"Remove"})]})]}):null})]},E.id))})]})}),e.jsx(Ia,{children:b.map((E,I)=>e.jsxs("div",{children:[e.jsx(No,{children:e.jsxs(Uo,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:E.email}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",background:"var(--color-input-background)",padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--color-border)"},children:E.id===(v==null?void 0:v.primary_email_address_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx("div",{style:{marginLeft:"auto"},children:(E.id!==(v==null?void 0:v.primary_email_address_id)||!E.verified)&&e.jsxs(ut,{open:n===E.id,openChange:O=>o(O?E.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{ref:O=>{O&&(m.current[E.id]=O)},children:e.jsx(wn,{size:16})})}),e.jsxs(pt,{children:[E.id!==(v==null?void 0:v.primary_email_address_id)&&E.verified&&e.jsx(Le,{onClick:async()=>{try{await R(E.id),v.refetch(),o(null),r("Primary email updated successfully","info")}catch(O){r(O.message||"Failed to update primary email","error")}},children:"Make primary"}),!E.verified&&e.jsx(Le,{onClick:async()=>{o(null),await _(E.id),p(E.id)},children:"Verify email"}),E.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Le,{$destructive:!0,onClick:()=>{y(E.id),o(null)},children:"Remove"})]})]})})]})}),I<b.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},E.id))})]}):e.jsx(kt,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),d&&e.jsx(Wc,{existingEmail:(w=(j=v==null?void 0:v.user_email_addresses)==null?void 0:j.find(E=>E.id===d))==null?void 0:w.email,triggerRef:{current:m.current[d]},onClose:()=>p(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await _(d),v.refetch()},onAttemptVerification:async E=>{await k(d,E),v.refetch(),p(null),r("Email verified successfully!","info")}})]})},Vy=h.div`
|
|
4502
4503
|
position: fixed;
|
|
4503
4504
|
background: var(--color-background);
|
|
4504
4505
|
border-radius: var(--radius-md);
|
|
@@ -4522,15 +4523,15 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4522
4523
|
font-weight: 400;
|
|
4523
4524
|
color: var(--color-foreground);
|
|
4524
4525
|
margin-bottom: 12px;
|
|
4525
|
-
`,Hc=({onClose:t,onAddPhone:r,onAttemptVerification:n,existingPhone:o,onPrepareVerification:i,triggerRef:a})=>{var j;const u=s.useRef(null),[c,d]=s.useState(!1),[p,l]=s.useState({top:0,left:0}),{toast:f}=lr();s.useEffect(()=>{d(!0);const w=setTimeout(()=>{if(!u.current||!(a!=null&&a.current))return;const O=a.current;if(O){const z=O.getBoundingClientRect(),T=380,
|
|
4526
|
+
`,Hc=({onClose:t,onAddPhone:r,onAttemptVerification:n,existingPhone:o,onPrepareVerification:i,triggerRef:a})=>{var j;const u=s.useRef(null),[c,d]=s.useState(!1),[p,l]=s.useState({top:0,left:0}),{toast:f}=lr();s.useEffect(()=>{d(!0);const w=setTimeout(()=>{if(!u.current||!(a!=null&&a.current))return;const O=a.current;if(O){const z=O.getBoundingClientRect(),T=380,M=300,D=8;let F=0,L=0;const A=window.innerHeight-z.bottom,P=z.top;A>=M+D?(F=z.bottom+D,L=z.right-T,L<D&&(L=z.left,L+T>window.innerWidth-D&&(L=(window.innerWidth-T)/2))):P>=M+D?(F=z.top-M-D,L=z.right-T,L<D&&(L=z.left,L+T>window.innerWidth-D&&(L=(window.innerWidth-T)/2))):(F=z.bottom+D,L=z.right-T,L<D&&(L=z.left)),l({top:F,left:L})}},10),E=O=>{u.current&&!u.current.contains(O.target)&&t()},I=O=>{O.key==="Escape"&&t()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",I),()=>{clearTimeout(w),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",I)}},[t,a]);const[x,m]=s.useState(o?"otp":"phone"),[v,C]=s.useState((o==null?void 0:o.replace(/^\+\d+/,""))||""),[$,_]=s.useState((j=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:j.pop()),[k,R]=s.useState(""),[y,b]=s.useState(!1),S=async()=>{if(!(!v||y)){b(!0);try{await r(v,$||""),m("otp")}catch(w){const E=w.message||"Failed to add phone number. Please try again.";f(E,"error")}finally{b(!1)}}},g=async()=>{b(!0);try{await n(k),t()}catch(w){const E=w.message||"Failed to verify phone. Please check the code and try again.";f(E,"error")}finally{b(!1)}};return c?e.jsx(Vy,{ref:u,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:x==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Gc,{children:"Add phone number"}),e.jsx(oe,{children:e.jsx(kn,{value:v,onChange:w=>C(w.target.value),error:"",countryCode:$,setCountryCode:_})}),e.jsxs(Vc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:S,disabled:!v||y,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Gc,{children:"Verify phone number"}),e.jsx(oe,{children:e.jsx(cr,{onComplete:w=>R(w),onResend:async()=>i()})}),e.jsxs(Vc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:g,disabled:k.length!==6||y,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Gy=()=>{var b,S,g,j;const{deployment:t}=be(),[r,n]=s.useState(null),[o,i]=s.useState(""),[a,u]=s.useState(!1),[c,d]=s.useState(null),[p,l]=s.useState(""),f=s.useRef(null),x=s.useRef({}),{user:m,createPhoneNumber:v,deletePhoneNumber:C,preparePhoneVerification:$,attemptPhoneVerification:_,makePhonePrimary:k}=sr();if(!((S=(b=t==null?void 0:t.auth_settings)==null?void 0:b.phone_number)!=null&&S.enabled))return null;const R=w=>{const E=ho.find(I=>I.dialCode===w);return(E==null?void 0:E.flag)||"🌍"},y=s.useMemo(()=>m!=null&&m.user_phone_numbers?p.trim()?m.user_phone_numbers.filter(w=>w.phone_number.toLowerCase().includes(p.toLowerCase())):m.user_phone_numbers:[],[m==null?void 0:m.user_phone_numbers,p]);return e.jsxs(e.Fragment,{children:[e.jsxs(wu,{children:[e.jsx("div",{style:{flex:1,minWidth:"200px"},children:e.jsx(Zt,{value:p,onChange:l,placeholder:"Search Phone"})}),e.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e.jsx(B,{ref:f,onClick:()=>u(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px",width:"100%"},children:"Add Phone"}),a&&e.jsx(Hc,{triggerRef:f,onClose:()=>u(!1),onAddPhone:async(w,E)=>{const I=await v(w,E);i(I.data.id),await $(I.data.id)},onPrepareVerification:async()=>{await $(o),m.refetch()},onAttemptVerification:async w=>{await _(o,w),m.refetch(),u(!1)}}),c&&e.jsx(Hc,{existingPhone:(j=(g=m==null?void 0:m.user_phone_numbers)==null?void 0:g.find(w=>w.id===c))==null?void 0:j.phone_number,triggerRef:{current:x.current[c]},onClose:()=>d(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(c),m.refetch()},onAttemptVerification:async w=>{await _(c,w),m.refetch(),d(null)}})]})]}),y!=null&&y.length?e.jsxs(e.Fragment,{children:[e.jsx(Ra,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Phone Number"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:y.map(w=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:R(w.country_code)}),e.jsx("span",{children:w.country_code}),e.jsx("span",{children:w.phone_number})]})}),e.jsx(Ne,{children:w.id===(m==null?void 0:m.primary_phone_number_id)?"Primary":w.verified?"Verified":"Not Verified"}),e.jsx(Ft,{children:e.jsxs(ut,{open:r===w.id,openChange:E=>n(E?w.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{ref:E=>{E&&(x.current[w.id]=E)},children:e.jsx(wn,{size:16})})}),e.jsxs(pt,{children:[w.id!==(m==null?void 0:m.primary_phone_number_id)&&w.verified&&e.jsx(Le,{onClick:async()=>{await k(w.id),m.refetch(),n(null)},children:"Make primary"}),!w.verified&&e.jsx(Le,{onClick:async()=>{n(null),await $(w.id),d(w.id)},children:"Verify phone"}),e.jsx(Le,{$destructive:!0,onClick:()=>{C(w.id),n(null)},children:"Remove"})]})]})})]},w.id))})]})}),e.jsx(Ia,{children:y.map((w,E)=>e.jsxs("div",{children:[e.jsx(No,{children:e.jsxs(Uo,{children:[e.jsx("span",{style:{fontSize:"18px"},children:R(w.country_code)}),e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[w.country_code," ",w.phone_number]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",background:"var(--color-input-background)",padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--color-border)"},children:w.id===(m==null?void 0:m.primary_phone_number_id)?"Primary":w.verified?"Verified":"Not Verified"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(ut,{open:r===w.id,openChange:I=>n(I?w.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{ref:I=>{I&&(x.current[w.id]=I)},children:e.jsx(wn,{size:16})})}),e.jsxs(pt,{children:[w.id!==(m==null?void 0:m.primary_phone_number_id)&&w.verified&&e.jsx(Le,{onClick:async()=>{await k(w.id),m.refetch(),n(null)},children:"Make primary"}),!w.verified&&e.jsx(Le,{onClick:async()=>{n(null),await $(w.id),d(w.id)},children:"Verify phone"}),e.jsx(Le,{$destructive:!0,onClick:()=>{C(w.id),n(null)},children:"Remove"})]})]})})]})}),E<y.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},w.id))})]}):e.jsx(kt,{title:p?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Hy=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),qy=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:n}=sr(),{deployment:o}=be(),i={google_oauth:{icon:e.jsx(Ad,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Hy,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Od,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Dd,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Md,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Fd,{}),label:"Discord"},x_oauth:{icon:e.jsx(Ld,{}),label:"X"}},a=(o==null?void 0:o.social_connections.filter(u=>u.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:a.map((u,c)=>{var l;const d=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(f=>f.provider===u.provider))||[],p=i[u.provider];return p?e.jsxs("div",{children:[e.jsxs(No,{children:[e.jsxs(Uo,{children:[e.jsx(oa,{children:p.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:p.label}),d.map(f=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:f.email_address}),e.jsx(Rr,{onClick:async()=>{await r(f.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Yt,{size:14})})]},f.id))]}),e.jsx(Ly,{children:d.length>0?e.jsx(B,{onClick:()=>{n({provider:u.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(B,{onClick:()=>{n({provider:u.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})})]}),c<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},u.provider):null})})]})};var Yy=Object.defineProperty,ko=Object.getOwnPropertySymbols,ju=Object.prototype.hasOwnProperty,_u=Object.prototype.propertyIsEnumerable,qc=(t,r,n)=>r in t?Yy(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,ia=(t,r)=>{for(var n in r||(r={}))ju.call(r,n)&&qc(t,n,r[n]);if(ko)for(var n of ko(r))_u.call(r,n)&&qc(t,n,r[n]);return t},aa=(t,r)=>{var n={};for(var o in t)ju.call(t,o)&&r.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&ko)for(var o of ko(t))r.indexOf(o)<0&&_u.call(t,o)&&(n[o]=t[o]);return n};/**
|
|
4526
4527
|
* @license QR Code generator library (TypeScript)
|
|
4527
4528
|
* Copyright (c) Project Nayuki.
|
|
4528
4529
|
* SPDX-License-Identifier: MIT
|
|
4529
|
-
*/var Ir;(t=>{const r=class Se{constructor(d,p,l,f){if(this.version=d,this.errorCorrectionLevel=p,this.modules=[],this.isFunction=[],d<Se.MIN_VERSION||d>Se.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let m=[];for(let v=0;v<this.size;v++)m.push(!1);for(let v=0;v<this.size;v++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(l);if(this.drawCodewords(x),f==-1){let v=1e9;for(let $=0;$<8;$++){this.applyMask($),this.drawFormatBits($);const S=this.getPenaltyScore();S<v&&(f=$,v=S),this.applyMask($)}}i(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(d,p){const l=t.QrSegment.makeSegments(d);return Se.encodeSegments(l,p)}static encodeBinary(d,p){const l=t.QrSegment.makeBytes(d);return Se.encodeSegments([l],p)}static encodeSegments(d,p,l=1,f=40,m=-1,x=!0){if(!(Se.MIN_VERSION<=l&&l<=f&&f<=Se.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,$;for(v=l;;v++){const P=Se.getNumDataCodewords(v,p)*8,y=u.getTotalBits(d,v);if(y<=P){$=y;break}if(v>=f)throw new RangeError("Data too long")}for(const P of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])x&&$<=Se.getNumDataCodewords(v,P)*8&&(p=P);let S=[];for(const P of d){n(P.mode.modeBits,4,S),n(P.numChars,P.mode.numCharCountBits(v),S);for(const y of P.getData())S.push(y)}i(S.length==$);const _=Se.getNumDataCodewords(v,p)*8;i(S.length<=_),n(0,Math.min(4,_-S.length),S),n(0,(8-S.length%8)%8,S),i(S.length%8==0);for(let P=236;S.length<_;P^=253)n(P,8,S);let k=[];for(;k.length*8<S.length;)k.push(0);return S.forEach((P,y)=>k[y>>>3]|=P<<7-(y&7)),new Se(v,p,k,m)}getModule(d,p){return 0<=d&&d<this.size&&0<=p&&p<this.size&&this.modules[p][d]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const d=this.getAlignmentPatternPositions(),p=d.length;for(let l=0;l<p;l++)for(let f=0;f<p;f++)l==0&&f==0||l==0&&f==p-1||l==p-1&&f==0||this.drawAlignmentPattern(d[l],d[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(d){const p=this.errorCorrectionLevel.formatBits<<3|d;let l=p;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const f=(p<<10|l)^21522;i(f>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,o(f,m));this.setFunctionModule(8,7,o(f,6)),this.setFunctionModule(8,8,o(f,7)),this.setFunctionModule(7,8,o(f,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,o(f,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,o(f,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,o(f,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let l=0;l<12;l++)d=d<<1^(d>>>11)*7973;const p=this.version<<12|d;i(p>>>18==0);for(let l=0;l<18;l++){const f=o(p,l),m=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(m,x,f),this.setFunctionModule(x,m,f)}}drawFinderPattern(d,p){for(let l=-4;l<=4;l++)for(let f=-4;f<=4;f++){const m=Math.max(Math.abs(f),Math.abs(l)),x=d+f,v=p+l;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(d,p){for(let l=-2;l<=2;l++)for(let f=-2;f<=2;f++)this.setFunctionModule(d+f,p+l,Math.max(Math.abs(f),Math.abs(l))!=1)}setFunctionModule(d,p,l){this.modules[p][d]=l,this.isFunction[p][d]=!0}addEccAndInterleave(d){const p=this.version,l=this.errorCorrectionLevel;if(d.length!=Se.getNumDataCodewords(p,l))throw new RangeError("Invalid argument");const f=Se.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][p],m=Se.ECC_CODEWORDS_PER_BLOCK[l.ordinal][p],x=Math.floor(Se.getNumRawDataModules(p)/8),v=f-x%f,$=Math.floor(x/f);let S=[];const _=Se.reedSolomonComputeDivisor(m);for(let P=0,y=0;P<f;P++){let b=d.slice(y,y+$-m+(P<v?0:1));y+=b.length;const C=Se.reedSolomonComputeRemainder(b,_);P<v&&b.push(0),S.push(b.concat(C))}let k=[];for(let P=0;P<S[0].length;P++)S.forEach((y,b)=>{(P!=$-m||b>=v)&&k.push(y[P])});return i(k.length==x),k}drawCodewords(d){if(d.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let p=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let f=0;f<this.size;f++)for(let m=0;m<2;m++){const x=l-m,$=(l+1&2)==0?this.size-1-f:f;!this.isFunction[$][x]&&p<d.length*8&&(this.modules[$][x]=o(d[p>>>3],7-(p&7)),p++)}}i(p==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let p=0;p<this.size;p++)for(let l=0;l<this.size;l++){let f;switch(d){case 0:f=(l+p)%2==0;break;case 1:f=p%2==0;break;case 2:f=l%3==0;break;case 3:f=(l+p)%3==0;break;case 4:f=(Math.floor(l/3)+Math.floor(p/2))%2==0;break;case 5:f=l*p%2+l*p%3==0;break;case 6:f=(l*p%2+l*p%3)%2==0;break;case 7:f=((l+p)%2+l*p%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[p][l]&&f&&(this.modules[p][l]=!this.modules[p][l])}}getPenaltyScore(){let d=0;for(let m=0;m<this.size;m++){let x=!1,v=0,$=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[m][S]==x?(v++,v==5?d+=Se.PENALTY_N1:v>5&&d++):(this.finderPenaltyAddHistory(v,$),x||(d+=this.finderPenaltyCountPatterns($)*Se.PENALTY_N3),x=this.modules[m][S],v=1);d+=this.finderPenaltyTerminateAndCount(x,v,$)*Se.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,$=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[S][m]==x?(v++,v==5?d+=Se.PENALTY_N1:v>5&&d++):(this.finderPenaltyAddHistory(v,$),x||(d+=this.finderPenaltyCountPatterns($)*Se.PENALTY_N3),x=this.modules[S][m],v=1);d+=this.finderPenaltyTerminateAndCount(x,v,$)*Se.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const v=this.modules[m][x];v==this.modules[m][x+1]&&v==this.modules[m+1][x]&&v==this.modules[m+1][x+1]&&(d+=Se.PENALTY_N2)}let p=0;for(const m of this.modules)p=m.reduce((x,v)=>x+(v?1:0),p);const l=this.size*this.size,f=Math.ceil(Math.abs(p*20-l*10)/l)-1;return i(0<=f&&f<=9),d+=f*Se.PENALTY_N4,i(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,p=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let l=[6];for(let f=this.size-7;l.length<d;f-=p)l.splice(1,0,f);return l}}static getNumRawDataModules(d){if(d<Se.MIN_VERSION||d>Se.MAX_VERSION)throw new RangeError("Version number out of range");let p=(16*d+128)*d+64;if(d>=2){const l=Math.floor(d/7)+2;p-=(25*l-10)*l-55,d>=7&&(p-=36)}return i(208<=p&&p<=29648),p}static getNumDataCodewords(d,p){return Math.floor(Se.getNumRawDataModules(d)/8)-Se.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d]*Se.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let p=[];for(let f=0;f<d-1;f++)p.push(0);p.push(1);let l=1;for(let f=0;f<d;f++){for(let m=0;m<p.length;m++)p[m]=Se.reedSolomonMultiply(p[m],l),m+1<p.length&&(p[m]^=p[m+1]);l=Se.reedSolomonMultiply(l,2)}return p}static reedSolomonComputeRemainder(d,p){let l=p.map(f=>0);for(const f of d){const m=f^l.shift();l.push(0),p.forEach((x,v)=>l[v]^=Se.reedSolomonMultiply(x,m))}return l}static reedSolomonMultiply(d,p){if(d>>>8||p>>>8)throw new RangeError("Byte out of range");let l=0;for(let f=7;f>=0;f--)l=l<<1^(l>>>7)*285,l^=(p>>>f&1)*d;return i(l>>>8==0),l}finderPenaltyCountPatterns(d){const p=d[1];i(p<=this.size*3);const l=p>0&&d[2]==p&&d[3]==p*3&&d[4]==p&&d[5]==p;return(l&&d[0]>=p*4&&d[6]>=p?1:0)+(l&&d[6]>=p*4&&d[0]>=p?1:0)}finderPenaltyTerminateAndCount(d,p,l){return d&&(this.finderPenaltyAddHistory(p,l),p=0),p+=this.size,this.finderPenaltyAddHistory(p,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(d,p){p[0]==0&&(d+=this.size),p.pop(),p.unshift(d)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function n(c,d,p){if(d<0||d>31||c>>>d)throw new RangeError("Value out of range");for(let l=d-1;l>=0;l--)p.push(c>>>l&1)}function o(c,d){return(c>>>d&1)!=0}function i(c){if(!c)throw new Error("Assertion error")}const a=class Ge{constructor(d,p,l){if(this.mode=d,this.numChars=p,this.bitData=l,p<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(d){let p=[];for(const l of d)n(l,8,p);return new Ge(Ge.Mode.BYTE,d.length,p)}static makeNumeric(d){if(!Ge.isNumeric(d))throw new RangeError("String contains non-numeric characters");let p=[];for(let l=0;l<d.length;){const f=Math.min(d.length-l,3);n(parseInt(d.substring(l,l+f),10),f*3+1,p),l+=f}return new Ge(Ge.Mode.NUMERIC,d.length,p)}static makeAlphanumeric(d){if(!Ge.isAlphanumeric(d))throw new RangeError("String contains unencodable characters in alphanumeric mode");let p=[],l;for(l=0;l+2<=d.length;l+=2){let f=Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l))*45;f+=Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l+1)),n(f,11,p)}return l<d.length&&n(Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l)),6,p),new Ge(Ge.Mode.ALPHANUMERIC,d.length,p)}static makeSegments(d){return d==""?[]:Ge.isNumeric(d)?[Ge.makeNumeric(d)]:Ge.isAlphanumeric(d)?[Ge.makeAlphanumeric(d)]:[Ge.makeBytes(Ge.toUtf8ByteArray(d))]}static makeEci(d){let p=[];if(d<0)throw new RangeError("ECI assignment value out of range");if(d<128)n(d,8,p);else if(d<16384)n(2,2,p),n(d,14,p);else if(d<1e6)n(6,3,p),n(d,21,p);else throw new RangeError("ECI assignment value out of range");return new Ge(Ge.Mode.ECI,0,p)}static isNumeric(d){return Ge.NUMERIC_REGEX.test(d)}static isAlphanumeric(d){return Ge.ALPHANUMERIC_REGEX.test(d)}getData(){return this.bitData.slice()}static getTotalBits(d,p){let l=0;for(const f of d){const m=f.mode.numCharCountBits(p);if(f.numChars>=1<<m)return 1/0;l+=4+m+f.bitData.length}return l}static toUtf8ByteArray(d){d=encodeURI(d);let p=[];for(let l=0;l<d.length;l++)d.charAt(l)!="%"?p.push(d.charCodeAt(l)):(p.push(parseInt(d.substring(l+1,l+3),16)),l+=2);return p}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let u=a;t.QrSegment=a})(Ir||(Ir={}));(t=>{(r=>{const n=class{constructor(i,a){this.ordinal=i,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),r.Ecc=n})(t.QrCode||(t.QrCode={}))})(Ir||(Ir={}));(t=>{(r=>{const n=class{constructor(i,a){this.modeBits=i,this.numBitsCharCount=a}numCharCountBits(i){return this.numBitsCharCount[Math.floor((i+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),r.Mode=n})(t.QrSegment||(t.QrSegment={}))})(Ir||(Ir={}));var Wr=Ir;/**
|
|
4530
|
+
*/var Ir;(t=>{const r=class Se{constructor(d,p,l,f){if(this.version=d,this.errorCorrectionLevel=p,this.modules=[],this.isFunction=[],d<Se.MIN_VERSION||d>Se.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let x=[];for(let v=0;v<this.size;v++)x.push(!1);for(let v=0;v<this.size;v++)this.modules.push(x.slice()),this.isFunction.push(x.slice());this.drawFunctionPatterns();const m=this.addEccAndInterleave(l);if(this.drawCodewords(m),f==-1){let v=1e9;for(let C=0;C<8;C++){this.applyMask(C),this.drawFormatBits(C);const $=this.getPenaltyScore();$<v&&(f=C,v=$),this.applyMask(C)}}i(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(d,p){const l=t.QrSegment.makeSegments(d);return Se.encodeSegments(l,p)}static encodeBinary(d,p){const l=t.QrSegment.makeBytes(d);return Se.encodeSegments([l],p)}static encodeSegments(d,p,l=1,f=40,x=-1,m=!0){if(!(Se.MIN_VERSION<=l&&l<=f&&f<=Se.MAX_VERSION)||x<-1||x>7)throw new RangeError("Invalid value");let v,C;for(v=l;;v++){const R=Se.getNumDataCodewords(v,p)*8,y=u.getTotalBits(d,v);if(y<=R){C=y;break}if(v>=f)throw new RangeError("Data too long")}for(const R of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])m&&C<=Se.getNumDataCodewords(v,R)*8&&(p=R);let $=[];for(const R of d){n(R.mode.modeBits,4,$),n(R.numChars,R.mode.numCharCountBits(v),$);for(const y of R.getData())$.push(y)}i($.length==C);const _=Se.getNumDataCodewords(v,p)*8;i($.length<=_),n(0,Math.min(4,_-$.length),$),n(0,(8-$.length%8)%8,$),i($.length%8==0);for(let R=236;$.length<_;R^=253)n(R,8,$);let k=[];for(;k.length*8<$.length;)k.push(0);return $.forEach((R,y)=>k[y>>>3]|=R<<7-(y&7)),new Se(v,p,k,x)}getModule(d,p){return 0<=d&&d<this.size&&0<=p&&p<this.size&&this.modules[p][d]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const d=this.getAlignmentPatternPositions(),p=d.length;for(let l=0;l<p;l++)for(let f=0;f<p;f++)l==0&&f==0||l==0&&f==p-1||l==p-1&&f==0||this.drawAlignmentPattern(d[l],d[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(d){const p=this.errorCorrectionLevel.formatBits<<3|d;let l=p;for(let x=0;x<10;x++)l=l<<1^(l>>>9)*1335;const f=(p<<10|l)^21522;i(f>>>15==0);for(let x=0;x<=5;x++)this.setFunctionModule(8,x,o(f,x));this.setFunctionModule(8,7,o(f,6)),this.setFunctionModule(8,8,o(f,7)),this.setFunctionModule(7,8,o(f,8));for(let x=9;x<15;x++)this.setFunctionModule(14-x,8,o(f,x));for(let x=0;x<8;x++)this.setFunctionModule(this.size-1-x,8,o(f,x));for(let x=8;x<15;x++)this.setFunctionModule(8,this.size-15+x,o(f,x));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let l=0;l<12;l++)d=d<<1^(d>>>11)*7973;const p=this.version<<12|d;i(p>>>18==0);for(let l=0;l<18;l++){const f=o(p,l),x=this.size-11+l%3,m=Math.floor(l/3);this.setFunctionModule(x,m,f),this.setFunctionModule(m,x,f)}}drawFinderPattern(d,p){for(let l=-4;l<=4;l++)for(let f=-4;f<=4;f++){const x=Math.max(Math.abs(f),Math.abs(l)),m=d+f,v=p+l;0<=m&&m<this.size&&0<=v&&v<this.size&&this.setFunctionModule(m,v,x!=2&&x!=4)}}drawAlignmentPattern(d,p){for(let l=-2;l<=2;l++)for(let f=-2;f<=2;f++)this.setFunctionModule(d+f,p+l,Math.max(Math.abs(f),Math.abs(l))!=1)}setFunctionModule(d,p,l){this.modules[p][d]=l,this.isFunction[p][d]=!0}addEccAndInterleave(d){const p=this.version,l=this.errorCorrectionLevel;if(d.length!=Se.getNumDataCodewords(p,l))throw new RangeError("Invalid argument");const f=Se.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][p],x=Se.ECC_CODEWORDS_PER_BLOCK[l.ordinal][p],m=Math.floor(Se.getNumRawDataModules(p)/8),v=f-m%f,C=Math.floor(m/f);let $=[];const _=Se.reedSolomonComputeDivisor(x);for(let R=0,y=0;R<f;R++){let b=d.slice(y,y+C-x+(R<v?0:1));y+=b.length;const S=Se.reedSolomonComputeRemainder(b,_);R<v&&b.push(0),$.push(b.concat(S))}let k=[];for(let R=0;R<$[0].length;R++)$.forEach((y,b)=>{(R!=C-x||b>=v)&&k.push(y[R])});return i(k.length==m),k}drawCodewords(d){if(d.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let p=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let f=0;f<this.size;f++)for(let x=0;x<2;x++){const m=l-x,C=(l+1&2)==0?this.size-1-f:f;!this.isFunction[C][m]&&p<d.length*8&&(this.modules[C][m]=o(d[p>>>3],7-(p&7)),p++)}}i(p==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let p=0;p<this.size;p++)for(let l=0;l<this.size;l++){let f;switch(d){case 0:f=(l+p)%2==0;break;case 1:f=p%2==0;break;case 2:f=l%3==0;break;case 3:f=(l+p)%3==0;break;case 4:f=(Math.floor(l/3)+Math.floor(p/2))%2==0;break;case 5:f=l*p%2+l*p%3==0;break;case 6:f=(l*p%2+l*p%3)%2==0;break;case 7:f=((l+p)%2+l*p%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[p][l]&&f&&(this.modules[p][l]=!this.modules[p][l])}}getPenaltyScore(){let d=0;for(let x=0;x<this.size;x++){let m=!1,v=0,C=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[x][$]==m?(v++,v==5?d+=Se.PENALTY_N1:v>5&&d++):(this.finderPenaltyAddHistory(v,C),m||(d+=this.finderPenaltyCountPatterns(C)*Se.PENALTY_N3),m=this.modules[x][$],v=1);d+=this.finderPenaltyTerminateAndCount(m,v,C)*Se.PENALTY_N3}for(let x=0;x<this.size;x++){let m=!1,v=0,C=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][x]==m?(v++,v==5?d+=Se.PENALTY_N1:v>5&&d++):(this.finderPenaltyAddHistory(v,C),m||(d+=this.finderPenaltyCountPatterns(C)*Se.PENALTY_N3),m=this.modules[$][x],v=1);d+=this.finderPenaltyTerminateAndCount(m,v,C)*Se.PENALTY_N3}for(let x=0;x<this.size-1;x++)for(let m=0;m<this.size-1;m++){const v=this.modules[x][m];v==this.modules[x][m+1]&&v==this.modules[x+1][m]&&v==this.modules[x+1][m+1]&&(d+=Se.PENALTY_N2)}let p=0;for(const x of this.modules)p=x.reduce((m,v)=>m+(v?1:0),p);const l=this.size*this.size,f=Math.ceil(Math.abs(p*20-l*10)/l)-1;return i(0<=f&&f<=9),d+=f*Se.PENALTY_N4,i(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,p=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let l=[6];for(let f=this.size-7;l.length<d;f-=p)l.splice(1,0,f);return l}}static getNumRawDataModules(d){if(d<Se.MIN_VERSION||d>Se.MAX_VERSION)throw new RangeError("Version number out of range");let p=(16*d+128)*d+64;if(d>=2){const l=Math.floor(d/7)+2;p-=(25*l-10)*l-55,d>=7&&(p-=36)}return i(208<=p&&p<=29648),p}static getNumDataCodewords(d,p){return Math.floor(Se.getNumRawDataModules(d)/8)-Se.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d]*Se.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let p=[];for(let f=0;f<d-1;f++)p.push(0);p.push(1);let l=1;for(let f=0;f<d;f++){for(let x=0;x<p.length;x++)p[x]=Se.reedSolomonMultiply(p[x],l),x+1<p.length&&(p[x]^=p[x+1]);l=Se.reedSolomonMultiply(l,2)}return p}static reedSolomonComputeRemainder(d,p){let l=p.map(f=>0);for(const f of d){const x=f^l.shift();l.push(0),p.forEach((m,v)=>l[v]^=Se.reedSolomonMultiply(m,x))}return l}static reedSolomonMultiply(d,p){if(d>>>8||p>>>8)throw new RangeError("Byte out of range");let l=0;for(let f=7;f>=0;f--)l=l<<1^(l>>>7)*285,l^=(p>>>f&1)*d;return i(l>>>8==0),l}finderPenaltyCountPatterns(d){const p=d[1];i(p<=this.size*3);const l=p>0&&d[2]==p&&d[3]==p*3&&d[4]==p&&d[5]==p;return(l&&d[0]>=p*4&&d[6]>=p?1:0)+(l&&d[6]>=p*4&&d[0]>=p?1:0)}finderPenaltyTerminateAndCount(d,p,l){return d&&(this.finderPenaltyAddHistory(p,l),p=0),p+=this.size,this.finderPenaltyAddHistory(p,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(d,p){p[0]==0&&(d+=this.size),p.pop(),p.unshift(d)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function n(c,d,p){if(d<0||d>31||c>>>d)throw new RangeError("Value out of range");for(let l=d-1;l>=0;l--)p.push(c>>>l&1)}function o(c,d){return(c>>>d&1)!=0}function i(c){if(!c)throw new Error("Assertion error")}const a=class Ge{constructor(d,p,l){if(this.mode=d,this.numChars=p,this.bitData=l,p<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(d){let p=[];for(const l of d)n(l,8,p);return new Ge(Ge.Mode.BYTE,d.length,p)}static makeNumeric(d){if(!Ge.isNumeric(d))throw new RangeError("String contains non-numeric characters");let p=[];for(let l=0;l<d.length;){const f=Math.min(d.length-l,3);n(parseInt(d.substring(l,l+f),10),f*3+1,p),l+=f}return new Ge(Ge.Mode.NUMERIC,d.length,p)}static makeAlphanumeric(d){if(!Ge.isAlphanumeric(d))throw new RangeError("String contains unencodable characters in alphanumeric mode");let p=[],l;for(l=0;l+2<=d.length;l+=2){let f=Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l))*45;f+=Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l+1)),n(f,11,p)}return l<d.length&&n(Ge.ALPHANUMERIC_CHARSET.indexOf(d.charAt(l)),6,p),new Ge(Ge.Mode.ALPHANUMERIC,d.length,p)}static makeSegments(d){return d==""?[]:Ge.isNumeric(d)?[Ge.makeNumeric(d)]:Ge.isAlphanumeric(d)?[Ge.makeAlphanumeric(d)]:[Ge.makeBytes(Ge.toUtf8ByteArray(d))]}static makeEci(d){let p=[];if(d<0)throw new RangeError("ECI assignment value out of range");if(d<128)n(d,8,p);else if(d<16384)n(2,2,p),n(d,14,p);else if(d<1e6)n(6,3,p),n(d,21,p);else throw new RangeError("ECI assignment value out of range");return new Ge(Ge.Mode.ECI,0,p)}static isNumeric(d){return Ge.NUMERIC_REGEX.test(d)}static isAlphanumeric(d){return Ge.ALPHANUMERIC_REGEX.test(d)}getData(){return this.bitData.slice()}static getTotalBits(d,p){let l=0;for(const f of d){const x=f.mode.numCharCountBits(p);if(f.numChars>=1<<x)return 1/0;l+=4+x+f.bitData.length}return l}static toUtf8ByteArray(d){d=encodeURI(d);let p=[];for(let l=0;l<d.length;l++)d.charAt(l)!="%"?p.push(d.charCodeAt(l)):(p.push(parseInt(d.substring(l+1,l+3),16)),l+=2);return p}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let u=a;t.QrSegment=a})(Ir||(Ir={}));(t=>{(r=>{const n=class{constructor(i,a){this.ordinal=i,this.formatBits=a}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),r.Ecc=n})(t.QrCode||(t.QrCode={}))})(Ir||(Ir={}));(t=>{(r=>{const n=class{constructor(i,a){this.modeBits=i,this.numBitsCharCount=a}numCharCountBits(i){return this.numBitsCharCount[Math.floor((i+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),r.Mode=n})(t.QrSegment||(t.QrSegment={}))})(Ir||(Ir={}));var Wr=Ir;/**
|
|
4530
4531
|
* @license qrcode.react
|
|
4531
4532
|
* Copyright (c) Paul O'Shannessy
|
|
4532
4533
|
* SPDX-License-Identifier: ISC
|
|
4533
|
-
*/var Ky={L:Wr.QrCode.Ecc.LOW,M:Wr.QrCode.Ecc.MEDIUM,Q:Wr.QrCode.Ecc.QUARTILE,H:Wr.QrCode.Ecc.HIGH},ku=128,Cu="L",Su="#FFFFFF",$u="#000000",Eu=!1,zu=1,Qy=4,Zy=0,Jy=.1;function Pu(t,r=0){const n=[];return t.forEach(function(o,i){let a=null;o.forEach(function(u,c){if(!u&&a!==null){n.push(`M${a+r} ${i+r}h${c-a}v1H${a+r}z`),a=null;return}if(c===o.length-1){if(!u)return;a===null?n.push(`M${c+r},${i+r} h1v1H${c+r}z`):n.push(`M${a+r},${i+r} h${c+1-a}v1H${a+r}z`);return}u&&a===null&&(a=c)})}),n.join("")}function Ru(t,r){return t.slice().map((n,o)=>o<r.y||o>=r.y+r.h?n:n.map((i,a)=>a<r.x||a>=r.x+r.w?i:!1))}function Xy(t,r,n,o){if(o==null)return null;const i=t.length+n*2,a=Math.floor(r*Jy),u=i/r,c=(o.width||a)*u,d=(o.height||a)*u,p=o.x==null?t.length/2-c/2:o.x*u,l=o.y==null?t.length/2-d/2:o.y*u,f=o.opacity==null?1:o.opacity;let
|
|
4534
|
+
*/var Ky={L:Wr.QrCode.Ecc.LOW,M:Wr.QrCode.Ecc.MEDIUM,Q:Wr.QrCode.Ecc.QUARTILE,H:Wr.QrCode.Ecc.HIGH},ku=128,Cu="L",Su="#FFFFFF",$u="#000000",Eu=!1,zu=1,Qy=4,Zy=0,Jy=.1;function Pu(t,r=0){const n=[];return t.forEach(function(o,i){let a=null;o.forEach(function(u,c){if(!u&&a!==null){n.push(`M${a+r} ${i+r}h${c-a}v1H${a+r}z`),a=null;return}if(c===o.length-1){if(!u)return;a===null?n.push(`M${c+r},${i+r} h1v1H${c+r}z`):n.push(`M${a+r},${i+r} h${c+1-a}v1H${a+r}z`);return}u&&a===null&&(a=c)})}),n.join("")}function Ru(t,r){return t.slice().map((n,o)=>o<r.y||o>=r.y+r.h?n:n.map((i,a)=>a<r.x||a>=r.x+r.w?i:!1))}function Xy(t,r,n,o){if(o==null)return null;const i=t.length+n*2,a=Math.floor(r*Jy),u=i/r,c=(o.width||a)*u,d=(o.height||a)*u,p=o.x==null?t.length/2-c/2:o.x*u,l=o.y==null?t.length/2-d/2:o.y*u,f=o.opacity==null?1:o.opacity;let x=null;if(o.excavate){let v=Math.floor(p),C=Math.floor(l),$=Math.ceil(c+p-v),_=Math.ceil(d+l-C);x={x:v,y:C,w:$,h:_}}const m=o.crossOrigin;return{x:p,y:l,h:d,w:c,excavation:x,opacity:f,crossOrigin:m}}function e2(t,r){return r!=null?Math.max(Math.floor(r),0):t?Qy:Zy}function Iu({value:t,level:r,minVersion:n,includeMargin:o,marginSize:i,imageSettings:a,size:u,boostLevel:c}){let d=s.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((C,$)=>(C.push(...Wr.QrSegment.makeSegments($)),C),[]);return Wr.QrCode.encodeSegments(v,Ky[r],n,void 0,void 0,c)},[t,r,n,c]);const{cells:p,margin:l,numCells:f,calculatedImageSettings:x}=s.useMemo(()=>{let m=d.getModules();const v=e2(o,i),C=m.length+v*2,$=Xy(m,u,v,a);return{cells:m,margin:v,numCells:C,calculatedImageSettings:$}},[d,u,a,o,i]);return{qrcode:d,margin:l,cells:p,numCells:f,calculatedImageSettings:x}}var t2=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),r2=s.forwardRef(function(r,n){const o=r,{value:i,size:a=ku,level:u=Cu,bgColor:c=Su,fgColor:d=$u,includeMargin:p=Eu,minVersion:l=zu,boostLevel:f,marginSize:x,imageSettings:m}=o,C=aa(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=C,_=aa(C,["style"]),k=m==null?void 0:m.src,R=s.useRef(null),y=s.useRef(null),b=s.useCallback(T=>{R.current=T,typeof n=="function"?n(T):n&&(n.current=T)},[n]),[S,g]=s.useState(!1),{margin:j,cells:w,numCells:E,calculatedImageSettings:I}=Iu({value:i,level:u,minVersion:l,boostLevel:f,includeMargin:p,marginSize:x,imageSettings:m,size:a});s.useEffect(()=>{if(R.current!=null){const T=R.current,M=T.getContext("2d");if(!M)return;let D=w;const F=y.current,L=I!=null&&F!==null&&F.complete&&F.naturalHeight!==0&&F.naturalWidth!==0;L&&I.excavation!=null&&(D=Ru(w,I.excavation));const A=window.devicePixelRatio||1;T.height=T.width=a*A;const P=a/E*A;M.scale(P,P),M.fillStyle=c,M.fillRect(0,0,E,E),M.fillStyle=d,t2?M.fill(new Path2D(Pu(D,j))):w.forEach(function(U,V){U.forEach(function(H,ae){H&&M.fillRect(ae+j,V+j,1,1)})}),I&&(M.globalAlpha=I.opacity),L&&M.drawImage(F,I.x+j,I.y+j,I.w,I.h)}}),s.useEffect(()=>{g(!1)},[k]);const O=ia({height:a,width:a},$);let z=null;return k!=null&&(z=s.createElement("img",{src:k,key:k,style:{display:"none"},onLoad:()=>{g(!0)},ref:y,crossOrigin:I==null?void 0:I.crossOrigin})),s.createElement(s.Fragment,null,s.createElement("canvas",ia({style:O,height:a,width:a,ref:b,role:"img"},_)),z)});r2.displayName="QRCodeCanvas";var Ta=s.forwardRef(function(r,n){const o=r,{value:i,size:a=ku,level:u=Cu,bgColor:c=Su,fgColor:d=$u,includeMargin:p=Eu,minVersion:l=zu,boostLevel:f,title:x,marginSize:m,imageSettings:v}=o,C=aa(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:_,numCells:k,calculatedImageSettings:R}=Iu({value:i,level:u,minVersion:l,boostLevel:f,includeMargin:p,marginSize:m,imageSettings:v,size:a});let y=_,b=null;v!=null&&R!=null&&(R.excavation!=null&&(y=Ru(_,R.excavation)),b=s.createElement("image",{href:v.src,height:R.h,width:R.w,x:R.x+$,y:R.y+$,preserveAspectRatio:"none",opacity:R.opacity,crossOrigin:R.crossOrigin}));const S=Pu(y,$);return s.createElement("svg",ia({height:a,width:a,viewBox:`0 0 ${k} ${k}`,ref:n,role:"img"},C),!!x&&s.createElement("title",null,x),s.createElement("path",{fill:c,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),s.createElement("path",{fill:d,d:S,shapeRendering:"crispEdges"}),b)});Ta.displayName="QRCodeSVG";const n2=h.div`
|
|
4534
4535
|
position: fixed;
|
|
4535
4536
|
background: var(--color-background);
|
|
4536
4537
|
border-radius: var(--radius-md);
|
|
@@ -4600,7 +4601,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4600
4601
|
color: var(--color-error);
|
|
4601
4602
|
font-size: 12px;
|
|
4602
4603
|
margin-top: 4px;
|
|
4603
|
-
`,Kc=({onClose:t,onChangePassword:r,triggerRef:n,isSetup:o=!1})=>{const i=s.useRef(null),[a,u]=s.useState(!1),[c,d]=s.useState({top:0,left:0}),[p,l]=s.useState(""),[f,
|
|
4604
|
+
`,Kc=({onClose:t,onChangePassword:r,triggerRef:n,isSetup:o=!1})=>{const i=s.useRef(null),[a,u]=s.useState(!1),[c,d]=s.useState({top:0,left:0}),[p,l]=s.useState(""),[f,x]=s.useState(""),[m,v]=s.useState(""),[C,$]=s.useState(!1),[_,k]=s.useState(!1),[R,y]=s.useState(!1),[b,S]=s.useState(!1),[g,j]=s.useState({});s.useEffect(()=>{u(!0);const E=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const z=n.current;if(z){const T=z.getBoundingClientRect(),M=380,D=350,F=8;let L=0,A=0;const P=window.innerHeight-T.bottom,U=T.top;P>=D+F?(L=T.bottom+F,A=T.right-M,A<F&&(A=T.left,A+M>window.innerWidth-F&&(A=(window.innerWidth-M)/2))):U>=D+F?(L=T.top-D-F,A=T.right-M,A<F&&(A=T.left,A+M>window.innerWidth-F&&(A=(window.innerWidth-M)/2))):(L=T.bottom+F,A=T.right-M,A<F&&(A=T.left)),d({top:L,left:A})}},10),I=z=>{i.current&&!i.current.contains(z.target)&&t()},O=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",O),()=>{clearTimeout(E),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",O)}},[t,n]);const w=async()=>{if(b)return;const E={};if(!o&&!p&&(E.currentPassword="Current password is required"),f?f.length<8&&(E.newPassword="Password must be at least 8 characters"):E.newPassword="New password is required",f!==m&&(E.confirmPassword="Passwords do not match"),Object.keys(E).length>0){j(E);return}S(!0);try{await r(o?"":p,f),t()}catch(I){j({form:I.message||"Failed to update password"})}finally{S(!1)}};return a?e.jsxs(n2,{ref:i,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:[e.jsx(i2,{children:o?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:o?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!o&&e.jsxs(Si,{children:[e.jsx(re,{children:"Current Password"}),e.jsxs($i,{children:[e.jsx(ne,{type:C?"text":"password",placeholder:"Enter your current password",value:p,onChange:E=>l(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!C),"aria-label":C?"Hide current password":"Show current password",children:C?e.jsx(oi,{size:16}):e.jsx(ii,{size:16})})]}),g.currentPassword&&e.jsx(ro,{children:g.currentPassword})]}),e.jsxs(Si,{children:[e.jsx(re,{children:o?"Password":"New Password"}),e.jsxs($i,{children:[e.jsx(ne,{type:_?"text":"password",placeholder:o?"Enter your password":"Enter your new password",value:f,onChange:E=>x(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!_),"aria-label":_?"Hide new password":"Show new password",children:_?e.jsx(oi,{size:16}):e.jsx(ii,{size:16})})]}),g.newPassword&&e.jsx(ro,{children:g.newPassword})]}),e.jsxs(Si,{children:[e.jsx(re,{children:"Confirm New Password"}),e.jsxs($i,{children:[e.jsx(ne,{type:R?"text":"password",placeholder:"Confirm your new password",value:m,onChange:E=>v(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>y(!R),"aria-label":R?"Hide confirm password":"Show confirm password",children:R?e.jsx(oi,{size:16}):e.jsx(ii,{size:16})})]}),g.confirmPassword&&e.jsx(ro,{children:g.confirmPassword})]}),g.form&&e.jsx(ro,{children:g.form}),e.jsxs(o2,{children:[e.jsx(Yc,{onClick:t,children:"Cancel"}),e.jsx(Yc,{$primary:!0,onClick:w,disabled:b,children:b?o?"Setting...":"Updating...":o?"Set Password":"Update Password"})]})]}):null},a2=h.div`
|
|
4604
4605
|
position: fixed;
|
|
4605
4606
|
background: var(--color-background);
|
|
4606
4607
|
border-radius: var(--radius-md);
|
|
@@ -4638,7 +4639,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4638
4639
|
color: var(--color-warning-text, var(--color-foreground));
|
|
4639
4640
|
margin: 0;
|
|
4640
4641
|
line-height: 1.5;
|
|
4641
|
-
`,u2=({onClose:t,onRemovePassword:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(!1),[u,c]=s.useState({top:0,left:0}),[d,p]=s.useState(""),[l,f]=s.useState(!1),{toast:
|
|
4642
|
+
`,u2=({onClose:t,onRemovePassword:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(!1),[u,c]=s.useState({top:0,left:0}),[d,p]=s.useState(""),[l,f]=s.useState(!1),{toast:x}=lr();s.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!o.current||!(n!=null&&n.current))return;const _=n.current;if(_){const k=_.getBoundingClientRect(),R=400,y=300,b=8;let S=0,g=0;const j=window.innerHeight-k.bottom,w=k.top;j>=y+b?(S=k.bottom+b,g=k.right-R,g<b&&(g=k.left,g+R>window.innerWidth-b&&(g=(window.innerWidth-R)/2))):w>=y+b?(S=k.top-y-b,g=k.right-R,g<b&&(g=k.left,g+R>window.innerWidth-b&&(g=(window.innerWidth-R)/2))):(S=k.bottom+b,g=k.right-R,g<b&&(g=k.left)),c({top:S,left:g})}},10),C=_=>{o.current&&!o.current.contains(_.target)&&t()},$=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",C),document.addEventListener("keydown",$),()=>{clearTimeout(v),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",$)}},[t,n]);const m=async()=>{if(!(!d||l)){f(!0);try{await r(d),t()}catch(v){const C=v.message||"Failed to remove password. Please try again.";x(C,"error")}finally{f(!1)}}};return i?e.jsxs(a2,{ref:o,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(c2,{children:[e.jsx(ir,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(l2,{children:e.jsx(d2,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(oe,{children:[e.jsx(re,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(ne,{id:"current-password",type:"password",placeholder:"Enter current password",value:d,onChange:v=>p(v.target.value),autoFocus:!0})]}),e.jsxs(s2,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:m,disabled:!d||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},p2=h.div`
|
|
4642
4643
|
position: fixed;
|
|
4643
4644
|
background: var(--color-background);
|
|
4644
4645
|
border-radius: var(--radius-md);
|
|
@@ -4681,7 +4682,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4681
4682
|
font-weight: 400;
|
|
4682
4683
|
color: var(--color-foreground);
|
|
4683
4684
|
margin-bottom: 8px;
|
|
4684
|
-
`,h2=({onClose:t,onSetupTOTP:r,onVerifyTOTP:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState("qr"),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,
|
|
4685
|
+
`,h2=({onClose:t,onSetupTOTP:r,onVerifyTOTP:n,triggerRef:o})=>{const i=s.useRef(null),[a,u]=s.useState("qr"),[c,d]=s.useState(""),[p,l]=s.useState(""),[f,x]=s.useState(["",""]),[m,v]=s.useState(!1),[C,$]=s.useState(!1),[_,k]=s.useState({top:0,left:0}),{toast:R}=lr();s.useEffect(()=>{$(!0);const b=setTimeout(()=>{if(!i.current||!(o!=null&&o.current))return;const j=o.current;if(j){const w=j.getBoundingClientRect(),E=380,I=400,O=8;let z=0,T=0;const M=window.innerHeight-w.bottom,D=w.top;M>=I+O?(z=w.bottom+O,T=w.right-E,T<O&&(T=w.left,T+E>window.innerWidth-O&&(T=(window.innerWidth-E)/2))):D>=I+O?(z=w.top-I-O,T=w.right-E,T<O&&(T=w.left,T+E>window.innerWidth-O&&(T=(window.innerWidth-E)/2))):(z=w.bottom+O,T=w.right-E,T<O&&(T=w.left)),k({top:z,left:T})}},10),S=j=>{i.current&&!i.current.contains(j.target)&&t()},g=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",g),()=>{clearTimeout(b),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",g)}},[t,o]),s.useEffect(()=>{(async()=>{v(!0);try{const S=await r();d(S.otp_url||""),l(S.totp_secret||"")}catch(S){const g=S.message||"Failed to setup two-factor authentication. Please try again.";R(g,"error")}finally{v(!1)}})()},[]);const y=async()=>{if(!f.some(b=>b.length!==6)){v(!0);try{await n(f),t()}catch(b){const S=b.message||"Failed to verify codes. Please check your authenticator app and try again.";R(S,"error")}finally{v(!1)}}};return C?e.jsx(p2,{ref:i,style:{top:`${_.top}px`,left:`${_.left}px`,visibility:_.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(Zc,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:m?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):c?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Ta,{value:c,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),p&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:p})]}),e.jsx(Qc,{children:e.jsx(Ei,{$primary:!0,onClick:()=>u("verify"),disabled:m||!c,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zc,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(ne,{id:"totp-code-1",type:"text",placeholder:"000000",value:f[0],onChange:b=>{const S=b.target.value.replace(/[^0-9]/g,"").substring(0,6);x([S,f[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(ne,{id:"totp-code-2",type:"text",placeholder:"000000",value:f[1],onChange:b=>{const S=b.target.value.replace(/[^0-9]/g,"").substring(0,6);x([f[0],S])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(Qc,{children:[e.jsx(Ei,{onClick:()=>u("qr"),children:"Back"}),e.jsx(Ei,{$primary:!0,onClick:y,disabled:m||f.some(b=>b.length!==6),children:m?"Verifying...":"Verify"})]})]})}):null},f2=h.div`
|
|
4685
4686
|
position: fixed;
|
|
4686
4687
|
background: var(--color-background);
|
|
4687
4688
|
border-radius: var(--radius-md);
|
|
@@ -4747,7 +4748,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4747
4748
|
background: var(--color-input-background-hover);
|
|
4748
4749
|
border-color: var(--color-primary);
|
|
4749
4750
|
}
|
|
4750
|
-
`,b2=({codes:t,onClose:r,onCopy:n,onDownload:o,triggerRef:i})=>{const a=s.useRef(null),[u,c]=s.useState(!1),[d,p]=s.useState({top:0,left:0});return s.useEffect(()=>{c(!0);const l=setTimeout(()=>{if(!a.current||!(i!=null&&i.current))return;const
|
|
4751
|
+
`,b2=({codes:t,onClose:r,onCopy:n,onDownload:o,triggerRef:i})=>{const a=s.useRef(null),[u,c]=s.useState(!1),[d,p]=s.useState({top:0,left:0});return s.useEffect(()=>{c(!0);const l=setTimeout(()=>{if(!a.current||!(i!=null&&i.current))return;const m=i.current;if(m){const v=m.getBoundingClientRect(),C=380,$=300,_=8;let k=0,R=0;const y=window.innerHeight-v.bottom,b=v.top;y>=$+_?(k=v.bottom+_,R=v.right-C,R<_&&(R=v.left,R+C>window.innerWidth-_&&(R=(window.innerWidth-C)/2))):b>=$+_?(k=v.top-$-_,R=v.right-C,R<_&&(R=v.left,R+C>window.innerWidth-_&&(R=(window.innerWidth-C)/2))):(k=v.bottom+_,R=v.right-C,R<_&&(R=v.left)),p({top:k,left:R})}},10),f=m=>{a.current&&!a.current.contains(m.target)&&r()},x=m=>{m.key==="Escape"&&r()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",x),()=>{clearTimeout(l),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",x)}},[r,i]),u?e.jsxs(f2,{ref:a,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(g2,{children:[e.jsx(m2,{children:"Backup Codes"}),e.jsxs(x2,{children:[e.jsxs(Jc,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Cr,{size:14}),"Copy"]}),e.jsxs(Jc,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Rd,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(v2,{children:t.map((l,f)=>e.jsx(y2,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},f))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},w2=h.div`
|
|
4751
4752
|
position: fixed;
|
|
4752
4753
|
background: var(--color-background);
|
|
4753
4754
|
border-radius: var(--radius-md);
|
|
@@ -4799,9 +4800,9 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4799
4800
|
color: var(--color-error);
|
|
4800
4801
|
font-size: 12px;
|
|
4801
4802
|
margin-top: 4px;
|
|
4802
|
-
`,S2=({onClose:t,onAddPasskey:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(!1),[u,c]=s.useState({top:0,left:0}),[d,p]=s.useState(""),[l,f]=s.useState(!1),[m
|
|
4803
|
-
`);navigator.clipboard.writeText(J).then(()=>{
|
|
4804
|
-
`),Te=new Blob([J],{type:"text/plain"}),De=URL.createObjectURL(Te),at=document.createElement("a");at.href=De,at.download="wacht-backup-codes.txt",at.click(),URL.revokeObjectURL(De),x("Backup codes downloaded","info")},ot=async()=>{var J,Te;if((Te=(J=t==null?void 0:t.auth_settings)==null?void 0:J.passkey)!=null&&Te.enabled)try{L(!0);const De=await l();F(De.data||[])}catch(De){console.error("Failed to load passkeys:",De)}finally{L(!1)}},$t=async J=>{try{R(!0),await f(J||void 0),await ot(),x("Passkey registered successfully!","info")}catch(Te){throw x(Te.message||"Failed to register passkey","error"),Te}finally{R(!1)}},Et=async J=>{try{await m(J),await ot(),x("Passkey removed","info")}catch(Te){x(Te.message||"Failed to remove passkey","error")}};s.useEffect(()=>{ot()},[(we=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:we.enabled]);const et=[];return fe&&et.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),(Ue=(Ee=t==null?void 0:t.auth_settings)==null?void 0:Ee.passkey)!=null&&Ue.enabled&&et.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:D.length>0?`${D.length} registered`:"",actions:D.length>0?["manage","add"]:["add"]}),G!=null&&G.authenticator&&et.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&et.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&et.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),Q!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(wt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[Q==="qr"&&"Setup Two-Factor Authentication",Q==="verify"&&"Verify Your Authenticator",Q==="backup"&&"Save Your Backup Codes",Q==="success"&&"Setup Complete!"]})]}),e.jsx(B,{onClick:()=>he("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[Q==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:xe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${Cy} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):X?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Ta,{value:X,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:se||"Loading..."})]}),e.jsx(B,{onClick:()=>he("verify"),disabled:!X||!se,style:{padding:"10px 20px",background:!X||!se?"var(--color-border)":"var(--color-primary)",color:!X||!se?"var(--color-secondary-text)":"white",border:`1px solid ${!X||!se?"var(--color-border)":"var(--color-primary)"}`,cursor:!X||!se?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),Q==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(ne,{type:"text",placeholder:"000000",value:Ce[0],onChange:J=>{const Te=J.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Te,Ce[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(ne,{type:"text",placeholder:"000000",value:Ce[1],onChange:J=>{const Te=J.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Ce[0],Te])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(B,{onClick:()=>he("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(B,{onClick:ct,disabled:ve||Ce.some(J=>J.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ve?"Verifying...":"Verify & Continue"})]})]}),Q==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ir,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:te.map((J,Te)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(J),children:J},Te))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(B,{onClick:mt,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(B,{onClick:We,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Rd,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(B,{onClick:Xe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),Q==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(st,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(B,{onClick:Xe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Nc,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),et.length?e.jsx("div",{children:et.map((J,Te)=>e.jsxs("div",{children:[e.jsxs(Iy,{children:[e.jsxs(Ty,{children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:J.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:J.description})]}),e.jsx(Oy,{children:e.jsxs("div",{style:{position:"relative"},children:[J.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),b&&e.jsx(Kc,{triggerRef:O,onClose:()=>C(!1),onChangePassword:Me})]}),nt()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:z,onClick:()=>j(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(u2,{triggerRef:z,onClose:()=>j(!1),onRemovePassword:Ve})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),b&&e.jsx(Kc,{triggerRef:O,onClose:()=>C(!1),onChangePassword:Me,isSetup:!0})]})}),J.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:I,onClick:()=>y(!0),disabled:xe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:xe?"Setting up...":"Setup"}),P&&e.jsx(h2,{triggerRef:I,onClose:()=>y(!1),onSetupTOTP:async()=>{const De=await i();return me(De.id),De},onVerifyTOTP:async De=>{await a(_e,De),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>_(!0),disabled:qe,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:qe?"not-allowed":"pointer",opacity:qe?.6:1},children:qe?"Removing...":"Remove"}),S&&e.jsx(Zr,{title:"Remove MFA and reset policy to default?",onConfirm:Ct,onCancel:()=>_(!1)})]}),J.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:T,onClick:St,disabled:ie,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ie?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),w&&e.jsx(b2,{triggerRef:T,codes:te,onClose:()=>E(!1),onCopy:mt,onDownload:We})]})}),J.id==="second_factor_policy"&&e.jsx(Pr,{checked:v==="enforced",onChange:De=>{k(De?"enforced":"none")}}),J.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(B,{onClick:()=>V(!U),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"110px",height:"36px"},children:[U?"Hide":"Manage"," (",D.length,")",e.jsx(or,{size:14,style:{transform:U?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:pe,onClick:()=>ae(!0),disabled:A,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:A?"not-allowed":"pointer",opacity:A?.7:1,whiteSpace:"nowrap",minWidth:"80px",width:"auto",height:"36px"},children:A?"Adding...":"Add"}),H&&e.jsx(S2,{triggerRef:pe,onClose:()=>ae(!1),onAddPasskey:$t})]})]})]})})]}),J.id==="passkey"&&U&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:M?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Ie,{})}):D.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:D.map(De=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:De.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[De.device_type==="platform"?"This device":"Security key",De.last_used_at&&` • Last used ${new Date(De.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>ge(De.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),ee===De.id&&e.jsx(Zr,{title:`Remove "${De.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Et(De.id),ge(null)},onCancel:()=>ge(null)})]})]},De.id))})}),Te<et.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},J.id))}):e.jsx(kt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},E2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),z2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),P2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),R2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),I2=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),T2=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),O2=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),el=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",n={width:20,height:20};return r.includes("chrome")?e.jsx(E2,{...n}):r.includes("firefox")?e.jsx(z2,{...n}):r.includes("safari")?e.jsx(P2,{...n}):r.includes("edge")?e.jsx(R2,{...n}):r.includes("opera")?e.jsx(I2,{...n}):r.includes("brave")?e.jsx(T2,{...n}):e.jsx(O2,{})},A2=()=>{const[t,r]=s.useState(null),{signins:n,removeSignin:o,refetch:i,loading:a}=Yl(),{refetch:u}=He(),{toast:c}=lr(),d=Dy("(max-width: 600px)"),p=n,l=async m=>{try{await o(m),await Promise.all([i(),u()]),r(null),c("Session ended successfully","info")}catch(x){c(x.message||"Failed to end session. Please try again.","error")}},f=m=>{if(!m||m.trim()==="")return"Unknown";const x=new Date(m);if(isNaN(x.getTime()))return"Unknown";const $=Math.floor((new Date().getTime()-x.getTime())/(1e3*60));return $<1?"Just now":$<60?`${$}m ago`:$<1440?`${Math.floor($/60)}h ago`:x.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ie,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:p&&p.length>0?e.jsxs(e.Fragment,{children:[!d&&e.jsx(Ra,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Browser & Device"}),e.jsx(Pe,{children:"Location"}),e.jsx(Pe,{children:"Last Active"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:p.map(m=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oa,{children:e.jsx(el,{browser:m.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:m.browser||"Unknown Browser"}),m.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.device})]})]})}),e.jsx(Ne,{children:e.jsxs("div",{children:[e.jsx("div",{children:m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"}),m.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.ip_address})]})}),e.jsx(Ne,{children:f(m.last_active_at)}),e.jsx(Ft,{children:e.jsxs(ut,{open:t===m.id,openChange:x=>r(x?m.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{children:"•••"})}),e.jsx(pt,{children:e.jsx(Le,{onClick:()=>l(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ht,{size:14}),"End Session"]})})})]})})]},m.id))})]})}),d&&e.jsx(Ia,{children:p.map((m,x)=>e.jsxs("div",{children:[e.jsx(No,{children:e.jsxs(Uo,{children:[e.jsx(oa,{children:e.jsx(el,{browser:m.browser||"Unknown"})}),e.jsxs("div",{style:{marginLeft:"12px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[m.browser||"Unknown"," ",m.device?`on ${m.device}`:""]}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"," • ",f(m.last_active_at)]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(ut,{open:t===m.id,openChange:v=>r(v?m.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{children:"•••"})}),e.jsx(pt,{children:e.jsx(Le,{onClick:()=>l(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ht,{size:14}),"End Session"]})})})]})})]})}),x<p.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},m.id))})]}):e.jsx(kt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},Tu=()=>{var v,$,S,_,k,P,y;const{loading:t}=sr(),{deployment:r}=be(),[n,o]=s.useState("profile"),[i,a]=s.useState(null),[u,c]=s.useState("info"),d=s.useCallback((b,C="info")=>{a(b),c(C),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(le,{children:e.jsx(Fc,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})});const p=r==null?void 0:r.auth_settings,l=(v=p==null?void 0:p.email_address)==null?void 0:v.enabled,f=($=p==null?void 0:p.phone_number)==null?void 0:$.enabled,m=((S=r==null?void 0:r.social_connections)==null?void 0:S.some(b=>b.enabled))||!1,x=((_=p==null?void 0:p.password)==null?void 0:_.enabled)||((k=p==null?void 0:p.auth_factors_enabled)==null?void 0:k.authenticator)||((P=p==null?void 0:p.auth_factors_enabled)==null?void 0:P.phone_otp)||((y=p==null?void 0:p.auth_factors_enabled)==null?void 0:y.backup_code);return e.jsx(le,{children:e.jsx(Sy,{children:e.jsx(bu.Provider,{value:{screen:null,setScreen:()=>{},toast:d},children:e.jsxs(Fc,{children:[e.jsx($y,{children:e.jsxs(Ey,{children:[e.jsx(Ur,{$isActive:n==="profile",onClick:()=>o("profile"),children:e.jsxs(Br,{children:[e.jsx(bo,{size:16}),"Profile"]})}),l&&e.jsx(Ur,{$isActive:n==="email",onClick:()=>o("email"),children:e.jsxs(Br,{children:[e.jsx(To,{size:16}),"Email"]})}),f&&e.jsx(Ur,{$isActive:n==="phone",onClick:()=>o("phone"),children:e.jsxs(Br,{children:[e.jsx(Fg,{size:16}),"Phone"]})}),m&&e.jsx(Ur,{$isActive:n==="social",onClick:()=>o("social"),children:e.jsxs(Br,{children:[e.jsx(Og,{size:16}),"Connections"]})}),x&&e.jsx(Ur,{$isActive:n==="security",onClick:()=>o("security"),children:e.jsxs(Br,{children:[e.jsx(wt,{size:16}),"Security"]})}),e.jsx(Ur,{$isActive:n==="sessions",onClick:()=>o("sessions"),children:e.jsxs(Br,{children:[e.jsx(rg,{size:16}),"Sessions"]})})]})}),e.jsxs(zy,{children:[n==="profile"&&e.jsx(Fy,{}),n==="email"&&l&&e.jsx(Wy,{}),n==="phone"&&f&&e.jsx(Gy,{}),n==="social"&&m&&e.jsx(qy,{}),n==="security"&&x&&e.jsx($2,{}),n==="sessions"&&e.jsx(A2,{})]}),i&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ir,{size:16,color:"var(--color-error)"}):e.jsx(st,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})})})},Ou=({isOpen:t,onClose:r,title:n,showHeader:o,headerContent:i,footerContent:a,customContent:u,children:c,showCloseButton:d})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:[o&&e.jsx(ze.Header,{showCloseButton:d,children:i||n}),u||c||e.jsx(Tu,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),L2=h.div`
|
|
4803
|
+
`,S2=({onClose:t,onAddPasskey:r,triggerRef:n})=>{const o=s.useRef(null),[i,a]=s.useState(!1),[u,c]=s.useState({top:0,left:0}),[d,p]=s.useState(""),[l,f]=s.useState(!1),[x,m]=s.useState("");s.useEffect(()=>{a(!0);const C=setTimeout(()=>{if(!o.current||!(n!=null&&n.current))return;const k=n.current;if(k){const R=k.getBoundingClientRect(),y=320,b=180,S=8;let g=0,j=0;const w=window.innerHeight-R.bottom,E=R.top;w>=b+S?(g=R.bottom+S,j=R.right-y,j<S&&(j=R.left,j+y>window.innerWidth-S&&(j=(window.innerWidth-y)/2))):E>=b+S?(g=R.top-b-S,j=R.right-y,j<S&&(j=R.left,j+y>window.innerWidth-S&&(j=(window.innerWidth-y)/2))):(g=R.bottom+S,j=R.right-y,j<S&&(j=R.left)),c({top:g,left:j})}},10),$=k=>{o.current&&!o.current.contains(k.target)&&t()},_=k=>{k.key==="Escape"&&t()};return document.addEventListener("mousedown",$),document.addEventListener("keydown",_),()=>{clearTimeout(C),document.removeEventListener("mousedown",$),document.removeEventListener("keydown",_)}},[t,n]);const v=async()=>{if(!l){f(!0),m("");try{await r(d.trim()),t()}catch(C){m(C.message||"Failed to register passkey"),f(!1)}}};return i?e.jsxs(w2,{ref:o,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:C=>C.stopPropagation(),children:[e.jsx(_2,{children:"Add Passkey"}),e.jsx(k2,{children:e.jsx(ne,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:d,onChange:C=>p(C.target.value),autoFocus:!0})}),x&&e.jsx(C2,{children:x}),e.jsxs(j2,{children:[e.jsx(Xc,{onClick:t,children:"Cancel"}),e.jsx(Xc,{$primary:!0,onClick:v,disabled:l,children:l?"Registering...":"Continue"})]})]}):null},$2=()=>{var zt,Z,K,ue,we,Ee,Ue;const{deployment:t}=be(),{user:r,updatePassword:n,removePassword:o,setupAuthenticator:i,verifyAuthenticator:a,deleteAuthenticator:u,generateBackupCodes:c,regenerateBackupCodes:d,updateProfile:p,getPasskeys:l,registerPasskey:f,deletePasskey:x}=sr(),{toast:m}=lr(),[v,C]=s.useState((r==null?void 0:r.second_factor_policy)||"none"),[$,_]=s.useState(!1),k=async J=>{try{await p({second_factor_policy:J}),C(J),m("2FA requirement updated successfully","info")}catch(Te){m(Te.message||"Failed to update 2FA requirement","error")}},[R,y]=s.useState(!1),[b,S]=s.useState(!1),[g,j]=s.useState(!1),[w,E]=s.useState(!1),I=s.useRef(null),O=s.useRef(null),z=s.useRef(null),T=s.useRef(null),[M,D]=s.useState([]),[F,L]=s.useState(!1),[A,P]=s.useState(!1),[U,V]=s.useState(!1),[H,ae]=s.useState(!1),[ee,ge]=s.useState(null),pe=s.useRef(null),[Q,he]=s.useState("table"),[X,Oe]=s.useState(""),[se,ce]=s.useState(""),[_e,me]=s.useState(""),[Ce,q]=s.useState(["",""]),[te,de]=s.useState([]),[ie,Y]=s.useState(!1),[ve,W]=s.useState(!1),[xe]=s.useState(!1),[qe,it]=s.useState(!1),G=(zt=t==null?void 0:t.auth_settings)==null?void 0:zt.auth_factors_enabled,fe=(K=(Z=t==null?void 0:t.auth_settings)==null?void 0:Z.password)==null?void 0:K.enabled;if(!(G!=null&&G.authenticator)&&!(G!=null&&G.backup_code)&&!fe)return null;const Me=async(J,Te)=>{await n(J,Te),await r.refetch(),m("Password updated successfully","info")},Ve=async J=>{await o(J),await r.refetch(),m("Password removed successfully","info")},nt=()=>{var Aa,La,Ma,Da,Fa,Na;if(!r)return!1;const J=(Aa=r.user_email_addresses)==null?void 0:Aa.some(rn=>rn.verified),Te=(La=r.user_phone_numbers)==null?void 0:La.some(rn=>rn.verified),De=r.social_connections&&r.social_connections.length>0,at=t==null?void 0:t.auth_settings;return(at==null?void 0:at.first_factor)==="email_otp"&&J||((Ma=at==null?void 0:at.magic_link)==null?void 0:Ma.enabled)&&J||((Da=at==null?void 0:at.passkey)==null?void 0:Da.enabled)||((Fa=at==null?void 0:at.auth_factors_enabled)==null?void 0:Fa.phone_otp)&&Te||De&&((Na=t==null?void 0:t.social_connections)==null?void 0:Na.some(rn=>rn.enabled))},ct=async()=>{if(Ce.some(J=>J.length!==6)){m("Please enter both 6-digit verification codes","error");return}try{if(W(!0),await a(_e,Ce),await r.refetch(),G!=null&&G.backup_code){const J=await c();de(J),await r.refetch(),he("backup")}else he("success")}catch(J){m(J.message||"Invalid verification codes","error")}finally{W(!1)}},Xe=()=>{he("table"),Oe(""),ce(""),me(""),q(["",""]),de([]),m("Two-factor authentication setup completed successfully!","info")},Ct=async()=>{var J;if((J=r==null?void 0:r.user_authenticator)!=null&&J.id)try{it(!0),await u(r.user_authenticator.id),await r.refetch(),_(!1),m("Two-factor authentication removed successfully","info")}catch(Te){m(Te.message||"Failed to remove authenticator","error")}finally{it(!1)}},St=async()=>{if(!ie)try{Y(!0);const J=await d();de(J),await r.refetch(),E(!0),m("New backup codes generated","info")}catch(J){m(J.message||"Failed to generate backup codes","error")}finally{Y(!1)}},mt=()=>{const J=te.join(`
|
|
4804
|
+
`);navigator.clipboard.writeText(J).then(()=>{m("Backup codes copied to clipboard","info")}).catch(()=>{m("Failed to copy backup codes","error")})},We=()=>{const J=te.join(`
|
|
4805
|
+
`),Te=new Blob([J],{type:"text/plain"}),De=URL.createObjectURL(Te),at=document.createElement("a");at.href=De,at.download="wacht-backup-codes.txt",at.click(),URL.revokeObjectURL(De),m("Backup codes downloaded","info")},ot=async()=>{var J,Te;if((Te=(J=t==null?void 0:t.auth_settings)==null?void 0:J.passkey)!=null&&Te.enabled)try{L(!0);const De=await l();D(De.data||[])}catch(De){console.error("Failed to load passkeys:",De)}finally{L(!1)}},$t=async J=>{try{P(!0),await f(J||void 0),await ot(),m("Passkey registered successfully!","info")}catch(Te){throw m(Te.message||"Failed to register passkey","error"),Te}finally{P(!1)}},Et=async J=>{try{await x(J),await ot(),m("Passkey removed","info")}catch(Te){m(Te.message||"Failed to remove passkey","error")}};s.useEffect(()=>{ot()},[(we=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:we.enabled]);const et=[];return fe&&et.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),(Ue=(Ee=t==null?void 0:t.auth_settings)==null?void 0:Ee.passkey)!=null&&Ue.enabled&&et.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:M.length>0?`${M.length} registered`:"",actions:M.length>0?["manage","add"]:["add"]}),G!=null&&G.authenticator&&et.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&et.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&et.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),Q!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Nc,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(wt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[Q==="qr"&&"Setup Two-Factor Authentication",Q==="verify"&&"Verify Your Authenticator",Q==="backup"&&"Save Your Backup Codes",Q==="success"&&"Setup Complete!"]})]}),e.jsx(B,{onClick:()=>he("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[Q==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:xe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${Cy} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):X?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Ta,{value:X,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:se||"Loading..."})]}),e.jsx(B,{onClick:()=>he("verify"),disabled:!X||!se,style:{padding:"10px 20px",background:!X||!se?"var(--color-border)":"var(--color-primary)",color:!X||!se?"var(--color-secondary-text)":"white",border:`1px solid ${!X||!se?"var(--color-border)":"var(--color-primary)"}`,cursor:!X||!se?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),Q==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(ne,{type:"text",placeholder:"000000",value:Ce[0],onChange:J=>{const Te=J.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Te,Ce[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(ne,{type:"text",placeholder:"000000",value:Ce[1],onChange:J=>{const Te=J.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Ce[0],Te])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(B,{onClick:()=>he("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(B,{onClick:ct,disabled:ve||Ce.some(J=>J.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ve?"Verifying...":"Verify & Continue"})]})]}),Q==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ir,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:te.map((J,Te)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(J),children:J},Te))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(B,{onClick:mt,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(B,{onClick:We,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Rd,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(B,{onClick:Xe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),Q==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(st,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(B,{onClick:Xe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Nc,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),et.length?e.jsx("div",{children:et.map((J,Te)=>e.jsxs("div",{children:[e.jsxs(Iy,{children:[e.jsxs(Ty,{children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:J.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:J.description})]}),e.jsx(Oy,{children:e.jsxs("div",{style:{position:"relative"},children:[J.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>S(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),b&&e.jsx(Kc,{triggerRef:O,onClose:()=>S(!1),onChangePassword:Me})]}),nt()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:z,onClick:()=>j(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(u2,{triggerRef:z,onClose:()=>j(!1),onRemovePassword:Ve})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>S(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),b&&e.jsx(Kc,{triggerRef:O,onClose:()=>S(!1),onChangePassword:Me,isSetup:!0})]})}),J.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:I,onClick:()=>y(!0),disabled:xe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:xe?"Setting up...":"Setup"}),R&&e.jsx(h2,{triggerRef:I,onClose:()=>y(!1),onSetupTOTP:async()=>{const De=await i();return me(De.id),De},onVerifyTOTP:async De=>{await a(_e,De),await r.refetch(),m("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>_(!0),disabled:qe,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:qe?"not-allowed":"pointer",opacity:qe?.6:1},children:qe?"Removing...":"Remove"}),$&&e.jsx(Zr,{title:"Remove MFA and reset policy to default?",onConfirm:Ct,onCancel:()=>_(!1)})]}),J.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:T,onClick:St,disabled:ie,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:ie?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),w&&e.jsx(b2,{triggerRef:T,codes:te,onClose:()=>E(!1),onCopy:mt,onDownload:We})]})}),J.id==="second_factor_policy"&&e.jsx(Pr,{checked:v==="enforced",onChange:De=>{k(De?"enforced":"none")}}),J.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(B,{onClick:()=>V(!U),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"110px",height:"36px"},children:[U?"Hide":"Manage"," (",M.length,")",e.jsx(or,{size:14,style:{transform:U?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:pe,onClick:()=>ae(!0),disabled:A,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:A?"not-allowed":"pointer",opacity:A?.7:1,whiteSpace:"nowrap",minWidth:"80px",width:"auto",height:"36px"},children:A?"Adding...":"Add"}),H&&e.jsx(S2,{triggerRef:pe,onClose:()=>ae(!1),onAddPasskey:$t})]})]})]})})]}),J.id==="passkey"&&U&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:F?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Ie,{})}):M.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:M.map(De=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:De.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[De.device_type==="platform"?"This device":"Security key",De.last_used_at&&` • Last used ${new Date(De.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>ge(De.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),ee===De.id&&e.jsx(Zr,{title:`Remove "${De.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Et(De.id),ge(null)},onCancel:()=>ge(null)})]})]},De.id))})}),Te<et.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},J.id))}):e.jsx(kt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},E2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),z2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),P2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),R2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),I2=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),T2=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),O2=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),el=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",n={width:20,height:20};return r.includes("chrome")?e.jsx(E2,{...n}):r.includes("firefox")?e.jsx(z2,{...n}):r.includes("safari")?e.jsx(P2,{...n}):r.includes("edge")?e.jsx(R2,{...n}):r.includes("opera")?e.jsx(I2,{...n}):r.includes("brave")?e.jsx(T2,{...n}):e.jsx(O2,{})},A2=()=>{const[t,r]=s.useState(null),{signins:n,removeSignin:o,refetch:i,loading:a}=Yl(),{refetch:u}=He(),{toast:c}=lr(),d=Dy("(max-width: 600px)"),p=n,l=async x=>{try{await o(x),await Promise.all([i(),u()]),r(null),c("Session ended successfully","info")}catch(m){c(m.message||"Failed to end session. Please try again.","error")}},f=x=>{if(!x||x.trim()==="")return"Unknown";const m=new Date(x);if(isNaN(m.getTime()))return"Unknown";const C=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return C<1?"Just now":C<60?`${C}m ago`:C<1440?`${Math.floor(C/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ie,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:p&&p.length>0?e.jsxs(e.Fragment,{children:[!d&&e.jsx(Ra,{children:e.jsxs(Lt,{children:[e.jsx(Mt,{children:e.jsxs(Ke,{children:[e.jsx(Pe,{children:"Browser & Device"}),e.jsx(Pe,{children:"Location"}),e.jsx(Pe,{children:"Last Active"}),e.jsx(Pe,{})]})}),e.jsx(Dt,{children:p.map(x=>e.jsxs(Ke,{children:[e.jsx(Ne,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oa,{children:e.jsx(el,{browser:x.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:x.browser||"Unknown Browser"}),x.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:x.device})]})]})}),e.jsx(Ne,{children:e.jsxs("div",{children:[e.jsx("div",{children:x.city&&x.country?`${x.city}, ${x.country}`:"Unknown location"}),x.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:x.ip_address})]})}),e.jsx(Ne,{children:f(x.last_active_at)}),e.jsx(Ft,{children:e.jsxs(ut,{open:t===x.id,openChange:m=>r(m?x.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{children:"•••"})}),e.jsx(pt,{children:e.jsx(Le,{onClick:()=>l(x.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ht,{size:14}),"End Session"]})})})]})})]},x.id))})]})}),d&&e.jsx(Ia,{children:p.map((x,m)=>e.jsxs("div",{children:[e.jsx(No,{children:e.jsxs(Uo,{children:[e.jsx(oa,{children:e.jsx(el,{browser:x.browser||"Unknown"})}),e.jsxs("div",{style:{marginLeft:"12px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[x.browser||"Unknown"," ",x.device?`on ${x.device}`:""]}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[x.city&&x.country?`${x.city}, ${x.country}`:"Unknown location"," • ",f(x.last_active_at)]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(ut,{open:t===x.id,openChange:v=>r(v?x.id:null),children:[e.jsx(ht,{children:e.jsx(Rr,{children:"•••"})}),e.jsx(pt,{children:e.jsx(Le,{onClick:()=>l(x.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ht,{size:14}),"End Session"]})})})]})})]})}),m<p.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},x.id))})]}):e.jsx(kt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},Tu=()=>{var v,C,$,_,k,R,y;const{loading:t}=sr(),{deployment:r}=be(),[n,o]=s.useState("profile"),[i,a]=s.useState(null),[u,c]=s.useState("info"),d=s.useCallback((b,S="info")=>{a(b),c(S),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(le,{children:e.jsx(Fc,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})});const p=r==null?void 0:r.auth_settings,l=(v=p==null?void 0:p.email_address)==null?void 0:v.enabled,f=(C=p==null?void 0:p.phone_number)==null?void 0:C.enabled,x=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(b=>b.enabled))||!1,m=((_=p==null?void 0:p.password)==null?void 0:_.enabled)||((k=p==null?void 0:p.auth_factors_enabled)==null?void 0:k.authenticator)||((R=p==null?void 0:p.auth_factors_enabled)==null?void 0:R.phone_otp)||((y=p==null?void 0:p.auth_factors_enabled)==null?void 0:y.backup_code);return e.jsx(le,{children:e.jsx(Sy,{children:e.jsx(bu.Provider,{value:{screen:null,setScreen:()=>{},toast:d},children:e.jsxs(Fc,{children:[e.jsx($y,{children:e.jsxs(Ey,{children:[e.jsx(Ur,{$isActive:n==="profile",onClick:()=>o("profile"),children:e.jsxs(Br,{children:[e.jsx(bo,{size:16}),"Profile"]})}),l&&e.jsx(Ur,{$isActive:n==="email",onClick:()=>o("email"),children:e.jsxs(Br,{children:[e.jsx(To,{size:16}),"Email"]})}),f&&e.jsx(Ur,{$isActive:n==="phone",onClick:()=>o("phone"),children:e.jsxs(Br,{children:[e.jsx(Fg,{size:16}),"Phone"]})}),x&&e.jsx(Ur,{$isActive:n==="social",onClick:()=>o("social"),children:e.jsxs(Br,{children:[e.jsx(Og,{size:16}),"Connections"]})}),m&&e.jsx(Ur,{$isActive:n==="security",onClick:()=>o("security"),children:e.jsxs(Br,{children:[e.jsx(wt,{size:16}),"Security"]})}),e.jsx(Ur,{$isActive:n==="sessions",onClick:()=>o("sessions"),children:e.jsxs(Br,{children:[e.jsx(rg,{size:16}),"Sessions"]})})]})}),e.jsxs(zy,{children:[n==="profile"&&e.jsx(Fy,{}),n==="email"&&l&&e.jsx(Wy,{}),n==="phone"&&f&&e.jsx(Gy,{}),n==="social"&&x&&e.jsx(qy,{}),n==="security"&&m&&e.jsx($2,{}),n==="sessions"&&e.jsx(A2,{})]}),i&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ir,{size:16,color:"var(--color-error)"}):e.jsx(st,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})})})},Ou=({isOpen:t,onClose:r,title:n,showHeader:o,headerContent:i,footerContent:a,customContent:u,children:c,showCloseButton:d})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:[o&&e.jsx(ze.Header,{showCloseButton:d,children:i||n}),u||c||e.jsx(Tu,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),L2=h.div`
|
|
4805
4806
|
position: relative;
|
|
4806
4807
|
`,M2=h.button`
|
|
4807
4808
|
display: flex;
|
|
@@ -4940,7 +4941,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4940
4941
|
width: 14px;
|
|
4941
4942
|
height: 14px;
|
|
4942
4943
|
}
|
|
4943
|
-
`,Oa=({showName:t=!0})=>{var
|
|
4944
|
+
`,Oa=({showName:t=!0})=>{var S,g,j,w;const[r,n]=s.useState(!1),o=s.useRef(null),i=s.useRef(null),a=Ea({triggerRef:o,isOpen:r,minWidth:380}),u=gn(!1),{session:c,signOut:d,switchSignIn:p,refetch:l}=He(),{navigateToSignIn:f}=lt(),{deployment:x}=be(),m=(S=c==null?void 0:c.active_signin)==null?void 0:S.user,v=((j=(g=x==null?void 0:x.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:j.enabled)??!1,C=(((w=c==null?void 0:c.signins)==null?void 0:w.length)??0)>1;s.useEffect(()=>{if(!r)return;const E=setTimeout(()=>{const I=O=>{var T,M;const z=O.target;(T=o.current)!=null&&T.contains(z)||(M=i.current)!=null&&M.contains(z)||n(!1)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},50);return()=>{clearTimeout(E)}},[r]);const $=()=>{n(!r)},_=E=>E.split(" ").map(I=>I[0]).join("").toUpperCase(),k=async E=>{try{await d(E),await l(),n(!1)}catch{}},R=async()=>{try{await d(),await l(),n(!1)}catch{}},y=async E=>{try{await p(E),await l(),n(!1)}catch{}},b=()=>{u.open(),n(!1)};return e.jsx(le,{children:e.jsxs(L2,{children:[e.jsxs(M2,{ref:o,onClick:$,children:[e.jsx(zi,{children:e.jsx(Au,{children:m!=null&&m.has_profile_picture?e.jsx("img",{src:m.profile_picture_url,alt:m.first_name}):_(`${(m==null?void 0:m.first_name)||""} ${(m==null?void 0:m.last_name)||""}`)})}),t&&e.jsx(D2,{children:`${(m==null?void 0:m.first_name)||""} ${(m==null?void 0:m.last_name)||""}`})]}),typeof window<"u"&&r&&Co.createPortal(e.jsx(le,{children:e.jsx(F2,{ref:i,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const E=[...(c==null?void 0:c.signins)||[]].sort((I,O)=>{const z=I.user.id===(m==null?void 0:m.id),T=O.user.id===(m==null?void 0:m.id);return z&&!T?-1:!z&&T?1:0});return E.map(({user:I,id:O},z)=>{const T=I.id===(m==null?void 0:m.id),M=!T;return e.jsxs(s.Fragment,{children:[e.jsxs(nl,{$isClickable:M,onClick:M?()=>y(O):void 0,children:[e.jsxs(ol,{children:[e.jsx(zi,{children:e.jsx(sl,{children:I.has_profile_picture?e.jsx("img",{src:I.profile_picture_url,alt:I.first_name}):_(`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`)})}),e.jsxs(il,{children:[e.jsx(al,{children:e.jsx(tl,{children:`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`})}),e.jsx(rl,{children:I.primary_email_address.email})]})]}),T&&e.jsxs(cl,{children:[e.jsxs(no,{onClick:b,children:[e.jsx(Sr,{}),"Manage account"]}),e.jsxs(no,{$destructive:!0,onClick:()=>k(O),children:[e.jsx(Ht,{}),"Sign out"]})]})]}),z===0&&E.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},I.id)})})():m&&e.jsxs(nl,{$isClickable:!1,children:[e.jsxs(ol,{children:[e.jsx(zi,{children:e.jsx(sl,{children:m.has_profile_picture?e.jsx("img",{src:m.profile_picture_url,alt:m.first_name}):_(`${(m==null?void 0:m.first_name)||""} ${(m==null?void 0:m.last_name)||""}`)})}),e.jsxs(il,{children:[e.jsx(al,{children:e.jsx(tl,{children:`${(m==null?void 0:m.first_name)||""} ${(m==null?void 0:m.last_name)||""}`})}),e.jsx(rl,{children:m.primary_email_address.email})]})]}),e.jsxs(cl,{children:[e.jsxs(no,{onClick:b,children:[e.jsx(Sr,{}),"Manage account"]}),e.jsxs(no,{$destructive:!0,onClick:()=>{var E;return k(((E=c==null?void 0:c.active_signin)==null?void 0:E.id)||"")},children:[e.jsx(Ht,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ll,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(dl,{onClick:()=>f(),children:[e.jsx(yt,{}),"Add new account"]})}),C&&e.jsx(ll,{children:e.jsxs(dl,{onClick:R,children:[e.jsx(Ht,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Ou,{isOpen:u.isOpen,onClose:u.close})]})})},N2=h.div`
|
|
4944
4945
|
padding: 12px 16px;
|
|
4945
4946
|
background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
|
|
4946
4947
|
transition: background-color 0.2s ease;
|
|
@@ -4998,7 +4999,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
4998
4999
|
height: 8px;
|
|
4999
5000
|
border-radius: 50%;
|
|
5000
5001
|
background: var(--color-primary);
|
|
5001
|
-
`;function Lu({notification:t,onAction:r}){const[n,o]=s.useState(!1),i=c=>{c.target.closest("button")||(o(!n),t.is_read||r({type:"read",id:t.id}))},a=c=>{r({type:"custom",payload:c.payload})},u=c=>{const d=new Date(c),l=new Date().getTime()-d.getTime();if(l<6e4)return"Just now";const f=Math.floor(l/6e4);if(f<60)return`${f}m`;const
|
|
5002
|
+
`;function Lu({notification:t,onAction:r}){const[n,o]=s.useState(!1),i=c=>{c.target.closest("button")||(o(!n),t.is_read||r({type:"read",id:t.id}))},a=c=>{r({type:"custom",payload:c.payload})},u=c=>{const d=new Date(c),l=new Date().getTime()-d.getTime();if(l<6e4)return"Just now";const f=Math.floor(l/6e4);if(f<60)return`${f}m`;const x=Math.floor(f/60);if(x<24)return`${x}h`;const m=Math.floor(x/24);return m<7?`${m}d`:d.toLocaleDateString(void 0,{month:"short",day:"numeric"})};return e.jsx(e.Fragment,{children:e.jsxs(N2,{$unread:!t.is_read,$expanded:n,onClick:i,children:[e.jsxs(U2,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"2px"},children:[!t.is_read&&e.jsx(H2,{}),e.jsx(B2,{children:t.title})]}),e.jsx(W2,{$expanded:n,children:t.body}),t.ctas&&t.ctas.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"10px",flexWrap:"wrap"},children:t.ctas.map((c,d)=>e.jsx("button",{onClick:()=>a(c),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"5px 12px",fontSize:"12px",fontWeight:500,borderRadius:"6px",cursor:"pointer",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)",border:"1px solid var(--color-border)",background:"var(--color-background)",color:"var(--color-foreground)",boxShadow:"0 1px 2px rgba(0,0,0,0.05)"},onMouseOver:p=>{p.currentTarget.style.background="var(--color-background-hover)",p.currentTarget.style.borderColor="var(--color-primary)"},onMouseOut:p=>{p.currentTarget.style.background="var(--color-background)",p.currentTarget.style.borderColor="var(--color-border)"},children:c.label},d))})]}),e.jsxs(V2,{children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.is_read&&e.jsx("button",{onClick:c=>{c.stopPropagation(),r({type:"unread",id:t.id})},title:"Mark as unread",style:{background:"transparent",border:"none",cursor:"pointer",color:"var(--color-muted)",padding:"4px 0",display:"flex",transition:"color 0.2s"},onMouseOver:c=>c.currentTarget.style.color="var(--color-foreground)",onMouseOut:c=>c.currentTarget.style.color="var(--color-muted)",children:e.jsx(wg,{size:14})}),e.jsx("button",{onClick:c=>{c.stopPropagation(),r({type:"star",id:t.id})},title:t.is_starred?"Unstar":"Star",style:{background:"transparent",border:"none",cursor:"pointer",color:t.is_starred?"var(--color-warning)":"var(--color-muted)",padding:"4px 0",display:"flex",transition:"color 0.2s"},onMouseOver:c=>c.currentTarget.style.color=t.is_starred?"var(--color-warning)":"var(--color-foreground)",onMouseOut:c=>c.currentTarget.style.color=t.is_starred?"var(--color-warning)":"var(--color-muted)",children:e.jsx(Kg,{size:14,fill:t.is_starred?"currentColor":"none"})}),e.jsx("button",{onClick:c=>{c.stopPropagation(),r({type:"archive",id:t.id})},title:t.is_archived?"Unarchive":"Archive",style:{background:"transparent",border:"none",cursor:"pointer",color:"var(--color-muted)",padding:"4px 0",display:"flex",transition:"color 0.2s"},onMouseOver:c=>c.currentTarget.style.color="var(--color-foreground)",onMouseOut:c=>c.currentTarget.style.color="var(--color-muted)",children:t.is_archived?e.jsx(Bg,{size:14}):e.jsx(zd,{size:14})})]}),e.jsx(G2,{children:u(t.created_at)})]})]})})}const q2=h.div`
|
|
5002
5003
|
width: ${t=>t.$fullWidth?"100%":"450px"};
|
|
5003
5004
|
max-width: 100%;
|
|
5004
5005
|
height: 100%;
|
|
@@ -5188,7 +5189,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
5188
5189
|
color: var(--color-secondary-text);
|
|
5189
5190
|
margin: 0;
|
|
5190
5191
|
line-height: 1.4;
|
|
5191
|
-
`,Mu=s.forwardRef(({scope:t="all",onAction:r,fullWidth:n,maxHeight:o,className:i},a)=>{const[u,c]=s.useState("inbox"),[d,p]=s.useState(!1),[l,f]=s.useState(!1),
|
|
5192
|
+
`,Mu=s.forwardRef(({scope:t="all",onAction:r,fullWidth:n,maxHeight:o,className:i},a)=>{const[u,c]=s.useState("inbox"),[d,p]=s.useState(!1),[l,f]=s.useState(!1),x=s.useRef(null),m={scope:t,limit:20,is_archived:u==="archive",is_starred:u==="starred",is_read:d?!1:void 0},{notifications:v,loading:C,error:$,hasMore:_,loadMore:k,markAsRead:R,markAsUnread:y,markAllAsRead:b,archiveAllRead:S,archiveNotification:g,starNotification:j}=td(m);s.useEffect(()=>{if(!l)return;const O=z=>{x.current&&!x.current.contains(z.target)&&f(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[l]);const w=async O=>{switch(O.type){case"read":await R(O.id);break;case"unread":await y(O.id);break;case"archive":await g(O.id);break;case"star":await j(O.id);break;case"custom":r==null||r(O.payload);break}},E=()=>{b(),f(!1)},I=()=>{S(),f(!1)};return e.jsxs(q2,{ref:a,$fullWidth:n,$maxHeight:o,className:i,children:[e.jsxs(Y2,{children:[e.jsxs(K2,{children:[e.jsx(oo,{$active:u==="inbox",onClick:()=>c("inbox"),children:"Inbox"}),e.jsx(oo,{$active:u==="archive",onClick:()=>c("archive"),children:"Archive"}),e.jsx(oo,{$active:u==="starred",onClick:()=>c("starred"),children:"Starred"})]}),e.jsxs(J2,{onClick:()=>p(!d),children:[e.jsx(X2,{$active:d}),e.jsx(eb,{children:"Unread Only"})]}),e.jsx(Q2,{onClick:()=>f(!l),style:{padding:"4px"},children:e.jsx(wn,{size:16})}),l&&e.jsxs(Z2,{ref:x,style:{top:"36px",right:"12px"},children:[u==="inbox"&&e.jsxs(ul,{onClick:E,children:[e.jsx(ug,{})," Mark all as read"]}),e.jsxs(ul,{onClick:I,children:[e.jsx(zd,{})," Archive all read"]})]})]}),e.jsx(tb,{children:C?e.jsx(rb,{children:e.jsx(Ie,{})}):$?e.jsxs(pl,{children:[e.jsx(hl,{children:e.jsx(ys,{size:24,style:{color:"var(--color-error)"}})}),e.jsx(fl,{children:"Failed to load notifications"}),e.jsx(gl,{children:$.message||"An unexpected error occurred."})]}):v.length===0?e.jsxs(pl,{children:[e.jsx(hl,{children:e.jsx(ys,{size:24})}),e.jsx(fl,{children:"No notifications"}),e.jsx(gl,{children:"You're all caught up!"})]}):e.jsxs(e.Fragment,{children:[v.map(O=>e.jsx(Lu,{notification:O,onAction:w},O.id)),_&&e.jsx("div",{style:{padding:"12px",display:"flex",justifyContent:"center"},children:e.jsx(oo,{$active:!1,onClick:k,style:{fontSize:"12px"},children:"Load more"})})]})})]})}),nb=h.div`
|
|
5192
5193
|
position: fixed;
|
|
5193
5194
|
${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
|
|
5194
5195
|
${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
|
|
@@ -5280,7 +5281,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
5280
5281
|
box-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
|
|
5281
5282
|
line-height: 1;
|
|
5282
5283
|
transition: all 0.2s ease;
|
|
5283
|
-
`;function Fu({className:t,showBadge:r=!0,scope:n="all",onAction:o}){const[i,a]=s.useState(!1),u=s.useRef(null),c=s.useRef(null),d=s.useRef(null),{count:p,refetch:l}=rd({scope:n}),f=async
|
|
5284
|
+
`;function Fu({className:t,showBadge:r=!0,scope:n="all",onAction:o}){const[i,a]=s.useState(!1),u=s.useRef(null),c=s.useRef(null),d=s.useRef(null),{count:p,refetch:l}=rd({scope:n}),f=async m=>{await l(),o==null||o(m.payload)},x=Ea({triggerRef:d,isOpen:i,minWidth:Math.min(450,typeof window<"u"?window.innerWidth-32:300),defaultMaxHeight:550});return s.useEffect(()=>{if(!i)return;const m=setTimeout(()=>{const v=C=>{var _,k;const $=C.target;(_=u.current)!=null&&_.contains($)||(k=c.current)!=null&&k.contains($)||a(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},50);return()=>{clearTimeout(m)}},[i]),e.jsx(le,{children:e.jsxs(ob,{ref:u,className:t,children:[e.jsxs(ab,{ref:d,onClick:()=>a(!i),$hasUnread:p>0,"aria-label":p>0?`${p} unread notifications`:"Notifications",children:[e.jsx(ag,{strokeWidth:1}),r&&p>0&&e.jsx(sb,{$dotOnly:p<=9,children:p>9?"9+":""})]}),typeof window<"u"&&i&&Co.createPortal(e.jsx(le,{children:e.jsx(Du,{ref:c,position:x,scope:n,onAction:f,onClose:()=>a(!1)})}),document.body)]})})}const cb=h.div`
|
|
5284
5285
|
display: flex;
|
|
5285
5286
|
align-items: center;
|
|
5286
5287
|
gap: 8px;
|
|
@@ -5513,7 +5514,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
5513
5514
|
&:hover {
|
|
5514
5515
|
color: var(--color-primary-hover);
|
|
5515
5516
|
}
|
|
5516
|
-
`,Cb=({onAccountSelect:t,showAddAccount:r=!0})=>{var y,b,
|
|
5517
|
+
`,Cb=({onAccountSelect:t,showAddAccount:r=!0})=>{var y,b,S,g,j;const{session:n,loading:o,switchSignIn:i,signOut:a}=He(),{deployment:u}=be(),{navigateToSignIn:c,navigate:d}=lt(),[p,l]=s.useState(null),[f,x]=s.useState(null),m=n==null?void 0:n.active_signin,v=(n==null?void 0:n.signins)||[],C=((b=(y=u==null?void 0:u.auth_settings)==null?void 0:y.multi_session_support)==null?void 0:b.enabled)??!1;s.useEffect(()=>{o||v.length||c()},[o,v,c]);const $=w=>w.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2),_=async w=>{var E;x(w);try{if(await i(w),t)t(w),x(null);else{let I=new URLSearchParams(window.location.search).get("redirect_uri");if(I||(I=(E=u.ui_settings)==null?void 0:E.after_signin_redirect_url),I){let O;try{O=new URL(I)}catch{O=new URL(I,window.location.origin)}(u==null?void 0:u.mode)==="staging"&&O.searchParams.set("__dev_session__",tt()??""),d(O.toString())}else x(null)}}catch(I){console.error("Failed to switch account:",I),x(null)}},k=async(w,E)=>{w.stopPropagation(),l(E);try{await a(E)}catch(I){console.error("Failed to sign out:",I)}finally{l(null)}},R=()=>{var E;let w=new URLSearchParams(window.location.search).get("redirect_uri");w||(w=(E=u.ui_settings)==null?void 0:E.after_signin_redirect_url),c(w)};return o?e.jsx(le,{children:e.jsxs(ml,{children:[e.jsx(Fe,{}),e.jsxs(vl,{children:[e.jsx(yl,{children:"Choose an account"}),e.jsxs(bl,{children:["to continue to"," ",((S=u==null?void 0:u.ui_settings)==null?void 0:S.app_name)||"App"]})]}),e.jsx(xl,{children:[1,2].map(w=>e.jsxs(bb,{children:[e.jsx(wb,{}),e.jsxs(jb,{children:[e.jsx(wl,{}),e.jsx(wl,{$width:"small"})]})]},w))})]})}):v.length?e.jsx(le,{children:e.jsxs(ml,{children:[e.jsx(Fe,{}),e.jsxs(vl,{children:[e.jsx(yl,{children:"Choose an account"}),e.jsxs(bl,{children:["to continue to ",(g=u==null?void 0:u.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(xl,{children:[v.map(({user:w,id:E})=>{var T,M,D,F,L;if(!w)return null;const I=E===(m==null?void 0:m.id),O=f===E,z=`${w.first_name||""} ${w.last_name||""}`.trim();return e.jsxs(hb,{$isActive:I,$isSwitching:O,onClick:()=>_(E),children:[e.jsx(fb,{children:w.has_profile_picture?e.jsx("img",{src:w.profile_picture_url,alt:z}):$(z||((T=w.primary_email_address)==null?void 0:T.email)||((M=w.primary_phone_number)==null?void 0:M.phone_number)||w.username||"U")}),e.jsxs(gb,{children:[e.jsx(mb,{children:z||((D=w.primary_email_address)==null?void 0:D.email)||((F=w.primary_phone_number)==null?void 0:F.phone_number)||w.username||"User"}),e.jsx(xb,{children:((L=w.primary_email_address)==null?void 0:L.email)||w.username})]}),!O&&e.jsxs(vb,{onClick:A=>k(A,E),$isLoading:p===E,disabled:p===E,children:[p===E?e.jsx(qt,{size:12}):e.jsx(Ht,{size:12}),p===E?"Signing out...":"Sign out"]})]},E)}),r&&C&&e.jsxs(yb,{onClick:R,children:[e.jsx(yt,{}),"Add another account"]})]}),e.jsxs(_b,{children:["Don't have an account?"," ",e.jsx(kb,{children:e.jsx(jt,{to:`${(j=u.ui_settings)==null?void 0:j.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},Sb=()=>{const{navigateToSignIn:t}=lt();return s.useEffect(()=>{t()},[t]),null},$b=()=>{const{navigateToSignUp:t}=lt();return s.useEffect(()=>{t()},[t]),null},Eb=h.div`
|
|
5517
5518
|
width: 100%;
|
|
5518
5519
|
max-width: 1000px;
|
|
5519
5520
|
height: 600px;
|
|
@@ -5778,7 +5779,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
5778
5779
|
margin: 0 auto;
|
|
5779
5780
|
padding: 6px 16px;
|
|
5780
5781
|
font-size: 13px;
|
|
5781
|
-
`,Nb=()=>{var I,O;const{organizationMemberships:t,refetch:r,loading:n}=Kt(),{workspaces:o}=ar(),{switchOrganization:i,switchWorkspace:a}=He(),{deployment:u}=be(),[c,d]=s.useState(null),[p,l]=s.useState("orgList"),[f,
|
|
5782
|
+
`,Nb=()=>{var I,O;const{organizationMemberships:t,refetch:r,loading:n}=Kt(),{workspaces:o}=ar(),{switchOrganization:i,switchWorkspace:a}=He(),{deployment:u}=be(),[c,d]=s.useState(null),[p,l]=s.useState("orgList"),[f,x]=s.useState(null),m=(u==null?void 0:u.b2b_settings.workspaces_enabled)??!1,v=(u==null?void 0:u.b2b_settings.allow_users_to_create_orgs)??!1,C=s.useRef(!1);s.useEffect(()=>{if(!(C.current||!t)){if(C.current=!0,t.length===0){l("createOrg");return}if(!m){l("orgList");return}if(!o||o.length===0){const z=t.find(T=>{var M,D;return!((M=T.eligibility_restriction)!=null&&M.type)||((D=T.eligibility_restriction)==null?void 0:D.type)==="none"});if(z){x(z.organization.id),l("createWorkspace");return}}l("orgList")}},[t,o,m]),console.log("view mode",p,m);const $=z=>z.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),_=async z=>{if(m){x(z.id),l("workspaceList");return}d(z.id);try{await i(z.id)}finally{d(null)}},k=async z=>{d(z.id);try{await a(z.id)}finally{d(null)}},R=async z=>{var M;await r();const T=((M=z==null?void 0:z.data)==null?void 0:M.organization)||(z==null?void 0:z.organization)||z;if(!m){l("orgList");return}T!=null&&T.id?(x(T.id),l("createWorkspace")):l("orgList")},y=()=>{},b=async()=>{x(null),l("orgList")},S=(I=t==null?void 0:t.find(z=>z.organization.id===f))==null?void 0:I.organization,g=f?o==null?void 0:o.filter(z=>z.organization.id===f):[];if(n)return null;if(p==="createOrg")return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Lo,{onSuccess:R,onCancel:()=>l("orgList")})});if(p==="createWorkspace"&&f)return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(ja,{organizationId:f,onSuccess:y,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const j=p==="workspaceList",w=j?"Select a workspace":"Select an organization",E=j?`Choose a workspace in ${(S==null?void 0:S.name)||""}`:`to continue to ${((O=u==null?void 0:u.ui_settings)==null?void 0:O.app_name)||"App"}`;return e.jsxs(Eb,{children:[e.jsxs(zb,{children:[e.jsxs(Pb,{children:[e.jsx(Fe,{}),e.jsxs(Lb,{children:[e.jsx(Mb,{children:w}),e.jsx(Db,{children:E})]})]}),e.jsx(Oa,{showName:!0})]}),e.jsxs(Rb,{children:[e.jsxs(Ib,{children:[e.jsxs(Tb,{children:[e.jsx(Ob,{children:j?"Workspaces":"Your organizations"}),j&&e.jsxs(Ab,{onClick:b,children:[e.jsx(ma,{}),"Go back"]})]}),e.jsx(Fb,{children:j?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(z=>{var M,D,F;const T=((M=z.eligibility_restriction)==null?void 0:M.type)!=="none"&&((D=z.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs(jl,{onClick:()=>!T&&k(z),disabled:c===z.id||T,style:{opacity:T?.6:1},children:[T&&e.jsx(_l,{className:"warning-popover",children:(F=z.eligibility_restriction)==null?void 0:F.message}),e.jsx(kl,{children:z.image_url?e.jsx(Cl,{src:z.image_url,alt:z.name}):$(z.name).charAt(0)}),e.jsxs(Sl,{children:[e.jsx($l,{children:z.name}),e.jsxs(El,{children:[e.jsx(wo,{}),"Workspace"]})]}),e.jsxs(zl,{children:[T&&e.jsx(jr,{size:16,style:{color:"var(--color-error)"}}),e.jsx(yo,{})]})]},z.id)}):e.jsxs(Pl,{children:[e.jsx(Rl,{children:"No workspaces yet"}),e.jsxs(Il,{children:["Create your first workspace for"," ",(S==null?void 0:S.name)||"this organization"]}),e.jsxs(Tl,{onClick:()=>l("createWorkspace"),children:[e.jsx(yt,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(z=>{var V,H,ae;const T=z.organization,M=o==null?void 0:o.filter(ee=>ee.organization.id===T.id),D=(M==null?void 0:M.length)||0,F=T.member_count,L=z.roles[0].name,A=z.roles.length-1,P=A>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${A}`:L.charAt(0).toUpperCase()+L.slice(1),U=((V=z.eligibility_restriction)==null?void 0:V.type)!=="none"&&((H=z.eligibility_restriction)==null?void 0:H.type)!==void 0;return e.jsxs(jl,{onClick:()=>!U&&_(T),disabled:c===T.id||U,style:{opacity:U?.6:1},children:[U&&e.jsx(_l,{className:"warning-popover",children:(ae=z.eligibility_restriction)==null?void 0:ae.message}),e.jsx(kl,{children:T.image_url?e.jsx(Cl,{src:T.image_url,alt:T.name}):$(T.name)}),e.jsxs(Sl,{children:[e.jsx($l,{children:T.name}),e.jsx(El,{children:m?e.jsxs(e.Fragment,{children:[e.jsx(wo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(cg,{}),P," • ",F," member",F!==1?"s":""]})})]}),e.jsxs(zl,{children:[U&&e.jsx(jr,{size:16,style:{color:"var(--color-error)"}}),e.jsx(yo,{})]})]},T.id)}):e.jsxs(Pl,{children:[e.jsx(Rl,{children:"No organizations yet"}),e.jsx(Il,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Tl,{onClick:()=>l("createOrg"),children:[e.jsx(yt,{}),"Create organization"]})]})})]}),!j&&t&&t.length>0&&v&&e.jsxs(B,{$outline:!0,style:{marginTop:m?"8px":"var(--space-md)"},onClick:()=>l("createOrg"),disabled:c!==null,children:[e.jsx(yt,{size:12}),"Create new organization"]})]})]})},Ub=h(ze.Content)`
|
|
5782
5783
|
padding: 0;
|
|
5783
5784
|
width: 90vw;
|
|
5784
5785
|
max-width: 1000px;
|
|
@@ -5787,5 +5788,5 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
5787
5788
|
max-width: 95vw;
|
|
5788
5789
|
width: 95vw;
|
|
5789
5790
|
}
|
|
5790
|
-
`,Bb=({children:t})=>{var
|
|
5791
|
+
`,Bb=({children:t})=>{var C,$,_,k;const{loading:r,session:n}=He(),{activeOrganization:o}=Tr(),{activeWorkspace:i,loading:a}=Qt(),{workspaces:u}=ar(),{deployment:c}=be(),{organizationMemberships:d}=Kt(),p=(c==null?void 0:c.b2b_settings.workspaces_enabled)??!1,l=d==null?void 0:d.find(R=>R.organization.id===(o==null?void 0:o.id)),f=u==null?void 0:u.find(R=>{var y;return R.id===((y=n==null?void 0:n.active_signin)==null?void 0:y.active_workspace_membership_id)}),x=((C=l==null?void 0:l.eligibility_restriction)==null?void 0:C.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,m=((_=f==null?void 0:f.eligibility_restriction)==null?void 0:_.type)!=="none"&&((k=f==null?void 0:f.eligibility_restriction)==null?void 0:k.type)!==void 0;return r||p&&a?null:(x||m||!o?!1:p?i?u==null?void 0:u.some(y=>y.id===i.id&&y.organization.id===o.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(ze,{isOpen:!0,children:e.jsx(ze.Overlay,{children:e.jsx(Ub,{children:e.jsx(Nb,{})})})})})},Wb=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>r.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>r.startsWith(i))},Vb=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(o=>r.startsWith(o))};exports.AcceptInvite=Y0;exports.AuthFormImage=Fe;exports.CreateOrganizationForm=Lo;exports.CreateWorkspaceDialog=ta;exports.CreateWorkspaceForm=ja;exports.DeploymentInitialized=Wh;exports.DeploymentInitializing=Vh;exports.DeploymentProvider=Bu;exports.Dialog=ze;exports.DialogTrigger=Km;exports.Dropdown=ut;exports.DropdownDivider=Oo;exports.DropdownItem=Le;exports.DropdownItems=pt;exports.DropdownTrigger=ht;exports.Form=It;exports.FormGroup=oe;exports.Input=ne;exports.Label=re;exports.MagicLinkVerification=U0;exports.ManageAccount=Tu;exports.ManageAccountDialog=Ou;exports.ManageOrganization=lu;exports.ManageWorkspace=hu;exports.ManageWorkspaceDialog=ra;exports.NavigateToSignIn=Sb;exports.NavigateToSignUp=$b;exports.NavigationLink=jt;exports.NotificationBell=Fu;exports.NotificationItem=Lu;exports.NotificationPanel=Mu;exports.NotificationPopover=Du;exports.OAuthProvider=Ll;exports.ORG_ADMIN_PERMISSIONS=fu;exports.ORG_MANAGEMENT_PERMISSIONS=gu;exports.OTPInput=cr;exports.OrganizationSwitcher=yu;exports.PhoneNumberInput=kn;exports.PhoneVerification=tu;exports.ProfileCompletion=nu;exports.RequireActiveTenancy=Bb;exports.SSOCallback=I0;exports.SignInForm=h0;exports.SignUpForm=Om;exports.SignedIn=db;exports.SignedInAccounts=Cb;exports.SignedOut=ub;exports.SimpleDialog=Ym;exports.Spinner=Ie;exports.Switch=Pr;exports.TwoFactorMethodSelector=eu;exports.TwoFactorVerification=ru;exports.UserButton=Oa;exports.UserControls=lb;exports.WORKSPACE_ADMIN_PERMISSIONS=mu;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=xu;exports.WaitlistForm=$0;exports.canManageOrganization=vu;exports.canManageWorkspace=na;exports.clearTokenCache=Rt;exports.hasIncompleteProfile=B0;exports.hasOrgPermission=za;exports.hasWorkspacePermission=Pa;exports.isExternalUrl=Wb;exports.isOrgAdmin=dy;exports.isSafeUrl=Vb;exports.isWorkspaceAdmin=uy;exports.redirectToProfileCompletion=W0;exports.useActiveOrganization=Tr;exports.useActiveTenancy=Bp;exports.useActiveWorkspace=Qt;exports.useAgentContext=ch;exports.useAgentContexts=ph;exports.useAgentIntegrations=lh;exports.useAgentMcpServers=dh;exports.useAgentSession=uh;exports.useApiAuthAppSession=Dh;exports.useApiAuthAuditAnalytics=Uh;exports.useApiAuthAuditLogs=Nh;exports.useApiAuthAuditTimeseries=Bh;exports.useApiAuthKeys=Fh;exports.useClient=$e;exports.useCreateWebhookEndpoint=Th;exports.useDeployment=be;exports.useForgotPassword=Xl;exports.useInvitation=nd;exports.useMagicLinkParams=Jl;exports.useMagicLinkVerification=Zl;exports.useNavigation=lt;exports.useNotificationStream=ed;exports.useNotifications=td;exports.useOrganizationList=Tt;exports.useOrganizationMemberships=Kt;exports.useSSOCallback=Ql;exports.useScopeUnread=rd;exports.useSession=He;exports.useSignIn=Ml;exports.useSignInWithStrategy=Gr;exports.useSignUp=Dl;exports.useUser=sr;exports.useUserSignins=Yl;exports.useWaitlist=Kl;exports.useWebhookAnalytics=Lh;exports.useWebhookAppSession=Ph;exports.useWebhookDeliveries=Ah;exports.useWebhookEndpoints=Ih;exports.useWebhookEvents=Oh;exports.useWebhookStats=Rh;exports.useWebhookTimeseries=Mh;exports.useWorkspaceList=ar;exports.useWorkspaceMemberships=So;Object.keys(Ua).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ua[t]})});
|
|
5791
5792
|
//# sourceMappingURL=index.cjs.js.map
|