@wacht/jsx 0.0.1-alpha.52 → 0.0.1-alpha.53

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var Ud=Object.defineProperty;var Wd=(t,r,o)=>r in t?Ud(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var dt=(t,r,o)=>Wd(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),eo=require("react-dom"),da=require("@wacht/types"),Ec=i.createContext(void 0);function Vd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,a]=i.useState(!0),[h,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function d(){if(c.current)return;c.current=!0,a(!0);const[p,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),b=m==="test",k=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){k=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",k??"");const w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else k=localStorage.getItem("__dev_session__");let $={};const S=new URLSearchParams;b?S.append("__dev_session__",k??""):$={credentials:"include"};const C=await fetch(`${v}/deployment${b?"?":""}${S.toString()}`,$);if(!C.ok){a(!1);return}const z=await C.json();z.data.backend_host=v,n&&(z.data.ui_settings={...z.data.ui_settings,...n}),f(z.data),b&&C.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",C.headers.get("x-development-session")??""),a(!1)}d()},[r]);const u=i.useMemo(()=>({loading:s,deployment:h,adapter:o}),[s,h,o]);return e.jsx(Ec.Provider,{value:u,children:t})}function ye(){const t=i.useContext(Ec);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 Ke(){const{deployment:t,loading:r}=ye();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const a=Gd(t),h=new Headers(a.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((d,p)=>{h.set(p,d)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...a,...s,headers:h});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function Gd(t){return t.mode==="staging"?{}:{credentials:"include"}}var so={exports:{}},bn={};/**
2
+ "use strict";var Wd=Object.defineProperty;var Vd=(t,r,o)=>r in t?Wd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var dt=(t,r,o)=>Vd(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),eo=require("react-dom"),da=require("@wacht/types"),Ec=i.createContext(void 0);function Gd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,a]=i.useState(!0),[h,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function d(){if(c.current)return;c.current=!0,a(!0);const[p,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),b=m==="test",k=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){k=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",k??"");const w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else k=localStorage.getItem("__dev_session__");let $={};const S=new URLSearchParams;b?S.append("__dev_session__",k??""):$={credentials:"include"};const C=await fetch(`${v}/deployment${b?"?":""}${S.toString()}`,$);if(!C.ok){a(!1);return}const z=await C.json();z.data.backend_host=v,n&&(z.data.ui_settings={...z.data.ui_settings,...n}),f(z.data),b&&C.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",C.headers.get("x-development-session")??""),a(!1)}d()},[r]);const u=i.useMemo(()=>({loading:s,deployment:h,adapter:o}),[s,h,o]);return e.jsx(Ec.Provider,{value:u,children:t})}function we(){const t=i.useContext(Ec);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 Ke(){const{deployment:t,loading:r}=we();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const a=Hd(t),h=new Headers(a.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((d,p)=>{h.set(p,d)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...a,...s,headers:h});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function Hd(t){return t.mode==="staging"?{}:{credentials:"include"}}var so={exports:{}},bn={};/**
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 ua;function Hd(){if(ua)return bn;ua=1;var t=i;function r(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,h=t.useDebugValue;function f(p,m){var x=m(),v=n({inst:{value:x,getSnapshot:m}}),b=v[0].inst,k=v[1];return a(function(){b.value=x,b.getSnapshot=m,c(b)&&k({inst:b})},[p,x,m]),s(function(){return c(b)&&k({inst:b}),p(function(){c(b)&&k({inst:b})})},[p]),h(x),x}function c(p){var m=p.getSnapshot;p=p.value;try{var x=m();return!o(p,x)}catch{return!0}}function u(p,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:f;return bn.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,bn}var yn={};/**
10
+ */var ua;function qd(){if(ua)return bn;ua=1;var t=i;function r(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,h=t.useDebugValue;function f(p,m){var x=m(),v=n({inst:{value:x,getSnapshot:m}}),b=v[0].inst,k=v[1];return a(function(){b.value=x,b.getSnapshot=m,c(b)&&k({inst:b})},[p,x,m]),s(function(){return c(b)&&k({inst:b}),p(function(){c(b)&&k({inst:b})})},[p]),h(x),x}function c(p){var m=p.getSnapshot;p=p.value;try{var x=m();return!o(p,x)}catch{return!0}}function u(p,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:f;return bn.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,bn}var yn={};/**
11
11
  * @license React
12
12
  * use-sync-external-store-shim.development.js
13
13
  *
@@ -15,12 +15,12 @@
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 pa;function qd(){return pa||(pa=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){d||s.startTransition===void 0||(d=!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 b=v();if(!p){var k=v();a(b,k)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),p=!0)}k=h({inst:{value:b,getSnapshot:v}});var $=k[0].inst,S=k[1];return c(function(){$.value=b,$.getSnapshot=v,o($)&&S({inst:$})},[x,b,v]),f(function(){return o($)&&S({inst:$}),x(function(){o($)&&S({inst:$})})},[x]),u(b),b}function o(x){var v=x.getSnapshot;x=x.value;try{var b=v();return!a(x,b)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=i,a=typeof Object.is=="function"?Object.is:t,h=s.useState,f=s.useEffect,c=s.useLayoutEffect,u=s.useDebugValue,d=!1,p=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;yn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),yn}var ha;function Yd(){return ha||(ha=1,process.env.NODE_ENV==="production"?so.exports=Hd():so.exports=qd()),so.exports}var Zd=Yd();const Pc=0,Ic=1,Rc=2,fa=3;var ga=Object.prototype.hasOwnProperty;function is(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&is(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(ga.call(t,o)&&++n&&!ga.call(r,o)||!(o in r)||!is(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const Tt=new WeakMap,Nt=()=>{},ot=Nt(),cs=Object,Pe=t=>t===ot,bt=t=>typeof t=="function",Bt=(t,r)=>({...t,...r}),Tc=t=>bt(t.then),wn={},ao={},Rs="undefined",to=typeof window!=Rs,ls=typeof document!=Rs,Kd=to&&"Deno"in window,Qd=()=>to&&typeof window.requestAnimationFrame!=Rs,Mc=(t,r)=>{const o=Tt.get(t);return[()=>!Pe(r)&&t.get(r)||wn,n=>{if(!Pe(r)){const s=t.get(r);r in ao||(ao[r]=s),o[5](r,Bt(s,n),s||wn)}},o[6],()=>!Pe(r)&&r in ao?ao[r]:!Pe(r)&&t.get(r)||wn]};let ds=!0;const Xd=()=>ds,[us,ps]=to&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Nt,Nt],Jd=()=>{const t=ls&&document.visibilityState;return Pe(t)||t!=="hidden"},eu=t=>(ls&&document.addEventListener("visibilitychange",t),us("focus",t),()=>{ls&&document.removeEventListener("visibilitychange",t),ps("focus",t)}),tu=t=>{const r=()=>{ds=!0,t()},o=()=>{ds=!1};return us("online",r),us("offline",o),()=>{ps("online",r),ps("offline",o)}},ru={isOnline:Xd,isVisible:Jd},ou={initFocus:eu,initReconnect:tu},ma=!i.useId,Xr=!to||Kd,nu=t=>Qd()?window.requestAnimationFrame(t):setTimeout(t,1),jn=Xr?i.useEffect:i.useLayoutEffect,kn=typeof navigator<"u"&&navigator.connection,xa=!Xr&&kn&&(["slow-2g","2g"].includes(kn.effectiveType)||kn.saveData),io=new WeakMap,su=t=>cs.prototype.toString.call(t),_n=(t,r)=>t===`[object ${r}]`;let au=0;const hs=t=>{const r=typeof t,o=su(t),n=_n(o,"Date"),s=_n(o,"RegExp"),a=_n(o,"Object");let h,f;if(cs(t)===t&&!n&&!s){if(h=io.get(t),h)return h;if(h=++au+"~",io.set(t,h),Array.isArray(t)){for(h="@",f=0;f<t.length;f++)h+=hs(t[f])+",";io.set(t,h)}if(a){h="#";const c=cs.keys(t).sort();for(;!Pe(f=c.pop());)Pe(t[f])||(h+=f+":"+hs(t[f])+",");io.set(t,h)}}else h=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return h},Ts=t=>{if(bt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?hs(t):"",[t,r]};let iu=0;const fs=()=>++iu;async function Oc(...t){const[r,o,n,s]=t,a=Bt({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let h=a.populateCache;const f=a.rollbackOnError;let c=a.optimisticData;const u=m=>typeof f=="function"?f(m):f!==!1,d=a.throwOnError;if(bt(o)){const m=o,x=[],v=r.keys();for(const b of v)!/^\$(inf|sub)\$/.test(b)&&m(r.get(b)._k)&&x.push(b);return Promise.all(x.map(p))}return p(o);async function p(m){const[x]=Ts(m);if(!x)return;const[v,b]=Mc(r,x),[k,$,S,C]=Tt.get(r),z=()=>{const I=k[x];return(bt(a.revalidate)?a.revalidate(v().data,m):a.revalidate!==!1)&&(delete S[x],delete C[x],I&&I[0])?I[0](Rc).then(()=>v().data):v().data};if(t.length<3)return z();let w=n,y,g=!1;const _=fs();$[x]=[_,0];const E=!Pe(c),j=v(),T=j.data,R=j._c,M=Pe(R)?T:R;if(E&&(c=bt(c)?c(M,T):c,b({data:c,_c:M})),bt(w))try{w=w(M)}catch(I){y=I,g=!0}if(w&&Tc(w))if(w=await w.catch(I=>{y=I,g=!0}),_!==$[x][0]){if(g)throw y;return w}else g&&E&&u(y)&&(h=!0,b({data:M,_c:ot}));if(h&&!g)if(bt(h)){const I=h(w,M);b({data:I,error:ot,_c:ot})}else b({data:w,error:ot,_c:ot});if($[x][1]=fs(),Promise.resolve(z()).then(()=>{b({_c:ot})}),g){if(d)throw y;return}return w}}const va=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},cu=(t,r)=>{if(!Tt.has(t)){const o=Bt(ou,r),n=Object.create(null),s=Oc.bind(ot,t);let a=Nt;const h=Object.create(null),f=(d,p)=>{const m=h[d]||[];return h[d]=m,m.push(p),()=>m.splice(m.indexOf(p),1)},c=(d,p,m)=>{t.set(d,p);const x=h[d];if(x)for(const v of x)v(p,m)},u=()=>{if(!Tt.has(t)&&(Tt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,f]),!Xr)){const d=o.initFocus(setTimeout.bind(ot,va.bind(ot,n,Pc))),p=o.initReconnect(setTimeout.bind(ot,va.bind(ot,n,Ic)));a=()=>{d&&d(),p&&p(),Tt.delete(t)}}};return u(),[t,s,u,a]}return[t,Tt.get(t)[4]]},lu=(t,r,o,n,s)=>{const a=o.errorRetryCount,h=s.retryCount,f=~~((Math.random()+.5)*(1<<(h<8?h:8)))*o.errorRetryInterval;!Pe(a)&&h>a||setTimeout(n,f,s)},du=is,[Ac,Hr]=cu(new Map),uu=Bt({onLoadingSlow:Nt,onSuccess:Nt,onError:Nt,onErrorRetry:lu,onDiscarded:Nt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:xa?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:xa?5e3:3e3,compare:du,isPaused:()=>!1,cache:Ac,mutate:Hr,fallback:{}},ru),pu=(t,r)=>{const o=Bt(t,r);if(r){const{use:n,fallback:s}=t,{use:a,fallback:h}=r;n&&a&&(o.use=n.concat(a)),s&&h&&(o.fallback=Bt(s,h))}return o},hu=i.createContext({}),fu="$inf$",Lc=to&&window.__SWR_DEVTOOLS_USE__,gu=Lc?window.__SWR_DEVTOOLS_USE__:[],mu=()=>{Lc&&(window.__SWR_DEVTOOLS_REACT__=i)},xu=t=>bt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Dc=()=>Bt(uu,i.useContext(hu)),vu=t=>(r,o,n)=>t(r,o&&((...a)=>{const[h]=Ts(r),[,,,f]=Tt.get(Ac);if(h.startsWith(fu))return o(...a);const c=f[h];return Pe(c)?o(...a):(delete f[h],c)}),n),bu=gu.concat(vu),yu=t=>function(...o){const n=Dc(),[s,a,h]=xu(o),f=pu(n,h);let c=t;const{use:u}=f,d=(u||[]).concat(bu);for(let p=d.length;p--;)c=d[p](c);return c(s,a||f.fetcher||null,f)},wu=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};mu();const Cn=i.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}}),Sn={dedupe:!0},ju=(t,r,o)=>{const{cache:n,compare:s,suspense:a,fallbackData:h,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:u,refreshWhenHidden:d,refreshWhenOffline:p,keepPreviousData:m}=o,[x,v,b,k]=Tt.get(n),[$,S]=Ts(t),C=i.useRef(!1),z=i.useRef(!1),w=i.useRef($),y=i.useRef(r),g=i.useRef(o),_=()=>g.current,E=()=>_().isVisible()&&_().isOnline(),[j,T,R,M]=Mc(n,$),I=i.useRef({}).current,O=Pe(h)?Pe(o.fallback)?ot:o.fallback[$]:h,N=(de,U)=>{for(const le in I){const K=le;if(K==="data"){if(!s(de[K],U[K])&&(!Pe(de[K])||!s(G,U[K])))return!1}else if(U[K]!==de[K])return!1}return!0},D=i.useMemo(()=>{const de=!$||!r?!1:Pe(f)?_().isPaused()||a?!1:c!==!1:f,U=ue=>{const ee=Bt(ue);return delete ee._k,de?{isValidating:!0,isLoading:!0,...ee}:ee},le=j(),K=M(),Z=U(le),re=le===K?Z:U(K);let fe=Z;return[()=>{const ue=U(j());return N(ue,fe)?(fe.data=ue.data,fe.isLoading=ue.isLoading,fe.isValidating=ue.isValidating,fe.error=ue.error,fe):(fe=ue,ue)},()=>re]},[n,$]),L=Zd.useSyncExternalStore(i.useCallback(de=>R($,(U,le)=>{N(le,U)||de()}),[n,$]),D[0],D[1]),P=!C.current,A=x[$]&&x[$].length>0,q=L.data,Y=Pe(q)?O&&Tc(O)?Cn(O):O:q,B=L.error,H=i.useRef(Y),G=m?Pe(q)?Pe(H.current)?Y:H.current:q:Y,X=A&&!Pe(B)?!1:P&&!Pe(f)?f:_().isPaused()?!1:a?Pe(Y)?!1:c:Pe(Y)||c,oe=!!($&&r&&P&&X),te=Pe(L.isValidating)?oe:L.isValidating,ce=Pe(L.isLoading)?oe:L.isLoading,Q=i.useCallback(async de=>{const U=y.current;if(!$||!U||z.current||_().isPaused())return!1;let le,K,Z=!0;const re=de||{},fe=!b[$]||!re.dedupe,ue=()=>ma?!z.current&&$===w.current&&C.current:$===w.current,ee={isValidating:!1,isLoading:!1},V=()=>{T(ee)},F=()=>{const be=b[$];be&&be[1]===K&&delete b[$]},ne={isValidating:!0};Pe(j().data)&&(ne.isLoading=!0);try{if(fe&&(T(ne),o.loadingTimeout&&Pe(j().data)&&setTimeout(()=>{Z&&ue()&&_().onLoadingSlow($,o)},o.loadingTimeout),b[$]=[U(S),fs()]),[le,K]=b[$],le=await le,fe&&setTimeout(F,o.dedupingInterval),!b[$]||b[$][1]!==K)return fe&&ue()&&_().onDiscarded($),!1;ee.error=ot;const be=v[$];if(!Pe(be)&&(K<=be[0]||K<=be[1]||be[1]===0))return V(),fe&&ue()&&_().onDiscarded($),!1;const Me=j().data;ee.data=s(Me,le)?Me:le,fe&&ue()&&_().onSuccess(le,$,o)}catch(be){F();const Me=_(),{shouldRetryOnError:Ce}=Me;Me.isPaused()||(ee.error=be,fe&&ue()&&(Me.onError(be,$,Me),(Ce===!0||bt(Ce)&&Ce(be))&&(!_().revalidateOnFocus||!_().revalidateOnReconnect||E())&&Me.onErrorRetry(be,$,Me,Se=>{const Ve=x[$];Ve&&Ve[0]&&Ve[0](fa,Se)},{retryCount:(re.retryCount||0)+1,dedupe:!0})))}return Z=!1,V(),!0},[$,n]),me=i.useCallback((...de)=>Oc(n,w.current,...de),[]);if(jn(()=>{y.current=r,g.current=o,Pe(q)||(H.current=q)}),jn(()=>{if(!$)return;const de=Q.bind(ot,Sn);let U=0;_().revalidateOnFocus&&(U=Date.now()+_().focusThrottleInterval);const K=wu($,x,(Z,re={})=>{if(Z==Pc){const fe=Date.now();_().revalidateOnFocus&&fe>U&&E()&&(U=fe+_().focusThrottleInterval,de())}else if(Z==Ic)_().revalidateOnReconnect&&E()&&de();else{if(Z==Rc)return Q();if(Z==fa)return Q(re)}});return z.current=!1,w.current=$,C.current=!0,T({_k:S}),X&&(b[$]||(Pe(Y)||Xr?de():nu(de))),()=>{z.current=!0,K()}},[$]),jn(()=>{let de;function U(){const K=bt(u)?u(j().data):u;K&&de!==-1&&(de=setTimeout(le,K))}function le(){!j().error&&(d||_().isVisible())&&(p||_().isOnline())?Q(Sn).then(U):U()}return U(),()=>{de&&(clearTimeout(de),de=-1)}},[u,d,p,$]),i.useDebugValue(G),a&&Pe(Y)&&$){if(!ma&&Xr)throw new Error("Fallback data is required when using Suspense in SSR.");y.current=r,g.current=o,z.current=!1;const de=k[$];if(!Pe(de)){const U=me(de);Cn(U)}if(Pe(B)){const U=Q(Sn);Pe(G)||(U.status="fulfilled",U.value=!0),Cn(U)}else throw B}return{mutate:me,get data(){return I.data=!0,G},get error(){return I.error=!0,B},get isValidating(){return I.isValidating=!0,te},get isLoading(){return I.isLoading=!0,ce}}},Ze=yu(ju);async function W(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function Nc(t){const{client:r}=Ke(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await W(c)).data},[r,t]),{data:n,error:s,mutate:a}=Ze(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),h=i.useCallback(async c=>{const u=new FormData;u.append("title",c.title),c.system_instructions&&u.append("system_instructions",c.system_instructions);const d=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:u}),p=await W(d);return await a(m=>m&&{...m,data:[p.data,...m.data]}),p.data},[r,t,a]),f=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await a(u=>u&&{...u,data:u.data.filter(d=>d.id!==c)})},[r,t,a]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:h,deleteSession:f,refetch:async()=>{await a()}}}const Fc=i.createContext(void 0);function rn(){const t=i.useContext(Fc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function ku({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:a,onSessionDeleted:h,onError:f}){const[c,u]=i.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[d,p]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:b,deleteSession:k,refetch:$}=Nc(o);i.useEffect(()=>{if(s&&m.length>0){const y=m.find(g=>g.id===s);y&&u(y)}},[s,m]);const S=i.useCallback(y=>{u(y),p(!1)},[]),C=i.useCallback(async y=>{try{const g=y||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,_=await b({title:g});return u(_),a==null||a(_),_}catch(g){const _=g instanceof Error?g.message:"Failed to create session";throw f==null||f(_),g}},[b,a,f]),z=i.useCallback(async y=>{try{await k(y),(c==null?void 0:c.id)===y&&u(null),h==null||h(y)}catch(g){const _=g instanceof Error?g.message:"Failed to delete session";throw f==null||f(_),g}},[k,c,h,f]),w={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:S,createSession:C,deleteSession:z,refreshSessions:$,showHistory:d,setShowHistory:p,onSessionCreated:a,onSessionDeleted:h,onError:f};return e.jsx(Fc.Provider,{value:w,children:t})}var Bc=(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))(Bc||{});function _u(t,r){const o={username:Cu(t,r),email:Su(t,r),phone:$u(t,r),email_otp:zu(t,r),magic_link:Eu(t,r),oauth:Pu(t),passkey:Iu(t),generic:Ru(t,r)};return function(s){return o[s]}}function Cu(t,r){return async({username:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(h.data.signin_attempts.at(-1)||null),h}}function Su(t,r){return async({email:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(h.data.signin_attempts.at(-1)||null),h}}function $u(t,r){return async({phone:o})=>{var h,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function zu(t,r){return async({email:o})=>{var h,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Eu(t,r){return async({email:o})=>{var h,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Pu(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),a=await W(s);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function Nr(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ba(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),s=new Uint8Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return s.buffer}function Iu(t){return async()=>{var u;const r=await t("/auth/passkey/login/begin",{method:"POST"}),o=await W(r);if(!("data"in o))return o;const n=o.data.options.publicKey,s={challenge:ba(n.challenge),timeout:n.timeout,rpId:n.rpId,userVerification:n.userVerification,allowCredentials:(u=n.allowCredentials)==null?void 0:u.map(d=>({type:d.type,id:ba(d.id),transports:d.transports}))};let a;try{const d=await navigator.credentials.get({publicKey:s});if(!d)throw new Error("Failed to get credential");a=d}catch(d){throw d.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):d.name==="AbortError"?new Error("Passkey sign-in was cancelled."):d}const h=a.response,f=new FormData;f.append("id",a.id),f.append("rawId",Nr(a.rawId)),f.append("type",a.type),f.append("clientDataJSON",Nr(h.clientDataJSON)),f.append("authenticatorData",Nr(h.authenticatorData)),f.append("signature",Nr(h.signature)),h.userHandle&&f.append("userHandle",Nr(h.userHandle));const c=await t("/auth/passkey/login/finish",{method:"POST",body:f});return W(c)}}function Ru(t,r){return async({email:o,username:n,password:s,phone:a,strategy:h,token:f})=>{var p,m;const c=new FormData;h&&c.append("strategy",h),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),a&&c.append("phone",a),f&&c.append("token",f);const u=await t("/auth/signin",{method:"POST",body:c}),d=await W(u);return"data"in d&&((m=(p=d.data)==null?void 0:p.signin_attempts)!=null&&m.length)&&r(d.data.signin_attempts.at(-1)||null),d}}function Uc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:_u(t,n),completeVerification:async s=>{var c,u;const a=new FormData;a.append("verification_code",s);const h=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:a}),f=await W(h);if("data"in f&&((u=(c=f.data)==null?void 0:c.signin_attempts)!=null&&u.length)){const d=f.data.signin_attempts.at(-1);return n(d||null),f.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var f;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),a.searchParams.set("strategy",s.strategy),a.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?a.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&a.searchParams.set("redirect_uri",s.redirectUri);const h=await t(a.pathname+a.search,{method:"POST"});return W(h)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const a=new FormData;for(const[u,d]of Object.entries(s))d&&a.append(u,d);const h=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:a}),f=await W(h);if("data"in f&&f.data){const u=(c=f.data.signin_attempts)==null?void 0:c.find(d=>d.id===o.id);return u&&n(u),f.data}else throw new Error("Profile completion failed")},identify:async s=>{const a=new FormData;a.append("identifier",s);const h=await t("/auth/identify",{method:"POST",body:a});return(await W(h)).data},initEnterpriseSso:async(s,a)=>{const h=new URLSearchParams({connection_id:s});a&&h.append("redirect_uri",a);const f=await t(`/auth/sso/login?${h.toString()}`,{method:"POST"});return(await W(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function zr(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:a}=Uc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:a};const h=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"passkey":return o.createStrategy("passkey");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:h,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:a}}function Tu(t,r,o){return{create:async n=>{var f,c,u;const s=new FormData;for(const[d,p]of Object.entries(n))s.append(d,p);const a=await t("/auth/signup",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((u=h.data.signup_attempts)==null?void 0:u.at(-1))||null),h},prepareVerification:async n=>{var h;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((h=r==null?void 0:r.id)==null?void 0:h.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const a=await t(s.pathname+s.search,{method:"POST"});return W(a)},completeVerification:async n=>{var f,c;const s=new FormData;s.append("verification_code",n);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(h.data.signup_attempts.at(-1)||null),h},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),a=await W(s);return"data"in a&&a.data?a.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function Wc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Tu(t,o,n)}}const rt=()=>{const{adapter:t,deployment:r}=ye(),o=t.useNavigate(),n=(c,u)=>{o?o(c,u):window.location.href=c},s=c=>{if(c)return c;const d=new URLSearchParams(window.location.search).get("redirect_uri");return d||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${d.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${d.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${d.toString()}`,{replace:!0})}}};async function Mu(t){const r=await t("/session",{method:"GET"});return(await W(r)).data}async function Ou(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return W(o)}async function Au(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return W(n)}async function Lu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return W(o)}async function Du(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return W(o)}const gs=new Map,qr=new Map;function Mt(){gs.clear(),qr.clear()}async function Nu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return W(o)}function Qe(){const{client:t,loading:r}=Ke(),{deployment:o}=ye(),{navigate:n}=rt(),{cache:s}=Dc(),{data:a,error:h,mutate:f,isLoading:c}=Ze(r?null:"/session",()=>Mu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),d=i.useCallback(async(p="default")=>{if(!a)throw new Error("no session");const m=gs.get(p);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";qr.get(p)||qr.set(p,Nu(t,p));const x=await qr.get(p);return qr.delete(p),gs.set(p,x.data),x.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||c?{loading:!0,error:h,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:u}:{loading:c,error:h,session:a,switchSignIn:async p=>{await Ou(t,p),Mt(),await Hr("/me/organization-memberships",void 0,{revalidate:!1}),await Hr("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Hr("/me/organization-memberships"),await Hr("/me/workspace-memberships")},signOut:async p=>{await Au(t,p);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const v=Array.from(s.keys());for(const b of v){let k=!1;(m.includes(b)||typeof b=="string"&&x.some($=>b.startsWith($)))&&(k=!0),k&&s.delete(b)}}Mt(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(p&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!p&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async p=>{await Lu(t,p),Mt(),await f(void 0,{revalidate:!0})},switchWorkspace:async p=>{await Du(t,p),Mt(),await f(void 0,{revalidate:!0})},getToken:d,refetch:u}}const on=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{client:n}=Ke(),{refetch:s}=Qe(),a=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),h=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),u=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/members/${P.id}/remove`,{method:"POST"})},[n]),d=i.useCallback(async L=>{const P=new FormData;P.append("name",L.name),L.image&&P.append("image",L.image),L.description&&P.append("description",L.description);const A=await W(await n("/organizations",{method:"POST",body:P}));return Mt(),await r(),await s(),A},[s,r,n]),p=i.useCallback(async(L,P)=>{const A=Object.entries(P).reduce((Y,[B,H])=>(H&&Y.append(B,H),Y),new FormData),q=await W(await n(`/organizations/${L.id}/update`,{method:"POST",body:A}));return await r(),q},[r,n]),m=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/roles/${P.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("domain",P.fqdn),await W(await n(`/organizations/${L.id}/domains`,{method:"POST",body:A}))},[n]),v=i.useCallback(async(L,P)=>await W(await n(`/organizations/${L.id}/domains/${P.id}/verify`,{method:"POST"})),[n]),b=i.useCallback(async(L,P)=>await W(await n(`/organizations/${L.id}/domains/${P.id}/delete`,{method:"POST"})),[n]),k=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),$=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("protocol",P.protocol),P.domain_id&&A.append("domain_id",P.domain_id),P.idp_entity_id&&A.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&A.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&A.append("idp_certificate",P.idp_certificate),P.oidc_client_id&&A.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&A.append("oidc_client_secret",P.oidc_client_secret),P.oidc_issuer_url&&A.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_scopes&&A.append("oidc_scopes",P.oidc_scopes),P.jit_enabled!==void 0&&A.append("jit_enabled",String(P.jit_enabled)),P.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(P.attribute_mapping)),(await W(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),S=i.useCallback(async(L,P,A)=>{const q=new FormData;return A.domain_id&&q.append("domain_id",A.domain_id),A.idp_entity_id&&q.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&q.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&q.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&q.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&q.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&q.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&q.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&q.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/update`,{method:"POST",body:q}))).data},[n]),C=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/enterprise-connections/${P}/delete`,{method:"POST"})},[n]),z=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("protocol",P.protocol),P.idp_entity_id&&A.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&A.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&A.append("idp_certificate",P.idp_certificate),P.oidc_issuer_url&&A.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_client_id&&A.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&A.append("oidc_client_secret",P.oidc_client_secret),(await W(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/test`,{method:"POST"}))).data,[n]),y=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token`,{method:"POST"}))).data,[n]),g=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token`,{method:"GET"}))).data,[n]),_=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token/revoke`,{method:"POST"})},[n]),E=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("name",P.name),P.permissions&&P.permissions.forEach((Y,B)=>{A.append(`permissions[${B}]`,Y)}),await W(await n(`/organizations/${L.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async L=>{const P=await W(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return Mt(),await r(),await s(),P.data},[n,r,s]),R=i.useCallback(async(L,P,A)=>(await W(await n(`/organizations/${L.id}/members/${P.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),M=i.useCallback(async(L,P,A)=>(await W(await n(`/organizations/${L.id}/members/${P.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=i.useCallback(async(L,P)=>{var Y,B;const A=new FormData;return A.append("email",P.email),A.append("role_id",P.organizationRole.id),(Y=P.workspace)!=null&&Y.id&&A.append("workspace_id",P.workspace.id),(B=P.workspaceRole)!=null&&B.id&&A.append("workspace_role_id",P.workspaceRole.id),(await W(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:A}))).data},[n]),O=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/invitations/${P.id}/discard`,{method:"POST"}))).data,[n]),N=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/invitations/${P.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:h,removeOrganizationMember:u,createOrganization:d,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:b,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:M,inviteOrganizationMember:I,discardOrganizationInvitation:O,resendOrganizationInvitation:N,updateOrganization:p,addRole:E,removeOrganizationRoles:m,deleteOrganization:T,getEnterpriseConnections:k,createEnterpriseConnection:$,updateEnterpriseConnection:S,deleteEnterpriseConnection:C,testEnterpriseConnectionConfig:z,testEnterpriseConnection:w,generateSCIMToken:y,getSCIMToken:g,revokeSCIMToken:_}},st=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:h,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:u,addOrganizationDomain:d,verifyOrganizationDomain:p,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:b,resendOrganizationInvitation:k,updateOrganization:$,removeOrganizationRoles:S,getEnterpriseConnections:C,createEnterpriseConnection:z,updateEnterpriseConnection:w,deleteEnterpriseConnection:y,testEnterpriseConnectionConfig:g,testEnterpriseConnection:_,generateSCIMToken:E,getSCIMToken:j,revokeSCIMToken:T}=on(),{session:R,error:M,loading:I}=Qe(),{organizationMemberships:O}=Ot(),N=i.useMemo(()=>(O==null?void 0:O.find(F=>{var ne;return F.id===((ne=R==null?void 0:R.active_signin)==null?void 0:ne.active_organization_membership_id)}))||null,[O,R]),D=i.useMemo(()=>(N==null?void 0:N.organization)||null,[N]),L=i.useCallback(async F=>D?await $(D,F):[],[D,$]),P=i.useCallback(async()=>D?await n(D):[],[D,n]),A=i.useCallback(async()=>D?await s(D):[],[D,s]),q=i.useCallback(async F=>D?await h(D,F):[],[D,h]),Y=i.useCallback(async F=>D?await S(D,F):void 0,[D,S]),B=i.useCallback(async()=>D?await c(D):[],[D,c]),H=i.useCallback(async F=>D?await d(D,F):void 0,[D,d]),G=i.useCallback(async F=>D?await p(D,F):void 0,[D,p]),X=i.useCallback(async F=>D?await u(D,F):void 0,[D,u]),oe=i.useCallback(async(F,ne)=>D?await m(D,F,ne):void 0,[D,m]),te=i.useCallback(async(F,ne)=>D?await x(D,F,ne):void 0,[D,x]),ce=i.useCallback(async F=>D?await v(D,F):void 0,[D,v]),Q=i.useCallback(async F=>D?await b(D,F):void 0,[D,b]),me=i.useCallback(async F=>D?await k(D,F):void 0,[D,k]),ve=i.useCallback(async()=>{D&&await a(D)},[D,a]),de=i.useCallback(async()=>D?await f(D):[],[D,f]),U=i.useCallback(async()=>D?await C(D):[],[D,C]),le=i.useCallback(async F=>{if(D)return await z(D,F)},[D,z]),K=i.useCallback(async(F,ne)=>{if(D)return await w(D,F,ne)},[D,w]),Z=i.useCallback(async F=>{D&&await y(D,F)},[D,y]),re=i.useCallback(async F=>D?await g(D,F):null,[D,g]),fe=i.useCallback(async F=>D?await _(D,F):null,[D,_]),ue=i.useCallback(async F=>{if(D)return await E(D,F)},[D,E]),ee=i.useCallback(async F=>{if(D)return await j(D,F)},[D,j]),V=i.useCallback(async F=>{D&&await T(D,F)},[D,T]);return I||t?{activeOrganization:null,activeMembership:null,loading:!0,error:M||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:D,activeMembership:N,loading:!1,refetch:o,getRoles:A,updateOrganization:L,getMembers:P,getDomains:B,addDomain:H,verifyDomain:G,removeDomain:X,getInvitations:de,removeMember:q,leave:ve,removeRole:Y,addMemberRole:oe,removeMemberRole:te,inviteMember:ce,discardInvitation:Q,resendInvitation:me,getEnterpriseConnections:U,createEnterpriseConnection:le,updateEnterpriseConnection:K,deleteEnterpriseConnection:Z,testEnterpriseConnectionConfig:re,testEnterpriseConnection:fe,generateSCIMToken:ue,getSCIMToken:ee,revokeSCIMToken:V,error:null}};async function Fu(t){return(await W(await t("/me/organization-memberships"))).data}const Ot=()=>{const{client:t,loading:r}=Ke(),{data:o,isLoading:n,error:s,mutate:a}=Ze(r?null:"/me/organization-memberships",()=>Fu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await a(void 0,{revalidate:!0})},[a]);return{organizationMemberships:o,loading:r||n,error:s,refetch:h}};async function Bu(t){return(await W(await t("/me/workspace-memberships"))).data}async function Uu(t,r,o){return(await W(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const nn=()=>{const{client:t,loading:r}=Ke(),{deployment:o}=ye(),{data:n,isLoading:s,error:a,mutate:h}=Ze(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Bu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=i.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]);return{workspaceMemberships:n,loading:r||s,error:a,refetch:f}},Wt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=nn(),{client:s}=Ke(),a=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),h=i.useCallback(async(w,y,g,_)=>{const E=new FormData;E.append("name",y),g&&E.append("image",g),_&&E.append("description",_),E.append("organization_id",w);const j=await W(await s("/workspaces",{method:"POST",body:E}));return Mt(),await r(),j.data},[s,r]),f=i.useCallback(async(w,y)=>{const g=await Uu(s,w,y);return await r(),g},[s,r]),c=i.useCallback(async(w,y)=>{const g=new FormData;y.name&&g.append("name",y.name),y.description&&g.append("description",y.description),y.image&&g.append("image",y.image),y.enforce_2fa!==void 0&&g.append("enforce_2fa",String(y.enforce_2fa)),y.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(y.enable_ip_restriction)),y.whitelisted_ips&&y.whitelisted_ips.forEach(E=>g.append("whitelisted_ips",E));const _=await W(await s(`/workspaces/${w.id}/update`,{method:"POST",body:g}));return await r(),_.data},[s,r]),u=i.useCallback(async w=>{const y=await W(await s(`/workspaces/${w.id}/delete`,{method:"POST"}));return Mt(),await r(),y.data},[s,r]),d=i.useCallback(async w=>(await W(await s(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[s]),p=i.useCallback(async w=>(await W(await s(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[s]),m=i.useCallback(async(w,y,g)=>{const _=new FormData;return _.append("name",y),g.forEach(j=>_.append("permissions",j)),(await W(await s(`/workspaces/${w.id}/roles`,{method:"POST",body:_}))).data},[s]),x=i.useCallback(async(w,y)=>(await W(await s(`/workspaces/${w.id}/roles/${y.id}/delete`,{method:"POST"}))).data,[s]),v=i.useCallback(async(w,y)=>{const g=await W(await s(`/workspaces/${w.id}/members/${y}/remove`,{method:"POST"}));return await r(),g.data},[s,r]),b=i.useCallback(async(w,y,g)=>(await W(await s(`/workspaces/${w.id}/members/${y}/roles/${g}/add`,{method:"POST"}))).data,[s]),k=i.useCallback(async(w,y,g)=>(await W(await s(`/workspaces/${w.id}/members/${y}/roles/${g}/remove`,{method:"POST"}))).data,[s]),$=i.useCallback(async w=>(await W(await s(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(g=>String(g.workspace_id)===String(w.id)),[s]),S=i.useCallback(async(w,y,g)=>{const _=new FormData;return _.append("email",y),_.append("workspace_id",w.id),g&&_.append("workspace_role_id",g),(await W(await s(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:_}))).data},[s]),C=i.useCallback(async(w,y)=>(await W(await s(`/organizations/${w.organization.id}/invitations/${y}/discard`,{method:"POST"}))).data,[s]),z=i.useCallback(async(w,y)=>(await W(await s(`/organizations/${w.organization.id}/invitations/${y}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:h,updateWorkspace:c,deleteWorkspace:u,getWorkspaceMembers:d,getWorkspaceRoles:p,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:b,removeWorkspaceMemberRole:k,getWorkspaceInvitations:$,createWorkspaceInvitation:S,discardWorkspaceInvitation:C,resendWorkspaceInvitation:z}},Vt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:h,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:u,deleteWorkspaceRole:d,removeWorkspaceMember:p,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:b,discardWorkspaceInvitation:k,resendWorkspaceInvitation:$}=Wt(),{workspaceMemberships:S}=nn(),{session:C,loading:z,error:w}=Qe(),y=i.useMemo(()=>(S==null?void 0:S.find(G=>{var X;return G.id===((X=C==null?void 0:C.active_signin)==null?void 0:X.active_workspace_membership_id)}))||null,[S,C]),g=i.useMemo(()=>(y==null?void 0:y.workspace)||null,[y]),_=i.useCallback(async()=>{var G;if(!(!g||!((G=C==null?void 0:C.active_signin)!=null&&G.user_id)))return await s(g.id,C.active_signin.user_id)},[g,s,C]),E=i.useCallback(async G=>{if(g)return await a(g,G)},[g,a]),j=i.useCallback(async()=>{if(g)return await h(g)},[g,h]),T=i.useCallback(async()=>g?await f(g):[],[g,f]),R=i.useCallback(async()=>g?await c(g):[],[g,c]),M=i.useCallback(async(G,X)=>{if(g)return await u(g,G,X)},[g,u]),I=i.useCallback(async G=>{if(g)return await d(g,G)},[g,d]),O=i.useCallback(async G=>{if(g)return await p(g,G)},[g,p]),N=i.useCallback(async(G,X)=>{if(g)return await m(g,G,X)},[g,m]),D=i.useCallback(async(G,X)=>{if(g)return await x(g,G,X)},[g,x]),L=i.useMemo(()=>(n==null?void 0:n.find(G=>G.id===(g==null?void 0:g.id)))||null,[n,g]),P=i.useCallback(async()=>L?await v(L):[],[L,v]),A=i.useCallback(async(G,X)=>{if(L)return await b(L,G,X)},[L,b]),q=i.useCallback(async G=>{if(L)return await k(L,G)},[L,k]),Y=i.useCallback(async G=>{if(L)return await $(L,G)},[L,$]),B=r||z,H=o||w;return B?{activeWorkspace:null,activeMembership:null,loading:!0,error:H,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:y,loading:!1,error:H,refetch:t,leave:_,updateWorkspace:E,deleteWorkspace:j,getMembers:T,getRoles:R,createRole:M,deleteRole:I,inviteMember:A,removeMember:O,addMemberRole:N,removeMemberRole:D,getInvitations:P,discardInvitation:q,resendInvitation:Y}};function $n(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function zn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),s=new Uint8Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return s.buffer}const Wu=async t=>(await W(await t("/me"))).data,Vu=async t=>(await W(await t("/me/signins"))).data;function Gt(){const{client:t,loading:r}=Ke(),{data:o,error:n,isLoading:s,mutate:a}=Ze(r?null:"/user",()=>Wu(t)),h=async L=>{const P=new FormData;for(const[q,Y]of Object.entries(L))Y!=null&&Y!==""&&P.append(q,String(Y));const A=await W(await t("/me",{method:"POST",body:P}));return a(),A},f=async()=>await W(await t("/me/email-addresses",{method:"GET"})),c=async L=>await W(await t(`/me/email-addresses/${L}`,{method:"GET"})),u=async L=>{const P=new FormData;return P.append("email",L),await W(await t("/me/email-addresses",{method:"POST",body:P}))},d=async L=>await W(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),p=async L=>await W(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,P)=>await W(await t(`/me/email-addresses/${L}/attempt-verification?code=${P}`,{method:"POST"})),x=async(L,P)=>{const A=new FormData;return A.append("phone_number",L),A.append("country_code",P),await W(await t("/me/phone-numbers",{method:"POST",body:A}))},v=async L=>await W(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),b=async L=>await W(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),k=async(L,P)=>{const A=new FormData;return A.append("code",P),await W(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:A}))},$=async L=>{const P=await W(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return a(),P},S=async L=>await W(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),C=async()=>(await W(await t("/me/authenticator",{method:"POST"}))).data,z=async(L,P)=>{const A=new FormData;return A.append("authenticator_id",L),P.forEach(Y=>{A.append("codes",Y)}),await W(await t("/me/authenticator/attempt-verification",{method:"POST",body:A}))},w=async L=>await W(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),y=async()=>(await W(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const P=new FormData;return P.append("file",L),await W(await t("/me/profile-picture",{method:"POST",body:P}))},_=async()=>(await W(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,E=async(L,P)=>{const A=new FormData;return A.append("current_password",L),A.append("new_password",P),await W(await t("/me/update-password",{method:"POST",body:A}))},j=async L=>{const P=new FormData;P.append("current_password",L);const A=await W(await t("/me/remove-password",{method:"POST",body:P}));return a(),A},T=async L=>{const P=new FormData;return P.append("password",L),await W(await t("/me/account/delete",{method:"POST",body:P}))},R=async L=>await W(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),M=async({provider:L,redirectUri:P})=>{var Y;const A=new URLSearchParams({provider:L});P&&A.append("redirect_uri",P);const q=await W(await t(`/me/init-sso-connection?${A.toString()}`,{method:"POST"}));return"data"in q&&((Y=q.data)!=null&&Y.oauth_url)&&window.open(q.data.oauth_url,"_blank"),q},I=async()=>await W(await t("/me/passkeys",{method:"GET"})),O=async L=>{var X,oe;const P=await W(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in P))return P;const A=P.data.options.publicKey,q={challenge:zn(A.challenge),rp:A.rp,user:{id:zn(A.user.id),name:A.user.name,displayName:A.user.displayName},pubKeyCredParams:A.pubKeyCredParams,timeout:A.timeout,attestation:A.attestation,authenticatorSelection:A.authenticatorSelection,excludeCredentials:(X=A.excludeCredentials)==null?void 0:X.map(te=>({type:te.type,id:zn(te.id),transports:te.transports}))},Y=await navigator.credentials.create({publicKey:q});if(!Y)throw new Error("Failed to create credential");const B=Y.response,H={id:Y.id,rawId:$n(Y.rawId),type:Y.type,response:{clientDataJSON:$n(B.clientDataJSON),attestationObject:$n(B.attestationObject),transports:((oe=B.getTransports)==null?void 0:oe.call(B))||[]}};return await W(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}))},N=async L=>await W(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),D=async(L,P)=>await W(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:P})}));return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:h,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:u,deleteEmailAddress:d,prepareEmailVerification:p,attemptEmailVerification:m,makeEmailPrimary:S,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:b,attemptPhoneVerification:k,makePhonePrimary:$,setupAuthenticator:C,verifyAuthenticator:z,deleteAuthenticator:w,generateBackupCodes:y,regenerateBackupCodes:_,updateProfilePicture:g,disconnectSocialConnection:R,connectSocialAccount:M,updatePassword:E,removePassword:j,deleteAccount:T,getPasskeys:I,registerPasskey:O,deletePasskey:N,renamePasskey:D}}function Vc(){const{client:t,loading:r}=Ke(),{data:o,error:n,isLoading:s,mutate:a}=Ze(r?null:"/me/signins",()=>Vu(t));return{signins:o,error:n||null,removeSignin:async f=>await W(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:a,loading:s||r}}function Gu(){const{session:t,loading:r}=Qe(),{loading:o,organizationMemberships:n}=Ot(),{loading:s,workspaceMemberships:a}=nn();if(r||o||s)return{loading:!0,orgMembership:null,workspaceMembership:null};const h=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var u;return c.id===((u=t.active_signin)==null?void 0:u.active_organization_membership_id)}),[t]),f=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:a==null?void 0:a.find(c=>{var u;return c.id===((u=t.active_signin)==null?void 0:u.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:h,workspaceMembership:f}}function Gc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),s=async a=>{n(!0);try{const h=new FormData;for(const[u,d]of Object.entries(a))d&&h.append(u,d);const f=await t("/waitlist/join",{method:"POST",body:h});return await W(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function Hc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),[s,a]=i.useState(null),[h,f]=i.useState(null),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(d||r)return;const b=new URLSearchParams(window.location.search),k=b.get("code"),$=b.get("state"),S=b.get("error"),C=b.get("error_description");if(!k&&!S){p(!0);const z=new Error("No OAuth callback data found.");a(z);return}if(p(!0),n(!0),S){const z=C||S,w=new Error(`OAuth Error: ${z}`);a(w),n(!1);return}if(k&&$)v(k,$);else{const z=new Error("Missing required OAuth parameters");a(z),n(!1)}},[d,r]);const v=async(b,k)=>{try{let $,S;try{const w=k.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const y=w[0].replace(/-/g,"+").replace(/_/g,"/"),g=y.length%4?"=".repeat(4-y.length%4):"",E=atob(y+g).split("|")[0];if(E==="sign_in")$="/auth/oauth2/callback",S="GET";else if(E==="connect_social")$="/me/sso-connection-callback",S="POST";else throw new Error(`Unknown OAuth action: ${E}`)}catch(w){const y=w instanceof Error?w:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${y.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const C=await t(`${$}?code=${encodeURIComponent(b)}&state=${encodeURIComponent(k)}`,{method:S}),z=await W(C);if("data"in z){const w=z.data.session,y=z.data.redirect_uri||null;if(f(w),u(y),w.signin_attempts&&w.signin_attempts.length>0){const g=w.signin_attempts.at(-1);g&&x(g)}}else{const w=new Error("SSO callback failed");a(w)}}catch($){const S=$ instanceof Error?$:new Error("Unknown error occurred");a(S)}finally{n(!1)}};return{loading:o,error:s,session:h,redirectUri:c,processed:d,signinAttempt:m}}function qc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),a(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const u=await t(c.pathname+c.search,{method:"GET"}),d=await W(u);return n(!1),a(!0),d}catch(c){throw n(!1),a(!1),c}},success:s}}function Yc(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function Zc(){const{client:t,loading:r}=Ke();return{loading:r,forgotPassword:async a=>{const h=new FormData;h.append("email",a);const f=await t("/auth/forgot-password",{method:"POST",body:h});return await W(f)},verifyOtp:async(a,h)=>{const f=new FormData;f.append("email",a),f.append("otp",h);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await W(c)},resetPassword:async(a,h)=>{const f=new FormData;f.append("token",a),f.append("password",h);const c=await t("/auth/reset-password",{method:"POST",body:f});return await W(c)}}}function Kc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:h=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:u}=Qe(),{deployment:d,loading:p}=ye(),[m,x]=i.useState(!1),[v,b]=i.useState(null),k=i.useRef(null),$=i.useRef(null),S=i.useRef(0),C=i.useRef(null),z=i.useRef(s),w=i.useRef(a),y=i.useRef(r),g=i.useRef(o),_=i.useRef(n),E=i.useRef(h),j=i.useRef(f);z.current=s,w.current=a,y.current=r,g.current=o,_.current=n,E.current=h,j.current=f;const T=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),C.current&&(clearInterval(C.current),C.current=null),k.current&&(k.current.close(),k.current=null)},[]),R=i.useCallback(async()=>{var L;if(!t||u||p||!c||!d)return;T();const O=new URL(d.backend_host),N=O.protocol==="https:"?"wss:":"ws:",D=new URL("/realtime/notifications",`${N}//${O.host}`);if(d.mode==="staging"){const P=localStorage.getItem("__dev_session__");P&&D.searchParams.set("__dev_session__",P)}y.current&&y.current.length>0&&y.current.forEach(P=>D.searchParams.append("channels",P)),g.current&&g.current.length>0&&g.current.forEach(P=>D.searchParams.append("organization_ids",P.toString())),_.current&&_.current.length>0&&_.current.forEach(P=>D.searchParams.append("workspace_ids",P.toString()));try{const P=new WebSocket(D.toString());k.current=P,P.onopen=()=>{x(!0),b(null),S.current=0,C.current=setInterval(()=>{P.readyState===WebSocket.OPEN&&P.send("ping")},3e4)},P.onmessage=A=>{var q,Y;try{const B=JSON.parse(A.data);if(B.type==="notification"&&B.data)(q=z.current)==null||q.call(z,B.data);else if(B.type==="error"){const H=B.error||"Unknown error occurred";b(H),(Y=w.current)==null||Y.call(w,H)}else B.type}catch{}},P.onerror=()=>{var A;b("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},P.onclose=A=>{var q;if(x(!1),C.current&&(clearInterval(C.current),C.current=null),t&&A.code!==1e3&&S.current<j.current){S.current++;const Y=E.current*Math.pow(2,S.current-1);$.current=setTimeout(()=>{R()},Y)}else S.current>=j.current&&(b("Max reconnection attempts reached"),(q=w.current)==null||q.call(w,"Max reconnection attempts reached"))}}catch{b("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,u,p,c,d,T]);i.useEffect(()=>(R(),()=>{T()}),[R,T]),i.useEffect(()=>{k.current&&k.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const M=i.useCallback(()=>{T(),x(!1)},[T]),I=i.useCallback(()=>{S.current=0,R()},[R]);return{isConnected:m,connectionError:v,disconnect:M,reconnect:I}}async function Hu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(h=>o.append("channels",h)),r.organization_ids&&r.organization_ids.forEach(h=>o.append("organization_ids",h.toString())),r.workspace_ids&&r.workspace_ids.forEach(h=>o.append("workspace_ids",h.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,s=await t(n,{method:"GET"});return(await W(s)).data}async function qu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await W(r)).data}async function Yu(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return W(o)}async function Zu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return W(r)}async function Ku(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return W(o)}function Qc(t){const{client:r,loading:o}=Ke(),{data:n,error:s,mutate:a,isLoading:h}=Ze(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>Hu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Kc({enabled:!o&&!!n,onNotification:i.useCallback(p=>{a(async m=>!m||m.notifications.some(v=>v.id===p.id.toString())?m:{...m,notifications:[{id:p.id.toString(),user_id:p.user_id.toString(),deployment_id:p.deployment_id.toString(),title:p.title,body:p.body,severity:p.severity,action_url:p.action_url,action_label:p.action_label,is_read:!1,is_archived:!1,created_at:p.created_at,updated_at:p.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async p=>{o||(await a(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===p?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await Yu(r,p),await a())},[r,o,a]),c=i.useCallback(async()=>{o||(await a(async p=>p&&{...p,notifications:p.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await Zu(r),await a())},[r,a]),u=i.useCallback(async p=>{o||(await a(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===p);return{...m,notifications:m.notifications.filter(v=>v.id!==p),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await Ku(r,p),await a())},[r,o,a]),d=i.useCallback(async()=>{await a()},[a]);return!n||o||h?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:s,refetch:d}:{loading:!1,error:s,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:u,refetch:d}}async function Qu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await W(r)).data}function Xu(){const{client:t,loading:r}=Ke(),{data:o,error:n,mutate:s}=Ze(r?null:"wacht-notifications:channel-counts",()=>Qu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),a=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:a}:{loading:!1,counts:o,error:n,refetch:a}}const ir=class ir{constructor(){dt(this,"ws",null);dt(this,"messageHandlers",new Set);dt(this,"connectionStateHandlers",new Set);dt(this,"reconnectTimer",null);dt(this,"reconnectAttempts",0);dt(this,"url",null);dt(this,"isIntentionalDisconnect",!1);dt(this,"sessionMessages",{});dt(this,"currentSessionKey",null)}static getInstance(){return ir.instance||(ir.instance=new ir),ir.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};dt(ir,"instance");let ms=ir;const at=ms.getInstance(),Rt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},He={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Zt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function ya(t){switch(t){case Zt.IDLE:return He.IDLE;case Zt.STARTING:return He.STARTING;case Zt.RUNNING:return He.RUNNING;case Zt.WAITING_FOR_INPUT:return He.WAITING_FOR_INPUT;case Zt.COMPLETED:return He.COMPLETED;case Zt.FAILED:case Zt.CANCELLED:return He.FAILED;default:return He.IDLE}}function wa(t){return t===He.STARTING||t===He.RUNNING||t===He.WAITING_FOR_INPUT}function Xc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:a}=ye(),{client:h}=Ke(),[f,c]=i.useState([]),[u,d]=i.useState(null),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(He.IDLE),[C,z]=i.useState({status:Rt.DISCONNECTED}),[w,y]=i.useState(!0),[g,_]=i.useState(!1),E=i.useRef(null),j=i.useRef(null),T=i.useCallback(B=>{var H,G;switch(B.message_type){case"session_connected":if(v(!0),z({status:Rt.CONNECTED}),(H=B.data)!=null&&H.execution_status){const oe=B.data.execution_status,te=ya(oe);S(te),k(wa(te))}break;case"conversation_message":R(B.data);break;case"user_input_request":M(B.data);break;case"platform_event":I(B.data);break;case"platform_function":O(B.data);break;case"execution_complete":k(!1),S(He.IDLE),j.current=null;break;case"execution_error":k(!1),S(He.FAILED),j.current=null;break;case"execution_cancelled":k(!1),S(He.IDLE),j.current=null;break;case"execution_status":const X=(G=B.data)==null?void 0:G.status;if(X){const oe=ya(X);S(oe),k(wa(oe))}break}},[u]),R=i.useCallback(B=>{var te,ce,Q,me,ve,de,U,le;const{id:H,message_type:G,content:X}=B,oe=K=>f.some(Z=>Z.id===K);if(G==="system_decision"||G==="action_execution_result"||G==="assistant_task_breakdown"||G==="assistant_validation"||G==="assistant_action_planning"||G==="context_results"){d(null),m(null);let K="";if(G==="system_decision"){const Z=X==null?void 0:X.step,re=X==null?void 0:X.reasoning;if(Z==="gathercontext")re&&re.length>0?K=re.length>60?`${re.substring(0,60)}...`:re:K="Gathering context...";else if(Z==="executeaction")K="Executing action";else if(Z==="deliverresponse")K="Preparing response";else if(Z==="taskplanning")K="Planning approach";else if(Z==="validateprogress")K="Validating progress";else if(Z==="acknowledge")K="Processing request";else if(Z==="finishplanning")K="Finalizing plan";else if(Z==="executetasks")K="Executing tasks";else if(Z==="requestuserinput")K="Waiting for input";else if(Z==="complete")K="Completed";else if(Z==="examinetool")K="Examining tool";else if(Z==="examineworkflow")K="Examining workflow";else{const fe=(X==null?void 0:X.confidence)||.5;fe>.8?K="Analyzing":fe>.6?K="Thinking":K="Reasoning"}}else if(G==="action_execution_result")((te=X.task_execution)==null?void 0:te.status)==="completed"?K="Task execution completed":(ce=X.task_execution)!=null&&ce.approach?K=X.task_execution.approach:K="Executing task";else if(G==="assistant_task_breakdown")(Q=X.task_breakdown)!=null&&Q.total_tasks?K=`Identified ${X.task_breakdown.total_tasks} tasks`:K="Planning tasks";else if(G==="assistant_validation")K="Validated results";else if(G==="assistant_action_planning")(me=X.task_execution)!=null&&me.total_tasks?K=`Planned ${X.task_execution.total_tasks} tasks`:(de=(ve=X.task_execution)==null?void 0:ve.tasks)!=null&&de.length?K=`Planned ${X.task_execution.tasks.length} tasks`:K="Planning actions";else if(G==="context_results"){const Z=X.query,re=X.result_count||0;Z&&Z!=="General context gathering"?K=`${Z}: Found ${re} results`:K=`Found ${re} results`}K&&!oe(H)&&c(Z=>[...Z,{id:H,role:"system",content:K,timestamp:new Date,metadata:{type:"log",messageType:G}}]);return}if(G==="user_message")oe(H)||(d(null),m(null),c(K=>[...K,{id:H,role:"user",content:X.message,images:X.images,timestamp:new Date}]));else if(G==="agent_response")oe(H)||(d(null),m(null),k(!1),S(He.IDLE),j.current=null,c(K=>[...K,{id:H,role:"assistant",content:X.response,timestamp:new Date,isStreaming:!1}]));else if(G==="assistant_acknowledgment")oe(H)||(d(null),m(null),c(K=>[...K,{id:H,role:"assistant",content:X.acknowledgment_message,timestamp:new Date}]));else if(G==="assistant_ideation"||G==="assistant_action_planning"||G==="action_execution_result"||G==="assistant_validation"||G==="assistant_context_gathering"||G==="assistant_task_breakdown"){let K="";if(X.reasoning_summary)K=X.reasoning_summary;else if((U=X.task_execution)!=null&&U.approach)K=X.task_execution.approach;else if(X.strategic_synthesis)K=X.strategic_synthesis;else if((le=X.task_breakdown)!=null&&le.total_tasks)K=`Breaking down into ${X.task_breakdown.total_tasks} tasks...`;else if(X.acknowledgment_message)K=X.acknowledgment_message;else return;c(Z=>[...Z,{id:H,role:"assistant",content:K,timestamp:new Date}])}else if(G==="user_input_request"){const K={question:X.question,context:X.context,input_type:X.input_type,options:X.options||X.suggestions,default_value:X.default_value,placeholder:X.placeholder};S("waiting_for_input"),c(Z=>[...Z,{id:H,role:"system",content:K.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:K}}])}},[]),M=i.useCallback(async B=>{S("waiting_for_input");const H=`input-request-${Date.now()}`;c(G=>[...G,{id:H,role:"system",content:B.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:B}}])},[]),I=i.useCallback(B=>{const{event_label:H,event_data:G}=B;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(H,G)},[n]),O=i.useCallback(async B=>{const{function_name:H,function_data:G}=B,{parameters:X,execution_id:oe}=G;if(!(n!=null&&n.onPlatformFunction)){at.send({message_type:{platform_function_result:[oe,{error:"No platform function handler registered"}]},data:{}});return}try{const te=await n.onPlatformFunction(H,X,oe),ce={message_type:{platform_function_result:[oe,te]},data:{}};at.send(ce)}catch(te){at.send({message_type:{platform_function_result:[oe,{error:te instanceof Error?te.message:"Function execution failed",stack:te instanceof Error?te.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!a)return;const H=`wss://${a==null?void 0:a.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;z({status:Rt.CONNECTING}),at.connect(H)},[a,o]),i.useEffect(()=>at.onConnectionStateChange(H=>{z({status:H.isConnected?Rt.CONNECTED:H.error?Rt.ERROR:Rt.DISCONNECTED}),v(H.isConnected)}),[]),i.useEffect(()=>at.onMessage(T),[T]),i.useEffect(()=>{x&&t&&r&&s&&at.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,s]);const N=i.useCallback(async()=>(x&&t&&r&&at.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),D=i.useCallback((B,H)=>{x&&(d(B),m(H||null),k(!0),S(He.STARTING),at.send({message_type:{message_input:B},data:H?{images:H}:{}}))},[x]),L=i.useCallback(()=>{c([]),j.current=null},[]),P=i.useCallback(B=>{!x||$!==He.WAITING_FOR_INPUT||(at.send({message_type:{user_input_response:B},data:{}}),S(He.RUNNING))},[x,$]),A=i.useCallback(async B=>{var H;if(!(!o||!t))try{const G=new URLSearchParams({token:o,limit:"50"});B&&(G.append("before_id",B),_(!0));const oe=await(await h(`/api/agent/contexts/${t}/messages?${G}`,{method:"GET"})).json();if(oe.status===200&&oe.data){const te=oe.data;if(Array.isArray(te.data)){const ce=te.data.filter(Q=>{var de;let me=Q.content;if(typeof Q.content=="string")try{me=JSON.parse(Q.content)}catch{me={message:Q.content}}const ve=((de=Q.metadata)==null?void 0:de.message_type)||(me==null?void 0:me.message_type);return ve==="user_message"||ve==="agent_response"||ve==="assistant_acknowledgment"||ve==="user_input_request"||ve==="system_decision"||ve==="action_execution_result"||ve==="assistant_task_breakdown"||ve==="assistant_validation"||ve==="assistant_action_planning"||ve==="context_results"}).map(Q=>{var K,Z,re,fe,ue,ee,V;let me="",ve,de,U=Q.content;if(typeof Q.content=="string")try{U=JSON.parse(Q.content)}catch{U=Q.content}const le=((K=Q.metadata)==null?void 0:K.message_type)||(U==null?void 0:U.message_type);if(le==="user_message"?(me=(U==null?void 0:U.message)||"",ve=(U==null?void 0:U.images)||void 0):le==="agent_response"?me=(U==null?void 0:U.response)||"":le==="assistant_acknowledgment"?me=(U==null?void 0:U.acknowledgment_message)||"":le==="user_input_request"&&(me=(U==null?void 0:U.question)||"",de={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),le==="system_decision"||le==="action_execution_result"||le==="assistant_task_breakdown"||le==="assistant_validation"||le==="assistant_action_planning"||le==="context_results"){let F="";if(le==="system_decision"){const ne=U==null?void 0:U.step,be=U==null?void 0:U.reasoning;if(ne==="gathercontext")be&&be.length>0?F=be.length>60?`${be.substring(0,60)}...`:be:F="Gathering context...";else if(ne==="executeaction")F="Executing action";else if(ne==="deliverresponse")F="Preparing response";else if(ne==="taskplanning")F="Planning approach";else if(ne==="validateprogress")F="Validating progress";else if(ne==="acknowledge")F="Processing request";else if(ne==="finishplanning")F="Finalizing plan";else if(ne==="executetasks")F="Executing tasks";else if(ne==="requestuserinput")F="Waiting for input";else if(ne==="complete")F="Completed";else if(ne==="examinetool")F="Examining tool";else if(ne==="examineworkflow")F="Examining workflow";else{const Me=(U==null?void 0:U.confidence)||.5;Me>.8?F="Analyzing":Me>.6?F="Thinking":F="Reasoning"}}else if(le==="action_execution_result")((Z=U==null?void 0:U.task_execution)==null?void 0:Z.status)==="completed"?F="Task execution completed":(re=U==null?void 0:U.task_execution)!=null&&re.approach?F=U.task_execution.approach:F="Executing task";else if(le==="assistant_task_breakdown")(fe=U==null?void 0:U.task_breakdown)!=null&&fe.total_tasks?F=`Identified ${U.task_breakdown.total_tasks} tasks`:F="Planning tasks";else if(le==="assistant_validation")F="Validated results";else if(le==="assistant_action_planning")(ue=U==null?void 0:U.task_execution)!=null&&ue.total_tasks?F=`Planned ${U.task_execution.total_tasks} tasks`:(V=(ee=U==null?void 0:U.task_execution)==null?void 0:ee.tasks)!=null&&V.length?F=`Planned ${U.task_execution.tasks.length} tasks`:F="Planning actions";else if(le==="context_results"){const ne=U==null?void 0:U.query,be=(U==null?void 0:U.result_count)||0;ne&&ne!=="General context gathering"?F=`${ne}: Found ${be} results`:F=`Found ${be} results`}me=F,de={type:"log",messageType:le}}return{id:Q.id,role:le==="user_message"?"user":le==="user_input_request"?"system":"assistant",content:me,images:ve,timestamp:new Date(Q.timestamp||Q.created_at||Date.now()),metadata:de}}).filter(Q=>Q.content||Q.metadata||Q.images).sort((Q,me)=>{const ve=BigInt(Q.id),de=BigInt(me.id);return ve<de?-1:ve>de?1:0});ce.length>0&&(E.current=ce[0].id),B?(c(Q=>[...ce,...Q]),y(ce.length>=50)):(c(ce),ce.length>0&&((H=ce[ce.length-1].metadata)==null?void 0:H.type)==="user_input_request"&&S(He.WAITING_FOR_INPUT)),_(!1)}}}catch(G){console.error("Failed to fetch messages:",G),_(!1)}},[o,t,h]);i.useEffect(()=>{t&&o&&A()},[t,o]);const q=i.useCallback(async()=>{if(!(g||!w||!E.current)){_(!0);try{await A(E.current)}finally{_(!1)}}},[g,w,A]),Y=i.useCallback(()=>{!x||!b||(at.send({message_type:{cancel_execution:null},data:{}}),k(!1),S("idle"))},[x,b]);return{messages:f,pendingMessage:u,pendingImages:p,connectionState:C,isConnected:x,isExecuting:b,executionStatus:$,isWaitingForInput:$==="waiting_for_input",hasMoreMessages:w,isLoadingMore:g,sendMessage:D,submitUserInput:P,clearMessages:L,loadMoreMessages:q,cancelExecution:Y,connect:N,disconnect:()=>at.disconnect()}}const Jc=()=>{const{client:t}=Ke(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,h]=i.useState(null),f=i.useCallback(async u=>{o(!0),s(null),h(null);try{const d=new FormData;d.append("token",u);const p=await t("/organizations/invitations/accept",{method:"POST",body:d}),x=(await W(p)).data;return h(x),x.error_code&&s(x.message||"Failed to accept invitation"),x}catch(d){const p=d.message||"Failed to accept invitation";s(p);const m={error_code:"NETWORK_ERROR",message:p};return h(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),h(null)},[]);return{acceptInvitation:f,invitationData:a,loading:r,error:n,reset:c}},Ju=({children:t})=>{const{loading:r}=ye();return r?null:e.jsx(e.Fragment,{children:t})},ep=({children:t})=>{const{loading:r}=ye();return r?e.jsx(e.Fragment,{children:t}):null};var nt=function(){return nt=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},nt.apply(this,arguments)};function fr(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,a;n<s;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}function tp(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var rp=/^((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|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|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)-.*))$/,op=tp(function(t){return rp.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Fe="-ms-",Kr="-moz-",Te="-webkit-",el="comm",sn="rule",Ms="decl",np="@import",tl="@keyframes",sp="@layer",rl=Math.abs,Os=String.fromCharCode,xs=Object.assign;function ap(t,r){return Xe(t,0)^45?(((r<<2^Xe(t,0))<<2^Xe(t,1))<<2^Xe(t,2))<<2^Xe(t,3):0}function ol(t){return t.trim()}function It(t,r){return(t=r.exec(t))?t[0]:t}function je(t,r,o){return t.replace(r,o)}function No(t,r,o){return t.indexOf(r,o)}function Xe(t,r){return t.charCodeAt(r)|0}function Er(t,r,o){return t.slice(r,o)}function vt(t){return t.length}function nl(t){return t.length}function Yr(t,r){return r.push(t),t}function ip(t,r){return t.map(r).join("")}function ja(t,r){return t.filter(function(o){return!It(o,r)})}var an=1,Pr=1,sl=0,ct=0,qe=0,Or="";function cn(t,r,o,n,s,a,h,f){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:an,column:Pr,length:h,return:"",siblings:f}}function Dt(t,r){return xs(cn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function vr(t){for(;t.root;)t=Dt(t.root,{children:[t]});Yr(t,t.siblings)}function cp(){return qe}function lp(){return qe=ct>0?Xe(Or,--ct):0,Pr--,qe===10&&(Pr=1,an--),qe}function ut(){return qe=ct<sl?Xe(Or,ct++):0,Pr++,qe===10&&(Pr=1,an++),qe}function lr(){return Xe(Or,ct)}function Fo(){return ct}function ln(t,r){return Er(Or,t,r)}function vs(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 dp(t){return an=Pr=1,sl=vt(Or=t),ct=0,[]}function up(t){return Or="",t}function En(t){return ol(ln(ct-1,bs(t===91?t+2:t===40?t+1:t)))}function pp(t){for(;(qe=lr())&&qe<33;)ut();return vs(t)>2||vs(qe)>3?"":" "}function hp(t,r){for(;--r&&ut()&&!(qe<48||qe>102||qe>57&&qe<65||qe>70&&qe<97););return ln(t,Fo()+(r<6&&lr()==32&&ut()==32))}function bs(t){for(;ut();)switch(qe){case t:return ct;case 34:case 39:t!==34&&t!==39&&bs(qe);break;case 40:t===41&&bs(t);break;case 92:ut();break}return ct}function fp(t,r){for(;ut()&&t+qe!==57;)if(t+qe===84&&lr()===47)break;return"/*"+ln(r,ct-1)+"*"+Os(t===47?t:ut())}function gp(t){for(;!vs(lr());)ut();return ln(t,ct)}function mp(t){return up(Bo("",null,null,null,[""],t=dp(t),0,[0],t))}function Bo(t,r,o,n,s,a,h,f,c){for(var u=0,d=0,p=h,m=0,x=0,v=0,b=1,k=1,$=1,S=0,C="",z=s,w=a,y=n,g=C;k;)switch(v=S,S=ut()){case 40:if(v!=108&&Xe(g,p-1)==58){No(g+=je(En(S),"&","&\f"),"&\f",rl(u?f[u-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:g+=En(S);break;case 9:case 10:case 13:case 32:g+=pp(v);break;case 92:g+=hp(Fo()-1,7);continue;case 47:switch(lr()){case 42:case 47:Yr(xp(fp(ut(),Fo()),r,o,c),c);break;default:g+="/"}break;case 123*b:f[u++]=vt(g)*$;case 125*b:case 59:case 0:switch(S){case 0:case 125:k=0;case 59+d:$==-1&&(g=je(g,/\f/g,"")),x>0&&vt(g)-p&&Yr(x>32?_a(g+";",n,o,p-1,c):_a(je(g," ","")+";",n,o,p-2,c),c);break;case 59:g+=";";default:if(Yr(y=ka(g,r,o,u,d,s,f,C,z=[],w=[],p,a),a),S===123)if(d===0)Bo(g,r,y,y,z,a,p,f,w);else switch(m===99&&Xe(g,3)===110?100:m){case 100:case 108:case 109:case 115:Bo(t,y,y,n&&Yr(ka(t,y,y,0,0,s,f,C,s,z=[],p,w),w),s,w,p,f,n?z:w);break;default:Bo(g,y,y,y,[""],w,0,f,w)}}u=d=x=0,b=$=1,C=g="",p=h;break;case 58:p=1+vt(g),x=v;default:if(b<1){if(S==123)--b;else if(S==125&&b++==0&&lp()==125)continue}switch(g+=Os(S),S*b){case 38:$=d>0?1:(g+="\f",-1);break;case 44:f[u++]=(vt(g)-1)*$,$=1;break;case 64:lr()===45&&(g+=En(ut())),m=lr(),d=p=vt(C=g+=gp(Fo())),S++;break;case 45:v===45&&vt(g)==2&&(b=0)}}return a}function ka(t,r,o,n,s,a,h,f,c,u,d,p){for(var m=s-1,x=s===0?a:[""],v=nl(x),b=0,k=0,$=0;b<n;++b)for(var S=0,C=Er(t,m+1,m=rl(k=h[b])),z=t;S<v;++S)(z=ol(k>0?x[S]+" "+C:je(C,/&\f/g,x[S])))&&(c[$++]=z);return cn(t,r,o,s===0?sn:f,c,u,d,p)}function xp(t,r,o,n){return cn(t,r,o,el,Os(cp()),Er(t,2,-2),0,n)}function _a(t,r,o,n,s){return cn(t,r,o,Ms,Er(t,0,n),Er(t,n+1,-1),n,s)}function al(t,r,o){switch(ap(t,r)){case 5103:return Te+"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 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Te+t+t;case 4789:return Kr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Te+t+Kr+t+Fe+t+t;case 5936:switch(Xe(t,r+11)){case 114:return Te+t+Fe+je(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Te+t+Fe+je(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Te+t+Fe+je(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Te+t+Fe+t+t;case 6165:return Te+t+Fe+"flex-"+t+t;case 5187:return Te+t+je(t,/(\w+).+(:[^]+)/,Te+"box-$1$2"+Fe+"flex-$1$2")+t;case 5443:return Te+t+Fe+"flex-item-"+je(t,/flex-|-self/g,"")+(It(t,/flex-|baseline/)?"":Fe+"grid-row-"+je(t,/flex-|-self/g,""))+t;case 4675:return Te+t+Fe+"flex-line-pack"+je(t,/align-content|flex-|-self/g,"")+t;case 5548:return Te+t+Fe+je(t,"shrink","negative")+t;case 5292:return Te+t+Fe+je(t,"basis","preferred-size")+t;case 6060:return Te+"box-"+je(t,"-grow","")+Te+t+Fe+je(t,"grow","positive")+t;case 4554:return Te+je(t,/([^-])(transform)/g,"$1"+Te+"$2")+t;case 6187:return je(je(je(t,/(zoom-|grab)/,Te+"$1"),/(image-set)/,Te+"$1"),t,"")+t;case 5495:case 3959:return je(t,/(image-set\([^]*)/,Te+"$1$`$1");case 4968:return je(je(t,/(.+:)(flex-)?(.*)/,Te+"box-pack:$3"+Fe+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Te+t+t;case 4200:if(!It(t,/flex-|baseline/))return Fe+"grid-column-align"+Er(t,r)+t;break;case 2592:case 3360:return Fe+je(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,It(n.props,/grid-\w+-end/)})?~No(t+(o=o[r].value),"span",0)?t:Fe+je(t,"-start","")+t+Fe+"grid-row-span:"+(~No(o,"span",0)?It(o,/\d+/):+It(o,/\d+/)-+It(t,/\d+/))+";":Fe+je(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return It(n.props,/grid-\w+-start/)})?t:Fe+je(je(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return je(t,/(.+)-inline(.+)/,Te+"$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(vt(t)-1-r>6)switch(Xe(t,r+1)){case 109:if(Xe(t,r+4)!==45)break;case 102:return je(t,/(.+:)(.+)-([^]+)/,"$1"+Te+"$2-$3$1"+Kr+(Xe(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~No(t,"stretch",0)?al(je(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return je(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,a,h,f,c,u){return Fe+s+":"+a+u+(h?Fe+s+"-span:"+(f?c:+c-+a)+u:"")+t});case 4949:if(Xe(t,r+6)===121)return je(t,":",":"+Te)+t;break;case 6444:switch(Xe(t,Xe(t,14)===45?18:11)){case 120:return je(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Te+(Xe(t,14)===45?"inline-":"")+"box$3$1"+Te+"$2$3$1"+Fe+"$2box$3")+t;case 100:return je(t,":",":"+Fe)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return je(t,"scroll-","scroll-snap-")+t}return t}function qo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function vp(t,r,o,n){switch(t.type){case sp:if(t.children.length)break;case np:case Ms:return t.return=t.return||t.value;case el:return"";case tl:return t.return=t.value+"{"+qo(t.children,n)+"}";case sn:if(!vt(t.value=t.props.join(",")))return""}return vt(o=qo(t.children,n))?t.return=t.value+"{"+o+"}":""}function bp(t){var r=nl(t);return function(o,n,s,a){for(var h="",f=0;f<r;f++)h+=t[f](o,n,s,a)||"";return h}}function yp(t){return function(r){r.root||(r=r.return)&&t(r)}}function wp(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case Ms:t.return=al(t.value,t.length,o);return;case tl:return qo([Dt(t,{value:je(t.value,"@","@"+Te)})],n);case sn:if(t.length)return ip(o=t.props,function(s){switch(It(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":vr(Dt(t,{props:[je(s,/:(read-\w+)/,":"+Kr+"$1")]})),vr(Dt(t,{props:[s]})),xs(t,{props:ja(o,n)});break;case"::placeholder":vr(Dt(t,{props:[je(s,/:(plac\w+)/,":"+Te+"input-$1")]})),vr(Dt(t,{props:[je(s,/:(plac\w+)/,":"+Kr+"$1")]})),vr(Dt(t,{props:[je(s,/:(plac\w+)/,Fe+"input-$1")]})),vr(Dt(t,{props:[s]})),xs(t,{props:ja(o,n)});break}return""})}}var jp={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,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},gr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",il="active",cl="data-styled-version",dn="6.1.19",As=`/*!sc*/
19
- `,Yo=typeof window<"u"&&typeof document<"u",kp=!!(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"),Ca=/invalid hook call/i,co=new Set,_p=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
18
+ */var pa;function Yd(){return pa||(pa=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){d||s.startTransition===void 0||(d=!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 b=v();if(!p){var k=v();a(b,k)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),p=!0)}k=h({inst:{value:b,getSnapshot:v}});var $=k[0].inst,S=k[1];return c(function(){$.value=b,$.getSnapshot=v,o($)&&S({inst:$})},[x,b,v]),f(function(){return o($)&&S({inst:$}),x(function(){o($)&&S({inst:$})})},[x]),u(b),b}function o(x){var v=x.getSnapshot;x=x.value;try{var b=v();return!a(x,b)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=i,a=typeof Object.is=="function"?Object.is:t,h=s.useState,f=s.useEffect,c=s.useLayoutEffect,u=s.useDebugValue,d=!1,p=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;yn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),yn}var ha;function Zd(){return ha||(ha=1,process.env.NODE_ENV==="production"?so.exports=qd():so.exports=Yd()),so.exports}var Kd=Zd();const Pc=0,Ic=1,Rc=2,fa=3;var ga=Object.prototype.hasOwnProperty;function is(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&is(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(ga.call(t,o)&&++n&&!ga.call(r,o)||!(o in r)||!is(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const Tt=new WeakMap,Nt=()=>{},ot=Nt(),cs=Object,Pe=t=>t===ot,bt=t=>typeof t=="function",Bt=(t,r)=>({...t,...r}),Tc=t=>bt(t.then),wn={},ao={},Rs="undefined",to=typeof window!=Rs,ls=typeof document!=Rs,Qd=to&&"Deno"in window,Xd=()=>to&&typeof window.requestAnimationFrame!=Rs,Mc=(t,r)=>{const o=Tt.get(t);return[()=>!Pe(r)&&t.get(r)||wn,n=>{if(!Pe(r)){const s=t.get(r);r in ao||(ao[r]=s),o[5](r,Bt(s,n),s||wn)}},o[6],()=>!Pe(r)&&r in ao?ao[r]:!Pe(r)&&t.get(r)||wn]};let ds=!0;const Jd=()=>ds,[us,ps]=to&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Nt,Nt],eu=()=>{const t=ls&&document.visibilityState;return Pe(t)||t!=="hidden"},tu=t=>(ls&&document.addEventListener("visibilitychange",t),us("focus",t),()=>{ls&&document.removeEventListener("visibilitychange",t),ps("focus",t)}),ru=t=>{const r=()=>{ds=!0,t()},o=()=>{ds=!1};return us("online",r),us("offline",o),()=>{ps("online",r),ps("offline",o)}},ou={isOnline:Jd,isVisible:eu},nu={initFocus:tu,initReconnect:ru},ma=!i.useId,Xr=!to||Qd,su=t=>Xd()?window.requestAnimationFrame(t):setTimeout(t,1),jn=Xr?i.useEffect:i.useLayoutEffect,kn=typeof navigator<"u"&&navigator.connection,xa=!Xr&&kn&&(["slow-2g","2g"].includes(kn.effectiveType)||kn.saveData),io=new WeakMap,au=t=>cs.prototype.toString.call(t),_n=(t,r)=>t===`[object ${r}]`;let iu=0;const hs=t=>{const r=typeof t,o=au(t),n=_n(o,"Date"),s=_n(o,"RegExp"),a=_n(o,"Object");let h,f;if(cs(t)===t&&!n&&!s){if(h=io.get(t),h)return h;if(h=++iu+"~",io.set(t,h),Array.isArray(t)){for(h="@",f=0;f<t.length;f++)h+=hs(t[f])+",";io.set(t,h)}if(a){h="#";const c=cs.keys(t).sort();for(;!Pe(f=c.pop());)Pe(t[f])||(h+=f+":"+hs(t[f])+",");io.set(t,h)}}else h=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return h},Ts=t=>{if(bt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?hs(t):"",[t,r]};let cu=0;const fs=()=>++cu;async function Oc(...t){const[r,o,n,s]=t,a=Bt({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let h=a.populateCache;const f=a.rollbackOnError;let c=a.optimisticData;const u=m=>typeof f=="function"?f(m):f!==!1,d=a.throwOnError;if(bt(o)){const m=o,x=[],v=r.keys();for(const b of v)!/^\$(inf|sub)\$/.test(b)&&m(r.get(b)._k)&&x.push(b);return Promise.all(x.map(p))}return p(o);async function p(m){const[x]=Ts(m);if(!x)return;const[v,b]=Mc(r,x),[k,$,S,C]=Tt.get(r),z=()=>{const I=k[x];return(bt(a.revalidate)?a.revalidate(v().data,m):a.revalidate!==!1)&&(delete S[x],delete C[x],I&&I[0])?I[0](Rc).then(()=>v().data):v().data};if(t.length<3)return z();let w=n,y,g=!1;const _=fs();$[x]=[_,0];const E=!Pe(c),j=v(),T=j.data,R=j._c,M=Pe(R)?T:R;if(E&&(c=bt(c)?c(M,T):c,b({data:c,_c:M})),bt(w))try{w=w(M)}catch(I){y=I,g=!0}if(w&&Tc(w))if(w=await w.catch(I=>{y=I,g=!0}),_!==$[x][0]){if(g)throw y;return w}else g&&E&&u(y)&&(h=!0,b({data:M,_c:ot}));if(h&&!g)if(bt(h)){const I=h(w,M);b({data:I,error:ot,_c:ot})}else b({data:w,error:ot,_c:ot});if($[x][1]=fs(),Promise.resolve(z()).then(()=>{b({_c:ot})}),g){if(d)throw y;return}return w}}const va=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},lu=(t,r)=>{if(!Tt.has(t)){const o=Bt(nu,r),n=Object.create(null),s=Oc.bind(ot,t);let a=Nt;const h=Object.create(null),f=(d,p)=>{const m=h[d]||[];return h[d]=m,m.push(p),()=>m.splice(m.indexOf(p),1)},c=(d,p,m)=>{t.set(d,p);const x=h[d];if(x)for(const v of x)v(p,m)},u=()=>{if(!Tt.has(t)&&(Tt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,f]),!Xr)){const d=o.initFocus(setTimeout.bind(ot,va.bind(ot,n,Pc))),p=o.initReconnect(setTimeout.bind(ot,va.bind(ot,n,Ic)));a=()=>{d&&d(),p&&p(),Tt.delete(t)}}};return u(),[t,s,u,a]}return[t,Tt.get(t)[4]]},du=(t,r,o,n,s)=>{const a=o.errorRetryCount,h=s.retryCount,f=~~((Math.random()+.5)*(1<<(h<8?h:8)))*o.errorRetryInterval;!Pe(a)&&h>a||setTimeout(n,f,s)},uu=is,[Ac,Hr]=lu(new Map),pu=Bt({onLoadingSlow:Nt,onSuccess:Nt,onError:Nt,onErrorRetry:du,onDiscarded:Nt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:xa?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:xa?5e3:3e3,compare:uu,isPaused:()=>!1,cache:Ac,mutate:Hr,fallback:{}},ou),hu=(t,r)=>{const o=Bt(t,r);if(r){const{use:n,fallback:s}=t,{use:a,fallback:h}=r;n&&a&&(o.use=n.concat(a)),s&&h&&(o.fallback=Bt(s,h))}return o},fu=i.createContext({}),gu="$inf$",Lc=to&&window.__SWR_DEVTOOLS_USE__,mu=Lc?window.__SWR_DEVTOOLS_USE__:[],xu=()=>{Lc&&(window.__SWR_DEVTOOLS_REACT__=i)},vu=t=>bt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Dc=()=>Bt(pu,i.useContext(fu)),bu=t=>(r,o,n)=>t(r,o&&((...a)=>{const[h]=Ts(r),[,,,f]=Tt.get(Ac);if(h.startsWith(gu))return o(...a);const c=f[h];return Pe(c)?o(...a):(delete f[h],c)}),n),yu=mu.concat(bu),wu=t=>function(...o){const n=Dc(),[s,a,h]=vu(o),f=hu(n,h);let c=t;const{use:u}=f,d=(u||[]).concat(yu);for(let p=d.length;p--;)c=d[p](c);return c(s,a||f.fetcher||null,f)},ju=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};xu();const Cn=i.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}}),Sn={dedupe:!0},ku=(t,r,o)=>{const{cache:n,compare:s,suspense:a,fallbackData:h,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:u,refreshWhenHidden:d,refreshWhenOffline:p,keepPreviousData:m}=o,[x,v,b,k]=Tt.get(n),[$,S]=Ts(t),C=i.useRef(!1),z=i.useRef(!1),w=i.useRef($),y=i.useRef(r),g=i.useRef(o),_=()=>g.current,E=()=>_().isVisible()&&_().isOnline(),[j,T,R,M]=Mc(n,$),I=i.useRef({}).current,O=Pe(h)?Pe(o.fallback)?ot:o.fallback[$]:h,N=(de,U)=>{for(const le in I){const K=le;if(K==="data"){if(!s(de[K],U[K])&&(!Pe(de[K])||!s(G,U[K])))return!1}else if(U[K]!==de[K])return!1}return!0},D=i.useMemo(()=>{const de=!$||!r?!1:Pe(f)?_().isPaused()||a?!1:c!==!1:f,U=ue=>{const ee=Bt(ue);return delete ee._k,de?{isValidating:!0,isLoading:!0,...ee}:ee},le=j(),K=M(),Z=U(le),re=le===K?Z:U(K);let ge=Z;return[()=>{const ue=U(j());return N(ue,ge)?(ge.data=ue.data,ge.isLoading=ue.isLoading,ge.isValidating=ue.isValidating,ge.error=ue.error,ge):(ge=ue,ue)},()=>re]},[n,$]),L=Kd.useSyncExternalStore(i.useCallback(de=>R($,(U,le)=>{N(le,U)||de()}),[n,$]),D[0],D[1]),P=!C.current,A=x[$]&&x[$].length>0,q=L.data,Y=Pe(q)?O&&Tc(O)?Cn(O):O:q,B=L.error,H=i.useRef(Y),G=m?Pe(q)?Pe(H.current)?Y:H.current:q:Y,X=A&&!Pe(B)?!1:P&&!Pe(f)?f:_().isPaused()?!1:a?Pe(Y)?!1:c:Pe(Y)||c,oe=!!($&&r&&P&&X),te=Pe(L.isValidating)?oe:L.isValidating,ce=Pe(L.isLoading)?oe:L.isLoading,Q=i.useCallback(async de=>{const U=y.current;if(!$||!U||z.current||_().isPaused())return!1;let le,K,Z=!0;const re=de||{},ge=!b[$]||!re.dedupe,ue=()=>ma?!z.current&&$===w.current&&C.current:$===w.current,ee={isValidating:!1,isLoading:!1},V=()=>{T(ee)},F=()=>{const be=b[$];be&&be[1]===K&&delete b[$]},ne={isValidating:!0};Pe(j().data)&&(ne.isLoading=!0);try{if(ge&&(T(ne),o.loadingTimeout&&Pe(j().data)&&setTimeout(()=>{Z&&ue()&&_().onLoadingSlow($,o)},o.loadingTimeout),b[$]=[U(S),fs()]),[le,K]=b[$],le=await le,ge&&setTimeout(F,o.dedupingInterval),!b[$]||b[$][1]!==K)return ge&&ue()&&_().onDiscarded($),!1;ee.error=ot;const be=v[$];if(!Pe(be)&&(K<=be[0]||K<=be[1]||be[1]===0))return V(),ge&&ue()&&_().onDiscarded($),!1;const Me=j().data;ee.data=s(Me,le)?Me:le,ge&&ue()&&_().onSuccess(le,$,o)}catch(be){F();const Me=_(),{shouldRetryOnError:Ce}=Me;Me.isPaused()||(ee.error=be,ge&&ue()&&(Me.onError(be,$,Me),(Ce===!0||bt(Ce)&&Ce(be))&&(!_().revalidateOnFocus||!_().revalidateOnReconnect||E())&&Me.onErrorRetry(be,$,Me,Se=>{const Ve=x[$];Ve&&Ve[0]&&Ve[0](fa,Se)},{retryCount:(re.retryCount||0)+1,dedupe:!0})))}return Z=!1,V(),!0},[$,n]),me=i.useCallback((...de)=>Oc(n,w.current,...de),[]);if(jn(()=>{y.current=r,g.current=o,Pe(q)||(H.current=q)}),jn(()=>{if(!$)return;const de=Q.bind(ot,Sn);let U=0;_().revalidateOnFocus&&(U=Date.now()+_().focusThrottleInterval);const K=ju($,x,(Z,re={})=>{if(Z==Pc){const ge=Date.now();_().revalidateOnFocus&&ge>U&&E()&&(U=ge+_().focusThrottleInterval,de())}else if(Z==Ic)_().revalidateOnReconnect&&E()&&de();else{if(Z==Rc)return Q();if(Z==fa)return Q(re)}});return z.current=!1,w.current=$,C.current=!0,T({_k:S}),X&&(b[$]||(Pe(Y)||Xr?de():su(de))),()=>{z.current=!0,K()}},[$]),jn(()=>{let de;function U(){const K=bt(u)?u(j().data):u;K&&de!==-1&&(de=setTimeout(le,K))}function le(){!j().error&&(d||_().isVisible())&&(p||_().isOnline())?Q(Sn).then(U):U()}return U(),()=>{de&&(clearTimeout(de),de=-1)}},[u,d,p,$]),i.useDebugValue(G),a&&Pe(Y)&&$){if(!ma&&Xr)throw new Error("Fallback data is required when using Suspense in SSR.");y.current=r,g.current=o,z.current=!1;const de=k[$];if(!Pe(de)){const U=me(de);Cn(U)}if(Pe(B)){const U=Q(Sn);Pe(G)||(U.status="fulfilled",U.value=!0),Cn(U)}else throw B}return{mutate:me,get data(){return I.data=!0,G},get error(){return I.error=!0,B},get isValidating(){return I.isValidating=!0,te},get isLoading(){return I.isLoading=!0,ce}}},Ze=wu(ku);async function W(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function Nc(t){const{client:r}=Ke(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await W(c)).data},[r,t]),{data:n,error:s,mutate:a}=Ze(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),h=i.useCallback(async c=>{const u=new FormData;u.append("title",c.title),c.system_instructions&&u.append("system_instructions",c.system_instructions);const d=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:u}),p=await W(d);return await a(m=>m&&{...m,data:[p.data,...m.data]}),p.data},[r,t,a]),f=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await a(u=>u&&{...u,data:u.data.filter(d=>d.id!==c)})},[r,t,a]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:h,deleteSession:f,refetch:async()=>{await a()}}}const Fc=i.createContext(void 0);function rn(){const t=i.useContext(Fc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function _u({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:a,onSessionDeleted:h,onError:f}){const[c,u]=i.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[d,p]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:b,deleteSession:k,refetch:$}=Nc(o);i.useEffect(()=>{if(s&&m.length>0){const y=m.find(g=>g.id===s);y&&u(y)}},[s,m]);const S=i.useCallback(y=>{u(y),p(!1)},[]),C=i.useCallback(async y=>{try{const g=y||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,_=await b({title:g});return u(_),a==null||a(_),_}catch(g){const _=g instanceof Error?g.message:"Failed to create session";throw f==null||f(_),g}},[b,a,f]),z=i.useCallback(async y=>{try{await k(y),(c==null?void 0:c.id)===y&&u(null),h==null||h(y)}catch(g){const _=g instanceof Error?g.message:"Failed to delete session";throw f==null||f(_),g}},[k,c,h,f]),w={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:S,createSession:C,deleteSession:z,refreshSessions:$,showHistory:d,setShowHistory:p,onSessionCreated:a,onSessionDeleted:h,onError:f};return e.jsx(Fc.Provider,{value:w,children:t})}var Bc=(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))(Bc||{});function Cu(t,r){const o={username:Su(t,r),email:$u(t,r),phone:zu(t,r),email_otp:Eu(t,r),magic_link:Pu(t,r),oauth:Iu(t),passkey:Ru(t),generic:Tu(t,r)};return function(s){return o[s]}}function Su(t,r){return async({username:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(h.data.signin_attempts.at(-1)||null),h}}function $u(t,r){return async({email:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(h.data.signin_attempts.at(-1)||null),h}}function zu(t,r){return async({phone:o})=>{var h,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Eu(t,r){return async({email:o})=>{var h,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Pu(t,r){return async({email:o})=>{var h,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await W(s);return"data"in a&&((f=(h=a.data)==null?void 0:h.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function Iu(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),a=await W(s);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function Nr(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ba(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),s=new Uint8Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return s.buffer}function Ru(t){return async()=>{var u;const r=await t("/auth/passkey/login/begin",{method:"POST"}),o=await W(r);if(!("data"in o))return o;const n=o.data.options.publicKey,s={challenge:ba(n.challenge),timeout:n.timeout,rpId:n.rpId,userVerification:n.userVerification,allowCredentials:(u=n.allowCredentials)==null?void 0:u.map(d=>({type:d.type,id:ba(d.id),transports:d.transports}))};let a;try{const d=await navigator.credentials.get({publicKey:s});if(!d)throw new Error("Failed to get credential");a=d}catch(d){throw d.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):d.name==="AbortError"?new Error("Passkey sign-in was cancelled."):d}const h=a.response,f=new FormData;f.append("id",a.id),f.append("rawId",Nr(a.rawId)),f.append("type",a.type),f.append("clientDataJSON",Nr(h.clientDataJSON)),f.append("authenticatorData",Nr(h.authenticatorData)),f.append("signature",Nr(h.signature)),h.userHandle&&f.append("userHandle",Nr(h.userHandle));const c=await t("/auth/passkey/login/finish",{method:"POST",body:f});return W(c)}}function Tu(t,r){return async({email:o,username:n,password:s,phone:a,strategy:h,token:f})=>{var p,m;const c=new FormData;h&&c.append("strategy",h),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),a&&c.append("phone",a),f&&c.append("token",f);const u=await t("/auth/signin",{method:"POST",body:c}),d=await W(u);return"data"in d&&((m=(p=d.data)==null?void 0:p.signin_attempts)!=null&&m.length)&&r(d.data.signin_attempts.at(-1)||null),d}}function Uc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Cu(t,n),completeVerification:async s=>{var c,u;const a=new FormData;a.append("verification_code",s);const h=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:a}),f=await W(h);if("data"in f&&((u=(c=f.data)==null?void 0:c.signin_attempts)!=null&&u.length)){const d=f.data.signin_attempts.at(-1);return n(d||null),f.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var f;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),a.searchParams.set("strategy",s.strategy),a.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?a.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&a.searchParams.set("redirect_uri",s.redirectUri);const h=await t(a.pathname+a.search,{method:"POST"});return W(h)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const a=new FormData;for(const[u,d]of Object.entries(s))d&&a.append(u,d);const h=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:a}),f=await W(h);if("data"in f&&f.data){const u=(c=f.data.signin_attempts)==null?void 0:c.find(d=>d.id===o.id);return u&&n(u),f.data}else throw new Error("Profile completion failed")},identify:async s=>{const a=new FormData;a.append("identifier",s);const h=await t("/auth/identify",{method:"POST",body:a});return(await W(h)).data},initEnterpriseSso:async(s,a)=>{const h=new URLSearchParams({connection_id:s});a&&h.append("redirect_uri",a);const f=await t(`/auth/sso/login?${h.toString()}`,{method:"POST"});return(await W(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function zr(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:a}=Uc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:a};const h=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"passkey":return o.createStrategy("passkey");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:h,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:a}}function Mu(t,r,o){return{create:async n=>{var f,c,u;const s=new FormData;for(const[d,p]of Object.entries(n))s.append(d,p);const a=await t("/auth/signup",{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((u=h.data.signup_attempts)==null?void 0:u.at(-1))||null),h},prepareVerification:async n=>{var h;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((h=r==null?void 0:r.id)==null?void 0:h.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const a=await t(s.pathname+s.search,{method:"POST"});return W(a)},completeVerification:async n=>{var f,c;const s=new FormData;s.append("verification_code",n);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),h=await W(a);return"data"in h&&((c=(f=h.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(h.data.signup_attempts.at(-1)||null),h},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),a=await W(s);return"data"in a&&a.data?a.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function Wc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Mu(t,o,n)}}const rt=()=>{const{adapter:t,deployment:r}=we(),o=t.useNavigate(),n=(c,u)=>{o?o(c,u):window.location.href=c},s=c=>{if(c)return c;const d=new URLSearchParams(window.location.search).get("redirect_uri");return d||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${d.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${d.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const u=s(c),d=new URLSearchParams;d.set("redirect_uri",u),(r==null?void 0:r.mode)==="staging"&&d.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${d.toString()}`,{replace:!0})}}};async function Ou(t){const r=await t("/session",{method:"GET"});return(await W(r)).data}async function Au(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return W(o)}async function Lu(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return W(n)}async function Du(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return W(o)}async function Nu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return W(o)}const gs=new Map,qr=new Map;function Mt(){gs.clear(),qr.clear()}async function Fu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return W(o)}function Qe(){const{client:t,loading:r}=Ke(),{deployment:o}=we(),{navigate:n}=rt(),{cache:s}=Dc(),{data:a,error:h,mutate:f,isLoading:c}=Ze(r?null:"/session",()=>Ou(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),d=i.useCallback(async(p="default")=>{if(!a)throw new Error("no session");const m=gs.get(p);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";qr.get(p)||qr.set(p,Fu(t,p));const x=await qr.get(p);return qr.delete(p),gs.set(p,x.data),x.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||c?{loading:!0,error:h,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:u}:{loading:c,error:h,session:a,switchSignIn:async p=>{await Au(t,p),Mt(),await Hr("/me/organization-memberships",void 0,{revalidate:!1}),await Hr("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Hr("/me/organization-memberships"),await Hr("/me/workspace-memberships")},signOut:async p=>{await Lu(t,p);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const v=Array.from(s.keys());for(const b of v){let k=!1;(m.includes(b)||typeof b=="string"&&x.some($=>b.startsWith($)))&&(k=!0),k&&s.delete(b)}}Mt(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(p&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!p&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async p=>{await Du(t,p),Mt(),await f(void 0,{revalidate:!0})},switchWorkspace:async p=>{await Nu(t,p),Mt(),await f(void 0,{revalidate:!0})},getToken:d,refetch:u}}const on=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{client:n}=Ke(),{refetch:s}=Qe(),a=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),h=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),u=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/members/${P.id}/remove`,{method:"POST"})},[n]),d=i.useCallback(async L=>{const P=new FormData;P.append("name",L.name),L.image&&P.append("image",L.image),L.description&&P.append("description",L.description);const A=await W(await n("/organizations",{method:"POST",body:P}));return Mt(),await r(),await s(),A},[s,r,n]),p=i.useCallback(async(L,P)=>{const A=Object.entries(P).reduce((Y,[B,H])=>(H&&Y.append(B,H),Y),new FormData),q=await W(await n(`/organizations/${L.id}/update`,{method:"POST",body:A}));return await r(),q},[r,n]),m=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/roles/${P.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("domain",P.fqdn),await W(await n(`/organizations/${L.id}/domains`,{method:"POST",body:A}))},[n]),v=i.useCallback(async(L,P)=>await W(await n(`/organizations/${L.id}/domains/${P.id}/verify`,{method:"POST"})),[n]),b=i.useCallback(async(L,P)=>await W(await n(`/organizations/${L.id}/domains/${P.id}/delete`,{method:"POST"})),[n]),k=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),$=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("protocol",P.protocol),P.domain_id&&A.append("domain_id",P.domain_id),P.idp_entity_id&&A.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&A.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&A.append("idp_certificate",P.idp_certificate),P.oidc_client_id&&A.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&A.append("oidc_client_secret",P.oidc_client_secret),P.oidc_issuer_url&&A.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_scopes&&A.append("oidc_scopes",P.oidc_scopes),P.jit_enabled!==void 0&&A.append("jit_enabled",String(P.jit_enabled)),P.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(P.attribute_mapping)),(await W(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),S=i.useCallback(async(L,P,A)=>{const q=new FormData;return A.domain_id&&q.append("domain_id",A.domain_id),A.idp_entity_id&&q.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&q.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&q.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&q.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&q.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&q.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&q.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&q.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/update`,{method:"POST",body:q}))).data},[n]),C=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/enterprise-connections/${P}/delete`,{method:"POST"})},[n]),z=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("protocol",P.protocol),P.idp_entity_id&&A.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&A.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&A.append("idp_certificate",P.idp_certificate),P.oidc_issuer_url&&A.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_client_id&&A.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&A.append("oidc_client_secret",P.oidc_client_secret),(await W(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/test`,{method:"POST"}))).data,[n]),y=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token`,{method:"POST"}))).data,[n]),g=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token`,{method:"GET"}))).data,[n]),_=i.useCallback(async(L,P)=>{await n(`/organizations/${L.id}/enterprise-connections/${P}/scim/token/revoke`,{method:"POST"})},[n]),E=i.useCallback(async(L,P)=>{const A=new FormData;return A.append("name",P.name),P.permissions&&P.permissions.forEach((Y,B)=>{A.append(`permissions[${B}]`,Y)}),await W(await n(`/organizations/${L.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async L=>(await W(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async L=>{const P=await W(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return Mt(),await r(),await s(),P.data},[n,r,s]),R=i.useCallback(async(L,P,A)=>(await W(await n(`/organizations/${L.id}/members/${P.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),M=i.useCallback(async(L,P,A)=>(await W(await n(`/organizations/${L.id}/members/${P.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=i.useCallback(async(L,P)=>{var Y,B;const A=new FormData;return A.append("email",P.email),A.append("role_id",P.organizationRole.id),(Y=P.workspace)!=null&&Y.id&&A.append("workspace_id",P.workspace.id),(B=P.workspaceRole)!=null&&B.id&&A.append("workspace_role_id",P.workspaceRole.id),(await W(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:A}))).data},[n]),O=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/invitations/${P.id}/discard`,{method:"POST"}))).data,[n]),N=i.useCallback(async(L,P)=>(await W(await n(`/organizations/${L.id}/invitations/${P.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:h,removeOrganizationMember:u,createOrganization:d,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:b,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:M,inviteOrganizationMember:I,discardOrganizationInvitation:O,resendOrganizationInvitation:N,updateOrganization:p,addRole:E,removeOrganizationRoles:m,deleteOrganization:T,getEnterpriseConnections:k,createEnterpriseConnection:$,updateEnterpriseConnection:S,deleteEnterpriseConnection:C,testEnterpriseConnectionConfig:z,testEnterpriseConnection:w,generateSCIMToken:y,getSCIMToken:g,revokeSCIMToken:_}},st=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:h,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:u,addOrganizationDomain:d,verifyOrganizationDomain:p,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:b,resendOrganizationInvitation:k,updateOrganization:$,removeOrganizationRoles:S,getEnterpriseConnections:C,createEnterpriseConnection:z,updateEnterpriseConnection:w,deleteEnterpriseConnection:y,testEnterpriseConnectionConfig:g,testEnterpriseConnection:_,generateSCIMToken:E,getSCIMToken:j,revokeSCIMToken:T}=on(),{session:R,error:M,loading:I}=Qe(),{organizationMemberships:O}=Ot(),N=i.useMemo(()=>(O==null?void 0:O.find(F=>{var ne;return F.id===((ne=R==null?void 0:R.active_signin)==null?void 0:ne.active_organization_membership_id)}))||null,[O,R]),D=i.useMemo(()=>(N==null?void 0:N.organization)||null,[N]),L=i.useCallback(async F=>D?await $(D,F):[],[D,$]),P=i.useCallback(async()=>D?await n(D):[],[D,n]),A=i.useCallback(async()=>D?await s(D):[],[D,s]),q=i.useCallback(async F=>D?await h(D,F):[],[D,h]),Y=i.useCallback(async F=>D?await S(D,F):void 0,[D,S]),B=i.useCallback(async()=>D?await c(D):[],[D,c]),H=i.useCallback(async F=>D?await d(D,F):void 0,[D,d]),G=i.useCallback(async F=>D?await p(D,F):void 0,[D,p]),X=i.useCallback(async F=>D?await u(D,F):void 0,[D,u]),oe=i.useCallback(async(F,ne)=>D?await m(D,F,ne):void 0,[D,m]),te=i.useCallback(async(F,ne)=>D?await x(D,F,ne):void 0,[D,x]),ce=i.useCallback(async F=>D?await v(D,F):void 0,[D,v]),Q=i.useCallback(async F=>D?await b(D,F):void 0,[D,b]),me=i.useCallback(async F=>D?await k(D,F):void 0,[D,k]),xe=i.useCallback(async()=>{D&&await a(D)},[D,a]),de=i.useCallback(async()=>D?await f(D):[],[D,f]),U=i.useCallback(async()=>D?await C(D):[],[D,C]),le=i.useCallback(async F=>{if(D)return await z(D,F)},[D,z]),K=i.useCallback(async(F,ne)=>{if(D)return await w(D,F,ne)},[D,w]),Z=i.useCallback(async F=>{D&&await y(D,F)},[D,y]),re=i.useCallback(async F=>D?await g(D,F):null,[D,g]),ge=i.useCallback(async F=>D?await _(D,F):null,[D,_]),ue=i.useCallback(async F=>{if(D)return await E(D,F)},[D,E]),ee=i.useCallback(async F=>{if(D)return await j(D,F)},[D,j]),V=i.useCallback(async F=>{D&&await T(D,F)},[D,T]);return I||t?{activeOrganization:null,activeMembership:null,loading:!0,error:M||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:D,activeMembership:N,loading:!1,refetch:o,getRoles:A,updateOrganization:L,getMembers:P,getDomains:B,addDomain:H,verifyDomain:G,removeDomain:X,getInvitations:de,removeMember:q,leave:xe,removeRole:Y,addMemberRole:oe,removeMemberRole:te,inviteMember:ce,discardInvitation:Q,resendInvitation:me,getEnterpriseConnections:U,createEnterpriseConnection:le,updateEnterpriseConnection:K,deleteEnterpriseConnection:Z,testEnterpriseConnectionConfig:re,testEnterpriseConnection:ge,generateSCIMToken:ue,getSCIMToken:ee,revokeSCIMToken:V,error:null}};async function Bu(t){return(await W(await t("/me/organization-memberships"))).data}const Ot=()=>{const{client:t,loading:r}=Ke(),{data:o,isLoading:n,error:s,mutate:a}=Ze(r?null:"/me/organization-memberships",()=>Bu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await a(void 0,{revalidate:!0})},[a]);return{organizationMemberships:o,loading:r||n,error:s,refetch:h}};async function Uu(t){return(await W(await t("/me/workspace-memberships"))).data}async function Wu(t,r,o){return(await W(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const nn=()=>{const{client:t,loading:r}=Ke(),{deployment:o}=we(),{data:n,isLoading:s,error:a,mutate:h}=Ze(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Uu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=i.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]);return{workspaceMemberships:n,loading:r||s,error:a,refetch:f}},Wt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=nn(),{client:s}=Ke(),a=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),h=i.useCallback(async(w,y,g,_)=>{const E=new FormData;E.append("name",y),g&&E.append("image",g),_&&E.append("description",_),E.append("organization_id",w);const j=await W(await s("/workspaces",{method:"POST",body:E}));return Mt(),await r(),j.data},[s,r]),f=i.useCallback(async(w,y)=>{const g=await Wu(s,w,y);return await r(),g},[s,r]),c=i.useCallback(async(w,y)=>{const g=new FormData;y.name&&g.append("name",y.name),y.description&&g.append("description",y.description),y.image&&g.append("image",y.image),y.enforce_2fa!==void 0&&g.append("enforce_2fa",String(y.enforce_2fa)),y.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(y.enable_ip_restriction)),y.whitelisted_ips&&y.whitelisted_ips.forEach(E=>g.append("whitelisted_ips",E));const _=await W(await s(`/workspaces/${w.id}/update`,{method:"POST",body:g}));return await r(),_.data},[s,r]),u=i.useCallback(async w=>{const y=await W(await s(`/workspaces/${w.id}/delete`,{method:"POST"}));return Mt(),await r(),y.data},[s,r]),d=i.useCallback(async w=>(await W(await s(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[s]),p=i.useCallback(async w=>(await W(await s(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[s]),m=i.useCallback(async(w,y,g)=>{const _=new FormData;return _.append("name",y),g.forEach(j=>_.append("permissions",j)),(await W(await s(`/workspaces/${w.id}/roles`,{method:"POST",body:_}))).data},[s]),x=i.useCallback(async(w,y)=>(await W(await s(`/workspaces/${w.id}/roles/${y.id}/delete`,{method:"POST"}))).data,[s]),v=i.useCallback(async(w,y)=>{const g=await W(await s(`/workspaces/${w.id}/members/${y}/remove`,{method:"POST"}));return await r(),g.data},[s,r]),b=i.useCallback(async(w,y,g)=>(await W(await s(`/workspaces/${w.id}/members/${y}/roles/${g}/add`,{method:"POST"}))).data,[s]),k=i.useCallback(async(w,y,g)=>(await W(await s(`/workspaces/${w.id}/members/${y}/roles/${g}/remove`,{method:"POST"}))).data,[s]),$=i.useCallback(async w=>(await W(await s(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(g=>String(g.workspace_id)===String(w.id)),[s]),S=i.useCallback(async(w,y,g)=>{const _=new FormData;return _.append("email",y),_.append("workspace_id",w.id),g&&_.append("workspace_role_id",g),(await W(await s(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:_}))).data},[s]),C=i.useCallback(async(w,y)=>(await W(await s(`/organizations/${w.organization.id}/invitations/${y}/discard`,{method:"POST"}))).data,[s]),z=i.useCallback(async(w,y)=>(await W(await s(`/organizations/${w.organization.id}/invitations/${y}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:h,updateWorkspace:c,deleteWorkspace:u,getWorkspaceMembers:d,getWorkspaceRoles:p,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:b,removeWorkspaceMemberRole:k,getWorkspaceInvitations:$,createWorkspaceInvitation:S,discardWorkspaceInvitation:C,resendWorkspaceInvitation:z}},Vt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:h,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:u,deleteWorkspaceRole:d,removeWorkspaceMember:p,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:b,discardWorkspaceInvitation:k,resendWorkspaceInvitation:$}=Wt(),{workspaceMemberships:S}=nn(),{session:C,loading:z,error:w}=Qe(),y=i.useMemo(()=>(S==null?void 0:S.find(G=>{var X;return G.id===((X=C==null?void 0:C.active_signin)==null?void 0:X.active_workspace_membership_id)}))||null,[S,C]),g=i.useMemo(()=>(y==null?void 0:y.workspace)||null,[y]),_=i.useCallback(async()=>{var G;if(!(!g||!((G=C==null?void 0:C.active_signin)!=null&&G.user_id)))return await s(g.id,C.active_signin.user_id)},[g,s,C]),E=i.useCallback(async G=>{if(g)return await a(g,G)},[g,a]),j=i.useCallback(async()=>{if(g)return await h(g)},[g,h]),T=i.useCallback(async()=>g?await f(g):[],[g,f]),R=i.useCallback(async()=>g?await c(g):[],[g,c]),M=i.useCallback(async(G,X)=>{if(g)return await u(g,G,X)},[g,u]),I=i.useCallback(async G=>{if(g)return await d(g,G)},[g,d]),O=i.useCallback(async G=>{if(g)return await p(g,G)},[g,p]),N=i.useCallback(async(G,X)=>{if(g)return await m(g,G,X)},[g,m]),D=i.useCallback(async(G,X)=>{if(g)return await x(g,G,X)},[g,x]),L=i.useMemo(()=>(n==null?void 0:n.find(G=>G.id===(g==null?void 0:g.id)))||null,[n,g]),P=i.useCallback(async()=>L?await v(L):[],[L,v]),A=i.useCallback(async(G,X)=>{if(L)return await b(L,G,X)},[L,b]),q=i.useCallback(async G=>{if(L)return await k(L,G)},[L,k]),Y=i.useCallback(async G=>{if(L)return await $(L,G)},[L,$]),B=r||z,H=o||w;return B?{activeWorkspace:null,activeMembership:null,loading:!0,error:H,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:y,loading:!1,error:H,refetch:t,leave:_,updateWorkspace:E,deleteWorkspace:j,getMembers:T,getRoles:R,createRole:M,deleteRole:I,inviteMember:A,removeMember:O,addMemberRole:N,removeMemberRole:D,getInvitations:P,discardInvitation:q,resendInvitation:Y}};function $n(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function zn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),s=new Uint8Array(n.length);for(let a=0;a<n.length;a++)s[a]=n.charCodeAt(a);return s.buffer}const Vu=async t=>(await W(await t("/me"))).data,Gu=async t=>(await W(await t("/me/signins"))).data;function Gt(){const{client:t,loading:r}=Ke(),{data:o,error:n,isLoading:s,mutate:a}=Ze(r?null:"/user",()=>Vu(t)),h=async L=>{const P=new FormData;for(const[q,Y]of Object.entries(L))Y!=null&&Y!==""&&P.append(q,String(Y));const A=await W(await t("/me",{method:"POST",body:P}));return a(),A},f=async()=>await W(await t("/me/email-addresses",{method:"GET"})),c=async L=>await W(await t(`/me/email-addresses/${L}`,{method:"GET"})),u=async L=>{const P=new FormData;return P.append("email",L),await W(await t("/me/email-addresses",{method:"POST",body:P}))},d=async L=>await W(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),p=async L=>await W(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,P)=>await W(await t(`/me/email-addresses/${L}/attempt-verification?code=${P}`,{method:"POST"})),x=async(L,P)=>{const A=new FormData;return A.append("phone_number",L),A.append("country_code",P),await W(await t("/me/phone-numbers",{method:"POST",body:A}))},v=async L=>await W(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),b=async L=>await W(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),k=async(L,P)=>{const A=new FormData;return A.append("code",P),await W(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:A}))},$=async L=>{const P=await W(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return a(),P},S=async L=>await W(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),C=async()=>(await W(await t("/me/authenticator",{method:"POST"}))).data,z=async(L,P)=>{const A=new FormData;return A.append("authenticator_id",L),P.forEach(Y=>{A.append("codes",Y)}),await W(await t("/me/authenticator/attempt-verification",{method:"POST",body:A}))},w=async L=>await W(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),y=async()=>(await W(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const P=new FormData;return P.append("file",L),await W(await t("/me/profile-picture",{method:"POST",body:P}))},_=async()=>(await W(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,E=async(L,P)=>{const A=new FormData;return A.append("current_password",L),A.append("new_password",P),await W(await t("/me/update-password",{method:"POST",body:A}))},j=async L=>{const P=new FormData;P.append("current_password",L);const A=await W(await t("/me/remove-password",{method:"POST",body:P}));return a(),A},T=async L=>{const P=new FormData;return P.append("password",L),await W(await t("/me/account/delete",{method:"POST",body:P}))},R=async L=>await W(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),M=async({provider:L,redirectUri:P})=>{var Y;const A=new URLSearchParams({provider:L});P&&A.append("redirect_uri",P);const q=await W(await t(`/me/init-sso-connection?${A.toString()}`,{method:"POST"}));return"data"in q&&((Y=q.data)!=null&&Y.oauth_url)&&window.open(q.data.oauth_url,"_blank"),q},I=async()=>await W(await t("/me/passkeys",{method:"GET"})),O=async L=>{var X,oe;const P=await W(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in P))return P;const A=P.data.options.publicKey,q={challenge:zn(A.challenge),rp:A.rp,user:{id:zn(A.user.id),name:A.user.name,displayName:A.user.displayName},pubKeyCredParams:A.pubKeyCredParams,timeout:A.timeout,attestation:A.attestation,authenticatorSelection:A.authenticatorSelection,excludeCredentials:(X=A.excludeCredentials)==null?void 0:X.map(te=>({type:te.type,id:zn(te.id),transports:te.transports}))},Y=await navigator.credentials.create({publicKey:q});if(!Y)throw new Error("Failed to create credential");const B=Y.response,H={id:Y.id,rawId:$n(Y.rawId),type:Y.type,response:{clientDataJSON:$n(B.clientDataJSON),attestationObject:$n(B.attestationObject),transports:((oe=B.getTransports)==null?void 0:oe.call(B))||[]}};return await W(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}))},N=async L=>await W(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),D=async(L,P)=>await W(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:P})}));return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:h,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:u,deleteEmailAddress:d,prepareEmailVerification:p,attemptEmailVerification:m,makeEmailPrimary:S,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:b,attemptPhoneVerification:k,makePhonePrimary:$,setupAuthenticator:C,verifyAuthenticator:z,deleteAuthenticator:w,generateBackupCodes:y,regenerateBackupCodes:_,updateProfilePicture:g,disconnectSocialConnection:R,connectSocialAccount:M,updatePassword:E,removePassword:j,deleteAccount:T,getPasskeys:I,registerPasskey:O,deletePasskey:N,renamePasskey:D}}function Vc(){const{client:t,loading:r}=Ke(),{data:o,error:n,isLoading:s,mutate:a}=Ze(r?null:"/me/signins",()=>Gu(t));return{signins:o,error:n||null,removeSignin:async f=>await W(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:a,loading:s||r}}function Hu(){const{session:t,loading:r}=Qe(),{loading:o,organizationMemberships:n}=Ot(),{loading:s,workspaceMemberships:a}=nn();if(r||o||s)return{loading:!0,orgMembership:null,workspaceMembership:null};const h=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var u;return c.id===((u=t.active_signin)==null?void 0:u.active_organization_membership_id)}),[t]),f=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:a==null?void 0:a.find(c=>{var u;return c.id===((u=t.active_signin)==null?void 0:u.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:h,workspaceMembership:f}}function Gc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),s=async a=>{n(!0);try{const h=new FormData;for(const[u,d]of Object.entries(a))d&&h.append(u,d);const f=await t("/waitlist/join",{method:"POST",body:h});return await W(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function Hc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),[s,a]=i.useState(null),[h,f]=i.useState(null),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(d||r)return;const b=new URLSearchParams(window.location.search),k=b.get("code"),$=b.get("state"),S=b.get("error"),C=b.get("error_description");if(!k&&!S){p(!0);const z=new Error("No OAuth callback data found.");a(z);return}if(p(!0),n(!0),S){const z=C||S,w=new Error(`OAuth Error: ${z}`);a(w),n(!1);return}if(k&&$)v(k,$);else{const z=new Error("Missing required OAuth parameters");a(z),n(!1)}},[d,r]);const v=async(b,k)=>{try{let $,S;try{const w=k.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const y=w[0].replace(/-/g,"+").replace(/_/g,"/"),g=y.length%4?"=".repeat(4-y.length%4):"",E=atob(y+g).split("|")[0];if(E==="sign_in")$="/auth/oauth2/callback",S="GET";else if(E==="connect_social")$="/me/sso-connection-callback",S="POST";else throw new Error(`Unknown OAuth action: ${E}`)}catch(w){const y=w instanceof Error?w:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${y.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const C=await t(`${$}?code=${encodeURIComponent(b)}&state=${encodeURIComponent(k)}`,{method:S}),z=await W(C);if("data"in z){const w=z.data.session,y=z.data.redirect_uri||null;if(f(w),u(y),w.signin_attempts&&w.signin_attempts.length>0){const g=w.signin_attempts.at(-1);g&&x(g)}}else{const w=new Error("SSO callback failed");a(w)}}catch($){const S=$ instanceof Error?$:new Error("Unknown error occurred");a(S)}finally{n(!1)}};return{loading:o,error:s,session:h,redirectUri:c,processed:d,signinAttempt:m}}function qc(){const{client:t,loading:r}=Ke(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),a(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const u=await t(c.pathname+c.search,{method:"GET"}),d=await W(u);return n(!1),a(!0),d}catch(c){throw n(!1),a(!1),c}},success:s}}function Yc(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function Zc(){const{client:t,loading:r}=Ke();return{loading:r,forgotPassword:async a=>{const h=new FormData;h.append("email",a);const f=await t("/auth/forgot-password",{method:"POST",body:h});return await W(f)},verifyOtp:async(a,h)=>{const f=new FormData;f.append("email",a),f.append("otp",h);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await W(c)},resetPassword:async(a,h)=>{const f=new FormData;f.append("token",a),f.append("password",h);const c=await t("/auth/reset-password",{method:"POST",body:f});return await W(c)}}}function Kc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:h=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:u}=Qe(),{deployment:d,loading:p}=we(),[m,x]=i.useState(!1),[v,b]=i.useState(null),k=i.useRef(null),$=i.useRef(null),S=i.useRef(0),C=i.useRef(null),z=i.useRef(s),w=i.useRef(a),y=i.useRef(r),g=i.useRef(o),_=i.useRef(n),E=i.useRef(h),j=i.useRef(f);z.current=s,w.current=a,y.current=r,g.current=o,_.current=n,E.current=h,j.current=f;const T=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),C.current&&(clearInterval(C.current),C.current=null),k.current&&(k.current.close(),k.current=null)},[]),R=i.useCallback(async()=>{var L;if(!t||u||p||!c||!d)return;T();const O=new URL(d.backend_host),N=O.protocol==="https:"?"wss:":"ws:",D=new URL("/realtime/notifications",`${N}//${O.host}`);if(d.mode==="staging"){const P=localStorage.getItem("__dev_session__");P&&D.searchParams.set("__dev_session__",P)}y.current&&y.current.length>0&&y.current.forEach(P=>D.searchParams.append("channels",P)),g.current&&g.current.length>0&&g.current.forEach(P=>D.searchParams.append("organization_ids",P.toString())),_.current&&_.current.length>0&&_.current.forEach(P=>D.searchParams.append("workspace_ids",P.toString()));try{const P=new WebSocket(D.toString());k.current=P,P.onopen=()=>{x(!0),b(null),S.current=0,C.current=setInterval(()=>{P.readyState===WebSocket.OPEN&&P.send("ping")},3e4)},P.onmessage=A=>{var q,Y;try{const B=JSON.parse(A.data);if(B.type==="notification"&&B.data)(q=z.current)==null||q.call(z,B.data);else if(B.type==="error"){const H=B.error||"Unknown error occurred";b(H),(Y=w.current)==null||Y.call(w,H)}else B.type}catch{}},P.onerror=()=>{var A;b("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},P.onclose=A=>{var q;if(x(!1),C.current&&(clearInterval(C.current),C.current=null),t&&A.code!==1e3&&S.current<j.current){S.current++;const Y=E.current*Math.pow(2,S.current-1);$.current=setTimeout(()=>{R()},Y)}else S.current>=j.current&&(b("Max reconnection attempts reached"),(q=w.current)==null||q.call(w,"Max reconnection attempts reached"))}}catch{b("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,u,p,c,d,T]);i.useEffect(()=>(R(),()=>{T()}),[R,T]),i.useEffect(()=>{k.current&&k.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const M=i.useCallback(()=>{T(),x(!1)},[T]),I=i.useCallback(()=>{S.current=0,R()},[R]);return{isConnected:m,connectionError:v,disconnect:M,reconnect:I}}async function qu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(h=>o.append("channels",h)),r.organization_ids&&r.organization_ids.forEach(h=>o.append("organization_ids",h.toString())),r.workspace_ids&&r.workspace_ids.forEach(h=>o.append("workspace_ids",h.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,s=await t(n,{method:"GET"});return(await W(s)).data}async function Yu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await W(r)).data}async function Zu(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return W(o)}async function Ku(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return W(r)}async function Qu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return W(o)}function Qc(t){const{client:r,loading:o}=Ke(),{data:n,error:s,mutate:a,isLoading:h}=Ze(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>qu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Kc({enabled:!o&&!!n,onNotification:i.useCallback(p=>{a(async m=>!m||m.notifications.some(v=>v.id===p.id.toString())?m:{...m,notifications:[{id:p.id.toString(),user_id:p.user_id.toString(),deployment_id:p.deployment_id.toString(),title:p.title,body:p.body,severity:p.severity,action_url:p.action_url,action_label:p.action_label,is_read:!1,is_archived:!1,created_at:p.created_at,updated_at:p.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async p=>{o||(await a(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===p?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await Zu(r,p),await a())},[r,o,a]),c=i.useCallback(async()=>{o||(await a(async p=>p&&{...p,notifications:p.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await Ku(r),await a())},[r,a]),u=i.useCallback(async p=>{o||(await a(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===p);return{...m,notifications:m.notifications.filter(v=>v.id!==p),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await Qu(r,p),await a())},[r,o,a]),d=i.useCallback(async()=>{await a()},[a]);return!n||o||h?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:s,refetch:d}:{loading:!1,error:s,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:u,refetch:d}}async function Xu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await W(r)).data}function Ju(){const{client:t,loading:r}=Ke(),{data:o,error:n,mutate:s}=Ze(r?null:"wacht-notifications:channel-counts",()=>Xu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),a=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:a}:{loading:!1,counts:o,error:n,refetch:a}}const ir=class ir{constructor(){dt(this,"ws",null);dt(this,"messageHandlers",new Set);dt(this,"connectionStateHandlers",new Set);dt(this,"reconnectTimer",null);dt(this,"reconnectAttempts",0);dt(this,"url",null);dt(this,"isIntentionalDisconnect",!1);dt(this,"sessionMessages",{});dt(this,"currentSessionKey",null)}static getInstance(){return ir.instance||(ir.instance=new ir),ir.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};dt(ir,"instance");let ms=ir;const at=ms.getInstance(),Rt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},He={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Zt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function ya(t){switch(t){case Zt.IDLE:return He.IDLE;case Zt.STARTING:return He.STARTING;case Zt.RUNNING:return He.RUNNING;case Zt.WAITING_FOR_INPUT:return He.WAITING_FOR_INPUT;case Zt.COMPLETED:return He.COMPLETED;case Zt.FAILED:case Zt.CANCELLED:return He.FAILED;default:return He.IDLE}}function wa(t){return t===He.STARTING||t===He.RUNNING||t===He.WAITING_FOR_INPUT}function Xc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:a}=we(),{client:h}=Ke(),[f,c]=i.useState([]),[u,d]=i.useState(null),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(He.IDLE),[C,z]=i.useState({status:Rt.DISCONNECTED}),[w,y]=i.useState(!0),[g,_]=i.useState(!1),E=i.useRef(null),j=i.useRef(null),T=i.useCallback(B=>{var H,G;switch(B.message_type){case"session_connected":if(v(!0),z({status:Rt.CONNECTED}),(H=B.data)!=null&&H.execution_status){const oe=B.data.execution_status,te=ya(oe);S(te),k(wa(te))}break;case"conversation_message":R(B.data);break;case"user_input_request":M(B.data);break;case"platform_event":I(B.data);break;case"platform_function":O(B.data);break;case"execution_complete":k(!1),S(He.IDLE),j.current=null;break;case"execution_error":k(!1),S(He.FAILED),j.current=null;break;case"execution_cancelled":k(!1),S(He.IDLE),j.current=null;break;case"execution_status":const X=(G=B.data)==null?void 0:G.status;if(X){const oe=ya(X);S(oe),k(wa(oe))}break}},[u]),R=i.useCallback(B=>{var te,ce,Q,me,xe,de,U,le;const{id:H,message_type:G,content:X}=B,oe=K=>f.some(Z=>Z.id===K);if(G==="system_decision"||G==="action_execution_result"||G==="assistant_task_breakdown"||G==="assistant_validation"||G==="assistant_action_planning"||G==="context_results"){d(null),m(null);let K="";if(G==="system_decision"){const Z=X==null?void 0:X.step,re=X==null?void 0:X.reasoning;if(Z==="gathercontext")re&&re.length>0?K=re.length>60?`${re.substring(0,60)}...`:re:K="Gathering context...";else if(Z==="executeaction")K="Executing action";else if(Z==="deliverresponse")K="Preparing response";else if(Z==="taskplanning")K="Planning approach";else if(Z==="validateprogress")K="Validating progress";else if(Z==="acknowledge")K="Processing request";else if(Z==="finishplanning")K="Finalizing plan";else if(Z==="executetasks")K="Executing tasks";else if(Z==="requestuserinput")K="Waiting for input";else if(Z==="complete")K="Completed";else if(Z==="examinetool")K="Examining tool";else if(Z==="examineworkflow")K="Examining workflow";else{const ge=(X==null?void 0:X.confidence)||.5;ge>.8?K="Analyzing":ge>.6?K="Thinking":K="Reasoning"}}else if(G==="action_execution_result")((te=X.task_execution)==null?void 0:te.status)==="completed"?K="Task execution completed":(ce=X.task_execution)!=null&&ce.approach?K=X.task_execution.approach:K="Executing task";else if(G==="assistant_task_breakdown")(Q=X.task_breakdown)!=null&&Q.total_tasks?K=`Identified ${X.task_breakdown.total_tasks} tasks`:K="Planning tasks";else if(G==="assistant_validation")K="Validated results";else if(G==="assistant_action_planning")(me=X.task_execution)!=null&&me.total_tasks?K=`Planned ${X.task_execution.total_tasks} tasks`:(de=(xe=X.task_execution)==null?void 0:xe.tasks)!=null&&de.length?K=`Planned ${X.task_execution.tasks.length} tasks`:K="Planning actions";else if(G==="context_results"){const Z=X.query,re=X.result_count||0;Z&&Z!=="General context gathering"?K=`${Z}: Found ${re} results`:K=`Found ${re} results`}K&&!oe(H)&&c(Z=>[...Z,{id:H,role:"system",content:K,timestamp:new Date,metadata:{type:"log",messageType:G}}]);return}if(G==="user_message")oe(H)||(d(null),m(null),c(K=>[...K,{id:H,role:"user",content:X.message,images:X.images,timestamp:new Date}]));else if(G==="agent_response")oe(H)||(d(null),m(null),k(!1),S(He.IDLE),j.current=null,c(K=>[...K,{id:H,role:"assistant",content:X.response,timestamp:new Date,isStreaming:!1}]));else if(G==="assistant_acknowledgment")oe(H)||(d(null),m(null),c(K=>[...K,{id:H,role:"assistant",content:X.acknowledgment_message,timestamp:new Date}]));else if(G==="assistant_ideation"||G==="assistant_action_planning"||G==="action_execution_result"||G==="assistant_validation"||G==="assistant_context_gathering"||G==="assistant_task_breakdown"){let K="";if(X.reasoning_summary)K=X.reasoning_summary;else if((U=X.task_execution)!=null&&U.approach)K=X.task_execution.approach;else if(X.strategic_synthesis)K=X.strategic_synthesis;else if((le=X.task_breakdown)!=null&&le.total_tasks)K=`Breaking down into ${X.task_breakdown.total_tasks} tasks...`;else if(X.acknowledgment_message)K=X.acknowledgment_message;else return;c(Z=>[...Z,{id:H,role:"assistant",content:K,timestamp:new Date}])}else if(G==="user_input_request"){const K={question:X.question,context:X.context,input_type:X.input_type,options:X.options||X.suggestions,default_value:X.default_value,placeholder:X.placeholder};S("waiting_for_input"),c(Z=>[...Z,{id:H,role:"system",content:K.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:K}}])}},[]),M=i.useCallback(async B=>{S("waiting_for_input");const H=`input-request-${Date.now()}`;c(G=>[...G,{id:H,role:"system",content:B.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:B}}])},[]),I=i.useCallback(B=>{const{event_label:H,event_data:G}=B;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(H,G)},[n]),O=i.useCallback(async B=>{const{function_name:H,function_data:G}=B,{parameters:X,execution_id:oe}=G;if(!(n!=null&&n.onPlatformFunction)){at.send({message_type:{platform_function_result:[oe,{error:"No platform function handler registered"}]},data:{}});return}try{const te=await n.onPlatformFunction(H,X,oe),ce={message_type:{platform_function_result:[oe,te]},data:{}};at.send(ce)}catch(te){at.send({message_type:{platform_function_result:[oe,{error:te instanceof Error?te.message:"Function execution failed",stack:te instanceof Error?te.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!a)return;const H=`wss://${a==null?void 0:a.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;z({status:Rt.CONNECTING}),at.connect(H)},[a,o]),i.useEffect(()=>at.onConnectionStateChange(H=>{z({status:H.isConnected?Rt.CONNECTED:H.error?Rt.ERROR:Rt.DISCONNECTED}),v(H.isConnected)}),[]),i.useEffect(()=>at.onMessage(T),[T]),i.useEffect(()=>{x&&t&&r&&s&&at.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,s]);const N=i.useCallback(async()=>(x&&t&&r&&at.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),D=i.useCallback((B,H)=>{x&&(d(B),m(H||null),k(!0),S(He.STARTING),at.send({message_type:{message_input:B},data:H?{images:H}:{}}))},[x]),L=i.useCallback(()=>{c([]),j.current=null},[]),P=i.useCallback(B=>{!x||$!==He.WAITING_FOR_INPUT||(at.send({message_type:{user_input_response:B},data:{}}),S(He.RUNNING))},[x,$]),A=i.useCallback(async B=>{var H;if(!(!o||!t))try{const G=new URLSearchParams({token:o,limit:"50"});B&&(G.append("before_id",B),_(!0));const oe=await(await h(`/api/agent/contexts/${t}/messages?${G}`,{method:"GET"})).json();if(oe.status===200&&oe.data){const te=oe.data;if(Array.isArray(te.data)){const ce=te.data.filter(Q=>{var de;let me=Q.content;if(typeof Q.content=="string")try{me=JSON.parse(Q.content)}catch{me={message:Q.content}}const xe=((de=Q.metadata)==null?void 0:de.message_type)||(me==null?void 0:me.message_type);return xe==="user_message"||xe==="agent_response"||xe==="assistant_acknowledgment"||xe==="user_input_request"||xe==="system_decision"||xe==="action_execution_result"||xe==="assistant_task_breakdown"||xe==="assistant_validation"||xe==="assistant_action_planning"||xe==="context_results"}).map(Q=>{var K,Z,re,ge,ue,ee,V;let me="",xe,de,U=Q.content;if(typeof Q.content=="string")try{U=JSON.parse(Q.content)}catch{U=Q.content}const le=((K=Q.metadata)==null?void 0:K.message_type)||(U==null?void 0:U.message_type);if(le==="user_message"?(me=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):le==="agent_response"?me=(U==null?void 0:U.response)||"":le==="assistant_acknowledgment"?me=(U==null?void 0:U.acknowledgment_message)||"":le==="user_input_request"&&(me=(U==null?void 0:U.question)||"",de={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),le==="system_decision"||le==="action_execution_result"||le==="assistant_task_breakdown"||le==="assistant_validation"||le==="assistant_action_planning"||le==="context_results"){let F="";if(le==="system_decision"){const ne=U==null?void 0:U.step,be=U==null?void 0:U.reasoning;if(ne==="gathercontext")be&&be.length>0?F=be.length>60?`${be.substring(0,60)}...`:be:F="Gathering context...";else if(ne==="executeaction")F="Executing action";else if(ne==="deliverresponse")F="Preparing response";else if(ne==="taskplanning")F="Planning approach";else if(ne==="validateprogress")F="Validating progress";else if(ne==="acknowledge")F="Processing request";else if(ne==="finishplanning")F="Finalizing plan";else if(ne==="executetasks")F="Executing tasks";else if(ne==="requestuserinput")F="Waiting for input";else if(ne==="complete")F="Completed";else if(ne==="examinetool")F="Examining tool";else if(ne==="examineworkflow")F="Examining workflow";else{const Me=(U==null?void 0:U.confidence)||.5;Me>.8?F="Analyzing":Me>.6?F="Thinking":F="Reasoning"}}else if(le==="action_execution_result")((Z=U==null?void 0:U.task_execution)==null?void 0:Z.status)==="completed"?F="Task execution completed":(re=U==null?void 0:U.task_execution)!=null&&re.approach?F=U.task_execution.approach:F="Executing task";else if(le==="assistant_task_breakdown")(ge=U==null?void 0:U.task_breakdown)!=null&&ge.total_tasks?F=`Identified ${U.task_breakdown.total_tasks} tasks`:F="Planning tasks";else if(le==="assistant_validation")F="Validated results";else if(le==="assistant_action_planning")(ue=U==null?void 0:U.task_execution)!=null&&ue.total_tasks?F=`Planned ${U.task_execution.total_tasks} tasks`:(V=(ee=U==null?void 0:U.task_execution)==null?void 0:ee.tasks)!=null&&V.length?F=`Planned ${U.task_execution.tasks.length} tasks`:F="Planning actions";else if(le==="context_results"){const ne=U==null?void 0:U.query,be=(U==null?void 0:U.result_count)||0;ne&&ne!=="General context gathering"?F=`${ne}: Found ${be} results`:F=`Found ${be} results`}me=F,de={type:"log",messageType:le}}return{id:Q.id,role:le==="user_message"?"user":le==="user_input_request"?"system":"assistant",content:me,images:xe,timestamp:new Date(Q.timestamp||Q.created_at||Date.now()),metadata:de}}).filter(Q=>Q.content||Q.metadata||Q.images).sort((Q,me)=>{const xe=BigInt(Q.id),de=BigInt(me.id);return xe<de?-1:xe>de?1:0});ce.length>0&&(E.current=ce[0].id),B?(c(Q=>[...ce,...Q]),y(ce.length>=50)):(c(ce),ce.length>0&&((H=ce[ce.length-1].metadata)==null?void 0:H.type)==="user_input_request"&&S(He.WAITING_FOR_INPUT)),_(!1)}}}catch(G){console.error("Failed to fetch messages:",G),_(!1)}},[o,t,h]);i.useEffect(()=>{t&&o&&A()},[t,o]);const q=i.useCallback(async()=>{if(!(g||!w||!E.current)){_(!0);try{await A(E.current)}finally{_(!1)}}},[g,w,A]),Y=i.useCallback(()=>{!x||!b||(at.send({message_type:{cancel_execution:null},data:{}}),k(!1),S("idle"))},[x,b]);return{messages:f,pendingMessage:u,pendingImages:p,connectionState:C,isConnected:x,isExecuting:b,executionStatus:$,isWaitingForInput:$==="waiting_for_input",hasMoreMessages:w,isLoadingMore:g,sendMessage:D,submitUserInput:P,clearMessages:L,loadMoreMessages:q,cancelExecution:Y,connect:N,disconnect:()=>at.disconnect()}}const Jc=()=>{const{client:t}=Ke(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,h]=i.useState(null),f=i.useCallback(async u=>{o(!0),s(null),h(null);try{const d=new FormData;d.append("token",u);const p=await t("/organizations/invitations/accept",{method:"POST",body:d}),x=(await W(p)).data;return h(x),x.error_code&&s(x.message||"Failed to accept invitation"),x}catch(d){const p=d.message||"Failed to accept invitation";s(p);const m={error_code:"NETWORK_ERROR",message:p};return h(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),h(null)},[]);return{acceptInvitation:f,invitationData:a,loading:r,error:n,reset:c}},ep=({children:t})=>{const{loading:r}=we();return r?null:e.jsx(e.Fragment,{children:t})},tp=({children:t})=>{const{loading:r}=we();return r?e.jsx(e.Fragment,{children:t}):null};var nt=function(){return nt=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},nt.apply(this,arguments)};function fr(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,a;n<s;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}function rp(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var op=/^((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|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|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)-.*))$/,np=rp(function(t){return op.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Fe="-ms-",Kr="-moz-",Te="-webkit-",el="comm",sn="rule",Ms="decl",sp="@import",tl="@keyframes",ap="@layer",rl=Math.abs,Os=String.fromCharCode,xs=Object.assign;function ip(t,r){return Xe(t,0)^45?(((r<<2^Xe(t,0))<<2^Xe(t,1))<<2^Xe(t,2))<<2^Xe(t,3):0}function ol(t){return t.trim()}function It(t,r){return(t=r.exec(t))?t[0]:t}function ke(t,r,o){return t.replace(r,o)}function No(t,r,o){return t.indexOf(r,o)}function Xe(t,r){return t.charCodeAt(r)|0}function Er(t,r,o){return t.slice(r,o)}function vt(t){return t.length}function nl(t){return t.length}function Yr(t,r){return r.push(t),t}function cp(t,r){return t.map(r).join("")}function ja(t,r){return t.filter(function(o){return!It(o,r)})}var an=1,Pr=1,sl=0,ct=0,qe=0,Or="";function cn(t,r,o,n,s,a,h,f){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:an,column:Pr,length:h,return:"",siblings:f}}function Dt(t,r){return xs(cn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function vr(t){for(;t.root;)t=Dt(t.root,{children:[t]});Yr(t,t.siblings)}function lp(){return qe}function dp(){return qe=ct>0?Xe(Or,--ct):0,Pr--,qe===10&&(Pr=1,an--),qe}function ut(){return qe=ct<sl?Xe(Or,ct++):0,Pr++,qe===10&&(Pr=1,an++),qe}function lr(){return Xe(Or,ct)}function Fo(){return ct}function ln(t,r){return Er(Or,t,r)}function vs(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 up(t){return an=Pr=1,sl=vt(Or=t),ct=0,[]}function pp(t){return Or="",t}function En(t){return ol(ln(ct-1,bs(t===91?t+2:t===40?t+1:t)))}function hp(t){for(;(qe=lr())&&qe<33;)ut();return vs(t)>2||vs(qe)>3?"":" "}function fp(t,r){for(;--r&&ut()&&!(qe<48||qe>102||qe>57&&qe<65||qe>70&&qe<97););return ln(t,Fo()+(r<6&&lr()==32&&ut()==32))}function bs(t){for(;ut();)switch(qe){case t:return ct;case 34:case 39:t!==34&&t!==39&&bs(qe);break;case 40:t===41&&bs(t);break;case 92:ut();break}return ct}function gp(t,r){for(;ut()&&t+qe!==57;)if(t+qe===84&&lr()===47)break;return"/*"+ln(r,ct-1)+"*"+Os(t===47?t:ut())}function mp(t){for(;!vs(lr());)ut();return ln(t,ct)}function xp(t){return pp(Bo("",null,null,null,[""],t=up(t),0,[0],t))}function Bo(t,r,o,n,s,a,h,f,c){for(var u=0,d=0,p=h,m=0,x=0,v=0,b=1,k=1,$=1,S=0,C="",z=s,w=a,y=n,g=C;k;)switch(v=S,S=ut()){case 40:if(v!=108&&Xe(g,p-1)==58){No(g+=ke(En(S),"&","&\f"),"&\f",rl(u?f[u-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:g+=En(S);break;case 9:case 10:case 13:case 32:g+=hp(v);break;case 92:g+=fp(Fo()-1,7);continue;case 47:switch(lr()){case 42:case 47:Yr(vp(gp(ut(),Fo()),r,o,c),c);break;default:g+="/"}break;case 123*b:f[u++]=vt(g)*$;case 125*b:case 59:case 0:switch(S){case 0:case 125:k=0;case 59+d:$==-1&&(g=ke(g,/\f/g,"")),x>0&&vt(g)-p&&Yr(x>32?_a(g+";",n,o,p-1,c):_a(ke(g," ","")+";",n,o,p-2,c),c);break;case 59:g+=";";default:if(Yr(y=ka(g,r,o,u,d,s,f,C,z=[],w=[],p,a),a),S===123)if(d===0)Bo(g,r,y,y,z,a,p,f,w);else switch(m===99&&Xe(g,3)===110?100:m){case 100:case 108:case 109:case 115:Bo(t,y,y,n&&Yr(ka(t,y,y,0,0,s,f,C,s,z=[],p,w),w),s,w,p,f,n?z:w);break;default:Bo(g,y,y,y,[""],w,0,f,w)}}u=d=x=0,b=$=1,C=g="",p=h;break;case 58:p=1+vt(g),x=v;default:if(b<1){if(S==123)--b;else if(S==125&&b++==0&&dp()==125)continue}switch(g+=Os(S),S*b){case 38:$=d>0?1:(g+="\f",-1);break;case 44:f[u++]=(vt(g)-1)*$,$=1;break;case 64:lr()===45&&(g+=En(ut())),m=lr(),d=p=vt(C=g+=mp(Fo())),S++;break;case 45:v===45&&vt(g)==2&&(b=0)}}return a}function ka(t,r,o,n,s,a,h,f,c,u,d,p){for(var m=s-1,x=s===0?a:[""],v=nl(x),b=0,k=0,$=0;b<n;++b)for(var S=0,C=Er(t,m+1,m=rl(k=h[b])),z=t;S<v;++S)(z=ol(k>0?x[S]+" "+C:ke(C,/&\f/g,x[S])))&&(c[$++]=z);return cn(t,r,o,s===0?sn:f,c,u,d,p)}function vp(t,r,o,n){return cn(t,r,o,el,Os(lp()),Er(t,2,-2),0,n)}function _a(t,r,o,n,s){return cn(t,r,o,Ms,Er(t,0,n),Er(t,n+1,-1),n,s)}function al(t,r,o){switch(ip(t,r)){case 5103:return Te+"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 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Te+t+t;case 4789:return Kr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Te+t+Kr+t+Fe+t+t;case 5936:switch(Xe(t,r+11)){case 114:return Te+t+Fe+ke(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Te+t+Fe+ke(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Te+t+Fe+ke(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Te+t+Fe+t+t;case 6165:return Te+t+Fe+"flex-"+t+t;case 5187:return Te+t+ke(t,/(\w+).+(:[^]+)/,Te+"box-$1$2"+Fe+"flex-$1$2")+t;case 5443:return Te+t+Fe+"flex-item-"+ke(t,/flex-|-self/g,"")+(It(t,/flex-|baseline/)?"":Fe+"grid-row-"+ke(t,/flex-|-self/g,""))+t;case 4675:return Te+t+Fe+"flex-line-pack"+ke(t,/align-content|flex-|-self/g,"")+t;case 5548:return Te+t+Fe+ke(t,"shrink","negative")+t;case 5292:return Te+t+Fe+ke(t,"basis","preferred-size")+t;case 6060:return Te+"box-"+ke(t,"-grow","")+Te+t+Fe+ke(t,"grow","positive")+t;case 4554:return Te+ke(t,/([^-])(transform)/g,"$1"+Te+"$2")+t;case 6187:return ke(ke(ke(t,/(zoom-|grab)/,Te+"$1"),/(image-set)/,Te+"$1"),t,"")+t;case 5495:case 3959:return ke(t,/(image-set\([^]*)/,Te+"$1$`$1");case 4968:return ke(ke(t,/(.+:)(flex-)?(.*)/,Te+"box-pack:$3"+Fe+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Te+t+t;case 4200:if(!It(t,/flex-|baseline/))return Fe+"grid-column-align"+Er(t,r)+t;break;case 2592:case 3360:return Fe+ke(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,It(n.props,/grid-\w+-end/)})?~No(t+(o=o[r].value),"span",0)?t:Fe+ke(t,"-start","")+t+Fe+"grid-row-span:"+(~No(o,"span",0)?It(o,/\d+/):+It(o,/\d+/)-+It(t,/\d+/))+";":Fe+ke(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return It(n.props,/grid-\w+-start/)})?t:Fe+ke(ke(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ke(t,/(.+)-inline(.+)/,Te+"$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(vt(t)-1-r>6)switch(Xe(t,r+1)){case 109:if(Xe(t,r+4)!==45)break;case 102:return ke(t,/(.+:)(.+)-([^]+)/,"$1"+Te+"$2-$3$1"+Kr+(Xe(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~No(t,"stretch",0)?al(ke(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ke(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,a,h,f,c,u){return Fe+s+":"+a+u+(h?Fe+s+"-span:"+(f?c:+c-+a)+u:"")+t});case 4949:if(Xe(t,r+6)===121)return ke(t,":",":"+Te)+t;break;case 6444:switch(Xe(t,Xe(t,14)===45?18:11)){case 120:return ke(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Te+(Xe(t,14)===45?"inline-":"")+"box$3$1"+Te+"$2$3$1"+Fe+"$2box$3")+t;case 100:return ke(t,":",":"+Fe)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ke(t,"scroll-","scroll-snap-")+t}return t}function qo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function bp(t,r,o,n){switch(t.type){case ap:if(t.children.length)break;case sp:case Ms:return t.return=t.return||t.value;case el:return"";case tl:return t.return=t.value+"{"+qo(t.children,n)+"}";case sn:if(!vt(t.value=t.props.join(",")))return""}return vt(o=qo(t.children,n))?t.return=t.value+"{"+o+"}":""}function yp(t){var r=nl(t);return function(o,n,s,a){for(var h="",f=0;f<r;f++)h+=t[f](o,n,s,a)||"";return h}}function wp(t){return function(r){r.root||(r=r.return)&&t(r)}}function jp(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case Ms:t.return=al(t.value,t.length,o);return;case tl:return qo([Dt(t,{value:ke(t.value,"@","@"+Te)})],n);case sn:if(t.length)return cp(o=t.props,function(s){switch(It(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":vr(Dt(t,{props:[ke(s,/:(read-\w+)/,":"+Kr+"$1")]})),vr(Dt(t,{props:[s]})),xs(t,{props:ja(o,n)});break;case"::placeholder":vr(Dt(t,{props:[ke(s,/:(plac\w+)/,":"+Te+"input-$1")]})),vr(Dt(t,{props:[ke(s,/:(plac\w+)/,":"+Kr+"$1")]})),vr(Dt(t,{props:[ke(s,/:(plac\w+)/,Fe+"input-$1")]})),vr(Dt(t,{props:[s]})),xs(t,{props:ja(o,n)});break}return""})}}var kp={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,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},gr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",il="active",cl="data-styled-version",dn="6.1.19",As=`/*!sc*/
19
+ `,Yo=typeof window<"u"&&typeof document<"u",_p=!!(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"),Ca=/invalid hook call/i,co=new Set,Cp=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
20
20
  `)+`You may see this warning because you've called styled inside another component.
21
21
  To resolve this only create new StyledComponents outside of any render method and function component.
22
22
  See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
23
- `,s=console.error;try{var a=!0;console.error=function(h){for(var f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];Ca.test(h)?(a=!1,co.delete(n)):s.apply(void 0,fr([h],f,!1))},i.useRef(),a&&!co.has(n)&&(console.warn(n),co.add(n))}catch(h){Ca.test(h.message)&&co.delete(n)}finally{console.error=s}}},un=Object.freeze([]),Ir=Object.freeze({});function Cp(t,r,o){return o===void 0&&(o=Ir),t.theme!==o.theme&&t.theme||r||o.theme}var ys=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","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","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Sp=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,$p=/(^-|-$)/g;function Sa(t){return t.replace(Sp,"-").replace($p,"")}var zp=/(a)(d)/gi,lo=52,$a=function(t){return String.fromCharCode(t+(t>25?39:97))};function ws(t){var r,o="";for(r=Math.abs(t);r>lo;r=r/lo|0)o=$a(r%lo)+o;return($a(r%lo)+o).replace(zp,"$1-$2")}var Pn,ll=5381,ar=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},dl=function(t){return ar(ll,t)};function ul(t){return ws(dl(t)>>>0)}function pl(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function In(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var hl=typeof Symbol=="function"&&Symbol.for,fl=hl?Symbol.for("react.memo"):60115,Ep=hl?Symbol.for("react.forward_ref"):60112,Pp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Ip={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},gl={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Rp=((Pn={})[Ep]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Pn[fl]=gl,Pn);function za(t){return("type"in(r=t)&&r.type.$$typeof)===fl?gl:"$$typeof"in t?Rp[t.$$typeof]:Pp;var r}var Tp=Object.defineProperty,Mp=Object.getOwnPropertyNames,Ea=Object.getOwnPropertySymbols,Op=Object.getOwnPropertyDescriptor,Ap=Object.getPrototypeOf,Pa=Object.prototype;function ml(t,r,o){if(typeof r!="string"){if(Pa){var n=Ap(r);n&&n!==Pa&&ml(t,n,o)}var s=Mp(r);Ea&&(s=s.concat(Ea(r)));for(var a=za(t),h=za(r),f=0;f<s.length;++f){var c=s[f];if(!(c in Ip||o&&o[c]||h&&c in h||a&&c in a)){var u=Op(r,c);try{Tp(t,c,u)}catch{}}}}return t}function Rr(t){return typeof t=="function"}function Ls(t){return typeof t=="object"&&"styledComponentId"in t}function cr(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function js(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function Tr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ks(t,r,o){if(o===void 0&&(o=!1),!o&&!Tr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ks(t[n],r[n]);else if(Tr(r))for(var n in r)t[n]=ks(t[n],r[n]);return t}function Ds(t,r){Object.defineProperty(t,"toString",{value:r})}var Lp=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
23
+ `,s=console.error;try{var a=!0;console.error=function(h){for(var f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];Ca.test(h)?(a=!1,co.delete(n)):s.apply(void 0,fr([h],f,!1))},i.useRef(),a&&!co.has(n)&&(console.warn(n),co.add(n))}catch(h){Ca.test(h.message)&&co.delete(n)}finally{console.error=s}}},un=Object.freeze([]),Ir=Object.freeze({});function Sp(t,r,o){return o===void 0&&(o=Ir),t.theme!==o.theme&&t.theme||r||o.theme}var ys=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","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","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),$p=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,zp=/(^-|-$)/g;function Sa(t){return t.replace($p,"-").replace(zp,"")}var Ep=/(a)(d)/gi,lo=52,$a=function(t){return String.fromCharCode(t+(t>25?39:97))};function ws(t){var r,o="";for(r=Math.abs(t);r>lo;r=r/lo|0)o=$a(r%lo)+o;return($a(r%lo)+o).replace(Ep,"$1-$2")}var Pn,ll=5381,ar=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},dl=function(t){return ar(ll,t)};function ul(t){return ws(dl(t)>>>0)}function pl(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function In(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var hl=typeof Symbol=="function"&&Symbol.for,fl=hl?Symbol.for("react.memo"):60115,Pp=hl?Symbol.for("react.forward_ref"):60112,Ip={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Rp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},gl={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Tp=((Pn={})[Pp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Pn[fl]=gl,Pn);function za(t){return("type"in(r=t)&&r.type.$$typeof)===fl?gl:"$$typeof"in t?Tp[t.$$typeof]:Ip;var r}var Mp=Object.defineProperty,Op=Object.getOwnPropertyNames,Ea=Object.getOwnPropertySymbols,Ap=Object.getOwnPropertyDescriptor,Lp=Object.getPrototypeOf,Pa=Object.prototype;function ml(t,r,o){if(typeof r!="string"){if(Pa){var n=Lp(r);n&&n!==Pa&&ml(t,n,o)}var s=Op(r);Ea&&(s=s.concat(Ea(r)));for(var a=za(t),h=za(r),f=0;f<s.length;++f){var c=s[f];if(!(c in Rp||o&&o[c]||h&&c in h||a&&c in a)){var u=Ap(r,c);try{Mp(t,c,u)}catch{}}}}return t}function Rr(t){return typeof t=="function"}function Ls(t){return typeof t=="object"&&"styledComponentId"in t}function cr(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function js(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function Tr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ks(t,r,o){if(o===void 0&&(o=!1),!o&&!Tr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ks(t[n],r[n]);else if(Tr(r))for(var n in r)t[n]=ks(t[n],r[n]);return t}function Ds(t,r){Object.defineProperty(t,"toString",{value:r})}var Dp=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
24
24
 
25
25
  `,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.
26
26
 
@@ -61,7 +61,7 @@ as for instance in your render method then you may be running into this limitati
61
61
 
62
62
  `,17:`CSSStyleSheet could not be found on HTMLStyleElement.
63
63
  Has styled-components' style tag been unmounted or altered by another script?
64
- `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Dp(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,a=t.length;s<a;s+=1)n.push(t[s]);return n.forEach(function(h){o=o.replace(/%[a-z]/,h)}),o}function Ar(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Dp.apply(void 0,fr([Lp[t]],r,!1)).trim())}var Np=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,a=s;r>=a;)if((a<<=1)<0)throw Ar(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(n),this.length=a;for(var h=s;h<a;h++)this.groupSizes[h]=0}for(var f=this.indexOfGroup(r+1),c=(h=0,o.length);h<c;h++)this.tag.insertRule(f,o[h])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),s=n+o;this.groupSizes[r]=0;for(var a=n;a<s;a++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],s=this.indexOfGroup(r),a=s+n,h=s;h<a;h++)o+="".concat(this.tag.getRule(h)).concat(As);return o},t}(),Fp=1<<30,Uo=new Map,Zo=new Map,Wo=1,uo=function(t){if(Uo.has(t))return Uo.get(t);for(;Zo.has(Wo);)Wo++;var r=Wo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Fp))throw Ar(16,"".concat(r));return Uo.set(t,r),Zo.set(r,t),r},Bp=function(t,r){Wo=r+1,Uo.set(t,r),Zo.set(r,t)},Up="style[".concat(gr,"][").concat(cl,'="').concat(dn,'"]'),Wp=new RegExp("^".concat(gr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Vp=function(t,r,o){for(var n,s=o.split(","),a=0,h=s.length;a<h;a++)(n=s[a])&&t.registerName(r,n)},Gp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(As),s=[],a=0,h=n.length;a<h;a++){var f=n[a].trim();if(f){var c=f.match(Wp);if(c){var u=0|parseInt(c[1],10),d=c[2];u!==0&&(Bp(d,u),Vp(t,d,c[3]),t.getTag().insertRules(u,s)),s.length=0}else s.push(f)}}},Ia=function(t){for(var r=document.querySelectorAll(Up),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(gr)!==il&&(Gp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function Hp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var xl=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(f){var c=Array.from(f.querySelectorAll("style[".concat(gr,"]")));return c[c.length-1]}(o),a=s!==void 0?s.nextSibling:null;n.setAttribute(gr,il),n.setAttribute(cl,dn);var h=Hp();return h&&n.setAttribute("nonce",h),o.insertBefore(n,a),n},qp=function(){function t(r){this.element=xl(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,a=n.length;s<a;s++){var h=n[s];if(h.ownerNode===o)return h}throw Ar(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),Yp=function(){function t(r){this.element=xl(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,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}(),Zp=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),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}(),Ra=Yo,Kp={isServer:!Yo,useCSSOMInjection:!kp},vl=function(){function t(r,o,n){r===void 0&&(r=Ir),o===void 0&&(o={});var s=this;this.options=nt(nt({},Kp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&Yo&&Ra&&(Ra=!1,Ia(this)),Ds(this,function(){return function(a){for(var h=a.getTag(),f=h.length,c="",u=function(p){var m=function($){return Zo.get($)}(p);if(m===void 0)return"continue";var x=a.names.get(m),v=h.getGroup(p);if(x===void 0||!x.size||v.length===0)return"continue";var b="".concat(gr,".g").concat(p,'[id="').concat(m,'"]'),k="";x!==void 0&&x.forEach(function($){$.length>0&&(k+="".concat($,","))}),c+="".concat(v).concat(b,'{content:"').concat(k,'"}').concat(As)},d=0;d<f;d++)u(d);return c}(s)})}return t.registerId=function(r){return uo(r)},t.prototype.rehydrate=function(){!this.server&&Yo&&Ia(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(nt(nt({},this.options),r),this.gs,o&&this.names||void 0)},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(o){var n=o.useCSSOMInjection,s=o.target;return o.isServer?new Zp(s):n?new qp(s):new Yp(s)}(this.options),new Np(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(uo(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(uo(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(uo(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Qp=/&/g,Xp=/^\s*\/\/.*$/gm;function bl(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=bl(o.children,r)),o})}function Jp(t){var r,o,n,s=Ir,a=s.options,h=a===void 0?Ir:a,f=s.plugins,c=f===void 0?un:f,u=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},d=c.slice();d.push(function(m){m.type===sn&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Qp,o).replace(n,u))}),h.prefix&&d.push(wp),d.push(vp);var p=function(m,x,v,b){x===void 0&&(x=""),v===void 0&&(v=""),b===void 0&&(b="&"),r=b,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var k=m.replace(Xp,""),$=mp(v||x?"".concat(v," ").concat(x," { ").concat(k," }"):k);h.namespace&&($=bl($,h.namespace));var S=[];return qo($,bp(d.concat(yp(function(C){return S.push(C)})))),S};return p.hash=c.length?c.reduce(function(m,x){return x.name||Ar(15),ar(m,x.name)},ll).toString():"",p}var eh=new vl,_s=Jp(),yl=i.createContext({shouldForwardProp:void 0,styleSheet:eh,stylis:_s});yl.Consumer;i.createContext(void 0);function Ta(){return i.useContext(yl)}var Cs=function(){function t(r,o){var n=this;this.inject=function(s,a){a===void 0&&(a=_s);var h=n.name+a.hash;s.hasNameForId(n.id,h)||s.insertRules(n.id,h,a(n.rules,h,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ds(this,function(){throw Ar(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=_s),this.name+r.hash},t}(),th=function(t){return t>="A"&&t<="Z"};function Ma(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;th(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var wl=function(t){return t==null||t===!1||t===""},jl=function(t){var r,o,n=[];for(var s in t){var a=t[s];t.hasOwnProperty(s)&&!wl(a)&&(Array.isArray(a)&&a.isCss||Rr(a)?n.push("".concat(Ma(s),":"),a,";"):Tr(a)?n.push.apply(n,fr(fr(["".concat(s," {")],jl(a),!1),["}"],!1)):n.push("".concat(Ma(s),": ").concat((r=s,(o=a)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in jp||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function dr(t,r,o,n){if(wl(t))return[];if(Ls(t))return[".".concat(t.styledComponentId)];if(Rr(t)){if(!Rr(a=t)||a.prototype&&a.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof Cs||Tr(s)||s===null||console.error("".concat(pl(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.")),dr(s,r,o,n)}var a;return t instanceof Cs?o?(t.inject(o,n),[t.getName(n)]):[t]:Tr(t)?jl(t):Array.isArray(t)?Array.prototype.concat.apply(un,t.map(function(h){return dr(h,r,o,n)})):[t.toString()]}function rh(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Rr(o)&&!Ls(o))return!1}return!0}var oh=dl(dn),nh=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&rh(r),this.componentId=o,this.baseHash=ar(oh,o),this.baseStyle=n,vl.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=cr(s,this.staticRulesId);else{var a=js(dr(this.rules,r,o,n)),h=ws(ar(this.baseHash,a)>>>0);if(!o.hasNameForId(this.componentId,h)){var f=n(a,".".concat(h),void 0,this.componentId);o.insertRules(this.componentId,h,f)}s=cr(s,h),this.staticRulesId=h}else{for(var c=ar(this.baseHash,n.hash),u="",d=0;d<this.rules.length;d++){var p=this.rules[d];if(typeof p=="string")u+=p,process.env.NODE_ENV!=="production"&&(c=ar(c,p));else if(p){var m=js(dr(p,r,o,n));c=ar(c,m+d),u+=m}}if(u){var x=ws(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(u,".".concat(x),void 0,this.componentId)),s=cr(s,x)}}return s},t}(),kl=i.createContext(void 0);kl.Consumer;var Rn={},Oa=new Set;function sh(t,r,o){var n=Ls(t),s=t,a=!In(t),h=r.attrs,f=h===void 0?un:h,c=r.componentId,u=c===void 0?function(z,w){var y=typeof z!="string"?"sc":Sa(z);Rn[y]=(Rn[y]||0)+1;var g="".concat(y,"-").concat(ul(dn+y+Rn[y]));return w?"".concat(w,"-").concat(g):g}(r.displayName,r.parentComponentId):c,d=r.displayName,p=d===void 0?function(z){return In(z)?"styled.".concat(z):"Styled(".concat(pl(z),")")}(t):d,m=r.displayName&&r.componentId?"".concat(Sa(r.displayName),"-").concat(r.componentId):r.componentId||u,x=n&&s.attrs?s.attrs.concat(f).filter(Boolean):f,v=r.shouldForwardProp;if(n&&s.shouldForwardProp){var b=s.shouldForwardProp;if(r.shouldForwardProp){var k=r.shouldForwardProp;v=function(z,w){return b(z,w)&&k(z,w)}}else v=b}var $=new nh(o,m,n?s.componentStyle:void 0);function S(z,w){return function(y,g,_){var E=y.attrs,j=y.componentStyle,T=y.defaultProps,R=y.foldedComponentIds,M=y.styledComponentId,I=y.target,O=i.useContext(kl),N=Ta(),D=y.shouldForwardProp||N.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(M);var L=Cp(g,O,T)||Ir,P=function(G,X,oe){for(var te,ce=nt(nt({},X),{className:void 0,theme:oe}),Q=0;Q<G.length;Q+=1){var me=Rr(te=G[Q])?te(ce):te;for(var ve in me)ce[ve]=ve==="className"?cr(ce[ve],me[ve]):ve==="style"?nt(nt({},ce[ve]),me[ve]):me[ve]}return X.className&&(ce.className=cr(ce.className,X.className)),ce}(E,g,L),A=P.as||I,q={};for(var Y in P)P[Y]===void 0||Y[0]==="$"||Y==="as"||Y==="theme"&&P.theme===L||(Y==="forwardedAs"?q.as=P.forwardedAs:D&&!D(Y,A)||(q[Y]=P[Y],D||process.env.NODE_ENV!=="development"||op(Y)||Oa.has(Y)||!ys.has(A)||(Oa.add(Y),console.warn('styled-components: it looks like an unknown prop "'.concat(Y,'" 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 B=function(G,X){var oe=Ta(),te=G.generateAndInjectStyles(X,oe.styleSheet,oe.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(te),te}(j,P);process.env.NODE_ENV!=="production"&&y.warnTooManyClasses&&y.warnTooManyClasses(B);var H=cr(R,M);return B&&(H+=" "+B),P.className&&(H+=" "+P.className),q[In(A)&&!ys.has(A)?"class":"className"]=H,_&&(q.ref=_),i.createElement(A,q)}(C,z,w)}S.displayName=p;var C=i.forwardRef(S);return C.attrs=x,C.componentStyle=$,C.displayName=p,C.shouldForwardProp=v,C.foldedComponentIds=n?cr(s.foldedComponentIds,s.styledComponentId):"",C.styledComponentId=m,C.target=n?s.target:t,Object.defineProperty(C,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(z){this._foldedDefaultProps=n?function(w){for(var y=[],g=1;g<arguments.length;g++)y[g-1]=arguments[g];for(var _=0,E=y;_<E.length;_++)ks(w,E[_],!0);return w}({},s.defaultProps,z):z}}),process.env.NODE_ENV!=="production"&&(_p(p,m),C.warnTooManyClasses=function(z,w){var y={},g=!1;return function(_){if(!g&&(y[_]=!0,Object.keys(y).length>=200)){var E=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(z).concat(E,`.
64
+ `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Np(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,a=t.length;s<a;s+=1)n.push(t[s]);return n.forEach(function(h){o=o.replace(/%[a-z]/,h)}),o}function Ar(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Np.apply(void 0,fr([Dp[t]],r,!1)).trim())}var Fp=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,a=s;r>=a;)if((a<<=1)<0)throw Ar(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(n),this.length=a;for(var h=s;h<a;h++)this.groupSizes[h]=0}for(var f=this.indexOfGroup(r+1),c=(h=0,o.length);h<c;h++)this.tag.insertRule(f,o[h])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),s=n+o;this.groupSizes[r]=0;for(var a=n;a<s;a++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],s=this.indexOfGroup(r),a=s+n,h=s;h<a;h++)o+="".concat(this.tag.getRule(h)).concat(As);return o},t}(),Bp=1<<30,Uo=new Map,Zo=new Map,Wo=1,uo=function(t){if(Uo.has(t))return Uo.get(t);for(;Zo.has(Wo);)Wo++;var r=Wo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Bp))throw Ar(16,"".concat(r));return Uo.set(t,r),Zo.set(r,t),r},Up=function(t,r){Wo=r+1,Uo.set(t,r),Zo.set(r,t)},Wp="style[".concat(gr,"][").concat(cl,'="').concat(dn,'"]'),Vp=new RegExp("^".concat(gr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Gp=function(t,r,o){for(var n,s=o.split(","),a=0,h=s.length;a<h;a++)(n=s[a])&&t.registerName(r,n)},Hp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(As),s=[],a=0,h=n.length;a<h;a++){var f=n[a].trim();if(f){var c=f.match(Vp);if(c){var u=0|parseInt(c[1],10),d=c[2];u!==0&&(Up(d,u),Gp(t,d,c[3]),t.getTag().insertRules(u,s)),s.length=0}else s.push(f)}}},Ia=function(t){for(var r=document.querySelectorAll(Wp),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(gr)!==il&&(Hp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function qp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var xl=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(f){var c=Array.from(f.querySelectorAll("style[".concat(gr,"]")));return c[c.length-1]}(o),a=s!==void 0?s.nextSibling:null;n.setAttribute(gr,il),n.setAttribute(cl,dn);var h=qp();return h&&n.setAttribute("nonce",h),o.insertBefore(n,a),n},Yp=function(){function t(r){this.element=xl(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,a=n.length;s<a;s++){var h=n[s];if(h.ownerNode===o)return h}throw Ar(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),Zp=function(){function t(r){this.element=xl(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,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}(),Kp=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),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}(),Ra=Yo,Qp={isServer:!Yo,useCSSOMInjection:!_p},vl=function(){function t(r,o,n){r===void 0&&(r=Ir),o===void 0&&(o={});var s=this;this.options=nt(nt({},Qp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&Yo&&Ra&&(Ra=!1,Ia(this)),Ds(this,function(){return function(a){for(var h=a.getTag(),f=h.length,c="",u=function(p){var m=function($){return Zo.get($)}(p);if(m===void 0)return"continue";var x=a.names.get(m),v=h.getGroup(p);if(x===void 0||!x.size||v.length===0)return"continue";var b="".concat(gr,".g").concat(p,'[id="').concat(m,'"]'),k="";x!==void 0&&x.forEach(function($){$.length>0&&(k+="".concat($,","))}),c+="".concat(v).concat(b,'{content:"').concat(k,'"}').concat(As)},d=0;d<f;d++)u(d);return c}(s)})}return t.registerId=function(r){return uo(r)},t.prototype.rehydrate=function(){!this.server&&Yo&&Ia(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(nt(nt({},this.options),r),this.gs,o&&this.names||void 0)},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(o){var n=o.useCSSOMInjection,s=o.target;return o.isServer?new Kp(s):n?new Yp(s):new Zp(s)}(this.options),new Fp(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(uo(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(uo(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(uo(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Xp=/&/g,Jp=/^\s*\/\/.*$/gm;function bl(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=bl(o.children,r)),o})}function eh(t){var r,o,n,s=Ir,a=s.options,h=a===void 0?Ir:a,f=s.plugins,c=f===void 0?un:f,u=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},d=c.slice();d.push(function(m){m.type===sn&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Xp,o).replace(n,u))}),h.prefix&&d.push(jp),d.push(bp);var p=function(m,x,v,b){x===void 0&&(x=""),v===void 0&&(v=""),b===void 0&&(b="&"),r=b,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var k=m.replace(Jp,""),$=xp(v||x?"".concat(v," ").concat(x," { ").concat(k," }"):k);h.namespace&&($=bl($,h.namespace));var S=[];return qo($,yp(d.concat(wp(function(C){return S.push(C)})))),S};return p.hash=c.length?c.reduce(function(m,x){return x.name||Ar(15),ar(m,x.name)},ll).toString():"",p}var th=new vl,_s=eh(),yl=i.createContext({shouldForwardProp:void 0,styleSheet:th,stylis:_s});yl.Consumer;i.createContext(void 0);function Ta(){return i.useContext(yl)}var Cs=function(){function t(r,o){var n=this;this.inject=function(s,a){a===void 0&&(a=_s);var h=n.name+a.hash;s.hasNameForId(n.id,h)||s.insertRules(n.id,h,a(n.rules,h,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ds(this,function(){throw Ar(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=_s),this.name+r.hash},t}(),rh=function(t){return t>="A"&&t<="Z"};function Ma(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;rh(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var wl=function(t){return t==null||t===!1||t===""},jl=function(t){var r,o,n=[];for(var s in t){var a=t[s];t.hasOwnProperty(s)&&!wl(a)&&(Array.isArray(a)&&a.isCss||Rr(a)?n.push("".concat(Ma(s),":"),a,";"):Tr(a)?n.push.apply(n,fr(fr(["".concat(s," {")],jl(a),!1),["}"],!1)):n.push("".concat(Ma(s),": ").concat((r=s,(o=a)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in kp||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function dr(t,r,o,n){if(wl(t))return[];if(Ls(t))return[".".concat(t.styledComponentId)];if(Rr(t)){if(!Rr(a=t)||a.prototype&&a.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof Cs||Tr(s)||s===null||console.error("".concat(pl(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.")),dr(s,r,o,n)}var a;return t instanceof Cs?o?(t.inject(o,n),[t.getName(n)]):[t]:Tr(t)?jl(t):Array.isArray(t)?Array.prototype.concat.apply(un,t.map(function(h){return dr(h,r,o,n)})):[t.toString()]}function oh(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Rr(o)&&!Ls(o))return!1}return!0}var nh=dl(dn),sh=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&oh(r),this.componentId=o,this.baseHash=ar(nh,o),this.baseStyle=n,vl.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=cr(s,this.staticRulesId);else{var a=js(dr(this.rules,r,o,n)),h=ws(ar(this.baseHash,a)>>>0);if(!o.hasNameForId(this.componentId,h)){var f=n(a,".".concat(h),void 0,this.componentId);o.insertRules(this.componentId,h,f)}s=cr(s,h),this.staticRulesId=h}else{for(var c=ar(this.baseHash,n.hash),u="",d=0;d<this.rules.length;d++){var p=this.rules[d];if(typeof p=="string")u+=p,process.env.NODE_ENV!=="production"&&(c=ar(c,p));else if(p){var m=js(dr(p,r,o,n));c=ar(c,m+d),u+=m}}if(u){var x=ws(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(u,".".concat(x),void 0,this.componentId)),s=cr(s,x)}}return s},t}(),kl=i.createContext(void 0);kl.Consumer;var Rn={},Oa=new Set;function ah(t,r,o){var n=Ls(t),s=t,a=!In(t),h=r.attrs,f=h===void 0?un:h,c=r.componentId,u=c===void 0?function(z,w){var y=typeof z!="string"?"sc":Sa(z);Rn[y]=(Rn[y]||0)+1;var g="".concat(y,"-").concat(ul(dn+y+Rn[y]));return w?"".concat(w,"-").concat(g):g}(r.displayName,r.parentComponentId):c,d=r.displayName,p=d===void 0?function(z){return In(z)?"styled.".concat(z):"Styled(".concat(pl(z),")")}(t):d,m=r.displayName&&r.componentId?"".concat(Sa(r.displayName),"-").concat(r.componentId):r.componentId||u,x=n&&s.attrs?s.attrs.concat(f).filter(Boolean):f,v=r.shouldForwardProp;if(n&&s.shouldForwardProp){var b=s.shouldForwardProp;if(r.shouldForwardProp){var k=r.shouldForwardProp;v=function(z,w){return b(z,w)&&k(z,w)}}else v=b}var $=new sh(o,m,n?s.componentStyle:void 0);function S(z,w){return function(y,g,_){var E=y.attrs,j=y.componentStyle,T=y.defaultProps,R=y.foldedComponentIds,M=y.styledComponentId,I=y.target,O=i.useContext(kl),N=Ta(),D=y.shouldForwardProp||N.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(M);var L=Sp(g,O,T)||Ir,P=function(G,X,oe){for(var te,ce=nt(nt({},X),{className:void 0,theme:oe}),Q=0;Q<G.length;Q+=1){var me=Rr(te=G[Q])?te(ce):te;for(var xe in me)ce[xe]=xe==="className"?cr(ce[xe],me[xe]):xe==="style"?nt(nt({},ce[xe]),me[xe]):me[xe]}return X.className&&(ce.className=cr(ce.className,X.className)),ce}(E,g,L),A=P.as||I,q={};for(var Y in P)P[Y]===void 0||Y[0]==="$"||Y==="as"||Y==="theme"&&P.theme===L||(Y==="forwardedAs"?q.as=P.forwardedAs:D&&!D(Y,A)||(q[Y]=P[Y],D||process.env.NODE_ENV!=="development"||np(Y)||Oa.has(Y)||!ys.has(A)||(Oa.add(Y),console.warn('styled-components: it looks like an unknown prop "'.concat(Y,'" 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 B=function(G,X){var oe=Ta(),te=G.generateAndInjectStyles(X,oe.styleSheet,oe.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(te),te}(j,P);process.env.NODE_ENV!=="production"&&y.warnTooManyClasses&&y.warnTooManyClasses(B);var H=cr(R,M);return B&&(H+=" "+B),P.className&&(H+=" "+P.className),q[In(A)&&!ys.has(A)?"class":"className"]=H,_&&(q.ref=_),i.createElement(A,q)}(C,z,w)}S.displayName=p;var C=i.forwardRef(S);return C.attrs=x,C.componentStyle=$,C.displayName=p,C.shouldForwardProp=v,C.foldedComponentIds=n?cr(s.foldedComponentIds,s.styledComponentId):"",C.styledComponentId=m,C.target=n?s.target:t,Object.defineProperty(C,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(z){this._foldedDefaultProps=n?function(w){for(var y=[],g=1;g<arguments.length;g++)y[g-1]=arguments[g];for(var _=0,E=y;_<E.length;_++)ks(w,E[_],!0);return w}({},s.defaultProps,z):z}}),process.env.NODE_ENV!=="production"&&(Cp(p,m),C.warnTooManyClasses=function(z,w){var y={},g=!1;return function(_){if(!g&&(y[_]=!0,Object.keys(y).length>=200)){var E=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(z).concat(E,`.
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,y={}}}}(p,m)),Ds(C,function(){return".".concat(C.styledComponentId)}),a&&ml(C,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),C}function Aa(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var La=function(t){return Object.assign(t,{isCss:!0})};function ur(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(Rr(t)||Tr(t))return La(dr(Aa(un,fr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?dr(n):La(dr(Aa(n,r)))}function Ss(t,r,o){if(o===void 0&&(o=Ir),!r)throw Ar(1,r);var n=function(s){for(var a=[],h=1;h<arguments.length;h++)a[h-1]=arguments[h];return t(r,o,ur.apply(void 0,fr([s],a,!1)))};return n.attrs=function(s){return Ss(t,r,nt(nt({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return Ss(t,r,nt(nt({},o),s))},n}var _l=function(t){return Ss(sh,t)},l=_l;ys.forEach(function(t){l[t]=_l(t)});function Ht(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];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 n=js(ur.apply(void 0,fr([t],r,!1))),s=ul(n);return new Cs(s,n)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
73
+ <Component />`),g=!0,y={}}}}(p,m)),Ds(C,function(){return".".concat(C.styledComponentId)}),a&&ml(C,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),C}function Aa(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var La=function(t){return Object.assign(t,{isCss:!0})};function ur(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(Rr(t)||Tr(t))return La(dr(Aa(un,fr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?dr(n):La(dr(Aa(n,r)))}function Ss(t,r,o){if(o===void 0&&(o=Ir),!r)throw Ar(1,r);var n=function(s){for(var a=[],h=1;h<arguments.length;h++)a[h-1]=arguments[h];return t(r,o,ur.apply(void 0,fr([s],a,!1)))};return n.attrs=function(s){return Ss(t,r,nt(nt({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return Ss(t,r,nt(nt({},o),s))},n}var _l=function(t){return Ss(ah,t)},l=_l;ys.forEach(function(t){l[t]=_l(t)});function Ht(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];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 n=js(ur.apply(void 0,fr([t],r,!1))),s=ul(n);return new Cs(s,n)}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 po="__sc-".concat(gr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[po]||(window[po]=0),window[po]===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
 
@@ -79,227 +79,227 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const ah=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cl=(...t)=>t.filter((r,o,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===o).join(" ").trim();/**
82
+ */const ih=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cl=(...t)=>t.filter((r,o,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===o).join(" ").trim();/**
83
83
  * @license lucide-react v0.474.0 - ISC
84
84
  *
85
85
  * This source code is licensed under the ISC license.
86
86
  * See the LICENSE file in the root directory of this source tree.
87
- */var ih={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
87
+ */var ch={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
88
88
  * @license lucide-react v0.474.0 - ISC
89
89
  *
90
90
  * This source code is licensed under the ISC license.
91
91
  * See the LICENSE file in the root directory of this source tree.
92
- */const ch=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:h,...f},c)=>i.createElement("svg",{ref:c,...ih,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:Cl("lucide",s),...f},[...h.map(([u,d])=>i.createElement(u,d)),...Array.isArray(a)?a:[a]]));/**
92
+ */const lh=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:h,...f},c)=>i.createElement("svg",{ref:c,...ch,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:Cl("lucide",s),...f},[...h.map(([u,d])=>i.createElement(u,d)),...Array.isArray(a)?a:[a]]));/**
93
93
  * @license lucide-react v0.474.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
96
96
  * See the LICENSE file in the root directory of this source tree.
97
- */const we=(t,r)=>{const o=i.forwardRef(({className:n,...s},a)=>i.createElement(ch,{ref:a,iconNode:r,className:Cl(`lucide-${ah(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
97
+ */const je=(t,r)=>{const o=i.forwardRef(({className:n,...s},a)=>i.createElement(lh,{ref:a,iconNode:r,className:Cl(`lucide-${ih(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
98
98
  * @license lucide-react v0.474.0 - ISC
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const lh=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],dh=we("Activity",lh);/**
102
+ */const dh=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],uh=je("Activity",dh);/**
103
103
  * @license lucide-react v0.474.0 - ISC
104
104
  *
105
105
  * This source code is licensed under the ISC license.
106
106
  * See the LICENSE file in the root directory of this source tree.
107
- */const uh=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],ph=we("BellOff",uh);/**
107
+ */const ph=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],hh=je("BellOff",ph);/**
108
108
  * @license lucide-react v0.474.0 - ISC
109
109
  *
110
110
  * This source code is licensed under the ISC license.
111
111
  * See the LICENSE file in the root directory of this source tree.
112
- */const hh=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],fh=we("BellRing",hh);/**
112
+ */const fh=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],gh=je("BellRing",fh);/**
113
113
  * @license lucide-react v0.474.0 - ISC
114
114
  *
115
115
  * This source code is licensed under the ISC license.
116
116
  * See the LICENSE file in the root directory of this source tree.
117
- */const gh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Tn=we("Bot",gh);/**
117
+ */const mh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Tn=je("Bot",mh);/**
118
118
  * @license lucide-react v0.474.0 - ISC
119
119
  *
120
120
  * This source code is licensed under the ISC license.
121
121
  * See the LICENSE file in the root directory of this source tree.
122
- */const mh=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],xh=we("Building2",mh);/**
122
+ */const xh=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],vh=je("Building2",xh);/**
123
123
  * @license lucide-react v0.474.0 - ISC
124
124
  *
125
125
  * This source code is licensed under the ISC license.
126
126
  * See the LICENSE file in the root directory of this source tree.
127
- */const vh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Jr=we("Building",vh);/**
127
+ */const bh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Jr=je("Building",bh);/**
128
128
  * @license lucide-react v0.474.0 - ISC
129
129
  *
130
130
  * This source code is licensed under the ISC license.
131
131
  * See the LICENSE file in the root directory of this source tree.
132
- */const bh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],tt=we("Check",bh);/**
132
+ */const yh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],tt=je("Check",yh);/**
133
133
  * @license lucide-react v0.474.0 - ISC
134
134
  *
135
135
  * This source code is licensed under the ISC license.
136
136
  * See the LICENSE file in the root directory of this source tree.
137
- */const yh=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ut=we("ChevronDown",yh);/**
137
+ */const wh=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ut=je("ChevronDown",wh);/**
138
138
  * @license lucide-react v0.474.0 - ISC
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const wh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ro=we("ChevronLeft",wh);/**
142
+ */const jh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ro=je("ChevronLeft",jh);/**
143
143
  * @license lucide-react v0.474.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
146
146
  * See the LICENSE file in the root directory of this source tree.
147
- */const jh=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$s=we("ChevronRight",jh);/**
147
+ */const kh=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],$s=je("ChevronRight",kh);/**
148
148
  * @license lucide-react v0.474.0 - ISC
149
149
  *
150
150
  * This source code is licensed under the ISC license.
151
151
  * See the LICENSE file in the root directory of this source tree.
152
- */const kh=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Sl=we("ChevronUp",kh);/**
152
+ */const _h=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Sl=je("ChevronUp",_h);/**
153
153
  * @license lucide-react v0.474.0 - ISC
154
154
  *
155
155
  * This source code is licensed under the ISC license.
156
156
  * See the LICENSE file in the root directory of this source tree.
157
- */const _h=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ch=we("ChevronsUpDown",_h);/**
157
+ */const Ch=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Sh=je("ChevronsUpDown",Ch);/**
158
158
  * @license lucide-react v0.474.0 - ISC
159
159
  *
160
160
  * This source code is licensed under the ISC license.
161
161
  * See the LICENSE file in the root directory of this source tree.
162
- */const Sh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pr=we("Copy",Sh);/**
162
+ */const $h=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pr=je("Copy",$h);/**
163
163
  * @license lucide-react v0.474.0 - ISC
164
164
  *
165
165
  * This source code is licensed under the ISC license.
166
166
  * See the LICENSE file in the root directory of this source tree.
167
- */const $h=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],pn=we("Download",$h);/**
167
+ */const zh=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],pn=je("Download",zh);/**
168
168
  * @license lucide-react v0.474.0 - ISC
169
169
  *
170
170
  * This source code is licensed under the ISC license.
171
171
  * See the LICENSE file in the root directory of this source tree.
172
- */const zh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],Eh=we("Expand",zh);/**
172
+ */const Eh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],Ph=je("Expand",Eh);/**
173
173
  * @license lucide-react v0.474.0 - ISC
174
174
  *
175
175
  * This source code is licensed under the ISC license.
176
176
  * See the LICENSE file in the root directory of this source tree.
177
- */const Ph=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ns=we("ExternalLink",Ph);/**
177
+ */const Ih=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ns=je("ExternalLink",Ih);/**
178
178
  * @license lucide-react v0.474.0 - ISC
179
179
  *
180
180
  * This source code is licensed under the ISC license.
181
181
  * See the LICENSE file in the root directory of this source tree.
182
- */const Ih=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Mn=we("EyeOff",Ih);/**
182
+ */const Rh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Mn=je("EyeOff",Rh);/**
183
183
  * @license lucide-react v0.474.0 - ISC
184
184
  *
185
185
  * This source code is licensed under the ISC license.
186
186
  * See the LICENSE file in the root directory of this source tree.
187
- */const Rh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],On=we("Eye",Rh);/**
187
+ */const Th=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],On=je("Eye",Th);/**
188
188
  * @license lucide-react v0.474.0 - ISC
189
189
  *
190
190
  * This source code is licensed under the ISC license.
191
191
  * See the LICENSE file in the root directory of this source tree.
192
- */const Th=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],zs=we("Fingerprint",Th);/**
192
+ */const Mh=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],zs=je("Fingerprint",Mh);/**
193
193
  * @license lucide-react v0.474.0 - ISC
194
194
  *
195
195
  * This source code is licensed under the ISC license.
196
196
  * See the LICENSE file in the root directory of this source tree.
197
- */const Mh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Oh=we("Globe",Mh);/**
197
+ */const Oh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ah=je("Globe",Oh);/**
198
198
  * @license lucide-react v0.474.0 - ISC
199
199
  *
200
200
  * This source code is licensed under the ISC license.
201
201
  * See the LICENSE file in the root directory of this source tree.
202
- */const Ah=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Lh=we("Link2",Ah);/**
202
+ */const Lh=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Dh=je("Link2",Lh);/**
203
203
  * @license lucide-react v0.474.0 - ISC
204
204
  *
205
205
  * This source code is licensed under the ISC license.
206
206
  * See the LICENSE file in the root directory of this source tree.
207
- */const Dh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yt=we("LoaderCircle",Dh);/**
207
+ */const Nh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],yt=je("LoaderCircle",Nh);/**
208
208
  * @license lucide-react v0.474.0 - ISC
209
209
  *
210
210
  * This source code is licensed under the ISC license.
211
211
  * See the LICENSE file in the root directory of this source tree.
212
- */const Nh=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Ft=we("LogOut",Nh);/**
212
+ */const Fh=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Ft=je("LogOut",Fh);/**
213
213
  * @license lucide-react v0.474.0 - ISC
214
214
  *
215
215
  * This source code is licensed under the ISC license.
216
216
  * See the LICENSE file in the root directory of this source tree.
217
- */const Fh=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],hn=we("Mail",Fh);/**
217
+ */const Bh=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],hn=je("Mail",Bh);/**
218
218
  * @license lucide-react v0.474.0 - ISC
219
219
  *
220
220
  * This source code is licensed under the ISC license.
221
221
  * See the LICENSE file in the root directory of this source tree.
222
- */const Bh=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],Uh=we("Maximize2",Bh);/**
222
+ */const Uh=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],Wh=je("Maximize2",Uh);/**
223
223
  * @license lucide-react v0.474.0 - ISC
224
224
  *
225
225
  * This source code is licensed under the ISC license.
226
226
  * See the LICENSE file in the root directory of this source tree.
227
- */const Wh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],Da=we("MessageCircle",Wh);/**
227
+ */const Vh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],Da=je("MessageCircle",Vh);/**
228
228
  * @license lucide-react v0.474.0 - ISC
229
229
  *
230
230
  * This source code is licensed under the ISC license.
231
231
  * See the LICENSE file in the root directory of this source tree.
232
- */const Vh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],Gh=we("Paperclip",Vh);/**
232
+ */const Gh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],Hh=je("Paperclip",Gh);/**
233
233
  * @license lucide-react v0.474.0 - ISC
234
234
  *
235
235
  * This source code is licensed under the ISC license.
236
236
  * See the LICENSE file in the root directory of this source tree.
237
- */const Hh=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],qh=we("Phone",Hh);/**
237
+ */const qh=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Yh=je("Phone",qh);/**
238
238
  * @license lucide-react v0.474.0 - ISC
239
239
  *
240
240
  * This source code is licensed under the ISC license.
241
241
  * See the LICENSE file in the root directory of this source tree.
242
- */const Yh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],it=we("Plus",Yh);/**
242
+ */const Zh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],it=je("Plus",Zh);/**
243
243
  * @license lucide-react v0.474.0 - ISC
244
244
  *
245
245
  * This source code is licensed under the ISC license.
246
246
  * See the LICENSE file in the root directory of this source tree.
247
- */const Zh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Kh=we("Search",Zh);/**
247
+ */const Kh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Qh=je("Search",Kh);/**
248
248
  * @license lucide-react v0.474.0 - ISC
249
249
  *
250
250
  * This source code is licensed under the ISC license.
251
251
  * See the LICENSE file in the root directory of this source tree.
252
- */const Qh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Fs=we("Send",Qh);/**
252
+ */const Xh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Fs=je("Send",Xh);/**
253
253
  * @license lucide-react v0.474.0 - ISC
254
254
  *
255
255
  * This source code is licensed under the ISC license.
256
256
  * See the LICENSE file in the root directory of this source tree.
257
- */const Xh=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],hr=we("Settings",Xh);/**
257
+ */const Jh=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],hr=je("Settings",Jh);/**
258
258
  * @license lucide-react v0.474.0 - ISC
259
259
  *
260
260
  * This source code is licensed under the ISC license.
261
261
  * See the LICENSE file in the root directory of this source tree.
262
- */const Jh=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pt=we("Shield",Jh);/**
262
+ */const ef=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],pt=je("Shield",ef);/**
263
263
  * @license lucide-react v0.474.0 - ISC
264
264
  *
265
265
  * This source code is licensed under the ISC license.
266
266
  * See the LICENSE file in the root directory of this source tree.
267
- */const ef=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],fn=we("Trash2",ef);/**
267
+ */const tf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],fn=je("Trash2",tf);/**
268
268
  * @license lucide-react v0.474.0 - ISC
269
269
  *
270
270
  * This source code is licensed under the ISC license.
271
271
  * See the LICENSE file in the root directory of this source tree.
272
- */const tf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],gn=we("Trash",tf);/**
272
+ */const rf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],gn=je("Trash",rf);/**
273
273
  * @license lucide-react v0.474.0 - ISC
274
274
  *
275
275
  * This source code is licensed under the ISC license.
276
276
  * See the LICENSE file in the root directory of this source tree.
277
- */const rf=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],jt=we("TriangleAlert",rf);/**
277
+ */const of=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],jt=je("TriangleAlert",of);/**
278
278
  * @license lucide-react v0.474.0 - ISC
279
279
  *
280
280
  * This source code is licensed under the ISC license.
281
281
  * See the LICENSE file in the root directory of this source tree.
282
- */const of=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ko=we("User",of);/**
282
+ */const nf=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Ko=je("User",nf);/**
283
283
  * @license lucide-react v0.474.0 - ISC
284
284
  *
285
285
  * This source code is licensed under the ISC license.
286
286
  * See the LICENSE file in the root directory of this source tree.
287
- */const nf=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Qo=we("Users",nf);/**
287
+ */const sf=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Qo=je("Users",sf);/**
288
288
  * @license lucide-react v0.474.0 - ISC
289
289
  *
290
290
  * This source code is licensed under the ISC license.
291
291
  * See the LICENSE file in the root directory of this source tree.
292
- */const sf=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=we("X",sf);/**
292
+ */const af=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=je("X",af);/**
293
293
  * @license lucide-react v0.474.0 - ISC
294
294
  *
295
295
  * This source code is licensed under the ISC license.
296
296
  * See the LICENSE file in the root directory of this source tree.
297
- */const af=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],cf=we("ZoomIn",af);/**
297
+ */const cf=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],lf=je("ZoomIn",cf);/**
298
298
  * @license lucide-react v0.474.0 - ISC
299
299
  *
300
300
  * This source code is licensed under the ISC license.
301
301
  * See the LICENSE file in the root directory of this source tree.
302
- */const lf=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],df=we("ZoomOut",lf),he=l.div`
302
+ */const df=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],uf=je("ZoomOut",df),fe=l.div`
303
303
  /* Colors - Light Mode */
304
304
  --color-background: #ffffff;
305
305
  --color-foreground: #111827;
@@ -451,16 +451,16 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
451
451
  background: var(--color-scrollbar-thumb-hover);
452
452
  }
453
453
  }
454
- `,uf=l.div`
454
+ `,pf=l.div`
455
455
  width: 100%;
456
456
  display: flex;
457
457
  flex-direction: column;
458
458
  gap: var(--space-xs);
459
- `,pf=l.div`
459
+ `,hf=l.div`
460
460
  display: flex;
461
461
  gap: var(--space-xs);
462
462
  justify-content: center;
463
- `,hf=l.input`
463
+ `,ff=l.input`
464
464
  width: 40px;
465
465
  height: 40px;
466
466
  border: 1px solid var(--color-border);
@@ -481,13 +481,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
481
481
  &::placeholder {
482
482
  color: var(--color-secondary-text);
483
483
  }
484
- `,ff=l.p`
484
+ `,gf=l.p`
485
485
  font-size: var(--font-2xs);
486
486
  color: var(--color-error);
487
487
  margin: 0;
488
488
  margin-top: var(--space-2xs);
489
489
  text-align: center;
490
- `,gf=l.button`
490
+ `,mf=l.button`
491
491
  background: none;
492
492
  border: none;
493
493
  color: var(--color-primary);
@@ -507,21 +507,21 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
507
507
  color: var(--color-secondary-text);
508
508
  cursor: not-allowed;
509
509
  }
510
- `,mf=l.span`
510
+ `,xf=l.span`
511
511
  color: var(--color-secondary-text);
512
512
  font-size: var(--font-xs);
513
513
  display: block;
514
514
  text-align: center;
515
- `;function qt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[a,h]=i.useState(new Array(t).fill("")),[f,c]=i.useState(60),[u,d]=i.useState(!1),p=i.useRef([]),m=i.useCallback(()=>{const $=setInterval(()=>{c(S=>S<=1?(d(!0),clearInterval($),0):S-1)},1e3);return $},[]);i.useEffect(()=>{const $=m();return()=>clearInterval($)},[m]);const x=async()=>{var $;!u||s||!o||(await o(),d(!1),c(60),h(new Array(t).fill("")),($=p.current[0])==null||$.focus(),m())},v=($,S)=>{var y;if(s)return;const C=$.value,z=[...a];z[S]=C.replace(/[^0-9]/g,""),h(z);const w=z.join("");w.length===t&&r(w),C&&S<t-1&&((y=p.current[S+1])==null||y.focus())},b=($,S)=>{var C;s||$.key==="Backspace"&&!a[S]&&S>0&&((C=p.current[S-1])==null||C.focus())},k=($,S)=>{var g,_,E;if(s)return;$.preventDefault();const z=$.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(z.length===0)return;const w=[...a];for(let j=0;j<z.length&&S+j<t;j++)w[S+j]=z[j];if(S===0&&z.length===t)for(let j=0;j<t;j++)w[j]=z[j];h(w);const y=w.join("");if(y.length===t)r(y),(g=p.current[t-1])==null||g.focus();else{const j=w.findIndex((T,R)=>R>=S&&!T);if(j!==-1)(_=p.current[j])==null||_.focus();else{const T=w.map((R,M)=>R?M:-1).filter(R=>R!==-1).pop();T!==void 0&&T<t-1&&((E=p.current[T+1])==null||E.focus())}}};return e.jsxs(uf,{children:[e.jsx(pf,{children:a.map(($,S)=>e.jsx(hf,{type:"text",maxLength:1,value:$,onChange:C=>v(C.target,S),onKeyDown:C=>b(C,S),onPaste:C=>k(C,S),ref:C=>{p.current[S]=C},disabled:s,autoFocus:S===0},S))}),n&&e.jsx(ff,{children:n}),o&&e.jsx("div",{children:u?e.jsx(gf,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(mf,{children:["Resend code in ",f,"s"]})})]})}const $l=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"})]}),zl=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"})]}),El=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"})}),xf=()=>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"})}),Pl=()=>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"})}),Il=()=>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"})]}),vf=()=>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"})}),Rl=()=>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"}})]}),An={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(zl,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx($l,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(El,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(xf,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(Pl,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(Il,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(vf,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(Rl,{})}},bf=l.div`
515
+ `;function qt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[a,h]=i.useState(new Array(t).fill("")),[f,c]=i.useState(60),[u,d]=i.useState(!1),p=i.useRef([]),m=i.useCallback(()=>{const $=setInterval(()=>{c(S=>S<=1?(d(!0),clearInterval($),0):S-1)},1e3);return $},[]);i.useEffect(()=>{const $=m();return()=>clearInterval($)},[m]);const x=async()=>{var $;!u||s||!o||(await o(),d(!1),c(60),h(new Array(t).fill("")),($=p.current[0])==null||$.focus(),m())},v=($,S)=>{var y;if(s)return;const C=$.value,z=[...a];z[S]=C.replace(/[^0-9]/g,""),h(z);const w=z.join("");w.length===t&&r(w),C&&S<t-1&&((y=p.current[S+1])==null||y.focus())},b=($,S)=>{var C;s||$.key==="Backspace"&&!a[S]&&S>0&&((C=p.current[S-1])==null||C.focus())},k=($,S)=>{var g,_,E;if(s)return;$.preventDefault();const z=$.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(z.length===0)return;const w=[...a];for(let j=0;j<z.length&&S+j<t;j++)w[S+j]=z[j];if(S===0&&z.length===t)for(let j=0;j<t;j++)w[j]=z[j];h(w);const y=w.join("");if(y.length===t)r(y),(g=p.current[t-1])==null||g.focus();else{const j=w.findIndex((T,R)=>R>=S&&!T);if(j!==-1)(_=p.current[j])==null||_.focus();else{const T=w.map((R,M)=>R?M:-1).filter(R=>R!==-1).pop();T!==void 0&&T<t-1&&((E=p.current[T+1])==null||E.focus())}}};return e.jsxs(pf,{children:[e.jsx(hf,{children:a.map(($,S)=>e.jsx(ff,{type:"text",maxLength:1,value:$,onChange:C=>v(C.target,S),onKeyDown:C=>b(C,S),onPaste:C=>k(C,S),ref:C=>{p.current[S]=C},disabled:s,autoFocus:S===0},S))}),n&&e.jsx(gf,{children:n}),o&&e.jsx("div",{children:u?e.jsx(mf,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(xf,{children:["Resend code in ",f,"s"]})})]})}const $l=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"})]}),zl=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"})]}),El=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"})}),vf=()=>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"})}),Pl=()=>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"})}),Il=()=>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"})]}),bf=()=>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"})}),Rl=()=>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"}})]}),An={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(zl,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx($l,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(El,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(vf,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(Pl,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(Il,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(bf,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(Rl,{})}},yf=l.div`
516
516
  display: flex;
517
517
  flex-direction: column;
518
518
  gap: var(--space-xs);
519
519
  margin-bottom: var(--space-md);
520
- `,yf=l.div`
520
+ `,wf=l.div`
521
521
  display: flex;
522
522
  flex-wrap: wrap;
523
523
  gap: var(--space-xs);
524
- `,wf=l.button`
524
+ `,jf=l.button`
525
525
  display: flex;
526
526
  align-items: center;
527
527
  justify-content: center;
@@ -556,7 +556,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
556
556
  height: 16px;
557
557
  flex-shrink: 0;
558
558
  }
559
- `,Bs=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,s=o();return e.jsx(bf,{children:s.map((a,h)=>e.jsx(yf,{children:a.map((f,c)=>{const u=f.provider;return e.jsxs(wf,{onClick:()=>r(f),type:"button",$isWide:s.length>1&&h<s.length-1,$totalProviders:n,children:[An[u].icon,n<3&&e.jsx("span",{children:n===1?An[u].fullLabel:An[u].shortLabel})]},`${f.provider}-${c}`)})},`row-${h}`))})},ht=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=rt(),a=i.useCallback(h=>{h.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:a,...n,children:o})},jf={sm:"36rem"},se=l.input`
559
+ `,Bs=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,s=o();return e.jsx(yf,{children:s.map((a,h)=>e.jsx(wf,{children:a.map((f,c)=>{const u=f.provider;return e.jsxs(jf,{onClick:()=>r(f),type:"button",$isWide:s.length>1&&h<s.length-1,$totalProviders:n,children:[An[u].icon,n<3&&e.jsx("span",{children:n===1?An[u].fullLabel:An[u].shortLabel})]},`${f.provider}-${c}`)})},`row-${h}`))})},ht=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=rt(),a=i.useCallback(h=>{h.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:a,...n,children:o})},kf={sm:"36rem"},se=l.input`
560
560
  padding: var(--space-sm) var(--space-md);
561
561
  width: 100%;
562
562
  height: 36px;
@@ -596,12 +596,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
596
596
  color: var(--color-secondary-text);
597
597
  }
598
598
 
599
- @media (max-width: ${jf.sm}) {
599
+ @media (max-width: ${kf.sm}) {
600
600
  height: 32px;
601
601
  font-size: var(--font-2xs);
602
602
  padding: var(--space-xs) var(--space-sm);
603
603
  }
604
- `,Vo=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],Lr={sm:"36rem"},kf=l.div`
604
+ `,Vo=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],Lr={sm:"36rem"},_f=l.div`
605
605
  display: flex;
606
606
  gap: var(--space-xs);
607
607
  width: 100%;
@@ -609,9 +609,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
609
609
  @media (max-width: ${Lr.sm}) {
610
610
  gap: 0.375rem;
611
611
  }
612
- `,_f=l.div`
612
+ `,Cf=l.div`
613
613
  position: relative;
614
- `,Cf=l.button`
614
+ `,Sf=l.button`
615
615
  display: flex;
616
616
  align-items: center;
617
617
  gap: 0.375rem;
@@ -640,7 +640,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
640
640
  padding: 0.375rem 0.625rem;
641
641
  font-size: 0.8125rem;
642
642
  }
643
- `,Sf=l.div`
643
+ `,$f=l.div`
644
644
  position: absolute;
645
645
  top: calc(100% + 0.25rem);
646
646
  left: 0;
@@ -660,7 +660,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
660
660
  width: 15rem;
661
661
  max-height: 15rem;
662
662
  }
663
- `,$f=l.input`
663
+ `,zf=l.input`
664
664
  width: 100%;
665
665
  padding: 0.5rem 0.75rem;
666
666
  border: none;
@@ -682,14 +682,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
682
682
  padding: 0.375rem 0.625rem;
683
683
  font-size: 0.8125rem;
684
684
  }
685
- `,zf=l.div`
685
+ `,Ef=l.div`
686
686
  max-height: 15.625rem;
687
687
  overflow-y: auto;
688
688
 
689
689
  @media (max-width: ${Lr.sm}) {
690
690
  max-height: 12.5rem;
691
691
  }
692
- `,Ef=l.button`
692
+ `,Pf=l.button`
693
693
  display: flex;
694
694
  align-items: center;
695
695
  gap: 0.5rem;
@@ -716,13 +716,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
716
716
  font-size: 0.8125rem;
717
717
  gap: 0.375rem;
718
718
  }
719
- `,Pf=l(se)`
719
+ `,If=l(se)`
720
720
  flex: 1;
721
- `,oo=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,h]=i.useState(!1),[f,c]=i.useState(Vo.find(v=>v.code===n)||Vo[0]),u=i.useRef(null),[d,p]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function v(b){u.current&&!u.current.contains(b.target)&&h(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const x=Vo.filter(v=>v.name.toLowerCase().includes(d.toLowerCase())||v.dialCode.includes(d));return i.useEffect(()=>{s(f.dialCode)},[f,s]),e.jsxs(kf,{children:[e.jsxs(_f,{ref:u,children:[e.jsxs(Cf,{type:"button",onClick:()=>h(v=>!v),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Sf,{$isOpen:a,children:[e.jsx($f,{type:"text",placeholder:"Search country...",value:d,onChange:v=>p(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(zf,{children:x.map(v=>e.jsxs(Ef,{onClick:b=>{var k;b.stopPropagation(),b.preventDefault(),c(v),h(!1),(k=m.current)==null||k.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(Pf,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:m,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},If=l.div`
721
+ `,oo=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,h]=i.useState(!1),[f,c]=i.useState(Vo.find(v=>v.code===n)||Vo[0]),u=i.useRef(null),[d,p]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function v(b){u.current&&!u.current.contains(b.target)&&h(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const x=Vo.filter(v=>v.name.toLowerCase().includes(d.toLowerCase())||v.dialCode.includes(d));return i.useEffect(()=>{s(f.dialCode)},[f,s]),e.jsxs(_f,{children:[e.jsxs(Cf,{ref:u,children:[e.jsxs(Sf,{type:"button",onClick:()=>h(v=>!v),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs($f,{$isOpen:a,children:[e.jsx(zf,{type:"text",placeholder:"Search country...",value:d,onChange:v=>p(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(Ef,{children:x.map(v=>e.jsxs(Pf,{onClick:b=>{var k;b.stopPropagation(),b.preventDefault(),c(v),h(!1),(k=m.current)==null||k.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(If,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:m,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},Rf=l.div`
722
722
  display: flex;
723
723
  justify-content: center;
724
724
  margin-bottom: var(--space-lg);
725
- `,Rf=l.div`
725
+ `,Tf=l.div`
726
726
  display: flex;
727
727
  align-items: center;
728
728
  justify-content: center;
@@ -735,13 +735,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
735
735
  @media (prefers-color-scheme: dark) {
736
736
  background: var(--color-muted-background, rgba(255, 255, 255, 0.08));
737
737
  }
738
- `,Tf=l.img`
738
+ `,Mf=l.img`
739
739
  max-width: 100%;
740
740
  max-height: 100%;
741
741
  width: auto;
742
742
  height: auto;
743
743
  object-fit: contain;
744
- `;function Oe(){var s;const{deployment:t}=ye(),[r,o]=i.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(If,{children:e.jsx(Rf,{children:e.jsx(Tf,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const Mf=Ht`
744
+ `;function Oe(){var s;const{deployment:t}=we(),[r,o]=i.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(Rf,{children:e.jsx(Tf,{children:e.jsx(Mf,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const Of=Ht`
745
745
  from {
746
746
  transform: rotate(0deg);
747
747
  }
@@ -768,7 +768,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
768
768
  min-height: 200px;
769
769
 
770
770
  svg {
771
- animation: ${Mf} 1s linear infinite;
771
+ animation: ${Of} 1s linear infinite;
772
772
  color: var(--color-primary);
773
773
  }
774
774
  `,Ln=l.div`
@@ -797,7 +797,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
797
797
  @media (max-width: ${kt.sm}) {
798
798
  font-size: var(--font-2xs);
799
799
  }
800
- `,Of=l.div`
800
+ `,Af=l.div`
801
801
  position: relative;
802
802
  text-align: center;
803
803
  margin: var(--space-lg) 0;
@@ -815,7 +815,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
815
815
  @media (max-width: ${kt.sm}) {
816
816
  margin: var(--space-md) 0;
817
817
  }
818
- `,Af=l.span`
818
+ `,Lf=l.span`
819
819
  position: relative;
820
820
  background: var(--color-background);
821
821
  padding: 0 var(--space-sm);
@@ -829,7 +829,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
829
829
  @media (max-width: ${kt.sm}) {
830
830
  gap: 1rem;
831
831
  }
832
- `,Lf=l.div`
832
+ `,Df=l.div`
833
833
  display: grid;
834
834
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
835
835
  gap: var(--space-sm);
@@ -851,7 +851,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
851
851
  @media (max-width: ${kt.sm}) {
852
852
  font-size: 0.75rem;
853
853
  }
854
- `,Df=l.div`
854
+ `,Nf=l.div`
855
855
  position: relative;
856
856
  `,Kt=l.p`
857
857
  font-size: var(--font-2xs);
@@ -903,30 +903,30 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
903
903
  &:hover {
904
904
  color: var(--color-primary-hover);
905
905
  }
906
- `,Nf=l.div`
906
+ `,Ff=l.div`
907
907
  text-align: center;
908
908
  padding: var(--space-xl);
909
909
  margin-bottom: var(--space-lg);
910
- `,Ff=l.p`
910
+ `,Bf=l.p`
911
911
  font-size: var(--font-size-md);
912
912
  color: var(--color-text-secondary);
913
913
  margin: 0 0 var(--space-sm) 0;
914
914
  line-height: 1.5;
915
- `,Bf=l.div`
915
+ `,Uf=l.div`
916
916
  text-align: center;
917
917
  margin-top: var(--space-lg);
918
- `,Uf=l.p`
918
+ `,Wf=l.p`
919
919
  font-size: var(--font-xs);
920
920
  color: var(--color-muted);
921
921
  margin: 0;
922
- `,Wf=l.a`
922
+ `,Vf=l.a`
923
923
  color: var(--color-primary);
924
924
  text-decoration: none;
925
925
  cursor: pointer;
926
926
  `,wr=l.span`
927
927
  color: var(--color-danger);
928
928
  margin-left: 2px;
929
- `;function Vf(){var B,H,G,X,oe,te,ce,Q,me,ve,de,U,le,K,Z,re,fe;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=Wc(),{signIn:s}=zr("oauth"),{deployment:a}=ye(),{navigate:h}=rt(),{session:f,refetch:c,loading:u}=Qe(),[d,p]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,b]=i.useState(!1),[k,$]=i.useState(void 0),[S,C]=i.useState(null),[z,w]=i.useState(null),[y,g]=i.useState(!1),_=((B=a==null?void 0:a.restrictions)==null?void 0:B.sign_up_mode)==="restricted",E=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="waitlist",j=((X=(G=a==null?void 0:a.auth_settings)==null?void 0:G.multi_session_support)==null?void 0:X.enabled)??!1;i.useEffect(()=>{var ue;if(!u&&(f!=null&&f.active_signin)&&!j&&!y){g(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee&&h(ee)}},[f,u,j,a,h,y]),i.useEffect(()=>{var V;if(!a)return;const ee=new URLSearchParams(window.location.search).get("invite_token");if(E&&!ee){g(!0);const F=((V=a.ui_settings)==null?void 0:V.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;h(F);return}ee&&!S&&r&&(w(ee),r.validateDeploymentInvitation(ee).then(F=>{C(F),F.valid&&p(ne=>({...ne,first_name:F.first_name||ne.first_name,last_name:F.last_name||ne.last_name,email:F.email||ne.email}))}).catch(F=>{console.error("Failed to validate invitation:",F)}))},[a,E,h,S,r]);const[T,R]=i.useState(!1),[M,I]=i.useState(""),O=ue=>{let{name:ee,value:V}=ue.target;ee==="phone_number"?V=V.replace(/[^0-9-]/g,""):ee==="email"&&(V=V.toLowerCase()),p(F=>({...F,[ee]:V})),x(F=>({...F,[ee]:""}))},N=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},D=async ue=>{if(ue.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",d),t||v)return;const ee={},V=/^[a-zA-Z]{3,30}$/,F=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,ne=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,be=/^\d{7,15}$/,Me=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!d.first_name?ee.first_name="First name is required":d.first_name&&!V.test(d.first_name)&&(ee.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!d.last_name?ee.last_name="Last name is required":d.last_name&&!V.test(d.last_name)&&(ee.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!d.username?ee.username="Username is required":d.username&&!F.test(d.username)&&(ee.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!d.email?ee.email="Email address is required":d.email&&!ne.test(d.email)&&(ee.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!d.phone_number?ee.phone_number="Phone number is required":d.phone_number&&!be.test(d.phone_number)&&(ee.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(d.password?Me.test(d.password)||(ee.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):ee.password="Password is required"),x(ee),Object.keys(ee).length>0){console.log("Signup validation failed. Errors:",ee);return}console.log("Signup validation passed"),b(!0);try{const Ce={...d};d.phone_number&&k&&(Ce.phone_country_code=k),z&&(Ce.invite_token=z),console.log("Submitting signup data:",Ce),console.log("Phone number:",Ce.phone_number),console.log("Phone country code:",Ce.phone_country_code),await r.create(Ce)}catch(Ce){x({submit:Ce.message})}finally{b(!1)}},L=async ue=>{if(!(t||v)){b(!0);try{const V=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:F}=await s.create({provider:ue.provider,redirectUri:V});F&&typeof F=="object"&&"oauth_url"in F&&(window.location.href=F.oauth_url)}catch(ee){x({submit:ee.message})}finally{b(!1)}}},P=(a==null?void 0:a.social_connections.filter(ue=>ue.enabled))||[],A=a==null?void 0:a.auth_settings,q=!!((oe=A==null?void 0:A.first_name)!=null&&oe.enabled&&((te=A==null?void 0:A.last_name)!=null&&te.enabled)),Y=async ue=>{var V;if(ue.preventDefault(),t||v)return;b(!0);const ee={};if(!M){ee.otp="OTP code is required",x(ee),b(!1);return}x(ee);try{const F=await r.completeVerification(M);"data"in F&&((V=F.data)!=null&&V.active_signin)&&await c()}catch(F){console.error("Verification failed:",F)}finally{b(!1)}};return i.useEffect(()=>{var ue;if(o){if(o.completed){let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signup_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee){let V;try{V=new URL(ee)}catch{V=new URL(ee,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&V.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(V.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,a,f,h]),u?e.jsx(he,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):y?e.jsx(he,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):_?e.jsx(he,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Ln,{children:e.jsx(Dn,{children:"Sign up Restricted!"})}),e.jsx(Nf,{children:e.jsx(Ff,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Bf,{children:e.jsxs(Uf,{children:["Need assistance?"," ",e.jsx(Wf,{href:(ce=a==null?void 0:a.ui_settings)!=null&&ce.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(he,{children:e.jsx(ho,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Ln,{children:[e.jsxs(Dn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Fa,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Q=a==null?void 0:a.ui_settings)==null?void 0:Q.app_name}`:`${d.phone_number} to continue to ${(me=a==null?void 0:a.ui_settings)==null?void 0:me.app_name}`})]}),e.jsxs(Ba,{style:{gap:"15px"},onSubmit:Y,noValidate:!0,children:[e.jsx(qt,{onComplete:async ue=>{I(ue)},onResend:async()=>{const ue=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ue})},error:m.otp,isSubmitting:v}),e.jsx(Ua,{type:"submit",disabled:v||t||!M,children:v?"Verifying...":`Continue to ${(ve=a==null?void 0:a.ui_settings)==null?void 0:ve.app_name}`})]}),e.jsxs(Wa,{children:["Having trouble?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Nn,{onClick:()=>{N()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:"Create your account"}),e.jsx(Fa,{children:S!=null&&S.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),P.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Bs,{connections:P,callback:L}),e.jsx(Of,{children:e.jsx(Af,{children:"or"})})]}),e.jsxs(Ba,{onSubmit:D,noValidate:!0,children:[(((de=A==null?void 0:A.first_name)==null?void 0:de.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(Lf,{$isBothEnabled:q,children:[((le=A==null?void 0:A.first_name)==null?void 0:le.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"first_name",children:["First name",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:O,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Kt,{children:m.first_name})]}),((Z=A==null?void 0:A.last_name)==null?void 0:Z.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"last_name",children:["Last name",((re=A==null?void 0:A.last_name)==null?void 0:re.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:O,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Kt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:O,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Kt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:O,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(S==null?void 0:S.valid)&&!!(S!=null&&S.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Kt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(wr,{children:"*"})]}),e.jsx(oo,{value:d.phone_number,onChange:O,error:m.phone_number,countryCode:k,setCountryCode:$}),m.phone_number&&e.jsx(Kt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(wr,{children:"*"})]}),e.jsx(Df,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:d.password,onChange:O,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(Kt,{children:m.password})]}),m.submit&&e.jsx(Kt,{children:m.submit}),e.jsx(Ua,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(Wa,{children:["Already have an account?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:`${(fe=a.ui_settings)==null?void 0:fe.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Tl=i.createContext(void 0),Ml=()=>{const t=i.useContext(Tl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Gf=l.div`
929
+ `;function Gf(){var B,H,G,X,oe,te,ce,Q,me,xe,de,U,le,K,Z,re,ge;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=Wc(),{signIn:s}=zr("oauth"),{deployment:a}=we(),{navigate:h}=rt(),{session:f,refetch:c,loading:u}=Qe(),[d,p]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,b]=i.useState(!1),[k,$]=i.useState(void 0),[S,C]=i.useState(null),[z,w]=i.useState(null),[y,g]=i.useState(!1),_=((B=a==null?void 0:a.restrictions)==null?void 0:B.sign_up_mode)==="restricted",E=((H=a==null?void 0:a.restrictions)==null?void 0:H.sign_up_mode)==="waitlist",j=((X=(G=a==null?void 0:a.auth_settings)==null?void 0:G.multi_session_support)==null?void 0:X.enabled)??!1;i.useEffect(()=>{var ue;if(!u&&(f!=null&&f.active_signin)&&!j&&!y){g(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signin_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee&&h(ee)}},[f,u,j,a,h,y]),i.useEffect(()=>{var V;if(!a)return;const ee=new URLSearchParams(window.location.search).get("invite_token");if(E&&!ee){g(!0);const F=((V=a.ui_settings)==null?void 0:V.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;h(F);return}ee&&!S&&r&&(w(ee),r.validateDeploymentInvitation(ee).then(F=>{C(F),F.valid&&p(ne=>({...ne,first_name:F.first_name||ne.first_name,last_name:F.last_name||ne.last_name,email:F.email||ne.email}))}).catch(F=>{console.error("Failed to validate invitation:",F)}))},[a,E,h,S,r]);const[T,R]=i.useState(!1),[M,I]=i.useState(""),O=ue=>{let{name:ee,value:V}=ue.target;ee==="phone_number"?V=V.replace(/[^0-9-]/g,""):ee==="email"&&(V=V.toLowerCase()),p(F=>({...F,[ee]:V})),x(F=>({...F,[ee]:""}))},N=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},D=async ue=>{if(ue.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",d),t||v)return;const ee={},V=/^[a-zA-Z]{3,30}$/,F=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,ne=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,be=/^\d{7,15}$/,Me=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!d.first_name?ee.first_name="First name is required":d.first_name&&!V.test(d.first_name)&&(ee.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!d.last_name?ee.last_name="Last name is required":d.last_name&&!V.test(d.last_name)&&(ee.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!d.username?ee.username="Username is required":d.username&&!F.test(d.username)&&(ee.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!d.email?ee.email="Email address is required":d.email&&!ne.test(d.email)&&(ee.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!d.phone_number?ee.phone_number="Phone number is required":d.phone_number&&!be.test(d.phone_number)&&(ee.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(d.password?Me.test(d.password)||(ee.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):ee.password="Password is required"),x(ee),Object.keys(ee).length>0){console.log("Signup validation failed. Errors:",ee);return}console.log("Signup validation passed"),b(!0);try{const Ce={...d};d.phone_number&&k&&(Ce.phone_country_code=k),z&&(Ce.invite_token=z),console.log("Submitting signup data:",Ce),console.log("Phone number:",Ce.phone_number),console.log("Phone country code:",Ce.phone_country_code),await r.create(Ce)}catch(Ce){x({submit:Ce.message})}finally{b(!1)}},L=async ue=>{if(!(t||v)){b(!0);try{const V=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:F}=await s.create({provider:ue.provider,redirectUri:V});F&&typeof F=="object"&&"oauth_url"in F&&(window.location.href=F.oauth_url)}catch(ee){x({submit:ee.message})}finally{b(!1)}}},P=(a==null?void 0:a.social_connections.filter(ue=>ue.enabled))||[],A=a==null?void 0:a.auth_settings,q=!!((oe=A==null?void 0:A.first_name)!=null&&oe.enabled&&((te=A==null?void 0:A.last_name)!=null&&te.enabled)),Y=async ue=>{var V;if(ue.preventDefault(),t||v)return;b(!0);const ee={};if(!M){ee.otp="OTP code is required",x(ee),b(!1);return}x(ee);try{const F=await r.completeVerification(M);"data"in F&&((V=F.data)!=null&&V.active_signin)&&await c()}catch(F){console.error("Verification failed:",F)}finally{b(!1)}};return i.useEffect(()=>{var ue;if(o){if(o.completed){let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((ue=a==null?void 0:a.ui_settings)==null?void 0:ue.after_signup_redirect_url)||null),!ee&&(a!=null&&a.frontend_host)&&(ee=`https://${a.frontend_host}`),ee){let V;try{V=new URL(ee)}catch{V=new URL(ee,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&V.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(V.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,a,f,h]),u?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):y?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Na,{children:e.jsx(yt,{size:32})})]})}):_?e.jsx(fe,{children:e.jsxs(ho,{children:[e.jsx(Oe,{}),e.jsx(Ln,{children:e.jsx(Dn,{children:"Sign up Restricted!"})}),e.jsx(Ff,{children:e.jsx(Bf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Uf,{children:e.jsxs(Wf,{children:["Need assistance?"," ",e.jsx(Vf,{href:(ce=a==null?void 0:a.ui_settings)!=null&&ce.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(fe,{children:e.jsx(ho,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Ln,{children:[e.jsxs(Dn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Fa,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Q=a==null?void 0:a.ui_settings)==null?void 0:Q.app_name}`:`${d.phone_number} to continue to ${(me=a==null?void 0:a.ui_settings)==null?void 0:me.app_name}`})]}),e.jsxs(Ba,{style:{gap:"15px"},onSubmit:Y,noValidate:!0,children:[e.jsx(qt,{onComplete:async ue=>{I(ue)},onResend:async()=>{const ue=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ue})},error:m.otp,isSubmitting:v}),e.jsx(Ua,{type:"submit",disabled:v||t||!M,children:v?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(Wa,{children:["Having trouble?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Nn,{onClick:()=>{N()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:"Create your account"}),e.jsx(Fa,{children:S!=null&&S.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),P.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Bs,{connections:P,callback:L}),e.jsx(Af,{children:e.jsx(Lf,{children:"or"})})]}),e.jsxs(Ba,{onSubmit:D,noValidate:!0,children:[(((de=A==null?void 0:A.first_name)==null?void 0:de.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(Df,{$isBothEnabled:q,children:[((le=A==null?void 0:A.first_name)==null?void 0:le.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"first_name",children:["First name",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:O,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Kt,{children:m.first_name})]}),((Z=A==null?void 0:A.last_name)==null?void 0:Z.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"last_name",children:["Last name",((re=A==null?void 0:A.last_name)==null?void 0:re.required)&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:O,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Kt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:O,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Kt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(wr,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:O,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(S==null?void 0:S.valid)&&!!(S!=null&&S.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Kt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(wr,{children:"*"})]}),e.jsx(oo,{value:d.phone_number,onChange:O,error:m.phone_number,countryCode:k,setCountryCode:$}),m.phone_number&&e.jsx(Kt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(br,{children:[e.jsxs(yr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(wr,{children:"*"})]}),e.jsx(Nf,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:d.password,onChange:O,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(Kt,{children:m.password})]}),m.submit&&e.jsx(Kt,{children:m.submit}),e.jsx(Ua,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(Wa,{children:["Already have an account?"," ",e.jsx(Nn,{children:e.jsx(ht,{to:`${(ge=a.ui_settings)==null?void 0:ge.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const Tl=i.createContext(void 0),Ml=()=>{const t=i.useContext(Tl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Hf=l.div`
930
930
  position: fixed;
931
931
  inset: 0;
932
932
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -934,7 +934,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
934
934
  justify-content: center;
935
935
  align-items: center;
936
936
  z-index: 99999;
937
- `,Hf=l.div`
937
+ `,qf=l.div`
938
938
  background-color: var(--color-background);
939
939
  border-radius: 8px;
940
940
  box-shadow: 0 10px 25px -5px var(--color-shadow);
@@ -943,17 +943,17 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
943
943
  overflow-y: auto;
944
944
  position: relative;
945
945
  z-index: 100000;
946
- `,qf=l.div`
946
+ `,Yf=l.div`
947
947
  display: flex;
948
948
  align-items: center;
949
949
  justify-content: space-between;
950
950
  padding: var(--space-sm, 12px) var(--space-md, 16px);
951
951
  border-bottom: 1px solid var(--color-border);
952
- `,Yf=l.h2`
952
+ `,Zf=l.h2`
953
953
  font-size: 16px;
954
954
  color: var(--color-foreground);
955
955
  margin: 0;
956
- `,Zf=l.button`
956
+ `,Kf=l.button`
957
957
  background: transparent;
958
958
  border: none;
959
959
  cursor: pointer;
@@ -968,15 +968,15 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
968
968
  background-color: var(--color-background-hover);
969
969
  color: var(--color-foreground);
970
970
  }
971
- `,Kf=l.div`
972
- padding: 16px;
973
971
  `,Qf=l.div`
972
+ padding: 16px;
973
+ `,Xf=l.div`
974
974
  display: flex;
975
975
  justify-content: flex-end;
976
976
  gap: 8px;
977
977
  padding: 16px;
978
978
  border-top: 1px solid var(--color-border);
979
- `,Xf=({isOpen:t,onClose:r,children:o})=>{const[n,s]=i.useState(!1);return i.useEffect(()=>{s(!0);const a=h=>{h.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r]),!t||!n?null:eo.createPortal(e.jsx(he,{children:e.jsx(Tl.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Jf=({children:t})=>{const{onClose:r}=Ml(),o=i.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(Gf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},eg=({children:t,style:r})=>e.jsx(Hf,{style:r,children:t}),tg=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=Ml();return e.jsxs(qf,{children:[typeof t=="string"?e.jsx(Yf,{children:t}):t,r&&e.jsx(Zf,{onClick:o,children:e.jsx(lt,{size:18})})]})},rg=({children:t,style:r})=>e.jsx(Kf,{style:r,children:t}),og=({children:t})=>e.jsx(Qf,{children:t}),ze=Object.assign(Xf,{Overlay:Jf,Content:eg,Header:tg,Body:rg,Footer:og}),ng=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{children:[o&&e.jsx(ze.Header,{showCloseButton:s,children:o}),e.jsx(ze.Body,{children:n})]})})}),sg=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),s=()=>n(!0),a=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:a})]})},ag=l.div`
979
+ `,Jf=({isOpen:t,onClose:r,children:o})=>{const[n,s]=i.useState(!1);return i.useEffect(()=>{s(!0);const a=h=>{h.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r]),!t||!n?null:eo.createPortal(e.jsx(fe,{children:e.jsx(Tl.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},eg=({children:t})=>{const{onClose:r}=Ml(),o=i.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(Hf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},tg=({children:t,style:r})=>e.jsx(qf,{style:r,children:t}),rg=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=Ml();return e.jsxs(Yf,{children:[typeof t=="string"?e.jsx(Zf,{children:t}):t,r&&e.jsx(Kf,{onClick:o,children:e.jsx(lt,{size:18})})]})},og=({children:t,style:r})=>e.jsx(Qf,{style:r,children:t}),ng=({children:t})=>e.jsx(Xf,{children:t}),ze=Object.assign(Jf,{Overlay:eg,Content:tg,Header:rg,Body:og,Footer:ng}),sg=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{children:[o&&e.jsx(ze.Header,{showCloseButton:s,children:o}),e.jsx(ze.Body,{children:n})]})})}),ag=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),s=()=>n(!0),a=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:a})]})},ig=l.div`
980
980
  position: fixed;
981
981
  background: var(--color-background);
982
982
  border-radius: 8px;
@@ -986,9 +986,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
986
986
  z-index: 1000;
987
987
  min-width: 140px;
988
988
  display: grid;
989
- `,ig=l.div`
989
+ `,cg=l.div`
990
990
  width: fit-content;
991
- `,Ol=i.createContext(void 0),Al=()=>{const t=i.useContext(Ol);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ft=({children:t,open:r,openChange:o,style:n})=>{const s=i.useRef(null),[a,h]=i.useState(!1);return i.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&h(!1)};return a&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{h(!!r)},[r]),e.jsx(Ol.Provider,{value:{open:a,openChange:f=>h(f)},children:e.jsx(ig,{style:n,ref:s,children:t})})},gt=({children:t,style:r})=>{const{open:o}=Al(),[n,s]=i.useState({top:0,left:0}),[a,h]=i.useState(!1),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(h(!1),requestAnimationFrame(()=>{var d,p;const c=(d=f.current)==null?void 0:d.parentElement;if(!c)return;const u=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(u&&u!==f.current){const m=u.getBoundingClientRect(),x=(p=f.current)==null?void 0:p.getBoundingClientRect(),v=window.innerWidth,b=window.innerHeight;let k=m.bottom+4,$=m.right-200;$<8&&($=m.left),$+200>v-8&&($=v-208),x&&k+x.height>b-8&&(k=m.top-(x.height+4)),s({top:k,left:$}),h(!0)}})):h(!1)},[o]),o?e.jsx(ag,{ref:f,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},mt=({children:t})=>{const{openChange:r,open:o}=Al(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Be=l.button`
991
+ `,Ol=i.createContext(void 0),Al=()=>{const t=i.useContext(Ol);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ft=({children:t,open:r,openChange:o,style:n})=>{const s=i.useRef(null),[a,h]=i.useState(!1);return i.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&h(!1)};return a&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{h(!!r)},[r]),e.jsx(Ol.Provider,{value:{open:a,openChange:f=>h(f)},children:e.jsx(cg,{style:n,ref:s,children:t})})},gt=({children:t,style:r})=>{const{open:o}=Al(),[n,s]=i.useState({top:0,left:0}),[a,h]=i.useState(!1),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(h(!1),requestAnimationFrame(()=>{var d,p;const c=(d=f.current)==null?void 0:d.parentElement;if(!c)return;const u=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(u&&u!==f.current){const m=u.getBoundingClientRect(),x=(p=f.current)==null?void 0:p.getBoundingClientRect(),v=window.innerWidth,b=window.innerHeight;let k=m.bottom+4,$=m.right-200;$<8&&($=m.left),$+200>v-8&&($=v-208),x&&k+x.height>b-8&&(k=m.top-(x.height+4)),s({top:k,left:$}),h(!0)}})):h(!1)},[o]),o?e.jsx(ig,{ref:f,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},mt=({children:t})=>{const{openChange:r,open:o}=Al(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Be=l.button`
992
992
  width: 100%;
993
993
  padding: 8px 12px;
994
994
  background: none;
@@ -1010,7 +1010,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1010
1010
  display: flex;
1011
1011
  flex-direction: column;
1012
1012
  gap: var(--space-md);
1013
- `,pe=l.div`
1013
+ `,he=l.div`
1014
1014
  display: flex;
1015
1015
  flex-direction: column;
1016
1016
  gap: var(--space-xs);
@@ -1019,37 +1019,37 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1019
1019
  text-align: left;
1020
1020
  font-weight: 400;
1021
1021
  color: var(--color-foreground);
1022
- `,cg=Ht`
1022
+ `,lg=Ht`
1023
1023
  0% {
1024
1024
  transform: rotate(0deg);
1025
1025
  }
1026
1026
  100% {
1027
1027
  transform: rotate(360deg);
1028
1028
  }
1029
- `,lg=l.div`
1029
+ `,dg=l.div`
1030
1030
  display: flex;
1031
1031
  justify-content: center;
1032
1032
  align-items: center;
1033
1033
  width: 100%;
1034
1034
  height: ${t=>t.$size?`${t.$size}px`:"100%"};
1035
- `,dg=l.div`
1035
+ `,ug=l.div`
1036
1036
  width: ${t=>t.$size?`${t.$size}px`:"40px"};
1037
1037
  height: ${t=>t.$size?`${t.$size}px`:"40px"};
1038
1038
  border: 3px solid var(--color-border);
1039
1039
  border-top: 3px solid var(--color-primary);
1040
1040
  border-radius: 50%;
1041
- animation: ${cg} 1s linear infinite;
1042
- `,Re=({size:t,className:r})=>e.jsx(lg,{className:r,$size:t,children:e.jsx(dg,{$size:t})}),ug=l.label`
1041
+ animation: ${lg} 1s linear infinite;
1042
+ `,Re=({size:t,className:r})=>e.jsx(dg,{className:r,$size:t,children:e.jsx(ug,{$size:t})}),pg=l.label`
1043
1043
  display: inline-flex;
1044
1044
  align-items: center;
1045
1045
  cursor: pointer;
1046
1046
  position: relative;
1047
- `,pg=l.input`
1047
+ `,hg=l.input`
1048
1048
  opacity: 0;
1049
1049
  width: 0;
1050
1050
  height: 0;
1051
1051
  position: absolute;
1052
- `,hg=l.span`
1052
+ `,fg=l.span`
1053
1053
  position: relative;
1054
1054
  width: 40px;
1055
1055
  height: 24px;
@@ -1070,7 +1070,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1070
1070
  left: ${t=>t.checked?"20px":"2px"};
1071
1071
  transition: left 0.2s ease;
1072
1072
  }
1073
- `,mr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(ug,{children:[e.jsx(pg,{type:"checkbox",checked:t,onChange:o}),e.jsx(hg,{checked:t})]})},Zr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),s=i.useCallback(()=>{o(!1)},[]),a=i.useCallback(()=>{o(h=>!h)},[]);return{isOpen:r,open:n,close:s,toggle:a}},At=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(Kh,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),J=l.button`
1073
+ `,mr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(pg,{children:[e.jsx(hg,{type:"checkbox",checked:t,onChange:o}),e.jsx(fg,{checked:t})]})},Zr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),s=i.useCallback(()=>{o(!1)},[]),a=i.useCallback(()=>{o(h=>!h)},[]);return{isOpen:r,open:n,close:s,toggle:a}},At=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(Qh,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),J=l.button`
1074
1074
  width: 100%;
1075
1075
  padding: var(--space-sm) var(--space-md);
1076
1076
  border: 1px solid transparent;
@@ -1212,7 +1212,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1212
1212
  text-transform: uppercase;
1213
1213
  color: var(--color-muted);
1214
1214
  background: var(--color-background-hover);
1215
- `,Us=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:a=!1,width:h,name:f,id:c,groupsEnabled:u=!1,className:d})=>{const[p,m]=i.useState(!1),[x,v]=i.useState(""),b=i.useRef(null),k=i.useRef(null),$=u&&"options"in t[0],C=($?t.flatMap(g=>g.options):t).find(g=>g.value===r),z=x?$?t.map(g=>({...g,options:g.options.filter(_=>_.label.toLowerCase().includes(x.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(x.toLowerCase())):t,w=(g,_=!1)=>{_||(o(g),m(!1),v(""))},y=()=>{s||m(!p)};return i.useEffect(()=>{p&&a&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[p,a]),i.useEffect(()=>{const g=_=>{b.current&&!b.current.contains(_.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Ll,{ref:b,style:{width:h},className:d,children:[e.jsxs(Dl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[C?C.label:e.jsx(Bl,{children:n}),p?e.jsx(Sl,{size:16}):e.jsx(Ut,{size:16})]}),e.jsxs(Nl,{isOpen:p,role:"listbox",children:[a&&e.jsx(Fl,{ref:k,type:"text",placeholder:"Search...",value:x,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),$?z.map((g,_)=>e.jsxs(i.Fragment,{children:[e.jsx(Ul,{children:g.label}),g.options.length===0?e.jsx(Jo,{children:"No options available"}):g.options.map(E=>e.jsxs(Xo,{isSelected:E.value===r,disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":E.value===r,children:[E.label,E.value===r&&e.jsx(tt,{size:16})]},E.value))]},`group-${_}`)):e.jsx(e.Fragment,{children:z.length===0?e.jsx(Jo,{children:"No options available"}):z.map(g=>e.jsxs(Xo,{isSelected:g.value===r,disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":g.value===r,children:[g.label,g.value===r&&e.jsx(tt,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},Wl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:h,name:f,id:c,groupsEnabled:u=!1,className:d})=>{const[p,m]=i.useState(!1),[x,v]=i.useState(""),b=i.useRef(null),k=i.useRef(null),$=u&&"options"in t[0],C=($?t.flatMap(g=>g.options):t).filter(g=>r.includes(g.value)),z=x?$?t.map(g=>({...g,options:g.options.filter(_=>_.label.toLowerCase().includes(x.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(x.toLowerCase())):t,w=(g,_=!1)=>{_||(r.includes(g)?o(r.filter(E=>E!==g)):o([...r,g]))},y=()=>{s||m(!p)};return i.useEffect(()=>{p&&a&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[p,a]),i.useEffect(()=>{const g=_=>{b.current&&!b.current.contains(_.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Ll,{ref:b,style:{width:h},className:d,children:[e.jsxs(Dl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[C.length>0?C.map(g=>g.label).join(", "):e.jsx(Bl,{children:n}),p?e.jsx(Sl,{size:16}):e.jsx(Ut,{size:16})]}),e.jsxs(Nl,{isOpen:p,role:"listbox",children:[a&&e.jsx(Fl,{ref:k,type:"text",placeholder:"Search...",value:x,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),$?z.map((g,_)=>e.jsxs(i.Fragment,{children:[e.jsx(Ul,{children:g.label}),g.options.length===0?e.jsx(Jo,{children:"No options available"}):g.options.map(E=>e.jsxs(Xo,{isSelected:r.includes(E.value),disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":r.includes(E.value),children:[E.label,r.includes(E.value)&&e.jsx(tt,{size:16})]},E.value))]},`group-${_}`)):e.jsx(e.Fragment,{children:z.length===0?e.jsx(Jo,{children:"No options available"}):z.map(g=>e.jsxs(Xo,{isSelected:r.includes(g.value),disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":r.includes(g.value),children:[g.label,r.includes(g.value)&&e.jsx(tt,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},Vl=i.createContext(void 0);function Gl(){const t=i.useContext(Vl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function fg({children:t}){const{deployment:r}=ye(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState("identifier"),v=(r==null?void 0:r.social_connections.filter(k=>k.enabled))||[],b=r==null?void 0:r.auth_settings;return e.jsx(Vl.Provider,{value:{email:s,showOtherOptions:h,showForgotPassword:c,otpSent:d,setFirstFactor:n,setEmail:a,setShowOtherOptions:f,setShowForgotPassword:u,setOtpSent:p,enabledSocialsProviders:v,authSettings:b,firstFactor:o,signInStep:m,setSignInStep:x},children:t})}const Fr=l.button`
1215
+ `,Us=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:a=!1,width:h,name:f,id:c,groupsEnabled:u=!1,className:d})=>{const[p,m]=i.useState(!1),[x,v]=i.useState(""),b=i.useRef(null),k=i.useRef(null),$=u&&"options"in t[0],C=($?t.flatMap(g=>g.options):t).find(g=>g.value===r),z=x?$?t.map(g=>({...g,options:g.options.filter(_=>_.label.toLowerCase().includes(x.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(x.toLowerCase())):t,w=(g,_=!1)=>{_||(o(g),m(!1),v(""))},y=()=>{s||m(!p)};return i.useEffect(()=>{p&&a&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[p,a]),i.useEffect(()=>{const g=_=>{b.current&&!b.current.contains(_.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Ll,{ref:b,style:{width:h},className:d,children:[e.jsxs(Dl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[C?C.label:e.jsx(Bl,{children:n}),p?e.jsx(Sl,{size:16}):e.jsx(Ut,{size:16})]}),e.jsxs(Nl,{isOpen:p,role:"listbox",children:[a&&e.jsx(Fl,{ref:k,type:"text",placeholder:"Search...",value:x,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),$?z.map((g,_)=>e.jsxs(i.Fragment,{children:[e.jsx(Ul,{children:g.label}),g.options.length===0?e.jsx(Jo,{children:"No options available"}):g.options.map(E=>e.jsxs(Xo,{isSelected:E.value===r,disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":E.value===r,children:[E.label,E.value===r&&e.jsx(tt,{size:16})]},E.value))]},`group-${_}`)):e.jsx(e.Fragment,{children:z.length===0?e.jsx(Jo,{children:"No options available"}):z.map(g=>e.jsxs(Xo,{isSelected:g.value===r,disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":g.value===r,children:[g.label,g.value===r&&e.jsx(tt,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},Wl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:h,name:f,id:c,groupsEnabled:u=!1,className:d})=>{const[p,m]=i.useState(!1),[x,v]=i.useState(""),b=i.useRef(null),k=i.useRef(null),$=u&&"options"in t[0],C=($?t.flatMap(g=>g.options):t).filter(g=>r.includes(g.value)),z=x?$?t.map(g=>({...g,options:g.options.filter(_=>_.label.toLowerCase().includes(x.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(x.toLowerCase())):t,w=(g,_=!1)=>{_||(r.includes(g)?o(r.filter(E=>E!==g)):o([...r,g]))},y=()=>{s||m(!p)};return i.useEffect(()=>{p&&a&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[p,a]),i.useEffect(()=>{const g=_=>{b.current&&!b.current.contains(_.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(Ll,{ref:b,style:{width:h},className:d,children:[e.jsxs(Dl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[C.length>0?C.map(g=>g.label).join(", "):e.jsx(Bl,{children:n}),p?e.jsx(Sl,{size:16}):e.jsx(Ut,{size:16})]}),e.jsxs(Nl,{isOpen:p,role:"listbox",children:[a&&e.jsx(Fl,{ref:k,type:"text",placeholder:"Search...",value:x,onChange:g=>v(g.target.value),onClick:g=>g.stopPropagation()}),$?z.map((g,_)=>e.jsxs(i.Fragment,{children:[e.jsx(Ul,{children:g.label}),g.options.length===0?e.jsx(Jo,{children:"No options available"}):g.options.map(E=>e.jsxs(Xo,{isSelected:r.includes(E.value),disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":r.includes(E.value),children:[E.label,r.includes(E.value)&&e.jsx(tt,{size:16})]},E.value))]},`group-${_}`)):e.jsx(e.Fragment,{children:z.length===0?e.jsx(Jo,{children:"No options available"}):z.map(g=>e.jsxs(Xo,{isSelected:r.includes(g.value),disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":r.includes(g.value),children:[g.label,r.includes(g.value)&&e.jsx(tt,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},Vl=i.createContext(void 0);function Gl(){const t=i.useContext(Vl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function gg({children:t}){const{deployment:r}=we(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState("identifier"),v=(r==null?void 0:r.social_connections.filter(k=>k.enabled))||[],b=r==null?void 0:r.auth_settings;return e.jsx(Vl.Provider,{value:{email:s,showOtherOptions:h,showForgotPassword:c,otpSent:d,setFirstFactor:n,setEmail:a,setShowOtherOptions:f,setShowForgotPassword:u,setOtpSent:p,enabledSocialsProviders:v,authSettings:b,firstFactor:o,signInStep:m,setSignInStep:x},children:t})}const Fr=l.button`
1216
1216
  width: 100%;
1217
1217
  padding: var(--space-sm) var(--space-md);
1218
1218
  background: var(--color-input-background);
@@ -1235,7 +1235,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1235
1235
  opacity: 0.7;
1236
1236
  cursor: not-allowed;
1237
1237
  }
1238
- `;function Hl(){const{deployment:t}=ye(),{signIn:r}=zr("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:a}=Gl(),[h,f]=i.useState(!1),c=t==null?void 0:t.auth_settings,u=(t==null?void 0:t.social_connections.filter(m=>m.enabled))||[],d=async m=>{if(!h){f(!0);try{const{data:x}=await r.create({provider:m.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{f(!1)}}},p=()=>{a(!1),s(!1)};return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsx(Bs,{connections:u,callback:d}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Fr,{onClick:()=>{o("email_magic_link"),p()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Fr,{onClick:()=>{o("email_password"),p()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Fr,{onClick:()=>{o("email_otp"),p()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Fr,{onClick:()=>{o("phone_otp"),p()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Fr,{onClick:()=>{o("username_password"),p()},children:"Sign in with username and password"})]})]})}const gg=l.div`
1238
+ `;function Hl(){const{deployment:t}=we(),{signIn:r}=zr("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:a}=Gl(),[h,f]=i.useState(!1),c=t==null?void 0:t.auth_settings,u=(t==null?void 0:t.social_connections.filter(m=>m.enabled))||[],d=async m=>{if(!h){f(!0);try{const{data:x}=await r.create({provider:m.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{f(!1)}}},p=()=>{a(!1),s(!1)};return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsx(Bs,{connections:u,callback:d}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Fr,{onClick:()=>{o("email_magic_link"),p()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Fr,{onClick:()=>{o("email_password"),p()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Fr,{onClick:()=>{o("email_otp"),p()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Fr,{onClick:()=>{o("phone_otp"),p()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Fr,{onClick:()=>{o("username_password"),p()},children:"Sign in with username and password"})]})]})}const mg=l.div`
1239
1239
  max-width: 380px;
1240
1240
  width: 380px;
1241
1241
  padding: var(--space-3xl);
@@ -1258,10 +1258,10 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1258
1258
  color: var(--color-error);
1259
1259
  margin: 0;
1260
1260
  margin-top: var(--space-2xs);
1261
- `,mg=l(J)`
1261
+ `,xg=l(J)`
1262
1262
  width: 100%;
1263
1263
  margin-bottom: var(--space-lg);
1264
- `,xg=l.div`
1264
+ `,vg=l.div`
1265
1265
  display: flex;
1266
1266
  align-items: center;
1267
1267
  text-align: center;
@@ -1283,7 +1283,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1283
1283
  &::after {
1284
1284
  margin-left: var(--space-sm);
1285
1285
  }
1286
- `,vg=l.span`
1286
+ `,bg=l.span`
1287
1287
  white-space: nowrap;
1288
1288
  `,mo=l.div`
1289
1289
  text-align: center;
@@ -1299,28 +1299,28 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1299
1299
  &:hover {
1300
1300
  text-decoration: underline;
1301
1301
  }
1302
- `;function bg({onBack:t}){const{deployment:r}=ye(),{navigate:o}=rt(),[n,s]=i.useState("start"),[a,h]=i.useState(""),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:b,verifyOtp:k,resetPassword:$}=Zc(),[S,C]=i.useState(!1),[z,w]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){C(!0),w(null);try{await b(a),s("otp")}catch(T){w(T)}finally{C(!1)}}},g=async j=>{if(j.preventDefault(),f.length===6){C(!0),w(null);try{const T=await k(a,f);T.data&&(d(T.data.token),s("reset"))}catch(T){w(T)}finally{C(!1)}}},_=async j=>{var T,R;if(j.preventDefault(),p===x&&!(p.length<8)){C(!0),w(null);try{const M=await $(u,p);if(M.data){const I=M.data,O=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(O&&!O.completed){const N=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(N){const D=new URL(N,window.location.origin);D.searchParams.set("signin_attempt_id",O.id),o(D.toString())}else t()}else{const N=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(N)}}}catch(M){w(M)}finally{C(!1)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(fo,{children:e.jsx(go,{children:"Forgot Password"})}),e.jsx(mg,{onClick:()=>s("email"),disabled:S,children:"Reset your password"}),e.jsx(xg,{children:e.jsx(vg,{children:"Or, sign in with another method"})}),e.jsx(Hl,{}),e.jsxs(mo,{children:[e.jsxs(Br,{children:["Unable to reset password? ",e.jsx(Ur,{href:"/contact",children:"Get help"})]}),e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(he,{children:e.jsxs(gg,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Forgot Password"}),e.jsx(Fn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(wt,{onSubmit:y,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(se,{type:"email",id:"email",value:a,onChange:j=>h(j.target.value),placeholder:"Enter your email",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Sending...":"Send Code"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Enter Verification Code"}),e.jsxs(Fn,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(wt,{onSubmit:g,noValidate:!0,children:[e.jsx(qt,{onComplete:j=>c(j),isSubmitting:S,error:z==null?void 0:z.message,onResend:async()=>{await b(a)}}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Verifying...":"Verify"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Reset Password"}),e.jsx(Fn,{children:"Create a new password for your account."})]}),e.jsxs(wt,{onSubmit:_,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(se,{type:"password",id:"password",value:p,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(se,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Resetting...":"Reset Password"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const yg=l.div`
1302
+ `;function yg({onBack:t}){const{deployment:r}=we(),{navigate:o}=rt(),[n,s]=i.useState("start"),[a,h]=i.useState(""),[f,c]=i.useState(""),[u,d]=i.useState(""),[p,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:b,verifyOtp:k,resetPassword:$}=Zc(),[S,C]=i.useState(!1),[z,w]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){C(!0),w(null);try{await b(a),s("otp")}catch(T){w(T)}finally{C(!1)}}},g=async j=>{if(j.preventDefault(),f.length===6){C(!0),w(null);try{const T=await k(a,f);T.data&&(d(T.data.token),s("reset"))}catch(T){w(T)}finally{C(!1)}}},_=async j=>{var T,R;if(j.preventDefault(),p===x&&!(p.length<8)){C(!0),w(null);try{const M=await $(u,p);if(M.data){const I=M.data,O=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(O&&!O.completed){const N=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(N){const D=new URL(N,window.location.origin);D.searchParams.set("signin_attempt_id",O.id),o(D.toString())}else t()}else{const N=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(N)}}}catch(M){w(M)}finally{C(!1)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsx(fo,{children:e.jsx(go,{children:"Forgot Password"})}),e.jsx(xg,{onClick:()=>s("email"),disabled:S,children:"Reset your password"}),e.jsx(vg,{children:e.jsx(bg,{children:"Or, sign in with another method"})}),e.jsx(Hl,{}),e.jsxs(mo,{children:[e.jsxs(Br,{children:["Unable to reset password? ",e.jsx(Ur,{href:"/contact",children:"Get help"})]}),e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(fe,{children:e.jsxs(mg,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Forgot Password"}),e.jsx(Fn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(wt,{onSubmit:y,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(se,{type:"email",id:"email",value:a,onChange:j=>h(j.target.value),placeholder:"Enter your email",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Sending...":"Send Code"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Enter Verification Code"}),e.jsxs(Fn,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(wt,{onSubmit:g,noValidate:!0,children:[e.jsx(qt,{onComplete:j=>c(j),isSubmitting:S,error:z==null?void 0:z.message,onResend:async()=>{await b(a)}}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Verifying...":"Verify"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{}),e.jsxs(fo,{children:[e.jsx(go,{children:"Reset Password"}),e.jsx(Fn,{children:"Create a new password for your account."})]}),e.jsxs(wt,{onSubmit:_,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(se,{type:"password",id:"password",value:p,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(se,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),z&&e.jsx(Bn,{children:z.message}),e.jsx(J,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Resetting...":"Reset Password"})]}),e.jsx(mo,{children:e.jsx(Br,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ur,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const wg=l.div`
1303
1303
  max-width: 360px;
1304
1304
  width: 360px;
1305
1305
  padding: var(--space-2xl);
1306
1306
  background: var(--color-background);
1307
1307
  border-radius: var(--radius-lg);
1308
1308
  box-shadow: 0 4px 12px var(--color-shadow);
1309
- `,wg=l.div`
1309
+ `,jg=l.div`
1310
1310
  text-align: center;
1311
1311
  margin-bottom: var(--space-lg);
1312
1312
  position: relative;
1313
- `,jg=l.h1`
1313
+ `,kg=l.h1`
1314
1314
  font-size: var(--font-lg);
1315
1315
  font-weight: 400;
1316
1316
  color: var(--color-foreground);
1317
1317
  margin-bottom: var(--space-xs);
1318
1318
  margin-top: 0;
1319
- `,kg=l.p`
1319
+ `,_g=l.p`
1320
1320
  color: var(--color-secondary-text);
1321
1321
  font-size: var(--font-xs);
1322
1322
  margin: 0;
1323
- `,_g=l.div`
1323
+ `,Cg=l.div`
1324
1324
  text-align: center;
1325
1325
  margin-top: var(--space-lg);
1326
1326
  `,Va=l.p`
@@ -1329,31 +1329,31 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1329
1329
  `,Ga=l.a`
1330
1330
  color: var(--color-primary);
1331
1331
  text-decoration: none;
1332
- `;function Cg({onBack:t}){return e.jsx(he,{children:e.jsxs(yg,{children:[e.jsx(Oe,{}),e.jsxs(wg,{children:[e.jsx(jg,{children:"Supported Options"}),e.jsx(kg,{children:"Choose one of the following options to continue"})]}),e.jsx(Hl,{}),e.jsxs(_g,{children:[e.jsxs(Va,{children:["Don't have an account? ",e.jsx(Ga,{href:"/signup",children:"Sign up"})]}),e.jsx(Va,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ga,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Sg=l.div`
1332
+ `;function Sg({onBack:t}){return e.jsx(fe,{children:e.jsxs(wg,{children:[e.jsx(Oe,{}),e.jsxs(jg,{children:[e.jsx(kg,{children:"Supported Options"}),e.jsx(_g,{children:"Choose one of the following options to continue"})]}),e.jsx(Hl,{}),e.jsxs(Cg,{children:[e.jsxs(Va,{children:["Don't have an account? ",e.jsx(Ga,{href:"/signup",children:"Sign up"})]}),e.jsx(Va,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ga,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const $g=l.div`
1333
1333
  max-width: 380px;
1334
1334
  width: 380px;
1335
1335
  padding: var(--space-3xl);
1336
1336
  background: var(--color-background);
1337
1337
  border-radius: var(--radius-lg);
1338
1338
  box-shadow: 0 4px 12px var(--color-shadow);
1339
- `,$g=l.div`
1339
+ `,zg=l.div`
1340
1340
  text-align: center;
1341
1341
  margin-bottom: var(--space-lg);
1342
1342
  position: relative;
1343
- `,zg=l.h1`
1343
+ `,Eg=l.h1`
1344
1344
  font-size: var(--font-lg);
1345
1345
  font-weight: 400;
1346
1346
  color: var(--color-foreground);
1347
1347
  margin-bottom: var(--space-xs);
1348
1348
  margin-top: 0;
1349
- `,Eg=l.p`
1349
+ `,Pg=l.p`
1350
1350
  color: var(--color-secondary-text);
1351
1351
  font-size: var(--font-xs);
1352
- `,Pg=l.div`
1352
+ `,Ig=l.div`
1353
1353
  display: flex;
1354
1354
  flex-direction: column;
1355
1355
  gap: 0;
1356
- `,Ig=l.button`
1356
+ `,Rg=l.button`
1357
1357
  display: flex;
1358
1358
  align-items: flex-start;
1359
1359
  gap: var(--space-md);
@@ -1388,25 +1388,25 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1388
1388
  color: var(--color-primary);
1389
1389
  margin-top: 2px;
1390
1390
  }
1391
- `,Rg=l.div`
1391
+ `,Tg=l.div`
1392
1392
  flex: 1;
1393
1393
  display: flex;
1394
1394
  flex-direction: column;
1395
1395
  gap: var(--space-2xs);
1396
- `,Tg=l.div`
1396
+ `,Mg=l.div`
1397
1397
  font-weight: 400;
1398
1398
  font-size: var(--font-sm);
1399
1399
  color: var(--color-foreground);
1400
- `,Mg=l.div`
1400
+ `,Og=l.div`
1401
1401
  font-size: var(--font-xs);
1402
1402
  color: var(--color-secondary-text);
1403
1403
  line-height: 1.4;
1404
- `,Og=l.div`
1404
+ `,Ag=l.div`
1405
1405
  margin-top: var(--space-lg);
1406
1406
  text-align: center;
1407
1407
  font-size: var(--font-xs);
1408
1408
  color: var(--color-secondary-text);
1409
- `,Ag=l.span`
1409
+ `,Lg=l.span`
1410
1410
  color: var(--color-primary);
1411
1411
  text-decoration: none;
1412
1412
  font-weight: 400;
@@ -1416,40 +1416,40 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1416
1416
  &:hover {
1417
1417
  color: var(--color-primary-hover);
1418
1418
  }
1419
- `;function ql({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(he,{children:e.jsxs(Sg,{children:[e.jsx(Oe,{}),e.jsxs($g,{children:[e.jsx(zg,{children:"Two-factor authentication"}),e.jsx(Eg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(Pg,{children:t.map(s=>e.jsxs(Ig,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(Rg,{children:[e.jsx(Tg,{children:s.name}),e.jsxs(Mg,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(Og,{children:e.jsx(Ag,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const Lg=l.div`
1419
+ `;function ql({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(fe,{children:e.jsxs($g,{children:[e.jsx(Oe,{}),e.jsxs(zg,{children:[e.jsx(Eg,{children:"Two-factor authentication"}),e.jsx(Pg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(Ig,{children:t.map(s=>e.jsxs(Rg,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(Tg,{children:[e.jsx(Mg,{children:s.name}),e.jsxs(Og,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(Ag,{children:e.jsx(Lg,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const Dg=l.div`
1420
1420
  max-width: 380px;
1421
1421
  width: 380px;
1422
1422
  padding: var(--space-3xl);
1423
1423
  background: var(--color-background);
1424
1424
  border-radius: var(--radius-lg);
1425
1425
  box-shadow: 0 4px 12px var(--color-shadow);
1426
- `,Dg=l.div`
1426
+ `,Ng=l.div`
1427
1427
  text-align: center;
1428
1428
  margin-bottom: var(--space-lg);
1429
1429
  position: relative;
1430
- `,Ng=l.h1`
1430
+ `,Fg=l.h1`
1431
1431
  font-size: var(--font-lg);
1432
1432
  font-weight: 400;
1433
1433
  color: var(--color-foreground);
1434
1434
  margin-bottom: var(--space-xs);
1435
1435
  margin-top: 0;
1436
- `,Fg=l.p`
1436
+ `,Bg=l.p`
1437
1437
  color: var(--color-secondary-text);
1438
1438
  font-size: var(--font-xs);
1439
- `,Bg=l.p`
1439
+ `,Ug=l.p`
1440
1440
  font-size: var(--font-2xs);
1441
1441
  color: var(--color-error);
1442
1442
  margin: 0;
1443
1443
  margin-top: var(--space-2xs);
1444
- `,Ug=l(J)`
1444
+ `,Wg=l(J)`
1445
1445
  margin-top: var(--space-sm);
1446
1446
  width: 100%;
1447
- `,Wg=l.div`
1447
+ `,Vg=l.div`
1448
1448
  margin-top: var(--space-lg);
1449
1449
  text-align: center;
1450
1450
  font-size: var(--font-xs);
1451
1451
  color: var(--color-secondary-text);
1452
- `,Vg=l.span`
1452
+ `,Gg=l.span`
1453
1453
  color: var(--color-primary);
1454
1454
  text-decoration: none;
1455
1455
  font-weight: 400;
@@ -1459,30 +1459,30 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1459
1459
  &:hover {
1460
1460
  color: var(--color-primary-hover);
1461
1461
  }
1462
- `,Gg=l(se)`
1462
+ `,Hg=l(se)`
1463
1463
  padding: var(--space-sm) var(--space-md);
1464
- `;function Yl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,h]=i.useState(""),f=u=>{if(u.preventDefault(),n.length!==4){h("Please enter the last 4 digits of your phone number");return}t(n)},c=u=>{const d=u.target.value.replace(/\D/g,"").slice(0,4);s(d),h("")};return e.jsx(he,{children:e.jsxs(Lg,{children:[e.jsx(Oe,{}),e.jsxs(Dg,{children:[e.jsx(Ng,{children:"Verify your phone number"}),e.jsx(Fg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(wt,{onSubmit:f,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Gg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(Bg,{children:a})]}),e.jsx(Ug,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(Wg,{children:e.jsx(Vg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Hg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),qg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Yg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),Un=l.div`
1464
+ `;function Yl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,h]=i.useState(""),f=u=>{if(u.preventDefault(),n.length!==4){h("Please enter the last 4 digits of your phone number");return}t(n)},c=u=>{const d=u.target.value.replace(/\D/g,"").slice(0,4);s(d),h("")};return e.jsx(fe,{children:e.jsxs(Dg,{children:[e.jsx(Oe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Verify your phone number"}),e.jsx(Bg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(wt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Hg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(Ug,{children:a})]}),e.jsx(Wg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(Vg,{children:e.jsx(Gg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const qg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Yg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Zg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),Un=l.div`
1465
1465
  max-width: 380px;
1466
1466
  width: 380px;
1467
1467
  padding: var(--space-3xl);
1468
1468
  background: var(--color-background);
1469
1469
  border-radius: var(--radius-lg);
1470
1470
  box-shadow: 0 4px 12px var(--color-shadow);
1471
- `,Zg=Ht`
1471
+ `,Kg=Ht`
1472
1472
  from {
1473
1473
  transform: rotate(0deg);
1474
1474
  }
1475
1475
  to {
1476
1476
  transform: rotate(360deg);
1477
1477
  }
1478
- `,Kg=l.div`
1478
+ `,Qg=l.div`
1479
1479
  display: flex;
1480
1480
  justify-content: center;
1481
1481
  align-items: center;
1482
1482
  min-height: 200px;
1483
1483
 
1484
1484
  svg {
1485
- animation: ${Zg} 1s linear infinite;
1485
+ animation: ${Kg} 1s linear infinite;
1486
1486
  color: var(--color-primary);
1487
1487
  }
1488
1488
  `,Ha=l.div`
@@ -1503,7 +1503,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1503
1503
  color: var(--color-error);
1504
1504
  margin: 0;
1505
1505
  margin-top: var(--space-2xs);
1506
- `,Qg=l(J)`
1506
+ `,Xg=l(J)`
1507
1507
  margin-top: var(--space-sm);
1508
1508
  `,Ka=l.div`
1509
1509
  margin-top: var(--space-lg);
@@ -1520,9 +1520,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1520
1520
  &:hover {
1521
1521
  color: var(--color-primary-hover);
1522
1522
  }
1523
- `,Xg=l(se)`
1523
+ `,Jg=l(se)`
1524
1524
  padding: var(--space-sm) var(--space-md);
1525
- `;function Zl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=ye(),[a,h]=i.useState(""),[f,c]=i.useState({}),[u,d]=i.useState(!1),[p,m]=i.useState(null),[x,v]=i.useState(!0),[b,k]=i.useState(!1),[$,S]=i.useState(""),[C,z]=i.useState(!1),{navigate:w}=rt(),y=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Hg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(qg,{}),available:y.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Yg,{}),available:y.includes("backup_code")}].filter(R=>R.available),_=async R=>{m(R),v(!1),R==="phone_otp"&&k(!0)},E=async R=>{var M,I;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:R});O&&"data"in O&&((M=O.data)!=null&&M.otp_sent)?((I=O.data)!=null&&I.masked_phone&&S(O.data.masked_phone),k(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},j=async(R,M)=>{if(R.preventDefault(),u)return;const I=M||a,O={};if(I?p==="authenticator"&&I.length!==6?O.code="Authentication code must be 6 digits":p==="phone_otp"&&I.length!==6&&(O.code="SMS code must be 6 digits"):O.code="Verification code is required",c(O),!(Object.keys(O).length>0)){d(!0);try{await o(I)}catch(N){c({submit:N.message})}finally{d(!1)}}},T=R=>{let M=R.target.value;p!=="backup_code"&&(M=M.replace(/\D/g,"").slice(0,6)),h(M),c(I=>({...I,code:""}))};return i.useEffect(()=>{var R;if(r.completed){z(!0);let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!M&&(s!=null&&s.frontend_host)&&(M=`https://${s.frontend_host}`),M){let I;try{I=new URL(M)}catch{I=new URL(M,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(I.toString())}return}},[r,s]),C?e.jsx(he,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsx(Kg,{children:e.jsx(yt,{size:32})})]})}):x?g.length===0?e.jsx(he,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Set Up Two-Factor Authentication"}),e.jsx(Ya,{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(Ka,{children:[t&&e.jsx("div",{children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(ql,{methods:g,onSelectMethod:_,onBack:t}):b&&p==="phone_otp"?e.jsx(Yl,{onVerify:E,onBack:()=>{k(!1),v(!0),m(null)},loading:u}):e.jsx(he,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Two-factor authentication"}),e.jsxs(Ya,{children:[p==="authenticator"&&"Enter the 6-digit code from your authenticator app",p==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,p==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(wt,{onSubmit:j,noValidate:!0,children:[p==="backup_code"?e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(Xg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Za,{children:f.code})]}):e.jsx(qt,{onComplete:async R=>{if(h(R),p!=="backup_code"){const M=new Event("submit",{bubbles:!0,cancelable:!0});await j(M,R)}},onResend:p==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:u}),e.jsxs("div",{children:[f.submit&&e.jsx(Za,{children:f.submit}),e.jsx(Qg,{type:"submit",disabled:u||!a,children:u?"Verifying...":"Verify"})]})]}),e.jsxs(Ka,{children:[e.jsx(Wr,{onClick:()=>{v(!0),m(null),h(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Wn=l.div`
1525
+ `;function Zl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=we(),[a,h]=i.useState(""),[f,c]=i.useState({}),[u,d]=i.useState(!1),[p,m]=i.useState(null),[x,v]=i.useState(!0),[b,k]=i.useState(!1),[$,S]=i.useState(""),[C,z]=i.useState(!1),{navigate:w}=rt(),y=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(qg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Yg,{}),available:y.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Zg,{}),available:y.includes("backup_code")}].filter(R=>R.available),_=async R=>{m(R),v(!1),R==="phone_otp"&&k(!0)},E=async R=>{var M,I;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:R});O&&"data"in O&&((M=O.data)!=null&&M.otp_sent)?((I=O.data)!=null&&I.masked_phone&&S(O.data.masked_phone),k(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},j=async(R,M)=>{if(R.preventDefault(),u)return;const I=M||a,O={};if(I?p==="authenticator"&&I.length!==6?O.code="Authentication code must be 6 digits":p==="phone_otp"&&I.length!==6&&(O.code="SMS code must be 6 digits"):O.code="Verification code is required",c(O),!(Object.keys(O).length>0)){d(!0);try{await o(I)}catch(N){c({submit:N.message})}finally{d(!1)}}},T=R=>{let M=R.target.value;p!=="backup_code"&&(M=M.replace(/\D/g,"").slice(0,6)),h(M),c(I=>({...I,code:""}))};return i.useEffect(()=>{var R;if(r.completed){z(!0);let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!M&&(s!=null&&s.frontend_host)&&(M=`https://${s.frontend_host}`),M){let I;try{I=new URL(M)}catch{I=new URL(M,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(I.toString())}return}},[r,s]),C?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsx(Qg,{children:e.jsx(yt,{size:32})})]})}):x?g.length===0?e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Set Up Two-Factor Authentication"}),e.jsx(Ya,{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(Ka,{children:[t&&e.jsx("div",{children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(ql,{methods:g,onSelectMethod:_,onBack:t}):b&&p==="phone_otp"?e.jsx(Yl,{onVerify:E,onBack:()=>{k(!1),v(!0),m(null)},loading:u}):e.jsx(fe,{children:e.jsxs(Un,{children:[e.jsx(Oe,{}),e.jsxs(Ha,{children:[e.jsx(qa,{children:"Two-factor authentication"}),e.jsxs(Ya,{children:[p==="authenticator"&&"Enter the 6-digit code from your authenticator app",p==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,p==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(wt,{onSubmit:j,noValidate:!0,children:[p==="backup_code"?e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(Jg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Za,{children:f.code})]}):e.jsx(qt,{onComplete:async R=>{if(h(R),p!=="backup_code"){const M=new Event("submit",{bubbles:!0,cancelable:!0});await j(M,R)}},onResend:p==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:u}),e.jsxs("div",{children:[f.submit&&e.jsx(Za,{children:f.submit}),e.jsx(Xg,{type:"submit",disabled:u||!a,children:u?"Verifying...":"Verify"})]})]}),e.jsxs(Ka,{children:[e.jsx(Wr,{onClick:()=>{v(!0),m(null),h(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Wr,{children:e.jsx(ht,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Wr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Wn=l.div`
1526
1526
  max-width: 380px;
1527
1527
  width: 380px;
1528
1528
  padding: var(--space-3xl);
@@ -1542,7 +1542,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1542
1542
  `,Ja=l.p`
1543
1543
  color: var(--color-secondary-text);
1544
1544
  font-size: var(--font-xs);
1545
- `,Jg=l.div`
1545
+ `,em=l.div`
1546
1546
  display: grid;
1547
1547
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
1548
1548
  gap: var(--space-sm);
@@ -1551,7 +1551,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1551
1551
  color: var(--color-error);
1552
1552
  margin: 0;
1553
1553
  margin-top: var(--space-2xs);
1554
- `,em=l(J)`
1554
+ `,tm=l(J)`
1555
1555
  margin-top: var(--space-sm);
1556
1556
  `,ei=l.div`
1557
1557
  margin-top: var(--space-lg);
@@ -1568,7 +1568,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1568
1568
  &:hover {
1569
1569
  color: var(--color-primary-hover);
1570
1570
  }
1571
- `,tm=l.div`
1571
+ `,rm=l.div`
1572
1572
  display: flex;
1573
1573
  justify-content: center;
1574
1574
  align-items: center;
@@ -1587,10 +1587,10 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1587
1587
  transform: rotate(360deg);
1588
1588
  }
1589
1589
  }
1590
- `;function Kl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var L,P,A,q,Y,B,H,G,X;const{deployment:a}=ye(),{navigate:h}=rt(),[f,c]=i.useState({}),[u,d]=i.useState({}),[p,m]=i.useState("US"),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(null),[C,z]=i.useState(!1),w=$,y=b,g=async oe=>{var te;k(!0),S(null);try{if(await o(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}}catch(ce){const Q=ce;throw S(Q),Q}finally{k(!1)}},_=async oe=>{var te;k(!0),S(null);try{if(await n(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}return!0}catch(ce){return S(ce),!1}finally{k(!1)}};if(C||!t)return e.jsx(he,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsx(tm,{children:e.jsx(yt,{size:32})})]})});const E=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,M=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,I=oe=>{const{name:te,value:ce}=oe.target;c(Q=>({...Q,[te]:ce})),u[te]&&d(Q=>({...Q,[te]:""}))},O=()=>{const oe={};return E.forEach(te=>{var me,ve,de,U,le;const ce=f[te];let Q=!1;switch(te){case"first_name":Q=((me=R==null?void 0:R.first_name)==null?void 0:me.enabled)||!1;break;case"last_name":Q=((ve=R==null?void 0:R.last_name)==null?void 0:ve.enabled)||!1;break;case"username":Q=((de=R==null?void 0:R.username)==null?void 0:de.enabled)||!1;break;case"phone_number":Q=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Q=((le=R==null?void 0:R.email_address)==null?void 0:le.enabled)||!1;break;default:Q=!0}if(Q&&(!ce||ce.trim()==="")){const K=te.replace("_"," ").replace(/\b\w/g,Z=>Z.toUpperCase());oe[te]=`${K} is required`}}),f.username&&E.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(oe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&E.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(oe.phone_number="Phone number must contain 7-15 digits")),f.email&&E.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(oe.email_address="Please enter a valid email address")),d(oe),Object.keys(oe).length===0},N=async oe=>{if(oe.preventDefault(),!O())return;const te={...f};f.phone_number&&p&&(te.phone_country_code=p),await g(te)},D=oe=>{const te=oe.target.value;c(ce=>({...ce,phone_number:te})),u.phone_number&&d(ce=>({...ce,phone_number:""}))};if(M){const oe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(he,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:oe}),e.jsx(Ja,{children:te})]}),e.jsxs(wt,{onSubmit:Q=>Q.preventDefault(),noValidate:!0,children:[e.jsx(qt,{onComplete:_,onResend:async()=>{await s({strategy:ce})},error:w==null?void 0:w.message,isSubmitting:y}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(ei,{children:[e.jsx("div",{children:e.jsx(xo,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(he,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:j}),e.jsx(Ja,{children:T})]}),e.jsxs(wt,{onSubmit:N,noValidate:!0,children:[(E.includes("first_name")||E.includes("last_name"))&&(((L=R==null?void 0:R.first_name)==null?void 0:L.enabled)||((P=R==null?void 0:R.last_name)==null?void 0:P.enabled))&&e.jsxs(Jg,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((q=R==null?void 0:R.last_name)!=null&&q.enabled)&&E.includes("first_name")&&E.includes("last_name")),children:[E.includes("first_name")&&((Y=R==null?void 0:R.first_name)==null?void 0:Y.enabled)&&e.jsxs(pe,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!u.first_name,disabled:y,autoComplete:"given-name"}),u.first_name&&e.jsx(Qt,{children:u.first_name})]}),E.includes("last_name")&&((B=R==null?void 0:R.last_name)==null?void 0:B.enabled)&&e.jsxs(pe,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!u.last_name,disabled:y,autoComplete:"family-name"}),u.last_name&&e.jsx(Qt,{children:u.last_name})]})]}),E.includes("username")&&((H=R==null?void 0:R.username)==null?void 0:H.enabled)&&e.jsxs(pe,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(se,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!u.username,disabled:y,autoComplete:"username"}),u.username&&e.jsx(Qt,{children:u.username})]}),E.includes("phone_number")&&((G=R==null?void 0:R.phone_number)==null?void 0:G.enabled)&&e.jsxs(pe,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(oo,{value:f.phone_number||"",onChange:D,error:u.phone_number,countryCode:p,setCountryCode:m}),u.phone_number&&e.jsx(Qt,{children:u.phone_number})]}),E.includes("email_address")&&((X=R==null?void 0:R.email_address)==null?void 0:X.enabled)&&e.jsxs(pe,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(se,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!u.email_address,disabled:y,autoComplete:"email"}),u.email_address&&e.jsx(Qt,{children:u.email_address})]}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(em,{type:"submit",disabled:y,children:y?"Completing...":"Continue"})]}),e.jsxs(ei,{children:[r&&e.jsx("div",{children:e.jsx(xo,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const rm=l.div`
1590
+ `;function Kl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var L,P,A,q,Y,B,H,G,X;const{deployment:a}=we(),{navigate:h}=rt(),[f,c]=i.useState({}),[u,d]=i.useState({}),[p,m]=i.useState("US"),[x,v]=i.useState(!1),[b,k]=i.useState(!1),[$,S]=i.useState(null),[C,z]=i.useState(!1),w=$,y=b,g=async oe=>{var te;k(!0),S(null);try{if(await o(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}}catch(ce){const Q=ce;throw S(Q),Q}finally{k(!1)}},_=async oe=>{var te;k(!0),S(null);try{if(await n(oe)){z(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((te=a==null?void 0:a.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!Q&&(a!=null&&a.frontend_host)&&(Q=`https://${a.frontend_host}`),Q){let me;try{me=new URL(Q)}catch{me=new URL(Q,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(me.toString())}}return!0}catch(ce){return S(ce),!1}finally{k(!1)}};if(C||!t)return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsx(rm,{children:e.jsx(yt,{size:32})})]})});const E=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,M=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,I=oe=>{const{name:te,value:ce}=oe.target;c(Q=>({...Q,[te]:ce})),u[te]&&d(Q=>({...Q,[te]:""}))},O=()=>{const oe={};return E.forEach(te=>{var me,xe,de,U,le;const ce=f[te];let Q=!1;switch(te){case"first_name":Q=((me=R==null?void 0:R.first_name)==null?void 0:me.enabled)||!1;break;case"last_name":Q=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Q=((de=R==null?void 0:R.username)==null?void 0:de.enabled)||!1;break;case"phone_number":Q=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Q=((le=R==null?void 0:R.email_address)==null?void 0:le.enabled)||!1;break;default:Q=!0}if(Q&&(!ce||ce.trim()==="")){const K=te.replace("_"," ").replace(/\b\w/g,Z=>Z.toUpperCase());oe[te]=`${K} is required`}}),f.username&&E.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(oe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&E.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(oe.phone_number="Phone number must contain 7-15 digits")),f.email&&E.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(oe.email_address="Please enter a valid email address")),d(oe),Object.keys(oe).length===0},N=async oe=>{if(oe.preventDefault(),!O())return;const te={...f};f.phone_number&&p&&(te.phone_country_code=p),await g(te)},D=oe=>{const te=oe.target.value;c(ce=>({...ce,phone_number:te})),u.phone_number&&d(ce=>({...ce,phone_number:""}))};if(M){const oe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:oe}),e.jsx(Ja,{children:te})]}),e.jsxs(wt,{onSubmit:Q=>Q.preventDefault(),noValidate:!0,children:[e.jsx(qt,{onComplete:_,onResend:async()=>{await s({strategy:ce})},error:w==null?void 0:w.message,isSubmitting:y}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(ei,{children:[e.jsx("div",{children:e.jsx(xo,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(fe,{children:e.jsxs(Wn,{children:[e.jsx(Oe,{}),e.jsxs(Qa,{children:[e.jsx(Xa,{children:j}),e.jsx(Ja,{children:T})]}),e.jsxs(wt,{onSubmit:N,noValidate:!0,children:[(E.includes("first_name")||E.includes("last_name"))&&(((L=R==null?void 0:R.first_name)==null?void 0:L.enabled)||((P=R==null?void 0:R.last_name)==null?void 0:P.enabled))&&e.jsxs(em,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((q=R==null?void 0:R.last_name)!=null&&q.enabled)&&E.includes("first_name")&&E.includes("last_name")),children:[E.includes("first_name")&&((Y=R==null?void 0:R.first_name)==null?void 0:Y.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!u.first_name,disabled:y,autoComplete:"given-name"}),u.first_name&&e.jsx(Qt,{children:u.first_name})]}),E.includes("last_name")&&((B=R==null?void 0:R.last_name)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!u.last_name,disabled:y,autoComplete:"family-name"}),u.last_name&&e.jsx(Qt,{children:u.last_name})]})]}),E.includes("username")&&((H=R==null?void 0:R.username)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(se,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!u.username,disabled:y,autoComplete:"username"}),u.username&&e.jsx(Qt,{children:u.username})]}),E.includes("phone_number")&&((G=R==null?void 0:R.phone_number)==null?void 0:G.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(oo,{value:f.phone_number||"",onChange:D,error:u.phone_number,countryCode:p,setCountryCode:m}),u.phone_number&&e.jsx(Qt,{children:u.phone_number})]}),E.includes("email_address")&&((X=R==null?void 0:R.email_address)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(se,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!u.email_address,disabled:y,autoComplete:"email"}),u.email_address&&e.jsx(Qt,{children:u.email_address})]}),w&&e.jsx(Qt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(tm,{type:"submit",disabled:y,children:y?"Completing...":"Continue"})]}),e.jsxs(ei,{children:[r&&e.jsx("div",{children:e.jsx(xo,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(xo,{children:e.jsx(ht,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const om=l.div`
1591
1591
  text-align: center;
1592
1592
  margin-bottom: var(--space-2xl);
1593
- `,om=l.div`
1593
+ `,nm=l.div`
1594
1594
  width: 64px;
1595
1595
  height: 64px;
1596
1596
  border-radius: 50%;
@@ -1605,22 +1605,22 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1605
1605
  height: 32px;
1606
1606
  color: white;
1607
1607
  }
1608
- `,nm=l.h1`
1608
+ `,sm=l.h1`
1609
1609
  font-size: var(--font-lg);
1610
1610
  font-weight: 400;
1611
1611
  color: var(--color-foreground);
1612
1612
  margin: 0 0 var(--space-xs);
1613
- `,sm=l.p`
1613
+ `,am=l.p`
1614
1614
  color: var(--color-secondary-text);
1615
1615
  font-size: var(--font-xs);
1616
1616
  margin: 0;
1617
1617
  line-height: 1.5;
1618
- `,am=l.div`
1618
+ `,im=l.div`
1619
1619
  display: flex;
1620
1620
  flex-direction: column;
1621
1621
  gap: var(--space-sm);
1622
1622
  margin-top: var(--space-xl);
1623
- `,im=l.button`
1623
+ `,cm=l.button`
1624
1624
  width: 100%;
1625
1625
  padding: var(--space-md) var(--space-lg);
1626
1626
  background: var(--color-primary);
@@ -1644,7 +1644,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1644
1644
  opacity: 0.7;
1645
1645
  cursor: not-allowed;
1646
1646
  }
1647
- `,cm=l.button`
1647
+ `,lm=l.button`
1648
1648
  width: 100%;
1649
1649
  padding: var(--space-md) var(--space-lg);
1650
1650
  background: transparent;
@@ -1660,17 +1660,17 @@ See https://s-c.sh/2BAXzed for more info.`),window[po]+=1);/**
1660
1660
  background: var(--color-hover);
1661
1661
  color: var(--color-foreground);
1662
1662
  }
1663
- `,lm=Ht`
1663
+ `,dm=Ht`
1664
1664
  from { transform: rotate(0deg); }
1665
1665
  to { transform: rotate(360deg); }
1666
- `,dm=l(yt)`
1667
- animation: ${lm} 1s linear infinite;
1668
- `,um=l.p`
1666
+ `,um=l(yt)`
1667
+ animation: ${dm} 1s linear infinite;
1668
+ `,pm=l.p`
1669
1669
  font-size: var(--font-xs);
1670
1670
  color: var(--color-error);
1671
1671
  text-align: center;
1672
1672
  margin: var(--space-sm) 0 0;
1673
- `;function Ql({onComplete:t,onSkip:r}){var d;const[o,n]=i.useState(!1),[s,a]=i.useState(null),{registerPasskey:h}=Gt(),{deployment:f}=ye(),c=async()=>{n(!0),a(null);try{await h(),t==null||t()}catch(p){a(p instanceof Error?p.message:"Failed to register passkey")}finally{n(!1)}},u=((d=f==null?void 0:f.ui_settings)==null?void 0:d.app_name)||"this app";return e.jsxs(e.Fragment,{children:[e.jsxs(rm,{children:[e.jsx(om,{children:e.jsx(zs,{})}),e.jsx(nm,{children:"Add a Passkey"}),e.jsxs(sm,{children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",u,"."]})]}),e.jsxs(am,{children:[e.jsx(im,{onClick:c,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(dm,{size:16}),"Registering..."]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{size:16}),"Add Passkey"]})}),e.jsx(cm,{onClick:r,children:"Maybe Later"})]}),s&&e.jsx(um,{children:s})]})}const pm=Ht`
1673
+ `;function Ql({onComplete:t,onSkip:r}){var d;const[o,n]=i.useState(!1),[s,a]=i.useState(null),{registerPasskey:h}=Gt(),{deployment:f}=we(),c=async()=>{n(!0),a(null);try{await h(),t==null||t()}catch(p){a(p instanceof Error?p.message:"Failed to register passkey")}finally{n(!1)}},u=((d=f==null?void 0:f.ui_settings)==null?void 0:d.app_name)||"this app";return e.jsxs(e.Fragment,{children:[e.jsxs(om,{children:[e.jsx(nm,{children:e.jsx(zs,{})}),e.jsx(sm,{children:"Add a Passkey"}),e.jsxs(am,{children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",u,"."]})]}),e.jsxs(im,{children:[e.jsx(cm,{onClick:c,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(um,{size:16}),"Registering..."]}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{size:16}),"Add Passkey"]})}),e.jsx(lm,{onClick:r,children:"Maybe Later"})]}),s&&e.jsx(pm,{children:s})]})}const Xl=Ht`
1674
1674
  from {
1675
1675
  transform: rotate(0deg);
1676
1676
  }
@@ -1691,7 +1691,7 @@ display: flex;
1691
1691
  min-height: 200px;
1692
1692
 
1693
1693
  svg {
1694
- animation: ${pm} 1s linear infinite;
1694
+ animation: ${Xl} 1s linear infinite;
1695
1695
  color: var(--color-primary);
1696
1696
  }
1697
1697
  `,ri=l.div`
@@ -1809,7 +1809,7 @@ cursor: pointer;
1809
1809
  &:hover {
1810
1810
  color: var(--color-primary-hover);
1811
1811
  }
1812
- `;function wm(){return e.jsx(fg,{children:e.jsx(jm,{})})}function jm(){var K,Z,re,fe,ue,ee,V,F,ne,be,Me,Ce,Se,Ve,Le,Ae;const{deployment:t}=ye(),{navigate:r}=rt(),{session:o,loading:n,refetch:s}=Qe(),a=((Z=(K=t==null?void 0:t.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:h,otpSent:f,setOtpSent:c,showForgotPassword:u,setShowForgotPassword:d,showOtherOptions:p,setShowOtherOptions:m,enabledSocialsProviders:x,firstFactor:v,signInStep:b,setSignInStep:k}=Gl(),{loading:$,signIn:S,signinAttempt:C,discardSignInAttempt:z,setSignInAttempt:w}=zr("generic"),{signIn:y}=zr("oauth"),{signIn:g}=zr("passkey"),[_,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[R,M]=i.useState(!1),[I,O]=i.useState(""),[N,D]=i.useState("US"),[L,P]=i.useState(!1),[A,q]=i.useState(null),[Y,B]=i.useState(!1),[H,G]=i.useState(null);i.useEffect(()=>{const xe=new URLSearchParams(window.location.search),ge=xe.get("error"),_e=xe.get("error_description");if(ge==="access_denied"&&_e){q(_e),xe.delete("error"),xe.delete("error_description");const $e=xe.toString()?`${window.location.pathname}?${xe.toString()}`:window.location.pathname;window.history.replaceState({},"",$e)}},[]),i.useEffect(()=>{var xe,ge,_e,$e;if(!n&&(o!=null&&o.active_signin)&&!a&&!L&&!Y){let Ie=new URLSearchParams(window.location.search).get("redirect_uri");Ie||(Ie=((xe=t==null?void 0:t.ui_settings)==null?void 0:xe.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`);const Ge=(ge=t==null?void 0:t.auth_settings)==null?void 0:ge.passkey;(Ge==null?void 0:Ge.enabled)&&(Ge==null?void 0:Ge.prompt_registration_on_auth)&&!(($e=(_e=o.active_signin)==null?void 0:_e.user)!=null&&$e.has_passkeys)?(G(Ie),B(!0)):Ie&&(P(!0),r(Ie))}},[o,n,a,t,r,L]);const X=xe=>{let{name:ge,value:_e}=xe.target;ge==="phone"?_e=_e.replace(/[^0-9]/g,""):ge==="email"&&(h(_e),_e=_e.toLowerCase()),E($e=>({...$e,[ge]:_e})),T($e=>({...$e,[ge]:""}))},oe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),k("identifier")},te=async xe=>{if(!xe){T({email:"Email address is required"});return}M(!0),T({});try{const ge=await S.identify(xe);if(ge.strategy==="sso"&&ge.connection_id){const $e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ie=await S.initEnterpriseSso(ge.connection_id,$e);if(Ie&&Ie.sso_url){P(!0),window.location.href=Ie.sso_url;return}}else if(ge.strategy==="social"&&ge.provider){const _e=x.find($e=>$e.provider===ge.provider);if(_e){const Ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ge}=await y.create({provider:_e.provider,redirectUri:Ie});if(Ge&&typeof Ge=="object"&&"oauth_url"in Ge){P(!0),window.location.href=Ge.oauth_url;return}}else k("password")}else k("password")}catch(ge){T({submit:ge.message})}finally{L||M(!1)}},ce=async xe=>{if(xe.preventDefault(),$||R)return;z();const ge={};if(b==="identifier"&&v==="email_password"){if(!_.email){T({email:"Email address is required"});return}await te(_.email);return}if(v==="email_password"?(_.email||(ge.email="Email address is required"),_.password||(ge.password="Password is required")):v==="username_password"?(_.username||(ge.username="Username is required"),_.password||(ge.password="Password is required")):v==="email_otp"||v==="email_magic_link"?_.email||(ge.email="Email address is required"):v==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(ge.phone="Phone number must contain 7-15 digits"):ge.phone="Phone number is required"),T(ge),Object.keys(ge).length>0)return;let _e="";switch(v){case"email_password":_e="plain_email";break;case"username_password":_e="plain_username";break;case"email_otp":_e="email_otp";break;case"email_magic_link":_e="magic_link";break;case"phone_otp":_e="phone_otp";break}M(!0);try{const $e={..._,strategy:_e};v==="phone_otp"&&N&&($e.phone_country_code=N),await S.create($e)}catch($e){T({submit:$e.message}),M(!1)}},Q=async xe=>{if(xe.preventDefault(),$||R)return;const ge={};if(!I){ge.otp="OTP code is required",T(ge);return}M(!0),T({});try{await S.completeVerification(I),c(!1),O("")}catch(_e){T({otp:_e.message||"Verification failed"})}finally{M(!1)}},me=async xe=>{if(!($||R)){M(!0);try{const _e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:$e}=await y.create({provider:xe.provider,redirectUri:_e});$e&&typeof $e=="object"&&"oauth_url"in $e&&(window.location.href=$e.oauth_url)}catch(ge){T({submit:ge.message})}finally{M(!1)}}},ve=async()=>{if(!($||R)){M(!0),T({});try{const xe=await g.create();"data"in xe&&xe.data&&(await s(),P(!0))}catch(xe){T({submit:xe.message||"Passkey sign-in failed"})}finally{M(!1)}}},de=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const xe=new URLSearchParams(window.location.search),ge=xe.get("impersonation_token");if(ge&&!C&&!$&&!de.current){de.current=!0,xe.delete("impersonation_token");const $e=xe.toString()?`${window.location.pathname}?${xe.toString()} `:window.location.pathname;window.history.replaceState({},"",$e),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:ge})}catch(Ge){T({submit:Ge.message}),M(!1),de.current=!1}})();return}const _e=xe.get("signin_attempt_id");if(_e&&(o!=null&&o.signin_attempts)&&!C){const $e=o.signin_attempts.find(Ie=>Ie.id===_e);if($e){w($e),xe.delete("signin_attempt_id");const Ie=xe.toString()?`${window.location.pathname}?${xe.toString()} `:window.location.pathname;window.history.replaceState({},"",Ie)}}},[o,n,C,w,$]),i.useEffect(()=>{var $e;if(!C)return;if(C.completed){P(!0);let Ie=new URLSearchParams(window.location.search).get("redirect_uri");if(Ie||(Ie=(($e=t==null?void 0:t.ui_settings)==null?void 0:$e.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`),Ie){let Ge;try{Ge=new URL(Ie)}catch{Ge=new URL(Ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ge.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Ge.toString())}return}if(!S||f)return;const ge={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!ge)return;(async()=>{try{await S.prepareVerification({strategy:ge}),c(!0)}catch(Ie){console.error("Failed to prepare verification:",Ie),T({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[C,S,f,c,r,t]),i.useEffect(()=>{},[]),p)return e.jsx(Cg,{onBack:()=>m(!1)});if(u)return e.jsx(bg,{onBack:()=>d(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return e.jsx(Zl,{attempt:C,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return e.jsx(Kl,{attempt:C,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if(Y){const xe=()=>{B(!1),H&&(P(!0),r(H))},ge=()=>{B(!1),H&&(P(!0),r(H))};return e.jsx(he,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:xe,onSkip:ge})]})})}if(n)return e.jsx(he,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});if(L)return e.jsx(he,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});const le=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&f;return e.jsx(he,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),le?e.jsx(e.Fragment,{children:e.jsxs(ri,{children:[e.jsx(oi,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ni,{children:v==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ri,{children:[e.jsx(oi,{children:"Sign in to your account"}),e.jsxs(ni,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(xm,{children:[e.jsx(vm,{children:"Access Denied"}),e.jsx(bm,{children:A}),e.jsx(ym,{onClick:()=>q(null),children:"Try again"})]}),le?v==="email_magic_link"?e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(wt,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(qt,{onComplete:async xe=>{if(O(xe),xe&&xe.length===6){M(!0),T({});try{await S.completeVerification(xe),c(!1)}catch(ge){T({otp:ge.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const xe=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:xe})},error:j.otp,isSubmitting:R}),e.jsx(si,{type:"submit",disabled:R||$||!I,style:{margin:0},children:R?"Verifying...":`Continue to ${(Ae=t==null?void 0:t.ui_settings)==null?void 0:Ae.app_name}`})]}),e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsx(e.Fragment,{children:e.jsx(Bs,{connections:x,callback:me})}),((fe=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)==null?void 0:fe.enabled)&&e.jsxs(mm,{type:"button",onClick:ve,disabled:R,children:[e.jsx(zs,{size:18}),"Sign in with Passkey"]}),(x.length>0||((ee=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:ee.enabled))&&e.jsx(hm,{children:e.jsx(fm,{children:"or"})}),e.jsxs(wt,{onSubmit:ce,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((F=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:F.enabled)&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(se,{type:"email",id:"email",name:"email",value:_.email,onChange:X,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Vr,{children:j.email})]}),v==="username_password"&&((be=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.username)==null?void 0:be.enabled)&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{type:"text",id:"username",name:"username",value:_.username,onChange:X,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Vr,{children:j.username})]}),v==="phone_otp"&&((Ce=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.phone_number)==null?void 0:Ce.enabled)&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(oo,{value:_.phone,onChange:X,error:j.phone,countryCode:N,setCountryCode:D}),j.phone&&e.jsx(Vr,{children:j.phone})]}),b==="password"&&(v==="email_password"||v==="username_password")&&((Ve=(Se=t==null?void 0:t.auth_settings)==null?void 0:Se.password)==null?void 0:Ve.enabled)&&e.jsxs(pe,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Xt,{style:{fontSize:"12px"},onClick:()=>d(!0),children:"Forgot password?"})]}),e.jsx(gm,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:_.password,onChange:X,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Vr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Vr,{children:j.submit}),e.jsx(si,{type:"submit",disabled:R||$,children:R?e.jsxs(e.Fragment,{children:[e.jsx(yt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),b==="identifier"?"Checking...":"Signing in..."]}):b==="identifier"?"Continue":"Sign in"})]}),e.jsx(Xt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Vn,{children:["Don't have an account?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:`${(Le=t.ui_settings)==null?void 0:Le.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const ai=l.div`
1812
+ `;function wm(){return e.jsx(gg,{children:e.jsx(jm,{})})}function jm(){var K,Z,re,ge,ue,ee,V,F,ne,be,Me,Ce,Se,Ve,Le,Ae;const{deployment:t}=we(),{navigate:r}=rt(),{session:o,loading:n,refetch:s}=Qe(),a=((Z=(K=t==null?void 0:t.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:h,otpSent:f,setOtpSent:c,showForgotPassword:u,setShowForgotPassword:d,showOtherOptions:p,setShowOtherOptions:m,enabledSocialsProviders:x,firstFactor:v,signInStep:b,setSignInStep:k}=Gl(),{loading:$,signIn:S,signinAttempt:C,discardSignInAttempt:z,setSignInAttempt:w}=zr("generic"),{signIn:y}=zr("oauth"),{signIn:g}=zr("passkey"),[_,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[R,M]=i.useState(!1),[I,O]=i.useState(""),[N,D]=i.useState("US"),[L,P]=i.useState(!1),[A,q]=i.useState(null),[Y,B]=i.useState(!1),[H,G]=i.useState(null);i.useEffect(()=>{const ve=new URLSearchParams(window.location.search),pe=ve.get("error"),ye=ve.get("error_description");if(pe==="access_denied"&&ye){q(ye),ve.delete("error"),ve.delete("error_description");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()}`:window.location.pathname;window.history.replaceState({},"",$e)}},[]),i.useEffect(()=>{var ve,pe,ye,$e;if(!n&&(o!=null&&o.active_signin)&&!a&&!L&&!Y){let Ie=new URLSearchParams(window.location.search).get("redirect_uri");Ie||(Ie=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`);const Ge=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.passkey;(Ge==null?void 0:Ge.enabled)&&(Ge==null?void 0:Ge.prompt_registration_on_auth)&&!(($e=(ye=o.active_signin)==null?void 0:ye.user)!=null&&$e.has_passkeys)?(G(Ie),B(!0)):Ie&&(P(!0),r(Ie))}},[o,n,a,t,r,L]);const X=ve=>{let{name:pe,value:ye}=ve.target;pe==="phone"?ye=ye.replace(/[^0-9]/g,""):pe==="email"&&(h(ye),ye=ye.toLowerCase()),E($e=>({...$e,[pe]:ye})),T($e=>({...$e,[pe]:""}))},oe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),k("identifier")},te=async ve=>{if(!ve){T({email:"Email address is required"});return}M(!0),T({});try{const pe=await S.identify(ve);if(pe.strategy==="sso"&&pe.connection_id){const $e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ie=await S.initEnterpriseSso(pe.connection_id,$e);if(Ie&&Ie.sso_url){P(!0),window.location.href=Ie.sso_url;return}}else if(pe.strategy==="social"&&pe.provider){const ye=x.find($e=>$e.provider===pe.provider);if(ye){const Ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Ge}=await y.create({provider:ye.provider,redirectUri:Ie});if(Ge&&typeof Ge=="object"&&"oauth_url"in Ge){P(!0),window.location.href=Ge.oauth_url;return}}else k("password")}else k("password")}catch(pe){T({submit:pe.message})}finally{L||M(!1)}},ce=async ve=>{if(ve.preventDefault(),$||R)return;z();const pe={};if(b==="identifier"&&v==="email_password"){if(!_.email){T({email:"Email address is required"});return}await te(_.email);return}if(v==="email_password"?(_.email||(pe.email="Email address is required"),_.password||(pe.password="Password is required")):v==="username_password"?(_.username||(pe.username="Username is required"),_.password||(pe.password="Password is required")):v==="email_otp"||v==="email_magic_link"?_.email||(pe.email="Email address is required"):v==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(pe.phone="Phone number must contain 7-15 digits"):pe.phone="Phone number is required"),T(pe),Object.keys(pe).length>0)return;let ye="";switch(v){case"email_password":ye="plain_email";break;case"username_password":ye="plain_username";break;case"email_otp":ye="email_otp";break;case"email_magic_link":ye="magic_link";break;case"phone_otp":ye="phone_otp";break}M(!0);try{const $e={..._,strategy:ye};v==="phone_otp"&&N&&($e.phone_country_code=N),await S.create($e)}catch($e){T({submit:$e.message}),M(!1)}},Q=async ve=>{if(ve.preventDefault(),$||R)return;const pe={};if(!I){pe.otp="OTP code is required",T(pe);return}M(!0),T({});try{await S.completeVerification(I),c(!1),O("")}catch(ye){T({otp:ye.message||"Verification failed"})}finally{M(!1)}},me=async ve=>{if(!($||R)){M(!0);try{const ye=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:$e}=await y.create({provider:ve.provider,redirectUri:ye});$e&&typeof $e=="object"&&"oauth_url"in $e&&(window.location.href=$e.oauth_url)}catch(pe){T({submit:pe.message})}finally{M(!1)}}},xe=async()=>{var ve;if(!($||R)){M(!0),T({});try{const pe=await g.create();if("data"in pe&&pe.data){await s();let ye=new URLSearchParams(window.location.search).get("redirect_uri");ye||(ye=((ve=t==null?void 0:t.ui_settings)==null?void 0:ve.after_signin_redirect_url)||null),!ye&&(t!=null&&t.frontend_host)&&(ye=`https://${t.frontend_host}`),P(!0),ye&&r(ye)}}catch(pe){T({submit:pe.message||"Passkey sign-in failed"})}finally{M(!1)}}},de=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const ve=new URLSearchParams(window.location.search),pe=ve.get("impersonation_token");if(pe&&!C&&!$&&!de.current){de.current=!0,ve.delete("impersonation_token");const $e=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",$e),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:pe})}catch(Ge){T({submit:Ge.message}),M(!1),de.current=!1}})();return}const ye=ve.get("signin_attempt_id");if(ye&&(o!=null&&o.signin_attempts)&&!C){const $e=o.signin_attempts.find(Ie=>Ie.id===ye);if($e){w($e),ve.delete("signin_attempt_id");const Ie=ve.toString()?`${window.location.pathname}?${ve.toString()} `:window.location.pathname;window.history.replaceState({},"",Ie)}}},[o,n,C,w,$]),i.useEffect(()=>{var $e;if(!C)return;if(C.completed){P(!0);let Ie=new URLSearchParams(window.location.search).get("redirect_uri");if(Ie||(Ie=(($e=t==null?void 0:t.ui_settings)==null?void 0:$e.after_signin_redirect_url)||null),!Ie&&(t!=null&&t.frontend_host)&&(Ie=`https://${t.frontend_host}`),Ie){let Ge;try{Ge=new URL(Ie)}catch{Ge=new URL(Ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Ge.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Ge.toString())}return}if(!S||f)return;const pe={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[C.current_step];if(!pe)return;(async()=>{try{await S.prepareVerification({strategy:pe}),c(!0)}catch(Ie){console.error("Failed to prepare verification:",Ie),T({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[C,S,f,c,r,t]),i.useEffect(()=>{},[]),p)return e.jsx(Sg,{onBack:()=>m(!1)});if(u)return e.jsx(yg,{onBack:()=>d(!1)});if((C==null?void 0:C.current_step)==="verify_second_factor")return e.jsx(Zl,{attempt:C,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if((C==null?void 0:C.current_step)==="complete_profile")return e.jsx(Kl,{attempt:C,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),oe(),c(!1)}});if(Y){const ve=()=>{B(!1),H&&(P(!0),r(H))},pe=()=>{B(!1),H&&(P(!0),r(H))};return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:ve,onSkip:pe})]})})}if(n)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});if(L)return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),e.jsx(ti,{children:e.jsx(yt,{size:32})})]})});const le=(C==null?void 0:C.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(C.current_step)&&f;return e.jsx(fe,{children:e.jsxs(vo,{children:[e.jsx(Oe,{}),le?e.jsx(e.Fragment,{children:e.jsxs(ri,{children:[e.jsx(oi,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ni,{children:v==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ri,{children:[e.jsx(oi,{children:"Sign in to your account"}),e.jsxs(ni,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(xm,{children:[e.jsx(vm,{children:"Access Denied"}),e.jsx(bm,{children:A}),e.jsx(ym,{onClick:()=>q(null),children:"Try again"})]}),le?v==="email_magic_link"?e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(wt,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(qt,{onComplete:async ve=>{if(O(ve),ve&&ve.length===6){M(!0),T({});try{await S.completeVerification(ve),c(!1)}catch(pe){T({otp:pe.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const ve=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:ve})},error:j.otp,isSubmitting:R}),e.jsx(si,{type:"submit",disabled:R||$||!I,style:{margin:0},children:R?"Verifying...":`Continue to ${(Ae=t==null?void 0:t.ui_settings)==null?void 0:Ae.app_name}`})]}),e.jsxs(Vn,{children:["Having trouble?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Xt,{onClick:()=>{c(!1),z(),oe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsx(e.Fragment,{children:e.jsx(Bs,{connections:x,callback:me})}),((ge=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)==null?void 0:ge.enabled)&&e.jsxs(mm,{type:"button",onClick:xe,disabled:R,children:[e.jsx(zs,{size:18}),"Sign in with Passkey"]}),(x.length>0||((ee=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:ee.enabled))&&e.jsx(hm,{children:e.jsx(fm,{children:"or"})}),e.jsxs(wt,{onSubmit:ce,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((F=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(se,{type:"email",id:"email",name:"email",value:_.email,onChange:X,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Vr,{children:j.email})]}),v==="username_password"&&((be=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.username)==null?void 0:be.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{type:"text",id:"username",name:"username",value:_.username,onChange:X,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Vr,{children:j.username})]}),v==="phone_otp"&&((Ce=(Me=t==null?void 0:t.auth_settings)==null?void 0:Me.phone_number)==null?void 0:Ce.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(oo,{value:_.phone,onChange:X,error:j.phone,countryCode:N,setCountryCode:D}),j.phone&&e.jsx(Vr,{children:j.phone})]}),b==="password"&&(v==="email_password"||v==="username_password")&&((Ve=(Se=t==null?void 0:t.auth_settings)==null?void 0:Se.password)==null?void 0:Ve.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Xt,{style:{fontSize:"12px"},onClick:()=>d(!0),children:"Forgot password?"})]}),e.jsx(gm,{children:e.jsx(se,{type:"password",id:"password",name:"password",value:_.password,onChange:X,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Vr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Vr,{children:j.submit}),e.jsx(si,{type:"submit",disabled:R||$,children:R?e.jsx(yt,{size:16,className:"submit-spinner",style:{animation:`${Xl} 1s linear infinite`}}):b==="identifier"?"Continue":"Sign in"})]}),e.jsx(Xt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Vn,{children:["Don't have an account?"," ",e.jsx(Xt,{children:e.jsx(ht,{to:`${(Le=t.ui_settings)==null?void 0:Le.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const ai=l.div`
1813
1813
  max-width: 380px;
1814
1814
  width: 380px;
1815
1815
  padding: var(--space-3xl);
@@ -1910,7 +1910,7 @@ cursor: pointer;
1910
1910
  color: var(--color-primary);
1911
1911
  text-decoration: none;
1912
1912
  cursor: pointer;
1913
- `;function Am(){var k,$,S,C,z,w,y,g,_,E,j,T;const{deployment:t}=ye(),{loading:r,joinWaitlist:o}=Gc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,h]=i.useState(!1),[f,c]=i.useState(!1),[u,d]=i.useState(null),p=R=>{if(u)return u.message},m=t==null?void 0:t.auth_settings,x=!!((k=m==null?void 0:m.first_name)!=null&&k.enabled&&(($=m==null?void 0:m.last_name)!=null&&$.enabled)),v=R=>{const{name:M,value:I}=R.target;s(O=>({...O,[M]:I}))},b=async R=>{if(R.preventDefault(),!!m){c(!0),d(null);try{(await o(n)).data&&h(!0)}catch(M){d(M)}finally{c(!1)}}};return a?e.jsx(he,{children:e.jsx(ai,{children:e.jsxs(Em,{children:[e.jsx(Pm,{children:e.jsx(tt,{size:32})}),e.jsx(Im,{children:"You're on the waitlist!"}),e.jsxs(Rm,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(he,{children:e.jsxs(ai,{children:[e.jsx(Oe,{}),e.jsxs(km,{children:[e.jsx(_m,{children:"Join the waitlist"}),e.jsx(Cm,{children:"Be the first to know when we launch!"})]}),e.jsxs(Sm,{onSubmit:b,noValidate:!0,children:[(((S=m==null?void 0:m.first_name)==null?void 0:S.enabled)||((C=m==null?void 0:m.last_name)==null?void 0:C.enabled))&&e.jsxs($m,{$isBothEnabled:x,children:[((z=m==null?void 0:m.first_name)==null?void 0:z.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:(y=m==null?void 0:m.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),((g=m==null?void 0:m.last_name)==null?void 0:g.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"last_name",children:["Last name",((_=m==null?void 0:m.last_name)==null?void 0:_.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:(E=m==null?void 0:m.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]})]}),e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",required:(T=m==null?void 0:m.email_address)==null?void 0:T.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),p()&&e.jsx(bo,{children:p()}),e.jsx(zm,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Tm,{children:e.jsxs(Mm,{children:["Need assistance? ",e.jsx(Om,{href:"/contact",children:"Get help"})]})})]})})}const Gr=l.div`
1913
+ `;function Am(){var k,$,S,C,z,w,y,g,_,E,j,T;const{deployment:t}=we(),{loading:r,joinWaitlist:o}=Gc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,h]=i.useState(!1),[f,c]=i.useState(!1),[u,d]=i.useState(null),p=R=>{if(u)return u.message},m=t==null?void 0:t.auth_settings,x=!!((k=m==null?void 0:m.first_name)!=null&&k.enabled&&(($=m==null?void 0:m.last_name)!=null&&$.enabled)),v=R=>{const{name:M,value:I}=R.target;s(O=>({...O,[M]:I}))},b=async R=>{if(R.preventDefault(),!!m){c(!0),d(null);try{(await o(n)).data&&h(!0)}catch(M){d(M)}finally{c(!1)}}};return a?e.jsx(fe,{children:e.jsx(ai,{children:e.jsxs(Em,{children:[e.jsx(Pm,{children:e.jsx(tt,{size:32})}),e.jsx(Im,{children:"You're on the waitlist!"}),e.jsxs(Rm,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(fe,{children:e.jsxs(ai,{children:[e.jsx(Oe,{}),e.jsxs(km,{children:[e.jsx(_m,{children:"Join the waitlist"}),e.jsx(Cm,{children:"Be the first to know when we launch!"})]}),e.jsxs(Sm,{onSubmit:b,noValidate:!0,children:[(((S=m==null?void 0:m.first_name)==null?void 0:S.enabled)||((C=m==null?void 0:m.last_name)==null?void 0:C.enabled))&&e.jsxs($m,{$isBothEnabled:x,children:[((z=m==null?void 0:m.first_name)==null?void 0:z.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"first_name",name:"first_name",required:(y=m==null?void 0:m.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),((g=m==null?void 0:m.last_name)==null?void 0:g.enabled)&&e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"last_name",children:["Last name",((_=m==null?void 0:m.last_name)==null?void 0:_.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"text",id:"last_name",name:"last_name",required:(E=m==null?void 0:m.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]})]}),e.jsxs(Gn,{children:[e.jsxs(Hn,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(qn,{children:"*"})]}),e.jsx(se,{type:"email",id:"email",name:"email",required:(T=m==null?void 0:m.email_address)==null?void 0:T.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!p()}),p()&&e.jsx(bo,{children:p()})]}),p()&&e.jsx(bo,{children:p()}),e.jsx(zm,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Tm,{children:e.jsxs(Mm,{children:["Need assistance? ",e.jsx(Om,{href:"/contact",children:"Get help"})]})})]})})}const Gr=l.div`
1914
1914
  max-width: 380px;
1915
1915
  width: 380px;
1916
1916
  padding: var(--space-3xl);
@@ -1997,7 +1997,7 @@ cursor: pointer;
1997
1997
  color: var(--color-primary-hover);
1998
1998
  text-decoration: underline;
1999
1999
  }
2000
- `;function Bm(){const{deployment:t}=ye(),{navigate:r}=rt(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:h,loading:f}=Hc(),[c,u]=i.useState(!1),[d,p]=i.useState(null),m=()=>{window.location.reload()},x=()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||"/sign-in";r(k)},v=()=>{u(!1),d&&r(d)},b=()=>{u(!1),d&&r(d)};if(i.useEffect(()=>{var k,$,S,C,z;if(!(!s||f||c)){if(a&&!a.completed){const w=(k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url;if(w){const y=new URL(w,window.location.origin);y.searchParams.set("signin_attempt_id",a.id),h&&y.searchParams.set("redirect_uri",h),r(y.toString())}return}if(a!=null&&a.completed){const w=h||(($=t==null?void 0:t.ui_settings)==null?void 0:$.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let y;try{y=new URL(w)}catch{y=new URL(w,window.location.origin)}if(y){(t==null?void 0:t.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!((z=(C=n==null?void 0:n.active_signin)==null?void 0:C.user)!=null&&z.has_passkeys)?(p(y.toString()),u(!0)):r(y.toString())}}}},[n,s,f,h,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||(t==null?void 0:t.frontend_host);k&&r(k)},2e3)},[o,t,r]),f&&!s)return e.jsx(he,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})});if(c)return e.jsx(he,{children:e.jsxs(Gr,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:v,onSkip:b})]})});if(n&&s&&!o)return e.jsx(he,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Success!"}),e.jsx(jo,{children:"Authentication completed successfully"})]}),e.jsxs(ko,{children:[e.jsx(Dm,{children:"✓"}),e.jsx(_o,{children:"Redirecting you now..."}),e.jsx(Co,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const k=o.message.includes("No OAuth callback data found");return e.jsx(he,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Something went wrong"}),e.jsx(jo,{children:"We couldn't complete your sign in"})]}),e.jsxs(ko,{children:[e.jsx(Lm,{children:"✗"}),e.jsx(_o,{children:"Authentication Failed"}),e.jsx(Co,{children:o.message||"An unexpected error occurred during authentication."}),!k&&e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!k&&e.jsx(Nm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Fm,{onClick:x,children:"Return to sign in"})]})})]})})}return e.jsx(he,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})})}const Um=l.div`
2000
+ `;function Bm(){const{deployment:t}=we(),{navigate:r}=rt(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:h,loading:f}=Hc(),[c,u]=i.useState(!1),[d,p]=i.useState(null),m=()=>{window.location.reload()},x=()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||"/sign-in";r(k)},v=()=>{u(!1),d&&r(d)},b=()=>{u(!1),d&&r(d)};if(i.useEffect(()=>{var k,$,S,C,z;if(!(!s||f||c)){if(a&&!a.completed){const w=(k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url;if(w){const y=new URL(w,window.location.origin);y.searchParams.set("signin_attempt_id",a.id),h&&y.searchParams.set("redirect_uri",h),r(y.toString())}return}if(a!=null&&a.completed){const w=h||(($=t==null?void 0:t.ui_settings)==null?void 0:$.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let y;try{y=new URL(w)}catch{y=new URL(w,window.location.origin)}if(y){(t==null?void 0:t.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!((z=(C=n==null?void 0:n.active_signin)==null?void 0:C.user)!=null&&z.has_passkeys)?(p(y.toString()),u(!0)):r(y.toString())}}}},[n,s,f,h,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var $;const k=(($=t==null?void 0:t.ui_settings)==null?void 0:$.sign_in_page_url)||(t==null?void 0:t.frontend_host);k&&r(k)},2e3)},[o,t,r]),f&&!s)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})});if(c)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsx(Oe,{}),e.jsx(Ql,{onComplete:v,onSkip:b})]})});if(n&&s&&!o)return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Success!"}),e.jsx(jo,{children:"Authentication completed successfully"})]}),e.jsxs(ko,{children:[e.jsx(Dm,{children:"✓"}),e.jsx(_o,{children:"Redirecting you now..."}),e.jsx(Co,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const k=o.message.includes("No OAuth callback data found");return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Something went wrong"}),e.jsx(jo,{children:"We couldn't complete your sign in"})]}),e.jsxs(ko,{children:[e.jsx(Lm,{children:"✗"}),e.jsx(_o,{children:"Authentication Failed"}),e.jsx(Co,{children:o.message||"An unexpected error occurred during authentication."}),!k&&e.jsx(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!k&&e.jsx(Nm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Fm,{onClick:x,children:"Return to sign in"})]})})]})})}return e.jsx(fe,{children:e.jsxs(Gr,{children:[e.jsxs(yo,{children:[e.jsx(wo,{children:"Completing sign in"}),e.jsx(jo,{children:"Please wait while we authenticate you"})]}),e.jsxs(ko,{children:[e.jsx(ii,{}),e.jsx(_o,{children:"Verifying your credentials..."}),e.jsx(Co,{children:"This will only take a moment."})]})]})})}const Um=l.div`
2001
2001
  max-width: 380px;
2002
2002
  width: 380px;
2003
2003
  padding: var(--space-3xl);
@@ -2062,7 +2062,7 @@ cursor: pointer;
2062
2062
  `,Yn=l.p`
2063
2063
  font-size: var(--font-xs);
2064
2064
  color: var(--color-secondary-text);
2065
- `;function Km({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:h,attempt:f,redirectUri:c}=Yc(),{verifyMagicLink:u}=qc(),{navigate:d}=rt(),{deployment:p}=ye(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!h||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await u({token:h,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var k;let b=c;if(b||(b=(k=p==null?void 0:p.ui_settings)==null?void 0:k.after_signin_redirect_url),!b&&(p!=null&&p.frontend_host)&&(b=`https://${p.frontend_host}`),b){const $=new URL(b);(p==null?void 0:p.mode)==="staging"&&$.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d($.toString())}},2e3)}catch(b){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(b.message)}}})()},[h,f]);const x=()=>{var v;(v=p==null?void 0:p.ui_settings)!=null&&v.sign_in_page_url&&d(p.ui_settings.sign_in_page_url)};return e.jsx(he,{children:e.jsxs(Um,{children:[e.jsxs(Wm,{children:[e.jsx(Vm,{children:"Magic Link Verification"}),e.jsx(Gm,{children:"Verifying your magic link"})]}),e.jsxs(Hm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Zm,{}),e.jsx(Yn,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(qm,{children:"✓"}),e.jsx(Yn,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Ym,{children:"✗"}),e.jsx(Yn,{children:s}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Qm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var h,f;return((h=a.missing_fields)==null?void 0:h.length)>0||((f=a.remaining_steps)==null?void 0:f.length)>0&&!a.completed})):!1}function Xm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Jt=l.div`
2065
+ `;function Km({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:h,attempt:f,redirectUri:c}=Yc(),{verifyMagicLink:u}=qc(),{navigate:d}=rt(),{deployment:p}=we(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!h||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await u({token:h,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var k;let b=c;if(b||(b=(k=p==null?void 0:p.ui_settings)==null?void 0:k.after_signin_redirect_url),!b&&(p!=null&&p.frontend_host)&&(b=`https://${p.frontend_host}`),b){const $=new URL(b);(p==null?void 0:p.mode)==="staging"&&$.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d($.toString())}},2e3)}catch(b){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(b.message)}}})()},[h,f]);const x=()=>{var v;(v=p==null?void 0:p.ui_settings)!=null&&v.sign_in_page_url&&d(p.ui_settings.sign_in_page_url)};return e.jsx(fe,{children:e.jsxs(Um,{children:[e.jsxs(Wm,{children:[e.jsx(Vm,{children:"Magic Link Verification"}),e.jsx(Gm,{children:"Verifying your magic link"})]}),e.jsxs(Hm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Zm,{}),e.jsx(Yn,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(qm,{children:"✓"}),e.jsx(Yn,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Ym,{children:"✗"}),e.jsx(Yn,{children:s}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Qm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var h,f;return((h=a.missing_fields)==null?void 0:h.length)>0||((f=a.remaining_steps)==null?void 0:f.length)>0&&!a.completed})):!1}function Xm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Jt=l.div`
2066
2066
  max-width: 380px;
2067
2067
  width: 380px;
2068
2068
  padding: var(--space-3xl);
@@ -2162,7 +2162,7 @@ cursor: pointer;
2162
2162
  &:hover {
2163
2163
  color: var(--color-primary-hover);
2164
2164
  }
2165
- `;function ox({token:t,onSuccess:r,onError:o}){var b;const{acceptInvitation:n,invitationData:s,loading:a,error:h}=Jc(),{navigate:f}=rt(),{deployment:c}=ye(),u=i.useRef(!1),d=()=>{var $;const k=new URLSearchParams(window.location.search);return{token:t||k.get("invite_token")||k.get("token"),redirectUri:k.get("redirect_uri")||(($=c==null?void 0:c.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(u.current)return;const{token:k}=d();k&&(u.current=!0,n(k))},[n]),i.useEffect(()=>{var k;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,(k=s.workspace)==null?void 0:k.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const p=()=>{const{redirectUri:k}=d();f(k)},m=()=>{var g,_;const{token:k}=d(),$=((g=c==null?void 0:c.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",S=((_=c==null?void 0:c.ui_settings)==null?void 0:_.sign_up_page_url)||"/sign-up",C=new URLSearchParams;k&&C.set("invite_token",k),s!=null&&s.invited_email&&C.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${k}`;C.set("redirect_uri",w),s!=null&&s.message&&C.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?S:$}?${C.toString()}`)},x=()=>{const{token:k}=d();k&&(u.current=!1,n(k))},{token:v}=d();if(!v&&!a)return e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invalid Invitation"}),e.jsx(rr,{children:"No invitation token found"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Missing Invitation Token"}),e.jsx(sr,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(J,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Processing Invitation"}),e.jsx(rr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(or,{children:[e.jsx(ex,{}),e.jsx(nr,{children:"Verifying invitation..."}),e.jsx(sr,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Accepted!"}),e.jsx(rr,{children:"You've successfully joined the organization"})]}),e.jsxs(or,{children:[e.jsx(Jm,{children:"✓"}),e.jsxs(nr,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(sr,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Already a Member"}),e.jsx(rr,{children:"You're already part of this organization"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["You're already a member of ",((b=s.organization)==null?void 0:b.name)||"this organization"]}),e.jsx(sr,{children:"No action needed - you already have access."}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const k=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:k?"Sign Up Required":"Sign In Required"}),e.jsx(rr,{children:"To accept this invitation"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["This invitation is for ",e.jsx(li,{children:s.invited_email})]}),e.jsx(sr,{children:k?"You need to create an account with this email address to accept the invitation.":s.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(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:k?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Expired"}),e.jsx(rr,{children:"This invitation is no longer valid"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"⏱"}),e.jsxs(nr,{children:["Invitation for ",e.jsx(li,{children:s.invited_email})," has expired"]}),e.jsx(sr,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):h||s!=null&&s.error_code?e.jsx(he,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Error"}),e.jsx(rr,{children:"Unable to process invitation"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Something went wrong"}),e.jsx(sr,{children:(s==null?void 0:s.message)||h||"Failed to accept invitation"}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(tx,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(rx,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ws=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Je=()=>{const t=i.useContext(Ws);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},nx=l.div`
2165
+ `;function ox({token:t,onSuccess:r,onError:o}){var b;const{acceptInvitation:n,invitationData:s,loading:a,error:h}=Jc(),{navigate:f}=rt(),{deployment:c}=we(),u=i.useRef(!1),d=()=>{var $;const k=new URLSearchParams(window.location.search);return{token:t||k.get("invite_token")||k.get("token"),redirectUri:k.get("redirect_uri")||(($=c==null?void 0:c.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(u.current)return;const{token:k}=d();k&&(u.current=!0,n(k))},[n]),i.useEffect(()=>{var k;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,(k=s.workspace)==null?void 0:k.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const p=()=>{const{redirectUri:k}=d();f(k)},m=()=>{var g,_;const{token:k}=d(),$=((g=c==null?void 0:c.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",S=((_=c==null?void 0:c.ui_settings)==null?void 0:_.sign_up_page_url)||"/sign-up",C=new URLSearchParams;k&&C.set("invite_token",k),s!=null&&s.invited_email&&C.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${k}`;C.set("redirect_uri",w),s!=null&&s.message&&C.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?S:$}?${C.toString()}`)},x=()=>{const{token:k}=d();k&&(u.current=!1,n(k))},{token:v}=d();if(!v&&!a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invalid Invitation"}),e.jsx(rr,{children:"No invitation token found"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Missing Invitation Token"}),e.jsx(sr,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(J,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Processing Invitation"}),e.jsx(rr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(or,{children:[e.jsx(ex,{}),e.jsx(nr,{children:"Verifying invitation..."}),e.jsx(sr,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Accepted!"}),e.jsx(rr,{children:"You've successfully joined the organization"})]}),e.jsxs(or,{children:[e.jsx(Jm,{children:"✓"}),e.jsxs(nr,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(sr,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Already a Member"}),e.jsx(rr,{children:"You're already part of this organization"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["You're already a member of ",((b=s.organization)==null?void 0:b.name)||"this organization"]}),e.jsx(sr,{children:"No action needed - you already have access."}),e.jsx(J,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const k=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:k?"Sign Up Required":"Sign In Required"}),e.jsx(rr,{children:"To accept this invitation"})]}),e.jsxs(or,{children:[e.jsx(ci,{children:"ℹ"}),e.jsxs(nr,{children:["This invitation is for ",e.jsx(li,{children:s.invited_email})]}),e.jsx(sr,{children:k?"You need to create an account with this email address to accept the invitation.":s.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(J,{onClick:m,style:{marginTop:"var(--space-lg)"},children:k?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Expired"}),e.jsx(rr,{children:"This invitation is no longer valid"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"⏱"}),e.jsxs(nr,{children:["Invitation for ",e.jsx(li,{children:s.invited_email})," has expired"]}),e.jsx(sr,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):h||s!=null&&s.error_code?e.jsx(fe,{children:e.jsxs(Jt,{children:[e.jsxs(er,{children:[e.jsx(tr,{children:"Invitation Error"}),e.jsx(rr,{children:"Unable to process invitation"})]}),e.jsxs(or,{children:[e.jsx(Zn,{children:"✗"}),e.jsx(nr,{children:"Something went wrong"}),e.jsx(sr,{children:(s==null?void 0:s.message)||h||"Failed to accept invitation"}),e.jsx(J,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(tx,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(rx,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ws=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Je=()=>{const t=i.useContext(Ws);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},nx=l.div`
2166
2166
  display: flex;
2167
2167
  height: 100%;
2168
2168
  min-height: 400px;
@@ -2181,7 +2181,7 @@ cursor: pointer;
2181
2181
  padding: 32px;
2182
2182
  display: flex;
2183
2183
  flex-direction: column;
2184
- `,Xl=l.div`
2184
+ `,Jl=l.div`
2185
2185
  width: 80px;
2186
2186
  height: 80px;
2187
2187
  border-radius: 16px;
@@ -2344,14 +2344,14 @@ cursor: pointer;
2344
2344
  transition: opacity 0.2s ease;
2345
2345
  cursor: pointer;
2346
2346
 
2347
- ${Xl}:hover & {
2347
+ ${Jl}:hover & {
2348
2348
  opacity: 1;
2349
2349
  }
2350
2350
  `,jx=l.div`
2351
2351
  color: white;
2352
2352
  font-size: 12px;
2353
2353
  font-weight: 400;
2354
- `,xn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[h,f]=i.useState(),[c,u]=i.useState(null),[d,p]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=on(),{toast:v}=Je(),b=y=>{n(y)},k=y=>{if(y.target.files&&y.target.files[0]){const g=y.target.files[0];if(g.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!g.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(g),u(URL.createObjectURL(g))}},$=()=>{var y;(y=m.current)==null||y.click()},S=y=>y.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),z=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),w=async()=>{const y=C(o),g=C(s);if(!y){v("Please enter an organization name","error");return}if(!z(y)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(g.length>500){v("Description must be less than 500 characters","error");return}p(!0);try{const _=await x({name:y,description:g,image:h});t==null||t(_)}catch(_){const E=_.message||"Failed to create organization. Please try again.";v(E,"error")}finally{p(!1)}};return e.jsx(he,{children:e.jsxs(nx,{children:[e.jsxs(sx,{children:[e.jsxs(Xl,{hasImage:!!c,onClick:$,children:[c?e.jsx(ix,{src:c,alt:"Organization logo"}):e.jsx(cx,{children:S(o||"O")}),e.jsx(wx,{children:e.jsx(jx,{children:"Upload Logo"})})]}),e.jsx(yx,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:d}),e.jsx(lx,{children:"Create new organization"}),e.jsx(dx,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(ax,{children:[e.jsxs(ux,{children:[e.jsx(px,{children:"Choose your organization name"}),e.jsx(hx,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(fx,{children:[e.jsxs(di,{children:[e.jsx(ui,{children:"Organization name"}),e.jsx(gx,{type:"text",value:o,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:d})]}),e.jsxs(di,{children:[e.jsx(ui,{children:"Description (optional)"}),e.jsx(mx,{value:s,onChange:y=>a(y.target.value),placeholder:"What does your organization do?",disabled:d})]})]}),e.jsxs(xx,{children:[r?e.jsxs(vx,{onClick:r,disabled:d,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(bx,{onClick:w,disabled:d||!o.trim(),children:d?"Creating...":"Create"})]})]})]})})},kx=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(he,{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(xn,{onSuccess:n,onCancel:r})})})})})})},_x=l.div`
2354
+ `,xn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[h,f]=i.useState(),[c,u]=i.useState(null),[d,p]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=on(),{toast:v}=Je(),b=y=>{n(y)},k=y=>{if(y.target.files&&y.target.files[0]){const g=y.target.files[0];if(g.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!g.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(g),u(URL.createObjectURL(g))}},$=()=>{var y;(y=m.current)==null||y.click()},S=y=>y.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),z=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),w=async()=>{const y=C(o),g=C(s);if(!y){v("Please enter an organization name","error");return}if(!z(y)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(g.length>500){v("Description must be less than 500 characters","error");return}p(!0);try{const _=await x({name:y,description:g,image:h});t==null||t(_)}catch(_){const E=_.message||"Failed to create organization. Please try again.";v(E,"error")}finally{p(!1)}};return e.jsx(fe,{children:e.jsxs(nx,{children:[e.jsxs(sx,{children:[e.jsxs(Jl,{hasImage:!!c,onClick:$,children:[c?e.jsx(ix,{src:c,alt:"Organization logo"}):e.jsx(cx,{children:S(o||"O")}),e.jsx(wx,{children:e.jsx(jx,{children:"Upload Logo"})})]}),e.jsx(yx,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:d}),e.jsx(lx,{children:"Create new organization"}),e.jsx(dx,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(ax,{children:[e.jsxs(ux,{children:[e.jsx(px,{children:"Choose your organization name"}),e.jsx(hx,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(fx,{children:[e.jsxs(di,{children:[e.jsx(ui,{children:"Organization name"}),e.jsx(gx,{type:"text",value:o,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:d})]}),e.jsxs(di,{children:[e.jsx(ui,{children:"Description (optional)"}),e.jsx(mx,{value:s,onChange:y=>a(y.target.value),placeholder:"What does your organization do?",disabled:d})]})]}),e.jsxs(xx,{children:[r?e.jsxs(vx,{onClick:r,disabled:d,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(bx,{onClick:w,disabled:d||!o.trim(),children:d?"Creating...":"Create"})]})]})]})})},kx=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(fe,{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(xn,{onSuccess:n,onCancel:r})})})})})})},_x=l.div`
2355
2355
  position: fixed;
2356
2356
  width: 360px;
2357
2357
  max-width: calc(100vw - 48px);
@@ -2400,7 +2400,7 @@ cursor: pointer;
2400
2400
  color: var(--color-foreground);
2401
2401
  background: var(--color-input-background);
2402
2402
  }
2403
- `,xi=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[h,f]=i.useState(""),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:b}=st(),{toast:k}=Je(),$=w=>/^[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(w),S=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),C=async()=>{const w=S(h);if(!w){k("Please enter a domain name","error");return}if(!$(w)){k("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){k("Domain name is too long","error");return}try{const y=await v({fqdn:w});k("Domain added successfully","info"),a(y.data)}catch(y){const g=y.message||"Failed to add domain. Please try again.";k(g,"error")}},z=async()=>{if(!(!s||c)){u(!0);try{await b(s),t==null||t(),k("Domain verified successfully","info")}catch(w){const y=w.message||"Failed to verify domain. Please check DNS records and try again.";k(y,"error")}finally{u(!1)}}};return i.useEffect(()=>{p(!0);const w=setTimeout(()=>{if(!n.current)return;const _=o==null?void 0:o.current,E=360,j=250,T=8;let R=0,M=0;if(!_){const D=n.current.getBoundingClientRect(),L=D.width||E,P=D.height||j;R=Math.max(T,(window.innerHeight-P)/2),M=Math.max(T,(window.innerWidth-L)/2),x({top:R,left:M});return}const I=_.getBoundingClientRect(),O=window.innerHeight-I.bottom,N=I.top;O>=j+T?(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):N>=j+T?(R=I.top-j-T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left)),x({top:R,left:M})},10),y=_=>{n.current&&!n.current.contains(_.target)&&(t==null||t())},g=_=>{_.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),d?e.jsx(_x,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(lt,{size:16})})]}),e.jsxs(fi,{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(pe,{children:[e.jsx(ie,{children:"Record Type"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(se,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"add-domain-title",children:"Add Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(fi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(pe,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(se,{type:"text",placeholder:"Enter your domain",value:h,onChange:w=>f(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Cx=l.div`
2403
+ `,xi=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[h,f]=i.useState(""),[c,u]=i.useState(!1),[d,p]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:b}=st(),{toast:k}=Je(),$=w=>/^[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(w),S=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),C=async()=>{const w=S(h);if(!w){k("Please enter a domain name","error");return}if(!$(w)){k("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){k("Domain name is too long","error");return}try{const y=await v({fqdn:w});k("Domain added successfully","info"),a(y.data)}catch(y){const g=y.message||"Failed to add domain. Please try again.";k(g,"error")}},z=async()=>{if(!(!s||c)){u(!0);try{await b(s),t==null||t(),k("Domain verified successfully","info")}catch(w){const y=w.message||"Failed to verify domain. Please check DNS records and try again.";k(y,"error")}finally{u(!1)}}};return i.useEffect(()=>{p(!0);const w=setTimeout(()=>{if(!n.current)return;const _=o==null?void 0:o.current,E=360,j=250,T=8;let R=0,M=0;if(!_){const D=n.current.getBoundingClientRect(),L=D.width||E,P=D.height||j;R=Math.max(T,(window.innerHeight-P)/2),M=Math.max(T,(window.innerWidth-L)/2),x({top:R,left:M});return}const I=_.getBoundingClientRect(),O=window.innerHeight-I.bottom,N=I.top;O>=j+T?(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):N>=j+T?(R=I.top-j-T,M=I.right-E,M<T&&(M=I.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=I.bottom+T,M=I.right-E,M<T&&(M=I.left)),x({top:R,left:M})},10),y=_=>{n.current&&!n.current.contains(_.target)&&(t==null||t())},g=_=>{_.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),d?e.jsx(_x,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(lt,{size:16})})]}),e.jsxs(fi,{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(he,{children:[e.jsx(ie,{children:"Record Type"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(se,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(se,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pi,{children:[e.jsx(hi,{id:"add-domain-title",children:"Add Domain"}),e.jsx(mi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(fi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(se,{type:"text",placeholder:"Enter your domain",value:h,onChange:w=>f(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(gi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Cx=l.div`
2404
2404
  position: fixed;
2405
2405
  width: 360px;
2406
2406
  max-width: calc(100vw - 48px);
@@ -2449,7 +2449,7 @@ cursor: pointer;
2449
2449
  color: var(--color-foreground);
2450
2450
  background: var(--color-input-background);
2451
2451
  }
2452
- `,Jl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState(""),[f,c]=i.useState(null),[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:b}=st(),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name})),S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=a.trim().toLowerCase();if(!(!z||!f)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}d(!0);try{await b({email:z,organizationRole:f}),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const g=n.current;if(g){const _=g.getBoundingClientRect(),E=360,j=250,T=8;let R=0,M=0;const I=window.innerHeight-_.bottom,O=_.top;I>=j+T?(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):O>=j+T?(R=_.top-j-T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left)),v({top:R,left:M})}},10),w=g=>{s.current&&!s.current.contains(g.target)&&(t==null||t())},y=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",y),()=>{clearTimeout(z),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,n]),p?e.jsxs(Cx,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Sx,{children:[e.jsx($x,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Px,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(zx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:a,onChange:z=>h(z.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:f==null?void 0:f.id,onChange:z=>c(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Ex,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a||!f||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Ix=l.div`
2452
+ `,ed=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,h]=i.useState(""),[f,c]=i.useState(null),[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:b}=st(),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name})),S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=a.trim().toLowerCase();if(!(!z||!f)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}d(!0);try{await b({email:z,organizationRole:f}),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const g=n.current;if(g){const _=g.getBoundingClientRect(),E=360,j=250,T=8;let R=0,M=0;const I=window.innerHeight-_.bottom,O=_.top;I>=j+T?(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):O>=j+T?(R=_.top-j-T,M=_.right-E,M<T&&(M=_.left,M+E>window.innerWidth-T&&(M=(window.innerWidth-E)/2))):(R=_.bottom+T,M=_.right-E,M<T&&(M=_.left)),v({top:R,left:M})}},10),w=g=>{s.current&&!s.current.contains(g.target)&&(t==null||t())},y=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",y),()=>{clearTimeout(z),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,n]),p?e.jsxs(Cx,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Sx,{children:[e.jsx($x,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Px,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(zx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:a,onChange:z=>h(z.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:f==null?void 0:f.id,onChange:z=>c(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Ex,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a||!f||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Ix=l.div`
2453
2453
  position: fixed;
2454
2454
  width: 400px;
2455
2455
  max-width: calc(100vw - 48px);
@@ -2500,7 +2500,7 @@ cursor: pointer;
2500
2500
  color: var(--color-foreground);
2501
2501
  background: var(--color-input-background);
2502
2502
  }
2503
- `,vi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var y;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);st();const[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:b}=ye(),{toast:k}=Je(),$=!!o,S=Array.isArray((y=b==null?void 0:b.b2b_settings)==null?void 0:y.organization_permissions)?b.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];i.useEffect(()=>{m(!0);const g=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if($){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let M=0;M<R.length;M++){const I=R[M];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let M=0;M<R.length;M++){const I=R[M];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),M=400;let I=R.bottom+8,O=R.right-M;O<10&&(O=R.left),I+300>window.innerHeight&&(I=R.top-300-8),v({top:I,left:O})}},10),_=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},E=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",E)},100);return()=>{clearTimeout(g),clearTimeout(j),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",E)}},[t,$,n]);const C=g=>g.trim().replace(/[<>\"'&]/g,""),z=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),w=async()=>{const g=C(a);if(!g){k("Please enter a role name","error");return}if(!z(g)){k("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){k("Please select at least one permission","error");return}d(!0);try{const _={id:o==null?void 0:o.id,name:g,permissions:f||[]};r==null||r(_)}catch(_){const E=_.message||`Failed to ${$?"update":"create"} role. Please try again.`;k(E,"error")}finally{d(!1)}};return p?e.jsxs(Ix,{ref:s,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Rx,{children:[e.jsx(Tx,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Ax,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(lt,{size:16})})]}),e.jsx(Mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:g=>h(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Ox,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:w,disabled:!a||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},_t=l.table`
2503
+ `,vi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var y;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);st();const[u,d]=i.useState(!1),[p,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:b}=we(),{toast:k}=Je(),$=!!o,S=Array.isArray((y=b==null?void 0:b.b2b_settings)==null?void 0:y.organization_permissions)?b.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];i.useEffect(()=>{m(!0);const g=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if($){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let M=0;M<R.length;M++){const I=R[M];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let M=0;M<R.length;M++){const I=R[M];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),M=400;let I=R.bottom+8,O=R.right-M;O<10&&(O=R.left),I+300>window.innerHeight&&(I=R.top-300-8),v({top:I,left:O})}},10),_=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},E=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",E)},100);return()=>{clearTimeout(g),clearTimeout(j),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",E)}},[t,$,n]);const C=g=>g.trim().replace(/[<>\"'&]/g,""),z=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),w=async()=>{const g=C(a);if(!g){k("Please enter a role name","error");return}if(!z(g)){k("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){k("Please select at least one permission","error");return}d(!0);try{const _={id:o==null?void 0:o.id,name:g,permissions:f||[]};r==null||r(_)}catch(_){const E=_.message||`Failed to ${$?"update":"create"} role. Please try again.`;k(E,"error")}finally{d(!1)}};return p?e.jsxs(Ix,{ref:s,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Rx,{children:[e.jsx(Tx,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Ax,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(lt,{size:16})})]}),e.jsx(Mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:g=>h(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Ox,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:w,disabled:!a||u,style:{width:"auto"},children:u?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},_t=l.table`
2504
2504
  width: 100%;
2505
2505
  border-collapse: separate;
2506
2506
  border-spacing: 0;
@@ -2546,7 +2546,7 @@ cursor: pointer;
2546
2546
  vertical-align: middle;
2547
2547
  background-color: var(--color-background);
2548
2548
  white-space: nowrap;
2549
- `,ed=l(Ue)`
2549
+ `,td=l(Ue)`
2550
2550
  & > div {
2551
2551
  display: flex;
2552
2552
  align-items: center;
@@ -2749,7 +2749,7 @@ cursor: pointer;
2749
2749
  color: var(--color-foreground);
2750
2750
  text-transform: uppercase;
2751
2751
  letter-spacing: 0.5px;
2752
- `,e0=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=st(),{deployment:n}=ye(),{toast:s}=Je(),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState("saml"),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.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:""}),[$,S]=i.useState(!1),[C,z]=i.useState(null),{data:w=[],isLoading:y}=Ze("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(O=>O.verified),{revalidateOnFocus:!1}),g=I=>{c(I),d(I.protocol),I.protocol==="saml"?k(O=>{var N,D,L;return{...O,idp_entity_id:I.placeholders.entityId||"",idp_sso_url:I.placeholders.ssoUrl||"",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}}):k(O=>{var N,D,L;return{...O,oidc_issuer_url:I.placeholders.issuerUrl||"",oidc_scopes:I.placeholders.scopes||"openid profile email",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}})},_=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(I,O)=>{navigator.clipboard.writeText(I),m(O),setTimeout(()=>m(null),2e3)},R=async I=>{I.preventDefault();const O=N=>N.includes("{")||N.includes("}");if(u==="saml"){if(!b.idp_entity_id||O(b.idp_entity_id)){s("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||O(b.idp_sso_url)){s("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){s("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||O(b.oidc_issuer_url)){s("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||O(b.oidc_client_id)){s("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){s("Please enter the Client Secret","error");return}}h(!0);try{const N={};b.attr_first_name&&(N.first_name=b.attr_first_name),b.attr_last_name&&(N.last_name=b.attr_last_name),b.attr_email&&(N.email=b.attr_email);const D=Object.keys(N).length>0;u==="saml"?await t({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}}):await t({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}})}finally{h(!1)}},M=async()=>{S(!0),z(null);const I=D=>D.includes("{")||D.includes("}"),O={},N={};if(u==="saml"?(b.idp_entity_id?I(b.idp_entity_id)?(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):N.entity_id_valid=!0:(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?I(b.idp_sso_url)?(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):N.sso_url_valid=!0:(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?N.certificate_provided=!0:(N.certificate_provided=!1,O.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?I(b.oidc_issuer_url)?(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):N.issuer_url_valid=!0:(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?I(b.oidc_client_id)?(N.client_id_valid=!1,O.client_id_valid="Client ID contains placeholder values - please replace with actual values"):N.client_id_valid=!0:(N.client_id_valid=!1,O.client_id_valid="Client ID is required")),Object.keys(O).length>0){z({success:!1,checks:N,errors:O}),S(!1);return}try{const D=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},L=await(o==null?void 0:o(D));L&&z(L)}catch(D){z({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:R,autoComplete:"off",children:[f?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:[f.logo?e.jsx(Kn,{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(pt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(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(Qn,{children:"SAML Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="saml").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))}),e.jsx(Qn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="oidc").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(bi,{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:u==="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:j}),e.jsx(Qr,{onClick:()=>T(j,"acs"),children:p==="acs"?e.jsx(tt,{size:12}):e.jsx(pr,{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:E}),e.jsx(Qr,{onClick:()=>T(E,"metadata"),children:p==="metadata"?e.jsx(tt,{size:12}):e.jsx(pr,{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.jsx(Qr,{onClick:()=>T(_,"callback"),children:p==="callback"?e.jsx(tt,{size:12}):e.jsx(pr,{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(Qn,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ns,{size:12})," Docs"]}),e.jsx(J,{type:"button",onClick:M,disabled:$||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Re,{size:16}):"Test Connection"}),e.jsx(J,{type:"submit",disabled:a||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:a?e.jsx(Re,{size:16}):"Create Connection"})]})]}),C&&(()=>{const I={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:C.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${C.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:C.success?"#10b981":"#ef4444"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(C.checks).map(([O,N])=>{var D;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:N?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:N?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:I[O]||O.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=C.errors)==null?void 0:D[O])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:C.errors[O]})]})]},O)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(pe,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(_i,{value:u,onChange:I=>d(I.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(pe,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),y?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(bi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(_i,{value:b.domain_id,onChange:I=>k({...b,domain_id:I.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(I=>e.jsx("option",{value:I.id,children:I.fqdn},I.id))]})]}),u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(se,{type:"text",value:b.idp_entity_id,onChange:I=>k({...b,idp_entity_id:I.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(se,{type:"url",value:b.idp_sso_url,onChange:I=>k({...b,idp_sso_url:I.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(pe,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(Yx,{value:b.idp_certificate,onChange:I=>k({...b,idp_certificate:I.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(se,{type:"url",value:b.oidc_issuer_url,onChange:I=>k({...b,oidc_issuer_url:I.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(se,{type:"text",value:b.oidc_client_id,onChange:I=>k({...b,oidc_client_id:I.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(se,{type:"password",value:b.oidc_client_secret,onChange:I=>k({...b,oidc_client_secret:I.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(se,{type:"text",value:b.oidc_scopes,onChange:I=>k({...b,oidc_scopes:I.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(pe,{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(mr,{checked:b.jit_enabled,onChange:()=>k({...b,jit_enabled:!b.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>v(!x),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:x?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&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(pe,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_first_name,onChange:I=>k({...b,attr_first_name:I.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_last_name,onChange:I=>k({...b,attr_last_name:I.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(se,{type:"text",value:b.attr_email,onChange:I=>k({...b,attr_email:I.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Ci=l.div`
2752
+ `,e0=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=st(),{deployment:n}=we(),{toast:s}=Je(),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState("saml"),[p,m]=i.useState(null),[x,v]=i.useState(!1),[b,k]=i.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:""}),[$,S]=i.useState(!1),[C,z]=i.useState(null),{data:w=[],isLoading:y}=Ze("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(O=>O.verified),{revalidateOnFocus:!1}),g=I=>{c(I),d(I.protocol),I.protocol==="saml"?k(O=>{var N,D,L;return{...O,idp_entity_id:I.placeholders.entityId||"",idp_sso_url:I.placeholders.ssoUrl||"",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}}):k(O=>{var N,D,L;return{...O,oidc_issuer_url:I.placeholders.issuerUrl||"",oidc_scopes:I.placeholders.scopes||"openid profile email",attr_first_name:((N=I.attributeMapping)==null?void 0:N.first_name)||"",attr_last_name:((D=I.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=I.attributeMapping)==null?void 0:L.email)||""}})},_=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(I,O)=>{navigator.clipboard.writeText(I),m(O),setTimeout(()=>m(null),2e3)},R=async I=>{I.preventDefault();const O=N=>N.includes("{")||N.includes("}");if(u==="saml"){if(!b.idp_entity_id||O(b.idp_entity_id)){s("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||O(b.idp_sso_url)){s("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){s("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||O(b.oidc_issuer_url)){s("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||O(b.oidc_client_id)){s("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){s("Please enter the Client Secret","error");return}}h(!0);try{const N={};b.attr_first_name&&(N.first_name=b.attr_first_name),b.attr_last_name&&(N.last_name=b.attr_last_name),b.attr_email&&(N.email=b.attr_email);const D=Object.keys(N).length>0;u==="saml"?await t({protocol:"saml",domain_id:b.domain_id||void 0,idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}}):await t({protocol:"oidc",domain_id:b.domain_id||void 0,oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret,oidc_scopes:b.oidc_scopes,jit_enabled:b.jit_enabled,...D&&{attribute_mapping:N}})}finally{h(!1)}},M=async()=>{S(!0),z(null);const I=D=>D.includes("{")||D.includes("}"),O={},N={};if(u==="saml"?(b.idp_entity_id?I(b.idp_entity_id)?(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):N.entity_id_valid=!0:(N.entity_id_valid=!1,O.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?I(b.idp_sso_url)?(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):N.sso_url_valid=!0:(N.sso_url_valid=!1,O.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?N.certificate_provided=!0:(N.certificate_provided=!1,O.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?I(b.oidc_issuer_url)?(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):N.issuer_url_valid=!0:(N.issuer_url_valid=!1,O.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?I(b.oidc_client_id)?(N.client_id_valid=!1,O.client_id_valid="Client ID contains placeholder values - please replace with actual values"):N.client_id_valid=!0:(N.client_id_valid=!1,O.client_id_valid="Client ID is required")),Object.keys(O).length>0){z({success:!1,checks:N,errors:O}),S(!1);return}try{const D=u==="saml"?{protocol:"saml",idp_entity_id:b.idp_entity_id,idp_sso_url:b.idp_sso_url,idp_certificate:b.idp_certificate}:{protocol:"oidc",oidc_issuer_url:b.oidc_issuer_url,oidc_client_id:b.oidc_client_id,oidc_client_secret:b.oidc_client_secret},L=await(o==null?void 0:o(D));L&&z(L)}catch(D){z({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:R,autoComplete:"off",children:[f?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:[f.logo?e.jsx(Kn,{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(pt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(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(Qn,{children:"SAML Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="saml").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))}),e.jsx(Qn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(wi,{children:yi.filter(I=>I.protocol==="oidc").map(I=>e.jsxs(ji,{type:"button",$selected:!1,onClick:()=>g(I),children:[I.logo?e.jsx(Kn,{src:I.logo,alt:I.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(pt,{size:18,color:"#666"})}),e.jsx(ki,{children:I.name})]},I.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(bi,{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:u==="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:j}),e.jsx(Qr,{onClick:()=>T(j,"acs"),children:p==="acs"?e.jsx(tt,{size:12}):e.jsx(pr,{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:E}),e.jsx(Qr,{onClick:()=>T(E,"metadata"),children:p==="metadata"?e.jsx(tt,{size:12}):e.jsx(pr,{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.jsx(Qr,{onClick:()=>T(_,"callback"),children:p==="callback"?e.jsx(tt,{size:12}):e.jsx(pr,{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(Qn,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ns,{size:12})," Docs"]}),e.jsx(J,{type:"button",onClick:M,disabled:$||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Re,{size:16}):"Test Connection"}),e.jsx(J,{type:"submit",disabled:a||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:a?e.jsx(Re,{size:16}):"Create Connection"})]})]}),C&&(()=>{const I={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:C.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${C.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:C.success?"#10b981":"#ef4444"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(C.checks).map(([O,N])=>{var D;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:N?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:N?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:I[O]||O.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=C.errors)==null?void 0:D[O])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:C.errors[O]})]})]},O)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(he,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(_i,{value:u,onChange:I=>d(I.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),y?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(bi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(_i,{value:b.domain_id,onChange:I=>k({...b,domain_id:I.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(I=>e.jsx("option",{value:I.id,children:I.fqdn},I.id))]})]}),u==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(se,{type:"text",value:b.idp_entity_id,onChange:I=>k({...b,idp_entity_id:I.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(se,{type:"url",value:b.idp_sso_url,onChange:I=>k({...b,idp_sso_url:I.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(Yx,{value:b.idp_certificate,onChange:I=>k({...b,idp_certificate:I.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(se,{type:"url",value:b.oidc_issuer_url,onChange:I=>k({...b,oidc_issuer_url:I.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(se,{type:"text",value:b.oidc_client_id,onChange:I=>k({...b,oidc_client_id:I.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(se,{type:"password",value:b.oidc_client_secret,onChange:I=>k({...b,oidc_client_secret:I.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(se,{type:"text",value:b.oidc_scopes,onChange:I=>k({...b,oidc_scopes:I.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(he,{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(mr,{checked:b.jit_enabled,onChange:()=>k({...b,jit_enabled:!b.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>v(!x),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:x?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:x?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),x&&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(he,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_first_name,onChange:I=>k({...b,attr_first_name:I.target.value}),placeholder:u==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(se,{type:"text",value:b.attr_last_name,onChange:I=>k({...b,attr_last_name:I.target.value}),placeholder:u==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(se,{type:"text",value:b.attr_email,onChange:I=>k({...b,attr_email:I.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Ci=l.div`
2753
2753
  * {
2754
2754
  box-sizing: border-box;
2755
2755
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2845,15 +2845,15 @@ cursor: pointer;
2845
2845
  @media (max-width: 768px) {
2846
2846
  padding: 20px 20px 0 20px;
2847
2847
  }
2848
- `,td=l.div`
2848
+ `,rd=l.div`
2849
2849
  display: flex;
2850
2850
  align-items: center;
2851
2851
  flex-wrap: wrap;
2852
2852
  gap: 12px;
2853
2853
  margin-bottom: 24px;
2854
- `,n0=()=>{var O,N,D,L;const{activeOrganization:t,loading:r}=st(),{switchOrganization:o,refetch:n}=Qe(),{workspaces:s}=Wt(),{deployment:a}=ye(),{deleteOrganization:h,updateOrganization:f}=on(),{toast:c}=Je(),[u,d]=i.useState((t==null?void 0:t.name)||""),[p,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),b=i.useRef(null),[k,$]=i.useState(!1),[S,C]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||k))try{$(!0),await f(t,{name:u,description:p}),c("Changes saved","info")}catch(P){const A=P.message||"Failed to save changes. Please try again.";c(A,"error")}finally{$(!1)}},[t,u,p,x,S,f,c]);i.useEffect(()=>{var P;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),C({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
2855
- `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||z!==t.name))try{g(!0),await o(""),await h(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{g(!1),w("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const M=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];if(q.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!q.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(q)),setTimeout(()=>j(),100)}},I=()=>{b.current&&b.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",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"},onClick:I,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:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:M,"aria-label":"Upload organization logo"})]})}),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:"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("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=b.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),x?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{v(null),b.current&&(b.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(gn,{size:14}),"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:"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:"var(--space-lg)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"name",children:"Organization Name"}),e.jsx(se,{id:"name",type:"text",value:u,onChange:P=>d(P.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:p,onChange:P=>m(P.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((O=a==null?void 0:a.b2b_settings)==null?void 0:O.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:S.mfa_required,onChange:()=>{C(P=>({...P,mfa_required:!P.mfa_required})),setTimeout(()=>j(),100)}})]}),((N=a==null?void 0:a.b2b_settings)==null?void 0:N.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:S.ip_restrictions,onChange:()=>{C(P=>({...P,ip_restrictions:!P.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),S.ip_restrictions&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:S.allowed_ips,onChange:P=>C(A=>({...A,allowed_ips:P.target.value})),onBlur:j,placeholder:`192.168.1.1
2856
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=a==null?void 0:a.b2b_settings)==null?void 0:D.workspaces_enabled)&&T.length>0&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Us,{options:T.map(P=>({value:P.id,label:P.name})),value:S.default_workspace_id,onChange:P=>{C(A=>({...A,default_workspace_id:P})),setTimeout(()=>j(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[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:_?"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 this organization, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{_?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:_?"Cancel":"Delete"})]}),_&&e.jsxs("div",{children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(se,{id:"confirm_name",type:"text",value:z,onChange:P=>w(P.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(J,{onClick:R,disabled:z!==(t==null?void 0:t.name)||y,style:{background:z===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:z===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:z===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Si=l.span`
2854
+ `,n0=()=>{var O,N,D,L;const{activeOrganization:t,loading:r}=st(),{switchOrganization:o,refetch:n}=Qe(),{workspaces:s}=Wt(),{deployment:a}=we(),{deleteOrganization:h,updateOrganization:f}=on(),{toast:c}=Je(),[u,d]=i.useState((t==null?void 0:t.name)||""),[p,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),b=i.useRef(null),[k,$]=i.useState(!1),[S,C]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||k))try{$(!0),await f(t,{name:u,description:p}),c("Changes saved","info")}catch(P){const A=P.message||"Failed to save changes. Please try again.";c(A,"error")}finally{$(!1)}},[t,u,p,x,S,f,c]);i.useEffect(()=>{var P;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),C({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
2855
+ `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||z!==t.name))try{g(!0),await o(""),await h(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{g(!1),w("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const M=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];if(q.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!q.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(q)),setTimeout(()=>j(),100)}},I=()=>{b.current&&b.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",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"},onClick:I,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:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:M,"aria-label":"Upload organization logo"})]})}),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:"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("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=b.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),x?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{v(null),b.current&&(b.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(gn,{size:14}),"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:"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:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"name",children:"Organization Name"}),e.jsx(se,{id:"name",type:"text",value:u,onChange:P=>d(P.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:p,onChange:P=>m(P.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((O=a==null?void 0:a.b2b_settings)==null?void 0:O.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:S.mfa_required,onChange:()=>{C(P=>({...P,mfa_required:!P.mfa_required})),setTimeout(()=>j(),100)}})]}),((N=a==null?void 0:a.b2b_settings)==null?void 0:N.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:S.ip_restrictions,onChange:()=>{C(P=>({...P,ip_restrictions:!P.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),S.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:S.allowed_ips,onChange:P=>C(A=>({...A,allowed_ips:P.target.value})),onBlur:j,placeholder:`192.168.1.1
2856
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=a==null?void 0:a.b2b_settings)==null?void 0:D.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Us,{options:T.map(P=>({value:P.id,label:P.name})),value:S.default_workspace_id,onChange:P=>{C(A=>({...A,default_workspace_id:P})),setTimeout(()=>j(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[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:_?"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 this organization, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{_?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:_?"Cancel":"Delete"})]}),_&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(se,{id:"confirm_name",type:"text",value:z,onChange:P=>w(P.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(J,{onClick:R,disabled:z!==(t==null?void 0:t.name)||y,style:{background:z===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:z===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:z===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Si=l.span`
2857
2857
  background: var(--color-primary-background);
2858
2858
  color: var(--color-primary);
2859
2859
  padding: 4px 8px;
@@ -2890,7 +2890,7 @@ cursor: pointer;
2890
2890
  opacity: 0.5;
2891
2891
  cursor: not-allowed;
2892
2892
  }
2893
- `,s0=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=st(),s=i.useRef(null),[a,h]=i.useState(null),{data:f=[],isLoading:c,mutate:u}=Ze(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),d=f,[p,m]=i.useState(!1),[x,v]=i.useState(null),[b,k]=i.useState(""),[$,S]=i.useState(null),C=i.useRef(null),z=i.useRef({}),w=i.useMemo(()=>{let _=d;if(b.trim()!==""){const E=b.toLowerCase();_=_.filter(j=>j.fqdn.toLowerCase().includes(E))}return _},[d,b]),y=async _=>{await n(_),u()},g=async _=>{v(_)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(td,{children:[e.jsx(At,{value:b,onChange:k,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(J,{ref:C,onClick:()=>m(!p),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),p&&e.jsx(xi,{onClose:()=>{m(!1),u()},triggerRef:C})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),w!=null&&w.length?e.jsxs(_t,{ref:s,children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Domain"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{children:"Date Added"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(_=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:_.fqdn}),e.jsx(Ue,{children:_.verified?e.jsx(Si,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Si,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(jt,{size:9})," Pending Verification"]})}),e.jsx(Ue,{children:new Date(_.created_at).toLocaleDateString()}),e.jsx($t,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ft,{style:{marginLeft:"auto"},open:$===_.id,openChange:E=>S(E?_.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{ref:E=>{z.current[_.id]=E},children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{g(_.id),S(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:_.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Be,{onClick:()=>{S(null),navigator.clipboard.writeText(_.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pr,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Be,{onClick:()=>{window.open(`https://${_.fqdn}`,"_blank"),S(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ns,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>{S(null),h(_.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(_),onCancel:()=>h(null)}),x===_.id&&e.jsx(xi,{domain:_,onClose:()=>v(null),triggerRef:{current:z.current[_.id]}})]})})]},_.id))})]}):e.jsx(xt,{title:b!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},a0=l.div`
2893
+ `,s0=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=st(),s=i.useRef(null),[a,h]=i.useState(null),{data:f=[],isLoading:c,mutate:u}=Ze(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),d=f,[p,m]=i.useState(!1),[x,v]=i.useState(null),[b,k]=i.useState(""),[$,S]=i.useState(null),C=i.useRef(null),z=i.useRef({}),w=i.useMemo(()=>{let _=d;if(b.trim()!==""){const E=b.toLowerCase();_=_.filter(j=>j.fqdn.toLowerCase().includes(E))}return _},[d,b]),y=async _=>{await n(_),u()},g=async _=>{v(_)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(rd,{children:[e.jsx(At,{value:b,onChange:k,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(J,{ref:C,onClick:()=>m(!p),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),p&&e.jsx(xi,{onClose:()=>{m(!1),u()},triggerRef:C})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),w!=null&&w.length?e.jsxs(_t,{ref:s,children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Domain"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{children:"Date Added"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(_=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:_.fqdn}),e.jsx(Ue,{children:_.verified?e.jsx(Si,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Si,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(jt,{size:9})," Pending Verification"]})}),e.jsx(Ue,{children:new Date(_.created_at).toLocaleDateString()}),e.jsx($t,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ft,{style:{marginLeft:"auto"},open:$===_.id,openChange:E=>S(E?_.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{ref:E=>{z.current[_.id]=E},children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{g(_.id),S(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:_.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Be,{onClick:()=>{S(null),navigator.clipboard.writeText(_.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pr,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Be,{onClick:()=>{window.open(`https://${_.fqdn}`,"_blank"),S(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ns,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>{S(null),h(_.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(_),onCancel:()=>h(null)}),x===_.id&&e.jsx(xi,{domain:_,onClose:()=>v(null),triggerRef:{current:z.current[_.id]}})]})})]},_.id))})]}):e.jsx(xt,{title:b!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},a0=l.div`
2894
2894
  width: 40px;
2895
2895
  height: 40px;
2896
2896
  border-radius: 50%;
@@ -2902,7 +2902,7 @@ cursor: pointer;
2902
2902
  font-weight: 400;
2903
2903
  font-size: 14px;
2904
2904
  overflow: hidden;
2905
- `,i0=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:h}=st(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),[p,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:b,mutate:k}=Ze(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:$=[],isLoading:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),C=$,z=i.useMemo(()=>u?v.filter(j=>{var N;const T=j.user;if(!T)return!1;const R=T.first_name||"",M=T.last_name||"",I=((N=T.primary_email_address)==null?void 0:N.email)||"";return`${R} ${M}`.trim().toLowerCase().includes(u.toLowerCase())||I.toLowerCase().includes(u.toLowerCase())}):v,[v,u]),w=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),k()}catch(M){const I=M.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(M=>M.id===T))||!1},_=async j=>{try{await h(j),k(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},E=()=>{m(!1),k(),c("Invitation sent successfully","info")};return r||b||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),e.jsx(J,{ref:x,onClick:()=>m(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx(Jl,{onClose:()=>m(!1),onSuccess:E,roles:C,triggerRef:x}),z.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Roles"})]})}),e.jsx(St,{children:z.map(j=>{var I,O;const T=j.roles||[],R=j.user,M=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.user_id);return e.jsxs(Ye,{children:[e.jsx(ed,{children:e.jsxs("div",{children:[e.jsx(a0,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):y(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!R)return"Unknown User";const N=`${R.first_name||""} ${R.last_name||""}`.trim();return N||((D=R.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),M&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(O=R==null?void 0:R.primary_email_address)==null?void 0:O.email})]})]})}),e.jsx(Ue,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[C.map(N=>{const D=g(j,N.id);return e.jsx(Be,{onClick:()=>w(j,N,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:N.name}),D&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},N.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>_(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},c0=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=st(),{toast:h}=Je(),[f,c]=i.useState(!1),[u,d]=i.useState(""),p=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=Ze(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:b=[],isLoading:k}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),$=b,S=i.useMemo(()=>u?m.filter(y=>y.email.toLowerCase().includes(u.toLowerCase())):m,[m,u]),C=()=>{h("Invitation sent successfully","info"),v(),c(!1)},z=async y=>{try{await s(y),v(),h("Invitation cancelled successfully","info")}catch(g){const _=g.message||"Failed to cancel invitation. Please try again.";h(_,"error")}},w=async y=>{try{await a(y),h("Invitation resent successfully","info")}catch(g){const _=g.message||"Failed to resend invitation. Please try again.";h(_,"error")}};return r||x||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search invitations..."})}),e.jsx(J,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(Jl,{onClose:()=>c(!1),onSuccess:C,roles:$,triggerRef:p}),S.length===0?e.jsx(xt,{title:u?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:S.map(y=>{var g;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:y.email}),e.jsx(Ue,{children:((g=y.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(Vs,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>w(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hn,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>z(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},y.id)})})]})]})},l0=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=st(),{deployment:s}=ye(),[a,h]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[u,d]=i.useState(null),[p,m]=i.useState(""),[x,v]=i.useState(null),b=i.useRef(null),{data:k=[],isLoading:$,mutate:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),C=i.useMemo(()=>p?k.filter(g=>g.name.toLowerCase().includes(p.toLowerCase())):k,[k,p]),z=async g=>{try{g.id?(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role created successfully",type:"success"})),h({isOpen:!1}),S()}catch(_){const E=(_==null?void 0:_.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),S()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(jt,{size:16}),f.text]}),e.jsxs(td,{children:[e.jsx(At,{placeholder:"Search roles",onChange:m,value:p}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(J,{ref:b,onClick:()=>h({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(vi,{role:a.role,onClose:()=>h({isOpen:!1}),onSuccess:z,triggerRef:b})]})]}),C.length===0?e.jsx(xt,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:C.map(g=>{var _;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:u===g.id,openChange:E=>d(E?g.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{d(null),h({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{d(null),v(g.id)},children:"Remove Role"})]})]}),x===g.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>v(null)}),a.isOpen&&((_=a.role)==null?void 0:_.id)===g.id&&e.jsx(vi,{role:a.role,onClose:()=>{h({isOpen:!1}),d(null)},onSuccess:z})]})})]},g.id)})})]})]})},rd=()=>{var d;const{loading:t,activeOrganization:r}=st(),{deployment:o}=ye(),[n,s]=i.useState("general"),[a,h]=i.useState(null),[f,c]=i.useState("info"),u=i.useCallback((p,m="info")=>{h(p),c(m),setTimeout(()=>h(null),3e3)},[h]);return t?e.jsx(Xn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ci,{children:e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:u},children:e.jsxs(Xn,{children:[e.jsx(t0,{children:e.jsxs(r0,{children:[e.jsx(jr,{$isActive:n==="general",onClick:()=>s("general"),children:e.jsxs(kr,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(jr,{$isActive:n==="domains",onClick:()=>s("domains"),children:e.jsxs(kr,{children:[e.jsx(Oh,{size:16}),"Domains"]})}),e.jsx(jr,{$isActive:n==="members",onClick:()=>s("members"),children:e.jsxs(kr,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(jr,{$isActive:n==="invitations",onClick:()=>s("invitations"),children:e.jsxs(kr,{children:[e.jsx(hn,{size:16}),"Invitations"]})}),e.jsx(jr,{$isActive:n==="roles",onClick:()=>s("roles"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Roles"]})}),((d=o==null?void 0:o.b2b_settings)==null?void 0:d.enterprise_sso_enabled)&&e.jsx(jr,{$isActive:n==="sso",onClick:()=>s("sso"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(o0,{children:[n==="general"&&e.jsx(n0,{}),n==="domains"&&e.jsx(s0,{}),n==="members"&&e.jsx(i0,{}),n==="invitations"&&e.jsx(c0,{}),n==="roles"&&e.jsx(l0,{}),n==="sso"&&e.jsx(Zx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",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",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ci,{children:e.jsx(Xn,{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(Jr,{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(gd,{})]})})})},d0=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(rd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),u0=l.div`
2905
+ `,i0=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:h}=st(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),[p,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:b,mutate:k}=Ze(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:$=[],isLoading:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),C=$,z=i.useMemo(()=>u?v.filter(j=>{var N;const T=j.user;if(!T)return!1;const R=T.first_name||"",M=T.last_name||"",I=((N=T.primary_email_address)==null?void 0:N.email)||"";return`${R} ${M}`.trim().toLowerCase().includes(u.toLowerCase())||I.toLowerCase().includes(u.toLowerCase())}):v,[v,u]),w=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),k()}catch(M){const I=M.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(M=>M.id===T))||!1},_=async j=>{try{await h(j),k(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},E=()=>{m(!1),k(),c("Invitation sent successfully","info")};return r||b||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),e.jsx(J,{ref:x,onClick:()=>m(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx(ed,{onClose:()=>m(!1),onSuccess:E,roles:C,triggerRef:x}),z.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Roles"})]})}),e.jsx(St,{children:z.map(j=>{var I,O;const T=j.roles||[],R=j.user,M=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(a0,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):y(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!R)return"Unknown User";const N=`${R.first_name||""} ${R.last_name||""}`.trim();return N||((D=R.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),M&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(O=R==null?void 0:R.primary_email_address)==null?void 0:O.email})]})]})}),e.jsx(Ue,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[C.map(N=>{const D=g(j,N.id);return e.jsx(Be,{onClick:()=>w(j,N,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:N.name}),D&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},N.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>_(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},c0=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=st(),{toast:h}=Je(),[f,c]=i.useState(!1),[u,d]=i.useState(""),p=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=Ze(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:b=[],isLoading:k}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),$=b,S=i.useMemo(()=>u?m.filter(y=>y.email.toLowerCase().includes(u.toLowerCase())):m,[m,u]),C=()=>{h("Invitation sent successfully","info"),v(),c(!1)},z=async y=>{try{await s(y),v(),h("Invitation cancelled successfully","info")}catch(g){const _=g.message||"Failed to cancel invitation. Please try again.";h(_,"error")}},w=async y=>{try{await a(y),h("Invitation resent successfully","info")}catch(g){const _=g.message||"Failed to resend invitation. Please try again.";h(_,"error")}};return r||x||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(At,{value:u,onChange:d,placeholder:"Search invitations..."})}),e.jsx(J,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(ed,{onClose:()=>c(!1),onSuccess:C,roles:$,triggerRef:p}),S.length===0?e.jsx(xt,{title:u?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:S.map(y=>{var g;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:y.email}),e.jsx(Ue,{children:((g=y.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(Vs,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>w(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hn,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>z(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},y.id)})})]})]})},l0=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=st(),{deployment:s}=we(),[a,h]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[u,d]=i.useState(null),[p,m]=i.useState(""),[x,v]=i.useState(null),b=i.useRef(null),{data:k=[],isLoading:$,mutate:S}=Ze(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),C=i.useMemo(()=>p?k.filter(g=>g.name.toLowerCase().includes(p.toLowerCase())):k,[k,p]),z=async g=>{try{g.id?(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(_=>setTimeout(_,1e3)),c({text:"Role created successfully",type:"success"})),h({isOpen:!1}),S()}catch(_){const E=(_==null?void 0:_.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),S()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(jt,{size:16}),f.text]}),e.jsxs(rd,{children:[e.jsx(At,{placeholder:"Search roles",onChange:m,value:p}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(J,{ref:b,onClick:()=>h({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(vi,{role:a.role,onClose:()=>h({isOpen:!1}),onSuccess:z,triggerRef:b})]})]}),C.length===0?e.jsx(xt,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:C.map(g=>{var _;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:u===g.id,openChange:E=>d(E?g.id:null),children:[e.jsx(mt,{children:e.jsx(Vs,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{d(null),h({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{d(null),v(g.id)},children:"Remove Role"})]})]}),x===g.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>v(null)}),a.isOpen&&((_=a.role)==null?void 0:_.id)===g.id&&e.jsx(vi,{role:a.role,onClose:()=>{h({isOpen:!1}),d(null)},onSuccess:z})]})})]},g.id)})})]})]})},od=()=>{var d;const{loading:t,activeOrganization:r}=st(),{deployment:o}=we(),[n,s]=i.useState("general"),[a,h]=i.useState(null),[f,c]=i.useState("info"),u=i.useCallback((p,m="info")=>{h(p),c(m),setTimeout(()=>h(null),3e3)},[h]);return t?e.jsx(Xn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ci,{children:e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:u},children:e.jsxs(Xn,{children:[e.jsx(t0,{children:e.jsxs(r0,{children:[e.jsx(jr,{$isActive:n==="general",onClick:()=>s("general"),children:e.jsxs(kr,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(jr,{$isActive:n==="domains",onClick:()=>s("domains"),children:e.jsxs(kr,{children:[e.jsx(Ah,{size:16}),"Domains"]})}),e.jsx(jr,{$isActive:n==="members",onClick:()=>s("members"),children:e.jsxs(kr,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(jr,{$isActive:n==="invitations",onClick:()=>s("invitations"),children:e.jsxs(kr,{children:[e.jsx(hn,{size:16}),"Invitations"]})}),e.jsx(jr,{$isActive:n==="roles",onClick:()=>s("roles"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Roles"]})}),((d=o==null?void 0:o.b2b_settings)==null?void 0:d.enterprise_sso_enabled)&&e.jsx(jr,{$isActive:n==="sso",onClick:()=>s("sso"),children:e.jsxs(kr,{children:[e.jsx(pt,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(o0,{children:[n==="general"&&e.jsx(n0,{}),n==="domains"&&e.jsx(s0,{}),n==="members"&&e.jsx(i0,{}),n==="invitations"&&e.jsx(c0,{}),n==="roles"&&e.jsx(l0,{}),n==="sso"&&e.jsx(Zx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",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",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ci,{children:e.jsx(Xn,{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(Jr,{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(md,{})]})})})},d0=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(od,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),u0=l.div`
2906
2906
  display: flex;
2907
2907
  height: 100%;
2908
2908
  min-height: 400px;
@@ -2921,7 +2921,7 @@ cursor: pointer;
2921
2921
  padding: 32px;
2922
2922
  display: flex;
2923
2923
  flex-direction: column;
2924
- `,od=l.div`
2924
+ `,nd=l.div`
2925
2925
  width: 80px;
2926
2926
  height: 80px;
2927
2927
  border-radius: 16px;
@@ -3084,7 +3084,7 @@ cursor: pointer;
3084
3084
  transition: opacity 0.2s ease;
3085
3085
  cursor: pointer;
3086
3086
 
3087
- ${od}:hover & {
3087
+ ${nd}:hover & {
3088
3088
  opacity: 1;
3089
3089
  }
3090
3090
  `,E0=l.div`
@@ -3136,7 +3136,7 @@ cursor: pointer;
3136
3136
  z-index: 10;
3137
3137
  max-height: 200px;
3138
3138
  overflow-y: auto;
3139
- `,nd=l.button`
3139
+ `,sd=l.button`
3140
3140
  width: 100%;
3141
3141
  padding: 8px 12px;
3142
3142
  border: none;
@@ -3175,7 +3175,7 @@ cursor: pointer;
3175
3175
  width: 100%;
3176
3176
  height: 100%;
3177
3177
  object-fit: cover;
3178
- `,T0=l(nd)`
3178
+ `,T0=l(sd)`
3179
3179
  border-top: 1px solid var(--color-border);
3180
3180
  color: var(--color-primary);
3181
3181
  font-weight: 400;
@@ -3193,7 +3193,7 @@ cursor: pointer;
3193
3193
  align-items: center;
3194
3194
  justify-content: center;
3195
3195
  color: var(--color-primary);
3196
- `,Gs=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[s,a]=i.useState(""),[h,f]=i.useState(""),[c,u]=i.useState(),[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(t),S=i.useRef(null),C=i.useRef(null),{toast:z}=Je(),{createWorkspace:w}=Wt(),{organizationMemberships:y}=Ot(),g=(I=y==null?void 0:y.find(O=>O.organization.id===k))==null?void 0:I.organization,_=O=>{if(O.target.files&&O.target.files[0]){const N=O.target.files[0];if(N.size>2*1024*1024){z("File size cannot exceed 2MB","error");return}if(!N.type.startsWith("image/")){z("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),u(N),p(URL.createObjectURL(N))}},E=()=>{var O;(O=S.current)==null||O.click()},j=O=>O.split(" ").map(N=>N[0]).join("").toUpperCase().slice(0,2)||"W",T=O=>O.trim().replace(/[<>\"'&]/g,""),R=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),M=async()=>{const O=T(s),N=T(h);if(!O||!k){z("Please enter a workspace name","error");return}if(!R(O)){z("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(N.length>500){z("Description must be less than 500 characters","error");return}x(!0);try{const D=await w(k,O,c,N);r==null||r(D)}catch(D){const L=D.message||"Failed to create workspace. Please try again.";z(L,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]),i.useEffect(()=>{const O=N=>{C.current&&!C.current.contains(N.target)&&b(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(he,{children:e.jsxs(u0,{children:[e.jsxs(p0,{children:[e.jsxs(od,{hasImage:!!d,onClick:E,children:[d?e.jsx(f0,{src:d,alt:"Workspace logo"}):e.jsx(g0,{children:j(s||"W")}),e.jsx(z0,{children:e.jsx(E0,{children:"Upload Logo"})})]}),e.jsx($0,{type:"file",ref:S,onChange:_,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(m0,{children:"Create new workspace"}),e.jsx(x0,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(h0,{children:[e.jsxs(v0,{children:[e.jsx(b0,{children:"Choose your workspace name"}),e.jsx(y0,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(w0,{children:[e.jsxs(Jn,{children:[e.jsx(es,{children:"Organization"}),e.jsxs(P0,{ref:C,children:[e.jsxs(I0,{type:"button",onClick:()=>b(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($i,{children:g!=null&&g.image_url?e.jsx(zi,{src:g.image_url,alt:g.name}):j((g==null?void 0:g.name)||"O").charAt(0)}),e.jsx("span",{children:(g==null?void 0:g.name)||"Select organization"})]}),e.jsx(Ut,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(R0,{children:[y==null?void 0:y.map(O=>e.jsxs(nd,{onClick:()=>{$(O.organization.id),b(!1)},children:[e.jsx($i,{children:O.organization.image_url?e.jsx(zi,{src:O.organization.image_url,alt:O.organization.name}):j(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(T0,{onClick:()=>{b(!1),n==null||n()},children:[e.jsx(M0,{children:e.jsx(it,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Workspace name"}),e.jsx(j0,{type:"text",value:s,onChange:O=>a(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Description (optional)"}),e.jsx(k0,{value:h,onChange:O=>f(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(_0,{children:[o?e.jsxs(C0,{onClick:o,disabled:m,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(S0,{onClick:M,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},sd=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[h,f]=i.useState(n),{refetch:c,organizationMemberships:u}=Ot(),d=()=>{o==null||o(),r==null||r()},p=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(u&&u.length>0){const x=u[u.length-1];f(x.organization.id)}a(!1)},500)};return e.jsx(he,{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:s?e.jsx(xn,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Gs,{organizationId:h||n,onSuccess:d,onCancel:r,onCreateOrganization:p})})})})})})},O0=l.div`
3196
+ `,Gs=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[s,a]=i.useState(""),[h,f]=i.useState(""),[c,u]=i.useState(),[d,p]=i.useState(null),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(t),S=i.useRef(null),C=i.useRef(null),{toast:z}=Je(),{createWorkspace:w}=Wt(),{organizationMemberships:y}=Ot(),g=(I=y==null?void 0:y.find(O=>O.organization.id===k))==null?void 0:I.organization,_=O=>{if(O.target.files&&O.target.files[0]){const N=O.target.files[0];if(N.size>2*1024*1024){z("File size cannot exceed 2MB","error");return}if(!N.type.startsWith("image/")){z("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),u(N),p(URL.createObjectURL(N))}},E=()=>{var O;(O=S.current)==null||O.click()},j=O=>O.split(" ").map(N=>N[0]).join("").toUpperCase().slice(0,2)||"W",T=O=>O.trim().replace(/[<>\"'&]/g,""),R=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),M=async()=>{const O=T(s),N=T(h);if(!O||!k){z("Please enter a workspace name","error");return}if(!R(O)){z("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(N.length>500){z("Description must be less than 500 characters","error");return}x(!0);try{const D=await w(k,O,c,N);r==null||r(D)}catch(D){const L=D.message||"Failed to create workspace. Please try again.";z(L,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]),i.useEffect(()=>{const O=N=>{C.current&&!C.current.contains(N.target)&&b(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(fe,{children:e.jsxs(u0,{children:[e.jsxs(p0,{children:[e.jsxs(nd,{hasImage:!!d,onClick:E,children:[d?e.jsx(f0,{src:d,alt:"Workspace logo"}):e.jsx(g0,{children:j(s||"W")}),e.jsx(z0,{children:e.jsx(E0,{children:"Upload Logo"})})]}),e.jsx($0,{type:"file",ref:S,onChange:_,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(m0,{children:"Create new workspace"}),e.jsx(x0,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(h0,{children:[e.jsxs(v0,{children:[e.jsx(b0,{children:"Choose your workspace name"}),e.jsx(y0,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(w0,{children:[e.jsxs(Jn,{children:[e.jsx(es,{children:"Organization"}),e.jsxs(P0,{ref:C,children:[e.jsxs(I0,{type:"button",onClick:()=>b(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($i,{children:g!=null&&g.image_url?e.jsx(zi,{src:g.image_url,alt:g.name}):j((g==null?void 0:g.name)||"O").charAt(0)}),e.jsx("span",{children:(g==null?void 0:g.name)||"Select organization"})]}),e.jsx(Ut,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(R0,{children:[y==null?void 0:y.map(O=>e.jsxs(sd,{onClick:()=>{$(O.organization.id),b(!1)},children:[e.jsx($i,{children:O.organization.image_url?e.jsx(zi,{src:O.organization.image_url,alt:O.organization.name}):j(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(T0,{onClick:()=>{b(!1),n==null||n()},children:[e.jsx(M0,{children:e.jsx(it,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Workspace name"}),e.jsx(j0,{type:"text",value:s,onChange:O=>a(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Jn,{children:[e.jsx(es,{children:"Description (optional)"}),e.jsx(k0,{value:h,onChange:O=>f(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(_0,{children:[o?e.jsxs(C0,{onClick:o,disabled:m,children:[e.jsx(ro,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(S0,{onClick:M,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},ad=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[h,f]=i.useState(n),{refetch:c,organizationMemberships:u}=Ot(),d=()=>{o==null||o(),r==null||r()},p=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(u&&u.length>0){const x=u[u.length-1];f(x.organization.id)}a(!1)},500)};return e.jsx(fe,{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:s?e.jsx(xn,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Gs,{organizationId:h||n,onSuccess:d,onCancel:r,onCreateOrganization:p})})})})})})},O0=l.div`
3197
3197
  position: fixed;
3198
3198
  width: 360px;
3199
3199
  max-width: calc(100vw - 48px);
@@ -3242,7 +3242,7 @@ cursor: pointer;
3242
3242
  color: var(--color-foreground);
3243
3243
  background: var(--color-input-background);
3244
3244
  }
3245
- `,B0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(""),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name}));i.useEffect(()=>{x(!0);const z=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const _=s.current;if(_){const E=_.getBoundingClientRect(),j=360,T=250,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),b({top:M,left:I})}},10),w=_=>{a.current&&!a.current.contains(_.target)&&(t==null||t())},y=_=>{_.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(z),clearTimeout(g),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,s]);const S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=h.trim().toLowerCase();if(!(!z||!c)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}p(!0);try{await n(z,c.id),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{p(!1)}}};return m?e.jsxs(O0,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(A0,{children:[e.jsx(L0,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(F0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(D0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:h,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:c==null?void 0:c.id,onChange:z=>u(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(N0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},U0=l.div`
3245
+ `,B0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[h,f]=i.useState(""),[c,u]=i.useState(null),[d,p]=i.useState(!1),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=o.map(z=>({value:z.id,label:z.name}));i.useEffect(()=>{x(!0);const z=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const _=s.current;if(_){const E=_.getBoundingClientRect(),j=360,T=250,R=8;let M=0,I=0;const O=window.innerHeight-E.bottom,N=E.top;O>=T+R?(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):N>=T+R?(M=E.top-T-R,I=E.right-j,I<R&&(I=E.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(M=E.bottom+R,I=E.right-j,I<R&&(I=E.left)),b({top:M,left:I})}},10),w=_=>{a.current&&!a.current.contains(_.target)&&(t==null||t())},y=_=>{_.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(z),clearTimeout(g),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",y)}},[t,s]);const S=z=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(z),C=async()=>{const z=h.trim().toLowerCase();if(!(!z||!c)){if(!S(z)){k("Please enter a valid email address","error");return}if(z.length>320){k("Email address is too long","error");return}p(!0);try{await n(z,c.id),r==null||r()}catch(w){const y=w.message||"Failed to send invitation. Please try again.";k(y,"error")}finally{p(!1)}}};return m?e.jsxs(O0,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(A0,{children:[e.jsx(L0,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(F0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(lt,{size:16})})]}),e.jsx(D0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(se,{type:"email",placeholder:"colleague@company.com",value:h,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Us,{options:$,value:c==null?void 0:c.id,onChange:z=>u(o.find(w=>w.id===z)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(N0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!h||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},U0=l.div`
3246
3246
  position: fixed;
3247
3247
  width: 360px;
3248
3248
  max-width: calc(100vw - 48px);
@@ -3291,7 +3291,7 @@ cursor: pointer;
3291
3291
  color: var(--color-foreground);
3292
3292
  background: var(--color-input-background);
3293
3293
  }
3294
- `,Ei=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var z;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[u,d]=i.useState(!1),{deployment:p}=ye(),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=!!o,S=(((z=p==null?void 0:p.b2b_settings)==null?void 0:z.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),T=360,R=250,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),b({top:I,left:O})}},10),y=E=>{s.current&&!s.current.contains(E.target)&&(t==null||t())},g=E=>{E.key==="Escape"&&(t==null||t())},_=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",g)},100);return()=>{clearTimeout(w),clearTimeout(_),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]);const C=async()=>{if(a.trim()){d(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(w)}catch(w){const y=w.message||"Failed to save role. Please try again.";k(y,"error")}finally{d(!1)}}};return m?e.jsxs(U0,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(W0,{children:[e.jsx(V0,{children:$?"Edit Role":"Add Role"}),e.jsx(q0,{onClick:t,children:e.jsx(lt,{size:16})})]}),e.jsx(G0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(H0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a.trim()||u,style:{width:"auto"},children:u?"Saving...":$?"Update":"Create"})]})]}):null},Y0=l.div`
3294
+ `,Ei=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var z;const s=i.useRef(null),[a,h]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[u,d]=i.useState(!1),{deployment:p}=we(),[m,x]=i.useState(!1),[v,b]=i.useState({top:0,left:0}),{toast:k}=Je(),$=!!o,S=(((z=p==null?void 0:p.b2b_settings)==null?void 0:z.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),T=360,R=250,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),b({top:I,left:O})}},10),y=E=>{s.current&&!s.current.contains(E.target)&&(t==null||t())},g=E=>{E.key==="Escape"&&(t==null||t())},_=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",g)},100);return()=>{clearTimeout(w),clearTimeout(_),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t,n]);const C=async()=>{if(a.trim()){d(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(w)}catch(w){const y=w.message||"Failed to save role. Please try again.";k(y,"error")}finally{d(!1)}}};return m?e.jsxs(U0,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(W0,{children:[e.jsx(V0,{children:$?"Edit Role":"Add Role"}),e.jsx(q0,{onClick:t,children:e.jsx(lt,{size:16})})]}),e.jsx(G0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(se,{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(Wl,{options:S,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(H0,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(J,{onClick:C,disabled:!a.trim()||u,style:{width:"auto"},children:u?"Saving...":$?"Update":"Create"})]})]}):null},Y0=l.div`
3295
3295
  * {
3296
3296
  box-sizing: border-box;
3297
3297
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -3405,7 +3405,7 @@ cursor: pointer;
3405
3405
  font-weight: 400;
3406
3406
  font-size: 14px;
3407
3407
  overflow: hidden;
3408
- `,ad=l.button`
3408
+ `,id=l.button`
3409
3409
  background: none;
3410
3410
  border: 1px solid var(--color-border);
3411
3411
  padding: 3px;
@@ -3427,11 +3427,11 @@ cursor: pointer;
3427
3427
  opacity: 0.5;
3428
3428
  cursor: not-allowed;
3429
3429
  }
3430
- `,J0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:h}=Vt(),{toast:f}=Je(),[c,u]=i.useState(!0),[d,p]=i.useState(!0),[m,x]=i.useState(""),[v,b]=i.useState([]),[k,$]=i.useState([]),[S,C]=i.useState(!1),z=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{u(!0),p(!0);try{const[j,T]=await Promise.all([o(),n()]);$(j),b(T)}catch{}finally{u(!1),p(!1)}})()},[t==null?void 0:t.id]);const w=async E=>{try{await a(E.id);const j=await n();b(j)}catch{}},y=async E=>{try{await h(E.id);const j=await n();b(j),f("Invitation resent successfully","info")}catch{}},g=async()=>{C(!1);const E=await n();b(E),f("Invitation sent successfully","info")},_=i.useMemo(()=>m?v.filter(E=>(E.email||"").toLowerCase().includes(m.toLowerCase())):v,[v,m]);return r||c||d?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{value:m,onChange:x,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(J,{ref:z,onClick:()=>C(!S),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),S&&e.jsx(B0,{onClose:()=>C(!1),onSuccess:g,roles:k,createInvitation:s,triggerRef:z})]})]}),e.jsx("div",{children:_.length===0?e.jsx(xt,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:_.map(E=>{var j,T;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:E.email}),e.jsx(Ue,{children:((j=E.initial_workspace_role)==null?void 0:j.name)||((T=E.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(Ue,{children:new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(ad,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>y(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>w(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},E.id)})})]})})]})},ev=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:h}=Vt(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),{data:p=[],isLoading:m,mutate:x}=Ze(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:v=[],isLoading:b}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),k=v,$=i.useMemo(()=>u?p.filter(y=>{var R;const g=y.public_user_data;if(!g)return!1;const _=g.first_name||"",E=g.last_name||"",j=((R=g.primary_email_address)==null?void 0:R.email)||"";return`${_} ${E}`.trim().toLowerCase().includes(u.toLowerCase())||j.toLowerCase().includes(u.toLowerCase())}):p,[p,u]),S=async y=>{try{await s(y),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},C=async(y,g,_)=>{try{_?(await h(y,g),c("Role removed successfully","info")):(await a(y,g),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},z=(y="",g="")=>`${y[0]||""}${g[0]||""}`.toUpperCase(),w=(y,g)=>{var _;return((_=y.roles)==null?void 0:_.some(E=>E.id===g))||!1};return r||m||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Role"})]})}),e.jsx(St,{children:$.map(y=>{var j,T;const g=y.public_user_data,_=y.roles||[],E=(g==null?void 0:g.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ye,{children:[e.jsx(ed,{children:e.jsxs("div",{children:[e.jsx(X0,{children:g&&g.profile_picture_url?e.jsx("img",{src:g.profile_picture_url,alt:`${g.first_name||""} ${g.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):z(g==null?void 0:g.first_name,g==null?void 0:g.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var M;if(!g)return"Unknown User";const R=`${g.first_name||""} ${g.last_name||""}`.trim();return R||((M=g.primary_email_address)==null?void 0:M.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=g==null?void 0:g.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:_.length>0?_[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[k.map(R=>{const M=w(y,R.id);return e.jsx(Be,{onClick:()=>C(y.id,R.id,M),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),M&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>S(y.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},y.id)})})]})]})},tv=()=>{var q,Y;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Vt(),{deleteWorkspace:n}=Wt(),{deployment:s}=ye(),{toast:a}=Je(),[h,f]=i.useState((t==null?void 0:t.name)||""),[c,u]=i.useState((t==null?void 0:t.description)||""),[d,p]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,b]=i.useState((t==null?void 0:t.image_url)||null),[k,$]=i.useState(!1),[S,C]=i.useState(!1),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var B;t&&(f(t.name||""),u(t.description||""),b(t.image_url||null),p({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((B=t.whitelisted_ips)==null?void 0:B.join(`
3430
+ `,J0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:h}=Vt(),{toast:f}=Je(),[c,u]=i.useState(!0),[d,p]=i.useState(!0),[m,x]=i.useState(""),[v,b]=i.useState([]),[k,$]=i.useState([]),[S,C]=i.useState(!1),z=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{u(!0),p(!0);try{const[j,T]=await Promise.all([o(),n()]);$(j),b(T)}catch{}finally{u(!1),p(!1)}})()},[t==null?void 0:t.id]);const w=async E=>{try{await a(E.id);const j=await n();b(j)}catch{}},y=async E=>{try{await h(E.id);const j=await n();b(j),f("Invitation resent successfully","info")}catch{}},g=async()=>{C(!1);const E=await n();b(E),f("Invitation sent successfully","info")},_=i.useMemo(()=>m?v.filter(E=>(E.email||"").toLowerCase().includes(m.toLowerCase())):v,[v,m]);return r||c||d?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{value:m,onChange:x,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(J,{ref:z,onClick:()=>C(!S),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),S&&e.jsx(B0,{onClose:()=>C(!1),onSuccess:g,roles:k,createInvitation:s,triggerRef:z})]})]}),e.jsx("div",{children:_.length===0?e.jsx(xt,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email"}),e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Invited"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:_.map(E=>{var j,T;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:E.email}),e.jsx(Ue,{children:((j=E.initial_workspace_role)==null?void 0:j.name)||((T=E.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(Ue,{children:new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsx(id,{children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>y(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Be,{$destructive:!0,onClick:()=>w(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},E.id)})})]})})]})},ev=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:h}=Vt(),{session:f}=Qe(),{toast:c}=Je(),[u,d]=i.useState(""),{data:p=[],isLoading:m,mutate:x}=Ze(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:v=[],isLoading:b}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),k=v,$=i.useMemo(()=>u?p.filter(y=>{var R;const g=y.public_user_data;if(!g)return!1;const _=g.first_name||"",E=g.last_name||"",j=((R=g.primary_email_address)==null?void 0:R.email)||"";return`${_} ${E}`.trim().toLowerCase().includes(u.toLowerCase())||j.toLowerCase().includes(u.toLowerCase())}):p,[p,u]),S=async y=>{try{await s(y),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},C=async(y,g,_)=>{try{_?(await h(y,g),c("Role removed successfully","info")):(await a(y,g),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},z=(y="",g="")=>`${y[0]||""}${g[0]||""}`.toUpperCase(),w=(y,g)=>{var _;return((_=y.roles)==null?void 0:_.some(E=>E.id===g))||!1};return r||m||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{children:e.jsx(At,{value:u,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(xt,{title:u?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Member"}),e.jsx(Ee,{children:"Joined"}),e.jsx(Ee,{children:"Role"})]})}),e.jsx(St,{children:$.map(y=>{var j,T;const g=y.public_user_data,_=y.roles||[],E=(g==null?void 0:g.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ye,{children:[e.jsx(td,{children:e.jsxs("div",{children:[e.jsx(X0,{children:g&&g.profile_picture_url?e.jsx("img",{src:g.profile_picture_url,alt:`${g.first_name||""} ${g.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):z(g==null?void 0:g.first_name,g==null?void 0:g.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var M;if(!g)return"Unknown User";const R=`${g.first_name||""} ${g.last_name||""}`.trim();return R||((M=g.primary_email_address)==null?void 0:M.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=g==null?void 0:g.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Ue,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx($t,{children:e.jsxs(ft,{children:[e.jsx(mt,{children:e.jsxs(J,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:_.length>0?_[0].name:"No role"}),e.jsx(Ut,{size:14})]})}),e.jsxs(gt,{children:[k.map(R=>{const M=w(y,R.id);return e.jsx(Be,{onClick:()=>C(y.id,R.id,M),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),M&&e.jsx(tt,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(mn,{}),e.jsx(Be,{$destructive:!0,onClick:()=>S(y.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(fn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},y.id)})})]})]})},tv=()=>{var q,Y;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Vt(),{deleteWorkspace:n}=Wt(),{deployment:s}=we(),{toast:a}=Je(),[h,f]=i.useState((t==null?void 0:t.name)||""),[c,u]=i.useState((t==null?void 0:t.description)||""),[d,p]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,b]=i.useState((t==null?void 0:t.image_url)||null),[k,$]=i.useState(!1),[S,C]=i.useState(!1),[z,w]=i.useState(""),[y,g]=i.useState(!1),[_,E]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var B;t&&(f(t.name||""),u(t.description||""),b(t.image_url||null),p({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((B=t.whitelisted_ips)==null?void 0:B.join(`
3431
3431
  `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const R=B=>{var H;if((H=B.target.files)!=null&&H[0]){const G=B.target.files[0];x(G),b(URL.createObjectURL(G)),setTimeout(()=>I(),100)}},M=()=>{j.current&&j.current.click()},I=i.useCallback(async()=>{if(!(!t||S))try{C(!0);const B={};m&&(B.image=m,x(null)),h!==t.name&&(B.name=h),c!==t.description&&(B.description=c),d.mfa_required!==t.enforce_2fa&&(B.enforce_2fa=d.mfa_required),d.ip_restrictions!==t.enable_ip_restriction&&(B.enable_ip_restriction=d.ip_restrictions);const H=(t.whitelisted_ips||[]).join(`
3432
3432
  `);d.allowed_ips!==H&&(B.whitelisted_ips=d.allowed_ips.split(`
3433
- `).map(G=>G.trim()).filter(G=>G!=="")),Object.keys(B).length>0&&(await o(B),$(!0),setTimeout(()=>$(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,h,c,m,d,S]),O=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),N=B=>{f(B.target.value),O()},D=B=>{u(B.target.value),O()},L=()=>{T.current&&clearTimeout(T.current),I()},P=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||z!==t.name))try{g(!0),await n(t),a("Workspace deleted successfully","info")}catch(B){a(B.message||"Failed to delete workspace","error")}finally{g(!1),w(""),E(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:B=>{B.currentTarget.style.borderColor="var(--color-primary)",B.currentTarget.style.transform="scale(1.02)"},onMouseLeave:B=>{B.currentTarget.style.borderColor="var(--color-border)",B.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:R})]})}),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:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var B;return(B=j.current)==null?void 0:B.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),v?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{b(null),x(null),j.current&&(j.current.value=""),setTimeout(()=>I(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(fn,{size:14}),"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:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"name",children:"Workspace Name"}),e.jsx(se,{id:"name",type:"text",value:h,onChange:N,onBlur:L,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:c,onChange:D,onBlur:P,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((q=s==null?void 0:s.b2b_settings)==null?void 0:q.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:d.mfa_required,onChange:()=>{p(B=>({...B,mfa_required:!B.mfa_required})),setTimeout(()=>I(),100)}})]}),((Y=s==null?void 0:s.b2b_settings)==null?void 0:Y.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:d.ip_restrictions,onChange:()=>{p(B=>({...B,ip_restrictions:!B.ip_restrictions})),setTimeout(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),d.ip_restrictions&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:d.allowed_ips,onChange:B=>p(H=>({...H,allowed_ips:B.target.value})),onBlur:I,placeholder:`192.168.1.1
3434
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),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:_?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{_?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:_?"Cancel":"Delete"})]}),_&&e.jsxs("div",{children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(se,{id:"confirm_workspace_name",type:"text",value:z,onChange:B=>w(B.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(J,{onClick:A,disabled:z!==(t==null?void 0:t.name)||y,style:{background:z===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:z===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:z===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),k&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3433
+ `).map(G=>G.trim()).filter(G=>G!=="")),Object.keys(B).length>0&&(await o(B),$(!0),setTimeout(()=>$(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,h,c,m,d,S]),O=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),N=B=>{f(B.target.value),O()},D=B=>{u(B.target.value),O()},L=()=>{T.current&&clearTimeout(T.current),I()},P=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||z!==t.name))try{g(!0),await n(t),a("Workspace deleted successfully","info")}catch(B){a(B.message||"Failed to delete workspace","error")}finally{g(!1),w(""),E(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:B=>{B.currentTarget.style.borderColor="var(--color-primary)",B.currentTarget.style.transform="scale(1.02)"},onMouseLeave:B=>{B.currentTarget.style.borderColor="var(--color-border)",B.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Jr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:R})]})}),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:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var B;return(B=j.current)==null?void 0:B.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jr,{size:14}),v?"Change":"Upload"]}),e.jsxs(J,{onClick:()=>{b(null),x(null),j.current&&(j.current.value=""),setTimeout(()=>I(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(fn,{size:14}),"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:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"name",children:"Workspace Name"}),e.jsx(se,{id:"name",type:"text",value:h,onChange:N,onBlur:L,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",as:"textarea",value:c,onChange:D,onBlur:P,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((q=s==null?void 0:s.b2b_settings)==null?void 0:q.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(mr,{checked:d.mfa_required,onChange:()=>{p(B=>({...B,mfa_required:!B.mfa_required})),setTimeout(()=>I(),100)}})]}),((Y=s==null?void 0:s.b2b_settings)==null?void 0:Y.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(mr,{checked:d.ip_restrictions,onChange:()=>{p(B=>({...B,ip_restrictions:!B.ip_restrictions})),setTimeout(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),d.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(se,{id:"allowed_ips",as:"textarea",value:d.allowed_ips,onChange:B=>p(H=>({...H,allowed_ips:B.target.value})),onBlur:I,placeholder:`192.168.1.1
3434
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),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:_?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(J,{onClick:()=>{_?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:_?"Cancel":"Delete"})]}),_&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(se,{id:"confirm_workspace_name",type:"text",value:z,onChange:B=>w(B.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(J,{onClick:A,disabled:z!==(t==null?void 0:t.name)||y,style:{background:z===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:z===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:z===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),k&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3435
3435
  @keyframes slideUp {
3436
3436
  from {
3437
3437
  opacity: 0;
@@ -3442,7 +3442,7 @@ cursor: pointer;
3442
3442
  transform: translateX(-50%) translateY(0);
3443
3443
  }
3444
3444
  }
3445
- `})]})},rv=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Vt(),{toast:a}=Je(),{deployment:h}=ye(),[f,c]=i.useState(""),[u,d]=i.useState({isOpen:!1}),[p,m]=i.useState(null),[x,v]=i.useState(null),b=i.useRef(null),k=i.useRef(new Map),{data:$=[],isLoading:S,mutate:C}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),z=i.useMemo(()=>f?$.filter(_=>_.name.toLowerCase().includes(f.toLowerCase())):$,[$,f]),w=async _=>{try{await n(_.name,_.permissions||[]),a("Role created successfully","info"),d({isOpen:!1}),C()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async _=>{try{await s(_),a("Role deleted successfully","info"),v(null),C()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((g=h==null?void 0:h.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(J,{ref:b,onClick:()=>d({isOpen:!0,triggerElement:b.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),u.isOpen&&!u.role&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:w})]})]}),z.length===0?e.jsx(xt,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(_=>{var E;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:_.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:_.permissions&&_.permissions.length>0?_.permissions.join(", "):""}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:p===_.id,openChange:j=>m(j?_.id:null),children:[e.jsx(mt,{children:e.jsx(ad,{ref:j=>{j&&k.current.set(_.id,j)},disabled:!_.workspace_id,"data-role-dropdown-trigger":_.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{m(null);const j=k.current.get(_.id);d({isOpen:!0,role:_,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{m(null),v(_.id)},children:"Remove Role"})]})]}),x===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(_),onCancel:()=>v(null)}),u.isOpen&&((E=u.role)==null?void 0:E.id)===_.id&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>{d({isOpen:!1}),m(null)},onSuccess:w})]})})]},_.id)})})]})})]})},id=()=>{const{activeWorkspace:t,loading:r}=Vt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((u,d="info")=>{a(u),f(d),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(Pi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Y0,{children:e.jsxs(Pi,{children:[e.jsx(Z0,{children:e.jsxs(K0,{children:[e.jsx(So,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs($o,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(So,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs($o,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(So,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs($o,{children:[e.jsx(Fs,{size:16}),"Invitations"]})}),e.jsx(So,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs($o,{children:[e.jsx(pt,{size:16}),"Roles"]})})]})}),e.jsxs(Q0,{children:[o==="general"&&e.jsx(tv,{}),o==="members"&&e.jsx(ev,{}),o==="invitations"&&e.jsx(J0,{}),o==="roles"&&e.jsx(rv,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},cd=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(id,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),ld=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,h]=i.useState();return i.useEffect(()=>{if(!r||!t.current){h(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,p=u-c.left,m=c.right,x=d-c.bottom,v=c.top;let b={};p>=o?b.left=c.left:m>=o?b.left=c.right-o:b.left=Math.max(s,Math.min(u-o-s,c.left)),x>=150?(b.top=c.bottom+s,b.maxHeight=Math.min(n,x-s*2)):v>=150?(b.bottom=d-c.top+s,b.maxHeight=Math.min(n,v-s*2)):(b.top=c.bottom+s,b.maxHeight=Math.max(100,x-s*2)),h(b)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),a},dd=["organization:admin"],ud=["organization:admin","organization:manage"],pd=["workspace:admin"],hd=["workspace:admin","workspace:manage"];function qs(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function fd(t){return qs(t,ud)}function ov(t){return qs(t,dd)}function Ys(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Es(t){return Ys(t,hd)}function nv(t){return Ys(t,pd)}const Ii=l.div`
3445
+ `})]})},rv=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Vt(),{toast:a}=Je(),{deployment:h}=we(),[f,c]=i.useState(""),[u,d]=i.useState({isOpen:!1}),[p,m]=i.useState(null),[x,v]=i.useState(null),b=i.useRef(null),k=i.useRef(new Map),{data:$=[],isLoading:S,mutate:C}=Ze(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),z=i.useMemo(()=>f?$.filter(_=>_.name.toLowerCase().includes(f.toLowerCase())):$,[$,f]),w=async _=>{try{await n(_.name,_.permissions||[]),a("Role created successfully","info"),d({isOpen:!1}),C()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async _=>{try{await s(_),a("Role deleted successfully","info"),v(null),C()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Hs,{children:[e.jsx(At,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((g=h==null?void 0:h.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(J,{ref:b,onClick:()=>d({isOpen:!0,triggerElement:b.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),u.isOpen&&!u.role&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>d({isOpen:!1}),onSuccess:w})]})]}),z.length===0?e.jsx(xt,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Role"}),e.jsx(Ee,{children:"Permissions"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(_=>{var E;return e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:_.name})}),e.jsx(Ue,{style:{color:"var(--color-secondary-text)"},children:_.permissions&&_.permissions.length>0?_.permissions.join(", "):""}),e.jsx($t,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ft,{open:p===_.id,openChange:j=>m(j?_.id:null),children:[e.jsx(mt,{children:e.jsx(id,{ref:j=>{j&&k.current.set(_.id,j)},disabled:!_.workspace_id,"data-role-dropdown-trigger":_.id,children:"•••"})}),e.jsxs(gt,{children:[e.jsx(Be,{onClick:()=>{m(null);const j=k.current.get(_.id);d({isOpen:!0,role:_,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Be,{$destructive:!0,onClick:()=>{m(null),v(_.id)},children:"Remove Role"})]})]}),x===_.id&&e.jsx(Mr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(_),onCancel:()=>v(null)}),u.isOpen&&((E=u.role)==null?void 0:E.id)===_.id&&e.jsx(Ei,{role:u.role,triggerRef:{current:u.triggerElement||null},onClose:()=>{d({isOpen:!1}),m(null)},onSuccess:w})]})})]},_.id)})})]})})]})},cd=()=>{const{activeWorkspace:t,loading:r}=Vt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((u,d="info")=>{a(u),f(d),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(Pi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(Ws.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Y0,{children:e.jsxs(Pi,{children:[e.jsx(Z0,{children:e.jsxs(K0,{children:[e.jsx(So,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs($o,{children:[e.jsx(hr,{size:16}),"General"]})}),e.jsx(So,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs($o,{children:[e.jsx(Qo,{size:16}),"Members"]})}),e.jsx(So,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs($o,{children:[e.jsx(Fs,{size:16}),"Invitations"]})}),e.jsx(So,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs($o,{children:[e.jsx(pt,{size:16}),"Roles"]})})]})}),e.jsxs(Q0,{children:[o==="general"&&e.jsx(tv,{}),o==="members"&&e.jsx(ev,{}),o==="invitations"&&e.jsx(J0,{}),o==="roles"&&e.jsx(rv,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},ld=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(cd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),dd=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,h]=i.useState();return i.useEffect(()=>{if(!r||!t.current){h(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),u=window.innerWidth,d=window.innerHeight,p=u-c.left,m=c.right,x=d-c.bottom,v=c.top;let b={};p>=o?b.left=c.left:m>=o?b.left=c.right-o:b.left=Math.max(s,Math.min(u-o-s,c.left)),x>=150?(b.top=c.bottom+s,b.maxHeight=Math.min(n,x-s*2)):v>=150?(b.bottom=d-c.top+s,b.maxHeight=Math.min(n,v-s*2)):(b.top=c.bottom+s,b.maxHeight=Math.max(100,x-s*2)),h(b)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),a},ud=["organization:admin"],pd=["organization:admin","organization:manage"],hd=["workspace:admin"],fd=["workspace:admin","workspace:manage"];function qs(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function gd(t){return qs(t,pd)}function ov(t){return qs(t,ud)}function Ys(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Es(t){return Ys(t,fd)}function nv(t){return Ys(t,hd)}const Ii=l.div`
3446
3446
  position: relative;
3447
3447
  display: inline-block;
3448
3448
  width: 100%;
@@ -3793,15 +3793,15 @@ cursor: pointer;
3793
3793
  height: 16px;
3794
3794
  background: var(--color-border);
3795
3795
  border-radius: 2px;
3796
- `,gd=({showPersonal:t=!0})=>{var de,U,le,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,h]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),u=ld({triggerRef:f,isOpen:r,minWidth:300}),d=Zr(!1),p=Zr(!1),m=Zr(!1),x=Zr(!1),[v,b]=i.useState(null),[k,$]=i.useState(!1),[S,C]=i.useState(null),{organizationMemberships:z,loading:w,refetch:y}=Ot(),{activeOrganization:g,activeMembership:_,leave:E}=st(),{activeWorkspace:j,activeMembership:T,leave:R}=Vt(),{workspaces:M,loading:I}=Wt(),{session:O,loading:N,switchOrganization:D,switchWorkspace:L}=Qe(),{deployment:P}=ye(),{toast:A}=Je(),q=P==null?void 0:P.b2b_settings.organizations_enabled,Y=P==null?void 0:P.b2b_settings.workspaces_enabled,B=P==null?void 0:P.b2b_settings.allow_users_to_create_orgs,H=!((de=O==null?void 0:O.active_signin)!=null&&de.active_organization_membership_id),G=i.useMemo(()=>{var re,fe;if(H)return{name:"Personal account",image_url:(fe=(re=O==null?void 0:O.active_signin)==null?void 0:re.user)==null?void 0:fe.profile_picture_url,isPersonal:!0};let Z=(g==null?void 0:g.name)||"";return Y&&j&&(Z=`${g==null?void 0:g.name} / ${j.name}`),{name:Z,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,j,O,Y]);i.useEffect(()=>{if(!r)return;let Z=null;const re=setTimeout(()=>{const fe=ue=>{var V,F;const ee=ue.target;(V=f.current)!=null&&V.contains(ee)||(F=c.current)!=null&&F.contains(ee)||(o(!1),C(null))};document.addEventListener("mousedown",fe),Z=()=>{document.removeEventListener("mousedown",fe)}},50);return()=>{clearTimeout(re),Z==null||Z()}},[r]),i.useEffect(()=>{if(S){const Z=setTimeout(()=>{C(null)},5e3);return()=>clearTimeout(Z)}},[S]);const X=()=>{y()};if(!q)return null;const oe=Z=>{s(!0),D(Z).finally(()=>{s(!1)})},te=Z=>{s(!0),L(Z).finally(()=>{s(!1)})},ce=Z=>{const re=new Set(a);re.has(Z)?re.delete(Z):re.add(Z),h(re)},Q=Z=>Z.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),me=!!((U=O==null?void 0:O.active_signin)!=null&&U.active_organization_membership_id);return w||N||!z&&me?e.jsx(he,{children:e.jsx(Ii,{children:e.jsxs(fv,{children:[e.jsxs(Ri,{children:[e.jsx(gv,{}),e.jsx(mv,{})]}),e.jsx(xv,{})]})})}):e.jsx(he,{children:e.jsxs(Ii,{children:[e.jsxs(sv,{ref:f,onClick:()=>{o(!r),r||C(null)},disabled:n,children:[e.jsxs(Ri,{children:[e.jsx(av,{children:G.image_url?e.jsx(iv,{src:G.image_url,alt:G.name}):G.isPersonal?e.jsx(Ko,{size:12}):Q(G.name)}),e.jsx(cv,{children:G.name})]}),e.jsx(Ch,{size:16})]}),typeof window<"u"&&eo.createPortal(e.jsx(he,{children:e.jsx(lv,{ref:c,$isOpen:r,$position:u,children:w||I?e.jsxs(hv,{children:[e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"120px"}),e.jsx(Di,{width:"80px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"100px"})})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"140px"}),e.jsx(Di,{width:"60px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:H,onClick:Z=>{Z.stopPropagation(),H||oe()},disabled:n||H,children:[H&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(dv,{children:(K=(le=O==null?void 0:O.active_signin)==null?void 0:le.user)!=null&&K.profile_picture_url?e.jsx(uv,{src:O.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Ko,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Personal account"})})]}),!H&&e.jsx(zo,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(_r,{})]}),!H&&g&&e.jsxs(Go,{$isActive:!0,onClick:()=>{Y&&ce(g.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(Po,{}),e.jsxs(zt,{children:[Y&&e.jsx(Ut,{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(Ti,{children:g.image_url?e.jsx(Mi,{src:g.image_url,alt:g.name}):Q(g.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[fd(_)&&e.jsx(Ho,{onClick:Z=>{Z.stopPropagation(),p.open()},title:"Manage organization",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async Z=>{Z.stopPropagation(),$(!0),C(null);try{await E(),await y(),setTimeout(()=>{$(!1)},500)}catch(re){C(re instanceof Error?re.message:"Failed to leave organization"),$(!1)}},disabled:k,title:"Leave organization",children:e.jsx(Ft,{size:12})})]})]}),g&&Y&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[M==null?void 0:M.filter(Z=>Z.organization.id===g.id).map(Z=>{const re=(j==null?void 0:j.id)===Z.id;return e.jsxs(Io,{as:re?void 0:"button",$isActive:re,onClick:re?void 0:()=>te(Z.id),...re?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[re&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(Z.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:Z.name})})]}),re?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:fe=>{fe.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async fe=>{fe.stopPropagation();try{R&&await R()}catch(ue){const ee=ue.message||"Failed to leave workspace. Please try again.";A(ee,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),(k||S)&&e.jsxs(e.Fragment,{children:[k&&e.jsxs(Li,{children:[e.jsx(pv,{}),"Leaving organization..."]}),S&&e.jsxs(Li,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),S]})]}),e.jsx(_r,{}),z&&z.length>0&&e.jsx(e.Fragment,{children:z.filter(Z=>Z.organization.id!==(g==null?void 0:g.id)).map(Z=>{const re=Z.organization,fe=(M==null?void 0:M.filter(ee=>ee.organization.id===re.id))||[],ue=a.has(re.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:!1,onClick:()=>{Y?ce(re.id):oe(re.id)},disabled:n,children:[e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:ue?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:re.image_url?e.jsx(Mi,{src:re.image_url,alt:re.name}):Q(re.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:re.name})})]}),e.jsx(zo,{className:"hover-arrow",size:14})]}),Y&&ue&&e.jsxs(e.Fragment,{children:[fe.map(ee=>{const V=(j==null?void 0:j.id)===ee.id;return e.jsxs(Io,{as:V?void 0:"button",$isActive:V,onClick:V?void 0:()=>te(ee.id),...V?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[V&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:ee.image_url?e.jsx("img",{src:ee.image_url,alt:ee.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(ee.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:ee.name})})]}),V?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:F=>{F.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async F=>{F.stopPropagation();try{R&&await R()}catch(ne){const be=ne.message||"Failed to leave workspace. Please try again.";A(be,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:16})]},ee.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(re.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:10})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),e.jsx(_r,{})]},re.id)})}),Y?g&&e.jsx(Oi,{onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})}):B&&e.jsx(Oi,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create organization"})})]})})]})})}),document.body),q&&B&&e.jsx(kx,{isOpen:d.isOpen,onClose:d.close,onCreated:X}),e.jsx(d0,{isOpen:p.isOpen,onClose:p.close}),e.jsx(cd,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(sd,{isOpen:m.isOpen,onClose:()=>{m.close(),b(null)},organizationId:v})]})})};var vv=Object.defineProperty,en=Object.getOwnPropertySymbols,md=Object.prototype.hasOwnProperty,xd=Object.prototype.propertyIsEnumerable,Ni=(t,r,o)=>r in t?vv(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,Ps=(t,r)=>{for(var o in r||(r={}))md.call(r,o)&&Ni(t,o,r[o]);if(en)for(var o of en(r))xd.call(r,o)&&Ni(t,o,r[o]);return t},Is=(t,r)=>{var o={};for(var n in t)md.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&en)for(var n of en(t))r.indexOf(n)<0&&xd.call(t,n)&&(o[n]=t[n]);return o};/**
3796
+ `,md=({showPersonal:t=!0})=>{var de,U,le,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,h]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),u=dd({triggerRef:f,isOpen:r,minWidth:300}),d=Zr(!1),p=Zr(!1),m=Zr(!1),x=Zr(!1),[v,b]=i.useState(null),[k,$]=i.useState(!1),[S,C]=i.useState(null),{organizationMemberships:z,loading:w,refetch:y}=Ot(),{activeOrganization:g,activeMembership:_,leave:E}=st(),{activeWorkspace:j,activeMembership:T,leave:R}=Vt(),{workspaces:M,loading:I}=Wt(),{session:O,loading:N,switchOrganization:D,switchWorkspace:L}=Qe(),{deployment:P}=we(),{toast:A}=Je(),q=P==null?void 0:P.b2b_settings.organizations_enabled,Y=P==null?void 0:P.b2b_settings.workspaces_enabled,B=P==null?void 0:P.b2b_settings.allow_users_to_create_orgs,H=!((de=O==null?void 0:O.active_signin)!=null&&de.active_organization_membership_id),G=i.useMemo(()=>{var re,ge;if(H)return{name:"Personal account",image_url:(ge=(re=O==null?void 0:O.active_signin)==null?void 0:re.user)==null?void 0:ge.profile_picture_url,isPersonal:!0};let Z=(g==null?void 0:g.name)||"";return Y&&j&&(Z=`${g==null?void 0:g.name} / ${j.name}`),{name:Z,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[H,g,j,O,Y]);i.useEffect(()=>{if(!r)return;let Z=null;const re=setTimeout(()=>{const ge=ue=>{var V,F;const ee=ue.target;(V=f.current)!=null&&V.contains(ee)||(F=c.current)!=null&&F.contains(ee)||(o(!1),C(null))};document.addEventListener("mousedown",ge),Z=()=>{document.removeEventListener("mousedown",ge)}},50);return()=>{clearTimeout(re),Z==null||Z()}},[r]),i.useEffect(()=>{if(S){const Z=setTimeout(()=>{C(null)},5e3);return()=>clearTimeout(Z)}},[S]);const X=()=>{y()};if(!q)return null;const oe=Z=>{s(!0),D(Z).finally(()=>{s(!1)})},te=Z=>{s(!0),L(Z).finally(()=>{s(!1)})},ce=Z=>{const re=new Set(a);re.has(Z)?re.delete(Z):re.add(Z),h(re)},Q=Z=>Z.split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),me=!!((U=O==null?void 0:O.active_signin)!=null&&U.active_organization_membership_id);return w||N||!z&&me?e.jsx(fe,{children:e.jsx(Ii,{children:e.jsxs(fv,{children:[e.jsxs(Ri,{children:[e.jsx(gv,{}),e.jsx(mv,{})]}),e.jsx(xv,{})]})})}):e.jsx(fe,{children:e.jsxs(Ii,{children:[e.jsxs(sv,{ref:f,onClick:()=>{o(!r),r||C(null)},disabled:n,children:[e.jsxs(Ri,{children:[e.jsx(av,{children:G.image_url?e.jsx(iv,{src:G.image_url,alt:G.name}):G.isPersonal?e.jsx(Ko,{size:12}):Q(G.name)}),e.jsx(cv,{children:G.name})]}),e.jsx(Sh,{size:16})]}),typeof window<"u"&&eo.createPortal(e.jsx(fe,{children:e.jsx(lv,{ref:c,$isOpen:r,$position:u,children:w||I?e.jsxs(hv,{children:[e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"120px"}),e.jsx(Di,{width:"80px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"100px"})})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsxs(Mo,{children:[e.jsx(Oo,{width:"140px"}),e.jsx(Di,{width:"60px"})]})]}),e.jsx(_r,{}),e.jsxs(Ro,{children:[e.jsx(To,{}),e.jsx(Mo,{children:e.jsx(Oo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:H,onClick:Z=>{Z.stopPropagation(),H||oe()},disabled:n||H,children:[H&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(dv,{children:(K=(le=O==null?void 0:O.active_signin)==null?void 0:le.user)!=null&&K.profile_picture_url?e.jsx(uv,{src:O.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Ko,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Personal account"})})]}),!H&&e.jsx(zo,{className:"hover-arrow",size:14})]}),!H&&g&&e.jsx(_r,{})]}),!H&&g&&e.jsxs(Go,{$isActive:!0,onClick:()=>{Y&&ce(g.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(Po,{}),e.jsxs(zt,{children:[Y&&e.jsx(Ut,{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(Ti,{children:g.image_url?e.jsx(Mi,{src:g.image_url,alt:g.name}):Q(g.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[gd(_)&&e.jsx(Ho,{onClick:Z=>{Z.stopPropagation(),p.open()},title:"Manage organization",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async Z=>{Z.stopPropagation(),$(!0),C(null);try{await E(),await y(),setTimeout(()=>{$(!1)},500)}catch(re){C(re instanceof Error?re.message:"Failed to leave organization"),$(!1)}},disabled:k,title:"Leave organization",children:e.jsx(Ft,{size:12})})]})]}),g&&Y&&a.has(g.id)&&e.jsxs(e.Fragment,{children:[M==null?void 0:M.filter(Z=>Z.organization.id===g.id).map(Z=>{const re=(j==null?void 0:j.id)===Z.id;return e.jsxs(Io,{as:re?void 0:"button",$isActive:re,onClick:re?void 0:()=>te(Z.id),...re?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[re&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(Z.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:Z.name})})]}),re?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:ge=>{ge.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async ge=>{ge.stopPropagation();try{R&&await R()}catch(ue){const ee=ue.message||"Failed to leave workspace. Please try again.";A(ee,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),(k||S)&&e.jsxs(e.Fragment,{children:[k&&e.jsxs(Li,{children:[e.jsx(pv,{}),"Leaving organization..."]}),S&&e.jsxs(Li,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),S]})]}),e.jsx(_r,{}),z&&z.length>0&&e.jsx(e.Fragment,{children:z.filter(Z=>Z.organization.id!==(g==null?void 0:g.id)).map(Z=>{const re=Z.organization,ge=(M==null?void 0:M.filter(ee=>ee.organization.id===re.id))||[],ue=a.has(re.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Go,{as:"button",$isActive:!1,onClick:()=>{Y?ce(re.id):oe(re.id)},disabled:n,children:[e.jsxs(zt,{children:[Y&&e.jsx(Ut,{size:12,style:{marginRight:"4px",transform:ue?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Ti,{children:re.image_url?e.jsx(Mi,{src:re.image_url,alt:re.name}):Q(re.name)}),e.jsx(Et,{children:e.jsx(Pt,{children:re.name})})]}),e.jsx(zo,{className:"hover-arrow",size:14})]}),Y&&ue&&e.jsxs(e.Fragment,{children:[ge.map(ee=>{const V=(j==null?void 0:j.id)===ee.id;return e.jsxs(Io,{as:V?void 0:"button",$isActive:V,onClick:V?void 0:()=>te(ee.id),...V?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[V&&e.jsx(Po,{}),e.jsxs(zt,{children:[e.jsx(Ai,{children:ee.image_url?e.jsx("img",{src:ee.image_url,alt:ee.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(ee.name).charAt(0)}),e.jsx(Et,{children:e.jsx(Pt,{children:ee.name})})]}),V?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Es(T)&&e.jsx(Ho,{onClick:F=>{F.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(hr,{size:12})}),e.jsx(ts,{onClick:async F=>{F.stopPropagation();try{R&&await R()}catch(ne){const be=ne.message||"Failed to leave workspace. Please try again.";A(be,"error")}},title:"Leave workspace",children:e.jsx(Ft,{size:12})})]}):e.jsx(zo,{className:"hover-arrow",size:16})]},ee.id)}),e.jsx(Io,{as:"button",onClick:()=>{b(re.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{style:{width:"14px",height:"14px"},children:e.jsx(it,{size:10})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})})]}),e.jsx(_r,{})]},re.id)})}),Y?g&&e.jsx(Oi,{onClick:()=>{b(g.id),m.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create workspace"})})]})}):B&&e.jsx(Oi,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(zt,{children:[e.jsx(Eo,{children:e.jsx(it,{size:12})}),e.jsx(Et,{children:e.jsx(Pt,{children:"Create organization"})})]})})]})})}),document.body),q&&B&&e.jsx(kx,{isOpen:d.isOpen,onClose:d.close,onCreated:X}),e.jsx(d0,{isOpen:p.isOpen,onClose:p.close}),e.jsx(ld,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(ad,{isOpen:m.isOpen,onClose:()=>{m.close(),b(null)},organizationId:v})]})})};var vv=Object.defineProperty,en=Object.getOwnPropertySymbols,xd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Ni=(t,r,o)=>r in t?vv(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,Ps=(t,r)=>{for(var o in r||(r={}))xd.call(r,o)&&Ni(t,o,r[o]);if(en)for(var o of en(r))vd.call(r,o)&&Ni(t,o,r[o]);return t},Is=(t,r)=>{var o={};for(var n in t)xd.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&en)for(var n of en(t))r.indexOf(n)<0&&vd.call(t,n)&&(o[n]=t[n]);return o};/**
3797
3797
  * @license QR Code generator library (TypeScript)
3798
3798
  * Copyright (c) Project Nayuki.
3799
3799
  * SPDX-License-Identifier: MIT
3800
- */var xr;(t=>{const r=class ke{constructor(c,u,d,p){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],c<ke.MIN_VERSION||c>ke.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*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(d);if(this.drawCodewords(x),p==-1){let v=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const k=this.getPenaltyScore();k<v&&(p=b,v=k),this.applyMask(b)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,u){const d=t.QrSegment.makeSegments(c);return ke.encodeSegments(d,u)}static encodeBinary(c,u){const d=t.QrSegment.makeBytes(c);return ke.encodeSegments([d],u)}static encodeSegments(c,u,d=1,p=40,m=-1,x=!0){if(!(ke.MIN_VERSION<=d&&d<=p&&p<=ke.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,b;for(v=d;;v++){const C=ke.getNumDataCodewords(v,u)*8,z=h.getTotalBits(c,v);if(z<=C){b=z;break}if(v>=p)throw new RangeError("Data too long")}for(const C of[ke.Ecc.MEDIUM,ke.Ecc.QUARTILE,ke.Ecc.HIGH])x&&b<=ke.getNumDataCodewords(v,C)*8&&(u=C);let k=[];for(const C of c){o(C.mode.modeBits,4,k),o(C.numChars,C.mode.numCharCountBits(v),k);for(const z of C.getData())k.push(z)}s(k.length==b);const $=ke.getNumDataCodewords(v,u)*8;s(k.length<=$),o(0,Math.min(4,$-k.length),k),o(0,(8-k.length%8)%8,k),s(k.length%8==0);for(let C=236;k.length<$;C^=253)o(C,8,k);let S=[];for(;S.length*8<k.length;)S.push(0);return k.forEach((C,z)=>S[z>>>3]|=C<<7-(z&7)),new ke(v,u,S,m)}getModule(c,u){return 0<=c&&c<this.size&&0<=u&&u<this.size&&this.modules[u][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),u=c.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d==0&&p==0||d==0&&p==u-1||d==u-1&&p==0||this.drawAlignmentPattern(c[d],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const u=this.errorCorrectionLevel.formatBits<<3|c;let d=u;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const p=(u<<10|d)^21522;s(p>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(p,m));this.setFunctionModule(8,7,n(p,6)),this.setFunctionModule(8,8,n(p,7)),this.setFunctionModule(7,8,n(p,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(p,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(p,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(p,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let d=0;d<12;d++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;s(u>>>18==0);for(let d=0;d<18;d++){const p=n(u,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,p),this.setFunctionModule(x,m,p)}}drawFinderPattern(c,u){for(let d=-4;d<=4;d++)for(let p=-4;p<=4;p++){const m=Math.max(Math.abs(p),Math.abs(d)),x=c+p,v=u+d;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(c,u){for(let d=-2;d<=2;d++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,u+d,Math.max(Math.abs(p),Math.abs(d))!=1)}setFunctionModule(c,u,d){this.modules[u][c]=d,this.isFunction[u][c]=!0}addEccAndInterleave(c){const u=this.version,d=this.errorCorrectionLevel;if(c.length!=ke.getNumDataCodewords(u,d))throw new RangeError("Invalid argument");const p=ke.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u],m=ke.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u],x=Math.floor(ke.getNumRawDataModules(u)/8),v=p-x%p,b=Math.floor(x/p);let k=[];const $=ke.reedSolomonComputeDivisor(m);for(let C=0,z=0;C<p;C++){let w=c.slice(z,z+b-m+(C<v?0:1));z+=w.length;const y=ke.reedSolomonComputeRemainder(w,$);C<v&&w.push(0),k.push(w.concat(y))}let S=[];for(let C=0;C<k[0].length;C++)k.forEach((z,w)=>{(C!=b-m||w>=v)&&S.push(z[C])});return s(S.length==x),S}drawCodewords(c){if(c.length!=Math.floor(ke.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let p=0;p<this.size;p++)for(let m=0;m<2;m++){const x=d-m,b=(d+1&2)==0?this.size-1-p:p;!this.isFunction[b][x]&&u<c.length*8&&(this.modules[b][x]=n(c[u>>>3],7-(u&7)),u++)}}s(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let d=0;d<this.size;d++){let p;switch(c){case 0:p=(d+u)%2==0;break;case 1:p=u%2==0;break;case 2:p=d%3==0;break;case 3:p=(d+u)%3==0;break;case 4:p=(Math.floor(d/3)+Math.floor(u/2))%2==0;break;case 5:p=d*u%2+d*u%3==0;break;case 6:p=(d*u%2+d*u%3)%2==0;break;case 7:p=((d+u)%2+d*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][d]&&p&&(this.modules[u][d]=!this.modules[u][d])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let x=!1,v=0,b=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[m][k]==x?(v++,v==5?c+=ke.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,b),x||(c+=this.finderPenaltyCountPatterns(b)*ke.PENALTY_N3),x=this.modules[m][k],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,b)*ke.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,b=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[k][m]==x?(v++,v==5?c+=ke.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,b),x||(c+=this.finderPenaltyCountPatterns(b)*ke.PENALTY_N3),x=this.modules[k][m],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,b)*ke.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]&&(c+=ke.PENALTY_N2)}let u=0;for(const m of this.modules)u=m.reduce((x,v)=>x+(v?1:0),u);const d=this.size*this.size,p=Math.ceil(Math.abs(u*20-d*10)/d)-1;return s(0<=p&&p<=9),c+=p*ke.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let d=[6];for(let p=this.size-7;d.length<c;p-=u)d.splice(1,0,p);return d}}static getNumRawDataModules(c){if(c<ke.MIN_VERSION||c>ke.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const d=Math.floor(c/7)+2;u-=(25*d-10)*d-55,c>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(ke.getNumRawDataModules(c)/8)-ke.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*ke.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let p=0;p<c-1;p++)u.push(0);u.push(1);let d=1;for(let p=0;p<c;p++){for(let m=0;m<u.length;m++)u[m]=ke.reedSolomonMultiply(u[m],d),m+1<u.length&&(u[m]^=u[m+1]);d=ke.reedSolomonMultiply(d,2)}return u}static reedSolomonComputeRemainder(c,u){let d=u.map(p=>0);for(const p of c){const m=p^d.shift();d.push(0),u.forEach((x,v)=>d[v]^=ke.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let d=0;for(let p=7;p>=0;p--)d=d<<1^(d>>>7)*285,d^=(u>>>p&1)*c;return s(d>>>8==0),d}finderPenaltyCountPatterns(c){const u=c[1];s(u<=this.size*3);const d=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(d&&c[0]>=u*4&&c[6]>=u?1:0)+(d&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,d){return c&&(this.finderPenaltyAddHistory(u,d),u=0),u+=this.size,this.finderPenaltyAddHistory(u,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};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 o(f,c,u){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let d=c-1;d>=0;d--)u.push(f>>>d&1)}function n(f,c){return(f>>>c&1)!=0}function s(f){if(!f)throw new Error("Assertion error")}const a=class We{constructor(c,u,d){if(this.mode=c,this.numChars=u,this.bitData=d,u<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(c){let u=[];for(const d of c)o(d,8,u);return new We(We.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!We.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let d=0;d<c.length;){const p=Math.min(c.length-d,3);o(parseInt(c.substring(d,d+p),10),p*3+1,u),d+=p}return new We(We.Mode.NUMERIC,c.length,u)}static makeAlphanumeric(c){if(!We.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],d;for(d=0;d+2<=c.length;d+=2){let p=We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d))*45;p+=We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d+1)),o(p,11,u)}return d<c.length&&o(We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d)),6,u),new We(We.Mode.ALPHANUMERIC,c.length,u)}static makeSegments(c){return c==""?[]:We.isNumeric(c)?[We.makeNumeric(c)]:We.isAlphanumeric(c)?[We.makeAlphanumeric(c)]:[We.makeBytes(We.toUtf8ByteArray(c))]}static makeEci(c){let u=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,u);else if(c<16384)o(2,2,u),o(c,14,u);else if(c<1e6)o(6,3,u),o(c,21,u);else throw new RangeError("ECI assignment value out of range");return new We(We.Mode.ECI,0,u)}static isNumeric(c){return We.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return We.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,u){let d=0;for(const p of c){const m=p.mode.numCharCountBits(u);if(p.numChars>=1<<m)return 1/0;d+=4+m+p.bitData.length}return d}static toUtf8ByteArray(c){c=encodeURI(c);let u=[];for(let d=0;d<c.length;d++)c.charAt(d)!="%"?u.push(c.charCodeAt(d)):(u.push(parseInt(c.substring(d+1,d+3),16)),d+=2);return u}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let h=a;t.QrSegment=a})(xr||(xr={}));(t=>{(r=>{const o=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(xr||(xr={}));(t=>{(r=>{const o=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(xr||(xr={}));var $r=xr;/**
3800
+ */var xr;(t=>{const r=class _e{constructor(c,u,d,p){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],c<_e.MIN_VERSION||c>_e.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*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(d);if(this.drawCodewords(x),p==-1){let v=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const k=this.getPenaltyScore();k<v&&(p=b,v=k),this.applyMask(b)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,u){const d=t.QrSegment.makeSegments(c);return _e.encodeSegments(d,u)}static encodeBinary(c,u){const d=t.QrSegment.makeBytes(c);return _e.encodeSegments([d],u)}static encodeSegments(c,u,d=1,p=40,m=-1,x=!0){if(!(_e.MIN_VERSION<=d&&d<=p&&p<=_e.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,b;for(v=d;;v++){const C=_e.getNumDataCodewords(v,u)*8,z=h.getTotalBits(c,v);if(z<=C){b=z;break}if(v>=p)throw new RangeError("Data too long")}for(const C of[_e.Ecc.MEDIUM,_e.Ecc.QUARTILE,_e.Ecc.HIGH])x&&b<=_e.getNumDataCodewords(v,C)*8&&(u=C);let k=[];for(const C of c){o(C.mode.modeBits,4,k),o(C.numChars,C.mode.numCharCountBits(v),k);for(const z of C.getData())k.push(z)}s(k.length==b);const $=_e.getNumDataCodewords(v,u)*8;s(k.length<=$),o(0,Math.min(4,$-k.length),k),o(0,(8-k.length%8)%8,k),s(k.length%8==0);for(let C=236;k.length<$;C^=253)o(C,8,k);let S=[];for(;S.length*8<k.length;)S.push(0);return k.forEach((C,z)=>S[z>>>3]|=C<<7-(z&7)),new _e(v,u,S,m)}getModule(c,u){return 0<=c&&c<this.size&&0<=u&&u<this.size&&this.modules[u][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),u=c.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d==0&&p==0||d==0&&p==u-1||d==u-1&&p==0||this.drawAlignmentPattern(c[d],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const u=this.errorCorrectionLevel.formatBits<<3|c;let d=u;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const p=(u<<10|d)^21522;s(p>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(p,m));this.setFunctionModule(8,7,n(p,6)),this.setFunctionModule(8,8,n(p,7)),this.setFunctionModule(7,8,n(p,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(p,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(p,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(p,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let d=0;d<12;d++)c=c<<1^(c>>>11)*7973;const u=this.version<<12|c;s(u>>>18==0);for(let d=0;d<18;d++){const p=n(u,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,p),this.setFunctionModule(x,m,p)}}drawFinderPattern(c,u){for(let d=-4;d<=4;d++)for(let p=-4;p<=4;p++){const m=Math.max(Math.abs(p),Math.abs(d)),x=c+p,v=u+d;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(c,u){for(let d=-2;d<=2;d++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,u+d,Math.max(Math.abs(p),Math.abs(d))!=1)}setFunctionModule(c,u,d){this.modules[u][c]=d,this.isFunction[u][c]=!0}addEccAndInterleave(c){const u=this.version,d=this.errorCorrectionLevel;if(c.length!=_e.getNumDataCodewords(u,d))throw new RangeError("Invalid argument");const p=_e.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u],m=_e.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u],x=Math.floor(_e.getNumRawDataModules(u)/8),v=p-x%p,b=Math.floor(x/p);let k=[];const $=_e.reedSolomonComputeDivisor(m);for(let C=0,z=0;C<p;C++){let w=c.slice(z,z+b-m+(C<v?0:1));z+=w.length;const y=_e.reedSolomonComputeRemainder(w,$);C<v&&w.push(0),k.push(w.concat(y))}let S=[];for(let C=0;C<k[0].length;C++)k.forEach((z,w)=>{(C!=b-m||w>=v)&&S.push(z[C])});return s(S.length==x),S}drawCodewords(c){if(c.length!=Math.floor(_e.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let p=0;p<this.size;p++)for(let m=0;m<2;m++){const x=d-m,b=(d+1&2)==0?this.size-1-p:p;!this.isFunction[b][x]&&u<c.length*8&&(this.modules[b][x]=n(c[u>>>3],7-(u&7)),u++)}}s(u==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let d=0;d<this.size;d++){let p;switch(c){case 0:p=(d+u)%2==0;break;case 1:p=u%2==0;break;case 2:p=d%3==0;break;case 3:p=(d+u)%3==0;break;case 4:p=(Math.floor(d/3)+Math.floor(u/2))%2==0;break;case 5:p=d*u%2+d*u%3==0;break;case 6:p=(d*u%2+d*u%3)%2==0;break;case 7:p=((d+u)%2+d*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][d]&&p&&(this.modules[u][d]=!this.modules[u][d])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let x=!1,v=0,b=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[m][k]==x?(v++,v==5?c+=_e.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,b),x||(c+=this.finderPenaltyCountPatterns(b)*_e.PENALTY_N3),x=this.modules[m][k],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,b)*_e.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,b=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[k][m]==x?(v++,v==5?c+=_e.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,b),x||(c+=this.finderPenaltyCountPatterns(b)*_e.PENALTY_N3),x=this.modules[k][m],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,b)*_e.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]&&(c+=_e.PENALTY_N2)}let u=0;for(const m of this.modules)u=m.reduce((x,v)=>x+(v?1:0),u);const d=this.size*this.size,p=Math.ceil(Math.abs(u*20-d*10)/d)-1;return s(0<=p&&p<=9),c+=p*_e.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let d=[6];for(let p=this.size-7;d.length<c;p-=u)d.splice(1,0,p);return d}}static getNumRawDataModules(c){if(c<_e.MIN_VERSION||c>_e.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*c+128)*c+64;if(c>=2){const d=Math.floor(c/7)+2;u-=(25*d-10)*d-55,c>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(c,u){return Math.floor(_e.getNumRawDataModules(c)/8)-_e.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*_e.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let u=[];for(let p=0;p<c-1;p++)u.push(0);u.push(1);let d=1;for(let p=0;p<c;p++){for(let m=0;m<u.length;m++)u[m]=_e.reedSolomonMultiply(u[m],d),m+1<u.length&&(u[m]^=u[m+1]);d=_e.reedSolomonMultiply(d,2)}return u}static reedSolomonComputeRemainder(c,u){let d=u.map(p=>0);for(const p of c){const m=p^d.shift();d.push(0),u.forEach((x,v)=>d[v]^=_e.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(c,u){if(c>>>8||u>>>8)throw new RangeError("Byte out of range");let d=0;for(let p=7;p>=0;p--)d=d<<1^(d>>>7)*285,d^=(u>>>p&1)*c;return s(d>>>8==0),d}finderPenaltyCountPatterns(c){const u=c[1];s(u<=this.size*3);const d=u>0&&c[2]==u&&c[3]==u*3&&c[4]==u&&c[5]==u;return(d&&c[0]>=u*4&&c[6]>=u?1:0)+(d&&c[6]>=u*4&&c[0]>=u?1:0)}finderPenaltyTerminateAndCount(c,u,d){return c&&(this.finderPenaltyAddHistory(u,d),u=0),u+=this.size,this.finderPenaltyAddHistory(u,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(c,u){u[0]==0&&(c+=this.size),u.pop(),u.unshift(c)}};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 o(f,c,u){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let d=c-1;d>=0;d--)u.push(f>>>d&1)}function n(f,c){return(f>>>c&1)!=0}function s(f){if(!f)throw new Error("Assertion error")}const a=class We{constructor(c,u,d){if(this.mode=c,this.numChars=u,this.bitData=d,u<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(c){let u=[];for(const d of c)o(d,8,u);return new We(We.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!We.isNumeric(c))throw new RangeError("String contains non-numeric characters");let u=[];for(let d=0;d<c.length;){const p=Math.min(c.length-d,3);o(parseInt(c.substring(d,d+p),10),p*3+1,u),d+=p}return new We(We.Mode.NUMERIC,c.length,u)}static makeAlphanumeric(c){if(!We.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],d;for(d=0;d+2<=c.length;d+=2){let p=We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d))*45;p+=We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d+1)),o(p,11,u)}return d<c.length&&o(We.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d)),6,u),new We(We.Mode.ALPHANUMERIC,c.length,u)}static makeSegments(c){return c==""?[]:We.isNumeric(c)?[We.makeNumeric(c)]:We.isAlphanumeric(c)?[We.makeAlphanumeric(c)]:[We.makeBytes(We.toUtf8ByteArray(c))]}static makeEci(c){let u=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,u);else if(c<16384)o(2,2,u),o(c,14,u);else if(c<1e6)o(6,3,u),o(c,21,u);else throw new RangeError("ECI assignment value out of range");return new We(We.Mode.ECI,0,u)}static isNumeric(c){return We.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return We.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,u){let d=0;for(const p of c){const m=p.mode.numCharCountBits(u);if(p.numChars>=1<<m)return 1/0;d+=4+m+p.bitData.length}return d}static toUtf8ByteArray(c){c=encodeURI(c);let u=[];for(let d=0;d<c.length;d++)c.charAt(d)!="%"?u.push(c.charCodeAt(d)):(u.push(parseInt(c.substring(d+1,d+3),16)),d+=2);return u}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let h=a;t.QrSegment=a})(xr||(xr={}));(t=>{(r=>{const o=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(xr||(xr={}));(t=>{(r=>{const o=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(xr||(xr={}));var $r=xr;/**
3801
3801
  * @license qrcode.react
3802
3802
  * Copyright (c) Paul O'Shannessy
3803
3803
  * SPDX-License-Identifier: ISC
3804
- */var bv={L:$r.QrCode.Ecc.LOW,M:$r.QrCode.Ecc.MEDIUM,Q:$r.QrCode.Ecc.QUARTILE,H:$r.QrCode.Ecc.HIGH},vd=128,bd="L",yd="#FFFFFF",wd="#000000",jd=!1,kd=1,yv=4,wv=0,jv=.1;function _d(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(h,f){if(!h&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!h)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}h&&a===null&&(a=f)})}),o.join("")}function Cd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function kv(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*jv),h=s/r,f=(n.width||a)*h,c=(n.height||a)*h,u=n.x==null?t.length/2-f/2:n.x*h,d=n.y==null?t.length/2-c/2:n.y*h,p=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(u),b=Math.floor(d),k=Math.ceil(f+u-v),$=Math.ceil(c+d-b);m={x:v,y:b,w:k,h:$}}const x=n.crossOrigin;return{x:u,y:d,h:c,w:f,excavation:m,opacity:p,crossOrigin:x}}function _v(t,r){return r!=null?Math.max(Math.floor(r),0):t?yv:wv}function Sd({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:h,boostLevel:f}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((b,k)=>(b.push(...$r.QrSegment.makeSegments(k)),b),[]);return $r.QrCode.encodeSegments(v,bv[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=_v(n,s),b=x.length+v*2,k=kv(x,h,v,a);return{cells:x,margin:v,numCells:b,calculatedImageSettings:k}},[c,h,a,n,s]);return{qrcode:c,margin:d,cells:u,numCells:p,calculatedImageSettings:m}}var Cv=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Sv=i.forwardRef(function(r,o){const n=r,{value:s,size:a=vd,level:h=bd,bgColor:f=yd,fgColor:c=wd,includeMargin:u=jd,minVersion:d=kd,boostLevel:p,marginSize:m,imageSettings:x}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=b,$=Is(b,["style"]),S=x==null?void 0:x.src,C=i.useRef(null),z=i.useRef(null),w=i.useCallback(I=>{C.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,g]=i.useState(!1),{margin:_,cells:E,numCells:j,calculatedImageSettings:T}=Sd({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:m,imageSettings:x,size:a});i.useEffect(()=>{if(C.current!=null){const I=C.current,O=I.getContext("2d");if(!O)return;let N=E;const D=z.current,L=T!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;L&&T.excavation!=null&&(N=Cd(E,T.excavation));const P=window.devicePixelRatio||1;I.height=I.width=a*P;const A=a/j*P;O.scale(A,A),O.fillStyle=f,O.fillRect(0,0,j,j),O.fillStyle=c,Cv?O.fill(new Path2D(_d(N,_))):E.forEach(function(q,Y){q.forEach(function(B,H){B&&O.fillRect(H+_,Y+_,1,1)})}),T&&(O.globalAlpha=T.opacity),L&&O.drawImage(D,T.x+_,T.y+_,T.w,T.h)}}),i.useEffect(()=>{g(!1)},[S]);const R=Ps({height:a,width:a},k);let M=null;return S!=null&&(M=i.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{g(!0)},ref:z,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",Ps({style:R,height:a,width:a,ref:w,role:"img"},$)),M)});Sv.displayName="QRCodeCanvas";var Zs=i.forwardRef(function(r,o){const n=r,{value:s,size:a=vd,level:h=bd,bgColor:f=yd,fgColor:c=wd,includeMargin:u=jd,minVersion:d=kd,boostLevel:p,title:m,marginSize:x,imageSettings:v}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:$,numCells:S,calculatedImageSettings:C}=Sd({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:x,imageSettings:v,size:a});let z=$,w=null;v!=null&&C!=null&&(C.excavation!=null&&(z=Cd($,C.excavation)),w=i.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+k,y:C.y+k,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const y=_d(z,k);return i.createElement("svg",Ps({height:a,width:a,viewBox:`0 0 ${S} ${S}`,ref:o,role:"img"},b),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:f,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),w)});Zs.displayName="QRCodeSVG";const $d=i.createContext(void 0),Yt=()=>{const t=i.useContext($d);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},$v=l.div`
3804
+ */var bv={L:$r.QrCode.Ecc.LOW,M:$r.QrCode.Ecc.MEDIUM,Q:$r.QrCode.Ecc.QUARTILE,H:$r.QrCode.Ecc.HIGH},bd=128,yd="L",wd="#FFFFFF",jd="#000000",kd=!1,_d=1,yv=4,wv=0,jv=.1;function Cd(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(h,f){if(!h&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!h)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}h&&a===null&&(a=f)})}),o.join("")}function Sd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function kv(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*jv),h=s/r,f=(n.width||a)*h,c=(n.height||a)*h,u=n.x==null?t.length/2-f/2:n.x*h,d=n.y==null?t.length/2-c/2:n.y*h,p=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(u),b=Math.floor(d),k=Math.ceil(f+u-v),$=Math.ceil(c+d-b);m={x:v,y:b,w:k,h:$}}const x=n.crossOrigin;return{x:u,y:d,h:c,w:f,excavation:m,opacity:p,crossOrigin:x}}function _v(t,r){return r!=null?Math.max(Math.floor(r),0):t?yv:wv}function $d({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:h,boostLevel:f}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((b,k)=>(b.push(...$r.QrSegment.makeSegments(k)),b),[]);return $r.QrCode.encodeSegments(v,bv[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=_v(n,s),b=x.length+v*2,k=kv(x,h,v,a);return{cells:x,margin:v,numCells:b,calculatedImageSettings:k}},[c,h,a,n,s]);return{qrcode:c,margin:d,cells:u,numCells:p,calculatedImageSettings:m}}var Cv=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Sv=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,marginSize:m,imageSettings:x}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=b,$=Is(b,["style"]),S=x==null?void 0:x.src,C=i.useRef(null),z=i.useRef(null),w=i.useCallback(I=>{C.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,g]=i.useState(!1),{margin:_,cells:E,numCells:j,calculatedImageSettings:T}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:m,imageSettings:x,size:a});i.useEffect(()=>{if(C.current!=null){const I=C.current,O=I.getContext("2d");if(!O)return;let N=E;const D=z.current,L=T!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;L&&T.excavation!=null&&(N=Sd(E,T.excavation));const P=window.devicePixelRatio||1;I.height=I.width=a*P;const A=a/j*P;O.scale(A,A),O.fillStyle=f,O.fillRect(0,0,j,j),O.fillStyle=c,Cv?O.fill(new Path2D(Cd(N,_))):E.forEach(function(q,Y){q.forEach(function(B,H){B&&O.fillRect(H+_,Y+_,1,1)})}),T&&(O.globalAlpha=T.opacity),L&&O.drawImage(D,T.x+_,T.y+_,T.w,T.h)}}),i.useEffect(()=>{g(!1)},[S]);const R=Ps({height:a,width:a},k);let M=null;return S!=null&&(M=i.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{g(!0)},ref:z,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",Ps({style:R,height:a,width:a,ref:w,role:"img"},$)),M)});Sv.displayName="QRCodeCanvas";var Zs=i.forwardRef(function(r,o){const n=r,{value:s,size:a=bd,level:h=yd,bgColor:f=wd,fgColor:c=jd,includeMargin:u=kd,minVersion:d=_d,boostLevel:p,title:m,marginSize:x,imageSettings:v}=n,b=Is(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:$,numCells:S,calculatedImageSettings:C}=$d({value:s,level:h,minVersion:d,boostLevel:p,includeMargin:u,marginSize:x,imageSettings:v,size:a});let z=$,w=null;v!=null&&C!=null&&(C.excavation!=null&&(z=Sd($,C.excavation)),w=i.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+k,y:C.y+k,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const y=Cd(z,k);return i.createElement("svg",Ps({height:a,width:a,viewBox:`0 0 ${S} ${S}`,ref:o,role:"img"},b),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:f,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),w)});Zs.displayName="QRCodeSVG";const zd=i.createContext(void 0),Yt=()=>{const t=i.useContext(zd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},$v=l.div`
3805
3805
  position: fixed;
3806
3806
  background: var(--color-background);
3807
3807
  border-radius: var(--radius-md);
@@ -3840,7 +3840,7 @@ cursor: pointer;
3840
3840
  justify-content: center;
3841
3841
  color: var(--color-muted);
3842
3842
  flex-shrink: 0;
3843
- `,Ui=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const E=a.current;if(E){const j=E.getBoundingClientRect(),T=380,R=300,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),d({top:I,left:O})}},10),g=E=>{h.current&&!h.current.contains(E.target)&&t()},_=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",_),()=>{clearTimeout(y),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",_)}},[t,a]);const[m,x]=i.useState(s?"otp":"email"),[v,b]=i.useState(s||""),[k,$]=i.useState(""),[S,C]=i.useState(!1),z=async()=>{if(!(!v||S)){C(!0);try{await r(v),x("otp")}catch(y){const g=y.message||"Failed to add email address. Please try again.";p(g,"error")}finally{C(!1)}}},w=async()=>{C(!0);try{await o(k),t()}catch(y){const g=y.message||"Failed to verify email. Please check the code and try again.";p(g,"error")}finally{C(!1)}};return f?e.jsx($v,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Add email address"}),e.jsx(pe,{children:e.jsxs(zv,{children:[e.jsx(Ev,{children:e.jsx(hn,{size:16})}),e.jsx(se,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:y=>b(y.target.value),style:{flex:1}})]})}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:!v||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bi,{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(qt,{onComplete:async y=>$(y),onResend:n,isSubmitting:S}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(J,{onClick:w,disabled:k.length<6||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Verifying...":"Verify"})]})]})}):null},Pv=l.div`
3843
+ `,Ui=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const E=a.current;if(E){const j=E.getBoundingClientRect(),T=380,R=300,M=8;let I=0,O=0;const N=window.innerHeight-j.bottom,D=j.top;N>=R+M?(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):D>=R+M?(I=j.top-R-M,O=j.right-T,O<M&&(O=j.left,O+T>window.innerWidth-M&&(O=(window.innerWidth-T)/2))):(I=j.bottom+M,O=j.right-T,O<M&&(O=j.left)),d({top:I,left:O})}},10),g=E=>{h.current&&!h.current.contains(E.target)&&t()},_=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",_),()=>{clearTimeout(y),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",_)}},[t,a]);const[m,x]=i.useState(s?"otp":"email"),[v,b]=i.useState(s||""),[k,$]=i.useState(""),[S,C]=i.useState(!1),z=async()=>{if(!(!v||S)){C(!0);try{await r(v),x("otp")}catch(y){const g=y.message||"Failed to add email address. Please try again.";p(g,"error")}finally{C(!1)}}},w=async()=>{C(!0);try{await o(k),t()}catch(y){const g=y.message||"Failed to verify email. Please check the code and try again.";p(g,"error")}finally{C(!1)}};return f?e.jsx($v,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Bi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(zv,{children:[e.jsx(Ev,{children:e.jsx(hn,{size:16})}),e.jsx(se,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:y=>b(y.target.value),style:{flex:1}})]})}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:z,disabled:!v||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bi,{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(qt,{onComplete:async y=>$(y),onResend:n,isSubmitting:S}),e.jsxs(Fi,{children:[e.jsx(J,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(J,{onClick:w,disabled:k.length<6||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Verifying...":"Verify"})]})]})}):null},Pv=l.div`
3844
3844
  position: fixed;
3845
3845
  background: var(--color-background);
3846
3846
  border-radius: var(--radius-md);
@@ -3864,7 +3864,7 @@ cursor: pointer;
3864
3864
  font-weight: 400;
3865
3865
  color: var(--color-foreground);
3866
3866
  margin-bottom: 12px;
3867
- `,Gi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var _;const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const R=a.current;if(R){const M=R.getBoundingClientRect(),I=380,O=300,N=8;let D=0,L=0;const P=window.innerHeight-M.bottom,A=M.top;P>=O+N?(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):A>=O+N?(D=M.top-O-N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left)),d({top:D,left:L})}},10),j=R=>{h.current&&!h.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[m,x]=i.useState(n?"otp":"phone"),[v,b]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[k,$]=i.useState((_=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:_.pop()),[S,C]=i.useState(""),[z,w]=i.useState(!1),y=async()=>{if(!(!v||z)){w(!0);try{await r(v,k||""),x("otp")}catch(E){const j=E.message||"Failed to add phone number. Please try again.";p(j,"error")}finally{w(!1)}}},g=async()=>{w(!0);try{await o(S),t()}catch(E){const j=E.message||"Failed to verify phone. Please check the code and try again.";p(j,"error")}finally{w(!1)}};return f?e.jsx(Pv,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Add phone number"}),e.jsx(pe,{children:e.jsx(oo,{value:v,onChange:E=>b(E.target.value),error:"",countryCode:k,setCountryCode:$})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:y,disabled:!v||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Verify phone number"}),e.jsx(pe,{children:e.jsx(qt,{onComplete:E=>C(E),onResend:async()=>s()})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:g,disabled:S.length!==6||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Iv=l.div`
3867
+ `,Gi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var _;const h=i.useRef(null),[f,c]=i.useState(!1),[u,d]=i.useState({top:0,left:0}),{toast:p}=Yt();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!h.current||!(a!=null&&a.current))return;const R=a.current;if(R){const M=R.getBoundingClientRect(),I=380,O=300,N=8;let D=0,L=0;const P=window.innerHeight-M.bottom,A=M.top;P>=O+N?(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):A>=O+N?(D=M.top-O-N,L=M.right-I,L<N&&(L=M.left,L+I>window.innerWidth-N&&(L=(window.innerWidth-I)/2))):(D=M.bottom+N,L=M.right-I,L<N&&(L=M.left)),d({top:D,left:L})}},10),j=R=>{h.current&&!h.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[m,x]=i.useState(n?"otp":"phone"),[v,b]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[k,$]=i.useState((_=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:_.pop()),[S,C]=i.useState(""),[z,w]=i.useState(!1),y=async()=>{if(!(!v||z)){w(!0);try{await r(v,k||""),x("otp")}catch(E){const j=E.message||"Failed to add phone number. Please try again.";p(j,"error")}finally{w(!1)}}},g=async()=>{w(!0);try{await o(S),t()}catch(E){const j=E.message||"Failed to verify phone. Please check the code and try again.";p(j,"error")}finally{w(!1)}};return f?e.jsx(Pv,{ref:h,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(oo,{value:v,onChange:E=>b(E.target.value),error:"",countryCode:k,setCountryCode:$})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:y,disabled:!v||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(qt,{onComplete:E=>C(E),onResend:async()=>s()})}),e.jsxs(Wi,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:g,disabled:S.length!==6||z,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Iv=l.div`
3868
3868
  position: fixed;
3869
3869
  background: var(--color-background);
3870
3870
  border-radius: var(--radius-md);
@@ -4015,7 +4015,7 @@ cursor: pointer;
4015
4015
  color: var(--color-warning-text, var(--color-foreground));
4016
4016
  margin: 0;
4017
4017
  line-height: 1.5;
4018
- `,Bv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),{toast:m}=Yt();i.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const S=$.getBoundingClientRect(),C=400,z=300,w=8;let y=0,g=0;const _=window.innerHeight-S.bottom,E=S.top;_>=z+w?(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):E>=z+w?(y=S.top-z-w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left)),f({top:y,left:g})}},10),b=$=>{n.current&&!n.current.contains($.target)&&t()},k=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",k),()=>{clearTimeout(v),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",k)}},[t,o]);const x=async()=>{if(!(!c||d)){p(!0);try{await r(c),t()}catch(v){const b=v.message||"Failed to remove password. Please try again.";m(b,"error")}finally{p(!1)}}};return s?e.jsxs(Av,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(Dv,{children:[e.jsx(jt,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(Nv,{children:e.jsx(Fv,{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(pe,{children:[e.jsx(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(se,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>u(v.target.value),autoFocus:!0})]}),e.jsxs(Lv,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},Uv=l.div`
4018
+ `,Bv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[h,f]=i.useState({top:0,left:0}),[c,u]=i.useState(""),[d,p]=i.useState(!1),{toast:m}=Yt();i.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const S=$.getBoundingClientRect(),C=400,z=300,w=8;let y=0,g=0;const _=window.innerHeight-S.bottom,E=S.top;_>=z+w?(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):E>=z+w?(y=S.top-z-w,g=S.right-C,g<w&&(g=S.left,g+C>window.innerWidth-w&&(g=(window.innerWidth-C)/2))):(y=S.bottom+w,g=S.right-C,g<w&&(g=S.left)),f({top:y,left:g})}},10),b=$=>{n.current&&!n.current.contains($.target)&&t()},k=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",k),()=>{clearTimeout(v),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",k)}},[t,o]);const x=async()=>{if(!(!c||d)){p(!0);try{await r(c),t()}catch(v){const b=v.message||"Failed to remove password. Please try again.";m(b,"error")}finally{p(!1)}}};return s?e.jsxs(Av,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(Dv,{children:[e.jsx(jt,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(Nv,{children:e.jsx(Fv,{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(he,{children:[e.jsx(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(se,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>u(v.target.value),autoFocus:!0})]}),e.jsxs(Lv,{children:[e.jsx(J,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(J,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},Uv=l.div`
4019
4019
  position: fixed;
4020
4020
  background: var(--color-background);
4021
4021
  border-radius: var(--radius-md);
@@ -4268,7 +4268,7 @@ cursor: pointer;
4268
4268
  flex-wrap: wrap;
4269
4269
  gap: 12px;
4270
4270
  margin-bottom: 0;
4271
- `,h1=()=>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:"?"})]}),f1=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(r1,{...o}):r.includes("firefox")?e.jsx(o1,{...o}):r.includes("safari")?e.jsx(n1,{...o}):r.includes("edge")?e.jsx(s1,{...o}):r.includes("opera")?e.jsx(a1,{...o}):r.includes("brave")?e.jsx(i1,{...o}):e.jsx(h1,{})},g1=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=Vc(),{refetch:h}=Qe(),{toast:f}=Yt(),c=o,u=async p=>{try{await n(p),await Promise.all([s(),h()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const m=new Date(p);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):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:c&&c.length>0?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Browser & Device"}),e.jsx(Ee,{children:"Location"}),e.jsx(Ee,{children:"Last Active"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:c.map(p=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zd,{children:e.jsx(f1,{browser:p.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.device})]})]})}),e.jsx(Ue,{children:e.jsxs("div",{children:[e.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.ip_address})]})}),e.jsx(Ue,{children:d(p.last_active_at)}),e.jsx($t,{children:e.jsxs(ft,{open:t===p.id,openChange:m=>r(m?p.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{children:"•••"})}),e.jsx(gt,{children:e.jsx(Be,{onClick:()=>u(p.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ft,{size:14}),"End Session"]})})})]})})]},p.id))})]}):e.jsx(xt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},m1=()=>{var y,g,_,E;const{deployment:t}=ye(),{toast:r}=Yt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(null),[d,p]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:b,deleteEmailAddress:k,prepareEmailVerification:$,attemptEmailVerification:S,makeEmailPrimary:C}=Gt();if(!((g=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&g.enabled))return null;const z=async j=>{try{if(j===(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 k(j),v.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>v!=null&&v.user_email_addresses?d.trim()?v.user_email_addresses.filter(j=>j.email.toLowerCase().includes(d.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:d,onChange:p,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:m,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),h&&e.jsx(Ui,{triggerRef:m,onClose:()=>f(!1),onAddEmail:async j=>{const T=await b(j);a(T.data.id),await $(T.data.id),v.refetch()},onPrepareVerification:async()=>{await $(s),v.refetch()},onAttemptVerification:async j=>{await S(s,j),v.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email Address"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(j=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:j.email}),e.jsx(Ue,{children:j.id===(v==null?void 0:v.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx($t,{children:j.id!==(v==null?void 0:v.primary_email_address_id)||!j.verified?e.jsxs(ft,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:T=>{T&&(x.current[j.id]=T)},children:"•••"})}),e.jsxs(gt,{children:[j.id!==(v==null?void 0:v.primary_email_address_id)&&j.verified&&e.jsx(Be,{onClick:async()=>{try{await C(j.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Be,{onClick:async()=>{n(null),await $(j.id),u(j.id)},children:"Verify email"}),j.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Be,{$destructive:!0,onClick:()=>{z(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(xt,{title:d?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(Ui,{existingEmail:(E=(_=v==null?void 0:v.user_email_addresses)==null?void 0:_.find(j=>j.id===c))==null?void 0:E.email,triggerRef:{current:x.current[c]},onClose:()=>u(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await $(c),v.refetch()},onAttemptVerification:async j=>{await S(c,j),v.refetch(),u(null),r("Email verified successfully!","info")}})]})},x1=()=>{var w,y,g,_;const{deployment:t}=ye(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState(""),p=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:b,preparePhoneVerification:k,attemptPhoneVerification:$,makePhonePrimary:S}=Gt();if(!((y=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&y.enabled))return null;const C=E=>{const j=Vo.find(T=>T.dialCode===E);return(j==null?void 0:j.flag)||"🌍"},z=i.useMemo(()=>x!=null&&x.user_phone_numbers?u.trim()?x.user_phone_numbers.filter(E=>E.phone_number.toLowerCase().includes(u.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,u]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:u,onChange:d,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:p,onClick:()=>h(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(Gi,{triggerRef:p,onClose:()=>h(!1),onAddPhone:async(E,j)=>{const T=await v(E,j);s(T.data.id),await k(T.data.id)},onPrepareVerification:async()=>{await k(n),x.refetch()},onAttemptVerification:async E=>{await $(n,E),x.refetch(),h(!1)}}),f&&e.jsx(Gi,{existingPhone:(_=(g=x==null?void 0:x.user_phone_numbers)==null?void 0:g.find(E=>E.id===f))==null?void 0:_.phone_number,triggerRef:{current:m.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await k(f),x.refetch()},onAttemptVerification:async E=>{await $(f,E),x.refetch(),c(null)}})]})]}),z!=null&&z.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Phone Number"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(E=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:C(E.country_code)}),e.jsx("span",{children:E.country_code}),e.jsx("span",{children:E.phone_number})]})}),e.jsx(Ue,{children:E.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx($t,{children:e.jsxs(ft,{open:r===E.id,openChange:j=>o(j?E.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:j=>{j&&(m.current[E.id]=j)},children:"•••"})}),e.jsxs(gt,{children:[E.id!==(x==null?void 0:x.primary_phone_number_id)&&E.verified&&e.jsx(Be,{onClick:async()=>{await S(E.id),o(null),x.refetch()},children:"Make primary"}),!E.verified&&e.jsx(Be,{onClick:async()=>{await k(E.id),c(E.id),o(null)},children:"Verify phone"}),e.jsx(Be,{$destructive:!0,onClick:async()=>{await b(E.id),o(null),x.refetch()},children:"Remove"})]})]})})]},E.id))})]}):e.jsx(xt,{title:u?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},zd=l.div`
4271
+ `,h1=()=>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:"?"})]}),f1=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(r1,{...o}):r.includes("firefox")?e.jsx(o1,{...o}):r.includes("safari")?e.jsx(n1,{...o}):r.includes("edge")?e.jsx(s1,{...o}):r.includes("opera")?e.jsx(a1,{...o}):r.includes("brave")?e.jsx(i1,{...o}):e.jsx(h1,{})},g1=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=Vc(),{refetch:h}=Qe(),{toast:f}=Yt(),c=o,u=async p=>{try{await n(p),await Promise.all([s(),h()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},d=p=>{if(!p||p.trim()==="")return"Unknown";const m=new Date(p);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):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:c&&c.length>0?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Browser & Device"}),e.jsx(Ee,{children:"Location"}),e.jsx(Ee,{children:"Last Active"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:c.map(p=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ed,{children:e.jsx(f1,{browser:p.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.device})]})]})}),e.jsx(Ue,{children:e.jsxs("div",{children:[e.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.ip_address})]})}),e.jsx(Ue,{children:d(p.last_active_at)}),e.jsx($t,{children:e.jsxs(ft,{open:t===p.id,openChange:m=>r(m?p.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{children:"•••"})}),e.jsx(gt,{children:e.jsx(Be,{onClick:()=>u(p.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ft,{size:14}),"End Session"]})})})]})})]},p.id))})]}):e.jsx(xt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},m1=()=>{var y,g,_,E;const{deployment:t}=we(),{toast:r}=Yt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[h,f]=i.useState(!1),[c,u]=i.useState(null),[d,p]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:b,deleteEmailAddress:k,prepareEmailVerification:$,attemptEmailVerification:S,makeEmailPrimary:C}=Gt();if(!((g=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&g.enabled))return null;const z=async j=>{try{if(j===(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 k(j),v.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>v!=null&&v.user_email_addresses?d.trim()?v.user_email_addresses.filter(j=>j.email.toLowerCase().includes(d.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:d,onChange:p,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:m,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),h&&e.jsx(Ui,{triggerRef:m,onClose:()=>f(!1),onAddEmail:async j=>{const T=await b(j);a(T.data.id),await $(T.data.id),v.refetch()},onPrepareVerification:async()=>{await $(s),v.refetch()},onAttemptVerification:async j=>{await S(s,j),v.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Email Address"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:w.map(j=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:j.email}),e.jsx(Ue,{children:j.id===(v==null?void 0:v.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx($t,{children:j.id!==(v==null?void 0:v.primary_email_address_id)||!j.verified?e.jsxs(ft,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:T=>{T&&(x.current[j.id]=T)},children:"•••"})}),e.jsxs(gt,{children:[j.id!==(v==null?void 0:v.primary_email_address_id)&&j.verified&&e.jsx(Be,{onClick:async()=>{try{await C(j.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Be,{onClick:async()=>{n(null),await $(j.id),u(j.id)},children:"Verify email"}),j.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Be,{$destructive:!0,onClick:()=>{z(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(xt,{title:d?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(Ui,{existingEmail:(E=(_=v==null?void 0:v.user_email_addresses)==null?void 0:_.find(j=>j.id===c))==null?void 0:E.email,triggerRef:{current:x.current[c]},onClose:()=>u(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await $(c),v.refetch()},onAttemptVerification:async j=>{await S(c,j),v.refetch(),u(null),r("Email verified successfully!","info")}})]})},x1=()=>{var w,y,g,_;const{deployment:t}=we(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,h]=i.useState(!1),[f,c]=i.useState(null),[u,d]=i.useState(""),p=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:b,preparePhoneVerification:k,attemptPhoneVerification:$,makePhonePrimary:S}=Gt();if(!((y=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&y.enabled))return null;const C=E=>{const j=Vo.find(T=>T.dialCode===E);return(j==null?void 0:j.flag)||"🌍"},z=i.useMemo(()=>x!=null&&x.user_phone_numbers?u.trim()?x.user_phone_numbers.filter(E=>E.phone_number.toLowerCase().includes(u.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,u]);return e.jsxs(e.Fragment,{children:[e.jsxs(tn,{style:{marginBottom:"20px"},children:[e.jsx(At,{value:u,onChange:d,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:p,onClick:()=>h(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(Gi,{triggerRef:p,onClose:()=>h(!1),onAddPhone:async(E,j)=>{const T=await v(E,j);s(T.data.id),await k(T.data.id)},onPrepareVerification:async()=>{await k(n),x.refetch()},onAttemptVerification:async E=>{await $(n,E),x.refetch(),h(!1)}}),f&&e.jsx(Gi,{existingPhone:(_=(g=x==null?void 0:x.user_phone_numbers)==null?void 0:g.find(E=>E.id===f))==null?void 0:_.phone_number,triggerRef:{current:m.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await k(f),x.refetch()},onAttemptVerification:async E=>{await $(f,E),x.refetch(),c(null)}})]})]}),z!=null&&z.length?e.jsxs(_t,{children:[e.jsx(Ct,{children:e.jsxs(Ye,{children:[e.jsx(Ee,{children:"Phone Number"}),e.jsx(Ee,{children:"Status"}),e.jsx(Ee,{})]})}),e.jsx(St,{children:z.map(E=>e.jsxs(Ye,{children:[e.jsx(Ue,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:C(E.country_code)}),e.jsx("span",{children:E.country_code}),e.jsx("span",{children:E.phone_number})]})}),e.jsx(Ue,{children:E.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx($t,{children:e.jsxs(ft,{open:r===E.id,openChange:j=>o(j?E.id:null),children:[e.jsx(mt,{children:e.jsx(vn,{ref:j=>{j&&(m.current[E.id]=j)},children:"•••"})}),e.jsxs(gt,{children:[E.id!==(x==null?void 0:x.primary_phone_number_id)&&E.verified&&e.jsx(Be,{onClick:async()=>{await S(E.id),o(null),x.refetch()},children:"Make primary"}),!E.verified&&e.jsx(Be,{onClick:async()=>{await k(E.id),c(E.id),o(null)},children:"Verify phone"}),e.jsx(Be,{$destructive:!0,onClick:async()=>{await b(E.id),o(null),x.refetch()},children:"Remove"})]})]})})]},E.id))})]}):e.jsx(xt,{title:u?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Ed=l.div`
4272
4272
  width: 20px;
4273
4273
  height: 20px;
4274
4274
  flex-shrink: 0;
@@ -4283,9 +4283,9 @@ cursor: pointer;
4283
4283
  flex-shrink: 0;
4284
4284
  display: block;
4285
4285
  }
4286
- `,v1=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Gt(),{deployment:n}=ye(),s={google_oauth:{icon:e.jsx(zl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(t1,{}),label:"Microsoft"},github_oauth:{icon:e.jsx($l,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Pl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Rl,{}),label:"Discord"},x_oauth:{icon:e.jsx(El,{}),label:"X"}},a=(n==null?void 0:n.social_connections.filter(h=>h.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((h,f)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(p=>p.provider===h.provider))||[],u=s[h.provider];return u?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(zd,{children:u.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:u.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(p=>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:p.email_address}),e.jsx(vn,{onClick:async()=>{await r(p.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(lt,{size:14})})]},p.id)),c.length>0?e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},h.provider):null})})]})},Ed=()=>{var v,b,k,$,S,C,z;const{loading:t}=Gt(),{deployment:r}=ye(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((w,y="info")=>{a(w),f(y),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(he,{children:e.jsx(Xi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const u=r==null?void 0:r.auth_settings,d=(v=u==null?void 0:u.email_address)==null?void 0:v.enabled,p=(b=u==null?void 0:u.phone_number)==null?void 0:b.enabled,m=((k=r==null?void 0:r.social_connections)==null?void 0:k.some(w=>w.enabled))||!1,x=(($=u==null?void 0:u.password)==null?void 0:$.enabled)||((S=u==null?void 0:u.auth_factors_enabled)==null?void 0:S.authenticator)||((C=u==null?void 0:u.auth_factors_enabled)==null?void 0:C.phone_otp)||((z=u==null?void 0:u.auth_factors_enabled)==null?void 0:z.backup_code);return e.jsx(he,{children:e.jsx(l1,{children:e.jsx($d.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Xi,{children:[e.jsx(d1,{children:e.jsxs(u1,{children:[e.jsx(Cr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Sr,{children:[e.jsx(Ko,{size:16}),"Profile"]})}),d&&e.jsx(Cr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Sr,{children:[e.jsx(hn,{size:16}),"Email"]})}),p&&e.jsx(Cr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Sr,{children:[e.jsx(qh,{size:16}),"Phone"]})}),m&&e.jsx(Cr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Sr,{children:[e.jsx(Lh,{size:16}),"Connections"]})}),x&&e.jsx(Cr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Sr,{children:[e.jsx(pt,{size:16}),"Security"]})}),e.jsx(Cr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Sr,{children:[e.jsx(dh,{size:16}),"Sessions"]})})]})}),e.jsxs(p1,{children:[o==="profile"&&e.jsx(y1,{}),o==="email"&&d&&e.jsx(m1,{}),o==="phone"&&p&&e.jsx(x1,{}),o==="social"&&m&&e.jsx(v1,{}),o==="security"&&x&&e.jsx(b1,{}),o==="sessions"&&e.jsx(g1,{})]}),s&&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:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},b1=()=>{var Qs,Xs,Js,ea,ta,ra,oa;const{deployment:t}=ye(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:h,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:u,getPasskeys:d,registerPasskey:p,deletePasskey:m}=Gt(),{toast:x}=Yt(),[v,b]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[k,$]=i.useState(!1),S=async ae=>{try{await u({second_factor_policy:ae}),b(ae),x("2FA requirement updated successfully","info")}catch(De){x(De.message||"Failed to update 2FA requirement","error")}},[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState(!1),[E,j]=i.useState(!1),T=i.useRef(null),R=i.useRef(null),M=i.useRef(null),I=i.useRef(null),[O,N]=i.useState([]),[D,L]=i.useState(!1),[P,A]=i.useState(!1),[q,Y]=i.useState(!1),[B,H]=i.useState(!1),[G,X]=i.useState(null),oe=i.useRef(null),[te,ce]=i.useState("table"),[Q,me]=i.useState(""),[ve,de]=i.useState(""),[U,le]=i.useState(""),[K,Z]=i.useState(["",""]),[re,fe]=i.useState([]),[ue,ee]=i.useState(!1),[V,F]=i.useState(!1),[ne]=i.useState(!1),[be,Me]=i.useState(!1),Ce=(Qs=t==null?void 0:t.auth_settings)==null?void 0:Qs.auth_factors_enabled,Se=(Js=(Xs=t==null?void 0:t.auth_settings)==null?void 0:Xs.password)==null?void 0:Js.enabled;if(!(Ce!=null&&Ce.authenticator)&&!(Ce!=null&&Ce.backup_code)&&!Se)return null;const Ve=async(ae,De)=>{await o(ae,De),await r.refetch(),x("Password updated successfully","info")},Le=async ae=>{await n(ae),await r.refetch(),x("Password removed successfully","info")},Ae=()=>{var na,sa,aa,ia,ca,la;if(!r)return!1;const ae=(na=r.user_email_addresses)==null?void 0:na.some(Dr=>Dr.verified),De=(sa=r.user_phone_numbers)==null?void 0:sa.some(Dr=>Dr.verified),Ne=r.social_connections&&r.social_connections.length>0,et=t==null?void 0:t.auth_settings;return(et==null?void 0:et.first_factor)==="email_otp"&&ae||((aa=et==null?void 0:et.magic_link)==null?void 0:aa.enabled)&&ae||((ia=et==null?void 0:et.passkey)==null?void 0:ia.enabled)||((ca=et==null?void 0:et.auth_factors_enabled)==null?void 0:ca.phone_otp)&&De||Ne&&((la=t==null?void 0:t.social_connections)==null?void 0:la.some(Dr=>Dr.enabled))},xe=async()=>{if(K.some(ae=>ae.length!==6)){x("Please enter both 6-digit verification codes","error");return}try{if(F(!0),await a(U,K),await r.refetch(),Ce!=null&&Ce.backup_code){const ae=await f();fe(ae),await r.refetch(),ce("backup")}else ce("success")}catch(ae){x(ae.message||"Invalid verification codes","error")}finally{F(!1)}},ge=()=>{ce("table"),me(""),de(""),le(""),Z(["",""]),fe([]),x("Two-factor authentication setup completed successfully!","info")},_e=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{Me(!0),await h(r.user_authenticator.id),await r.refetch(),$(!1),x("Two-factor authentication removed successfully","info")}catch(De){x(De.message||"Failed to remove authenticator","error")}finally{Me(!1)}},$e=async()=>{if(!ue)try{ee(!0);const ae=await c();fe(ae),await r.refetch(),j(!0),x("New backup codes generated","info")}catch(ae){x(ae.message||"Failed to generate backup codes","error")}finally{ee(!1)}},Ie=()=>{const ae=re.join(`
4286
+ `,v1=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Gt(),{deployment:n}=we(),s={google_oauth:{icon:e.jsx(zl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(t1,{}),label:"Microsoft"},github_oauth:{icon:e.jsx($l,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Pl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Rl,{}),label:"Discord"},x_oauth:{icon:e.jsx(El,{}),label:"X"}},a=(n==null?void 0:n.social_connections.filter(h=>h.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((h,f)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(p=>p.provider===h.provider))||[],u=s[h.provider];return u?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Ed,{children:u.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:u.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(p=>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:p.email_address}),e.jsx(vn,{onClick:async()=>{await r(p.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(lt,{size:14})})]},p.id)),c.length>0?e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(J,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},h.provider):null})})]})},Pd=()=>{var v,b,k,$,S,C,z;const{loading:t}=Gt(),{deployment:r}=we(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[h,f]=i.useState("info"),c=i.useCallback((w,y="info")=>{a(w),f(y),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(fe,{children:e.jsx(Xi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const u=r==null?void 0:r.auth_settings,d=(v=u==null?void 0:u.email_address)==null?void 0:v.enabled,p=(b=u==null?void 0:u.phone_number)==null?void 0:b.enabled,m=((k=r==null?void 0:r.social_connections)==null?void 0:k.some(w=>w.enabled))||!1,x=(($=u==null?void 0:u.password)==null?void 0:$.enabled)||((S=u==null?void 0:u.auth_factors_enabled)==null?void 0:S.authenticator)||((C=u==null?void 0:u.auth_factors_enabled)==null?void 0:C.phone_otp)||((z=u==null?void 0:u.auth_factors_enabled)==null?void 0:z.backup_code);return e.jsx(fe,{children:e.jsx(l1,{children:e.jsx(zd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Xi,{children:[e.jsx(d1,{children:e.jsxs(u1,{children:[e.jsx(Cr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Sr,{children:[e.jsx(Ko,{size:16}),"Profile"]})}),d&&e.jsx(Cr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Sr,{children:[e.jsx(hn,{size:16}),"Email"]})}),p&&e.jsx(Cr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Sr,{children:[e.jsx(Yh,{size:16}),"Phone"]})}),m&&e.jsx(Cr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Sr,{children:[e.jsx(Dh,{size:16}),"Connections"]})}),x&&e.jsx(Cr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Sr,{children:[e.jsx(pt,{size:16}),"Security"]})}),e.jsx(Cr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Sr,{children:[e.jsx(uh,{size:16}),"Sessions"]})})]})}),e.jsxs(p1,{children:[o==="profile"&&e.jsx(y1,{}),o==="email"&&d&&e.jsx(m1,{}),o==="phone"&&p&&e.jsx(x1,{}),o==="social"&&m&&e.jsx(v1,{}),o==="security"&&x&&e.jsx(b1,{}),o==="sessions"&&e.jsx(g1,{})]}),s&&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:[h==="error"?e.jsx(jt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},b1=()=>{var Qs,Xs,Js,ea,ta,ra,oa;const{deployment:t}=we(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:h,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:u,getPasskeys:d,registerPasskey:p,deletePasskey:m}=Gt(),{toast:x}=Yt(),[v,b]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[k,$]=i.useState(!1),S=async ae=>{try{await u({second_factor_policy:ae}),b(ae),x("2FA requirement updated successfully","info")}catch(De){x(De.message||"Failed to update 2FA requirement","error")}},[C,z]=i.useState(!1),[w,y]=i.useState(!1),[g,_]=i.useState(!1),[E,j]=i.useState(!1),T=i.useRef(null),R=i.useRef(null),M=i.useRef(null),I=i.useRef(null),[O,N]=i.useState([]),[D,L]=i.useState(!1),[P,A]=i.useState(!1),[q,Y]=i.useState(!1),[B,H]=i.useState(!1),[G,X]=i.useState(null),oe=i.useRef(null),[te,ce]=i.useState("table"),[Q,me]=i.useState(""),[xe,de]=i.useState(""),[U,le]=i.useState(""),[K,Z]=i.useState(["",""]),[re,ge]=i.useState([]),[ue,ee]=i.useState(!1),[V,F]=i.useState(!1),[ne]=i.useState(!1),[be,Me]=i.useState(!1),Ce=(Qs=t==null?void 0:t.auth_settings)==null?void 0:Qs.auth_factors_enabled,Se=(Js=(Xs=t==null?void 0:t.auth_settings)==null?void 0:Xs.password)==null?void 0:Js.enabled;if(!(Ce!=null&&Ce.authenticator)&&!(Ce!=null&&Ce.backup_code)&&!Se)return null;const Ve=async(ae,De)=>{await o(ae,De),await r.refetch(),x("Password updated successfully","info")},Le=async ae=>{await n(ae),await r.refetch(),x("Password removed successfully","info")},Ae=()=>{var na,sa,aa,ia,ca,la;if(!r)return!1;const ae=(na=r.user_email_addresses)==null?void 0:na.some(Dr=>Dr.verified),De=(sa=r.user_phone_numbers)==null?void 0:sa.some(Dr=>Dr.verified),Ne=r.social_connections&&r.social_connections.length>0,et=t==null?void 0:t.auth_settings;return(et==null?void 0:et.first_factor)==="email_otp"&&ae||((aa=et==null?void 0:et.magic_link)==null?void 0:aa.enabled)&&ae||((ia=et==null?void 0:et.passkey)==null?void 0:ia.enabled)||((ca=et==null?void 0:et.auth_factors_enabled)==null?void 0:ca.phone_otp)&&De||Ne&&((la=t==null?void 0:t.social_connections)==null?void 0:la.some(Dr=>Dr.enabled))},ve=async()=>{if(K.some(ae=>ae.length!==6)){x("Please enter both 6-digit verification codes","error");return}try{if(F(!0),await a(U,K),await r.refetch(),Ce!=null&&Ce.backup_code){const ae=await f();ge(ae),await r.refetch(),ce("backup")}else ce("success")}catch(ae){x(ae.message||"Invalid verification codes","error")}finally{F(!1)}},pe=()=>{ce("table"),me(""),de(""),le(""),Z(["",""]),ge([]),x("Two-factor authentication setup completed successfully!","info")},ye=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{Me(!0),await h(r.user_authenticator.id),await r.refetch(),$(!1),x("Two-factor authentication removed successfully","info")}catch(De){x(De.message||"Failed to remove authenticator","error")}finally{Me(!1)}},$e=async()=>{if(!ue)try{ee(!0);const ae=await c();ge(ae),await r.refetch(),j(!0),x("New backup codes generated","info")}catch(ae){x(ae.message||"Failed to generate backup codes","error")}finally{ee(!1)}},Ie=()=>{const ae=re.join(`
4287
4287
  `);navigator.clipboard.writeText(ae).then(()=>{x("Backup codes copied to clipboard","info")}).catch(()=>{x("Failed to copy backup codes","error")})},Ge=()=>{const ae=re.join(`
4288
- `),De=new Blob([ae],{type:"text/plain"}),Ne=URL.createObjectURL(De),et=document.createElement("a");et.href=Ne,et.download="wacht-backup-codes.txt",et.click(),URL.revokeObjectURL(Ne),x("Backup codes downloaded","info")},no=async()=>{var ae,De;if((De=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.passkey)!=null&&De.enabled)try{L(!0);const Ne=await d();N(Ne.data||[])}catch(Ne){console.error("Failed to load passkeys:",Ne)}finally{L(!1)}},Fd=async ae=>{try{A(!0),await p(ae||void 0),await no(),x("Passkey registered successfully!","info")}catch(De){throw x(De.message||"Failed to register passkey","error"),De}finally{A(!1)}},Bd=async ae=>{try{await m(ae),await no(),x("Passkey removed","info")}catch(De){x(De.message||"Failed to remove passkey","error")}};i.useEffect(()=>{no()},[(ta=(ea=t==null?void 0:t.auth_settings)==null?void 0:ea.passkey)==null?void 0:ta.enabled]);const Lt=[];return Se&&Lt.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"]}),(oa=(ra=t==null?void 0:t.auth_settings)==null?void 0:ra.passkey)!=null&&oa.enabled&&Lt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:O.length>0?`${O.length} registered`:"",actions:O.length>0?["manage","add"]:["add"]}),Ce!=null&&Ce.authenticator&&Lt.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&&Lt.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&&Lt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),te!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(tn,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[te==="qr"&&"Setup Two-Factor Authentication",te==="verify"&&"Verify Your Authenticator",te==="backup"&&"Save Your Backup Codes",te==="success"&&"Setup Complete!"]})]}),e.jsx(J,{onClick:()=>ce("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:[te==="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:ne?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:`${c1} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Zs,{value:Q,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:ve||"Loading..."})]}),e.jsx(J,{onClick:()=>ce("verify"),disabled:!Q||!ve,style:{padding:"10px 20px",background:!Q||!ve?"var(--color-border)":"var(--color-primary)",color:!Q||!ve?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!ve?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!ve?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="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(se,{type:"text",placeholder:"000000",value:K[0],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([De,K[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(se,{type:"text",placeholder:"000000",value:K[1],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([K[0],De])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(J,{onClick:()=>ce("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(J,{onClick:xe,disabled:V||K.some(ae=>ae.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:V?"Verifying...":"Verify & Continue"})]})]}),te==="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(jt,{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:re.map((ae,De)=>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(ae),children:ae},De))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(J,{onClick:Ie,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(J,{onClick:Ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(pn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(J,{onClick:ge,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(tt,{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(J,{onClick:ge,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(tn,{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"})})}),Lt.length?e.jsx("div",{children:Lt.map((ae,De)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:ae.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ae.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[ae.status&&ae.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ae.status}),e.jsxs("div",{style:{position:"relative"},children:[ae.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(J,{ref:R,onClick:()=>y(!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"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve})]}),Ae()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:M,onClick:()=>_(!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(Bv,{triggerRef:M,onClose:()=>_(!1),onRemovePassword:Le})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!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"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:T,onClick:()=>z(!0),disabled:ne,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:ne?"Setting up...":"Setup"}),C&&e.jsx(Rv,{triggerRef:T,onClose:()=>z(!1),onSetupTOTP:async()=>{const Ne=await s();return le(Ne.id),Ne},onVerifyTOTP:async Ne=>{await a(U,Ne),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>$(!0),disabled:be,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:be?"not-allowed":"pointer",opacity:be?.6:1},children:be?"Removing...":"Remove"}),k&&e.jsx(Mr,{title:"Remove MFA and reset policy to default?",onConfirm:_e,onCancel:()=>$(!1)})]}),ae.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:I,onClick:$e,disabled:ue,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:ue?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(Yv,{triggerRef:I,codes:re,onClose:()=>j(!1),onCopy:Ie,onDownload:Ge})]})}),ae.id==="second_factor_policy"&&e.jsx(mr,{checked:v==="enforced",onChange:Ne=>{S(Ne?"enforced":"none")}}),ae.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(J,{onClick:()=>Y(!q),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[q?"Hide":"Manage"," (",O.length,")",e.jsx(Ut,{size:14,style:{transform:q?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:oe,onClick:()=>H(!0),disabled:P,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:P?"not-allowed":"pointer",opacity:P?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:P?"Registering...":"Add"}),B&&e.jsx(e1,{triggerRef:oe,onClose:()=>H(!1),onAddPasskey:Fd})]})]})]})]})]}),ae.id==="passkey"&&q&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Re,{})}):O.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:O.map(Ne=>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:Ne.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Ne.device_type==="platform"?"This device":"Security key",Ne.last_used_at&&` • Last used ${new Date(Ne.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>X(Ne.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"}),G===Ne.id&&e.jsx(Mr,{title:`Remove "${Ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Bd(Ne.id),X(null)},onCancel:()=>X(null)})]})]},Ne.id))})}),De<Lt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ae.id))}):e.jsx(xt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},y1=()=>{var D,L;const{deployment:t}=ye(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=Gt(),{toast:a}=Yt(),[h,f]=i.useState(""),[c,u]=i.useState(""),[d,p]=i.useState(""),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(!1),[S,C]=i.useState(""),[z,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),u(r.last_name||""),p(r.username||""),w(r.profile_picture_url||null),x(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const P={};h!==r.first_name&&(P.first_name=h),c!==r.last_name&&(P.last_name=c),d!==r.username&&(P.username=d),Object.keys(P).length>0&&await o(P)}catch(P){a(P.message||"Failed to save profile changes","error")}},[r,o,h,c,d,a]),_=P=>{f(P.target.value)},E=P=>{u(P.target.value)},j=P=>{p(P.target.value)},T=()=>{g()},R=()=>{g()},M=()=>{g()},I=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];w(URL.createObjectURL(q)),setTimeout(async()=>{try{await n(q),r.refetch(),a("Profile picture updated successfully","info")}catch(Y){a(Y.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const N=async()=>{if(!(!r||S!==r.username)){$(!0);try{await s(""),a("Account deleted successfully","info")}catch(P){a(P.message||"Failed to delete account","error")}finally{$(!1),C(""),b(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:z?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,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:[z?e.jsx("img",{src:z,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ko,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),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("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=y.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(pn,{size:14}),z?"Change":"Upload"]}),e.jsxs(J,{onClick:async()=>{w(null),y.current&&(y.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(P){a(P.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(jt,{size:14}),"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("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(pe,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(se,{id:"firstName",type:"text",value:h,onChange:_,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(pe,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(se,{id:"lastName",type:"text",value:c,onChange:E,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{id:"username",type:"text",value:d,onChange:j,onBlur:M,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:v?"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(J,{onClick:()=>{v?(b(!1),C("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(pe,{children:[e.jsx(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(se,{id:"confirm_username",type:"text",value:S,onChange:P=>C(P.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(J,{onClick:N,disabled:S!==(r==null?void 0:r.username)||k,style:{background:S===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:S===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:S===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:S===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:k?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Pd=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(Ed,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),w1=l.div`
4288
+ `),De=new Blob([ae],{type:"text/plain"}),Ne=URL.createObjectURL(De),et=document.createElement("a");et.href=Ne,et.download="wacht-backup-codes.txt",et.click(),URL.revokeObjectURL(Ne),x("Backup codes downloaded","info")},no=async()=>{var ae,De;if((De=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.passkey)!=null&&De.enabled)try{L(!0);const Ne=await d();N(Ne.data||[])}catch(Ne){console.error("Failed to load passkeys:",Ne)}finally{L(!1)}},Bd=async ae=>{try{A(!0),await p(ae||void 0),await no(),x("Passkey registered successfully!","info")}catch(De){throw x(De.message||"Failed to register passkey","error"),De}finally{A(!1)}},Ud=async ae=>{try{await m(ae),await no(),x("Passkey removed","info")}catch(De){x(De.message||"Failed to remove passkey","error")}};i.useEffect(()=>{no()},[(ta=(ea=t==null?void 0:t.auth_settings)==null?void 0:ea.passkey)==null?void 0:ta.enabled]);const Lt=[];return Se&&Lt.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"]}),(oa=(ra=t==null?void 0:t.auth_settings)==null?void 0:ra.passkey)!=null&&oa.enabled&&Lt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:O.length>0?`${O.length} registered`:"",actions:O.length>0?["manage","add"]:["add"]}),Ce!=null&&Ce.authenticator&&Lt.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&&Lt.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&&Lt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),te!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(tn,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(pt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[te==="qr"&&"Setup Two-Factor Authentication",te==="verify"&&"Verify Your Authenticator",te==="backup"&&"Save Your Backup Codes",te==="success"&&"Setup Complete!"]})]}),e.jsx(J,{onClick:()=>ce("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:[te==="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:ne?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:`${c1} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Zs,{value:Q,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:xe||"Loading..."})]}),e.jsx(J,{onClick:()=>ce("verify"),disabled:!Q||!xe,style:{padding:"10px 20px",background:!Q||!xe?"var(--color-border)":"var(--color-primary)",color:!Q||!xe?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!xe?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!xe?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="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(se,{type:"text",placeholder:"000000",value:K[0],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([De,K[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(se,{type:"text",placeholder:"000000",value:K[1],onChange:ae=>{const De=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);Z([K[0],De])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(J,{onClick:()=>ce("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(J,{onClick:ve,disabled:V||K.some(ae=>ae.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:V?"Verifying...":"Verify & Continue"})]})]}),te==="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(jt,{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:re.map((ae,De)=>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(ae),children:ae},De))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(J,{onClick:Ie,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(J,{onClick:Ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(pn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(J,{onClick:pe,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(tt,{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(J,{onClick:pe,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(tn,{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"})})}),Lt.length?e.jsx("div",{children:Lt.map((ae,De)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:ae.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ae.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[ae.status&&ae.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ae.status==="Enabled"||ae.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ae.status}),e.jsxs("div",{style:{position:"relative"},children:[ae.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(J,{ref:R,onClick:()=>y(!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"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve})]}),Ae()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:M,onClick:()=>_(!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(Bv,{triggerRef:M,onClose:()=>_(!1),onRemovePassword:Le})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:R,onClick:()=>y(!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"}),w&&e.jsx(Zi,{triggerRef:R,onClose:()=>y(!1),onChangePassword:Ve,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:T,onClick:()=>z(!0),disabled:ne,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:ne?"Setting up...":"Setup"}),C&&e.jsx(Rv,{triggerRef:T,onClose:()=>z(!1),onSetupTOTP:async()=>{const Ne=await s();return le(Ne.id),Ne},onVerifyTOTP:async Ne=>{await a(U,Ne),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>$(!0),disabled:be,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:be?"not-allowed":"pointer",opacity:be?.6:1},children:be?"Removing...":"Remove"}),k&&e.jsx(Mr,{title:"Remove MFA and reset policy to default?",onConfirm:ye,onCancel:()=>$(!1)})]}),ae.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:I,onClick:$e,disabled:ue,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:ue?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(Yv,{triggerRef:I,codes:re,onClose:()=>j(!1),onCopy:Ie,onDownload:Ge})]})}),ae.id==="second_factor_policy"&&e.jsx(mr,{checked:v==="enforced",onChange:Ne=>{S(Ne?"enforced":"none")}}),ae.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(J,{onClick:()=>Y(!q),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[q?"Hide":"Manage"," (",O.length,")",e.jsx(Ut,{size:14,style:{transform:q?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{ref:oe,onClick:()=>H(!0),disabled:P,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:P?"not-allowed":"pointer",opacity:P?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:P?"Registering...":"Add"}),B&&e.jsx(e1,{triggerRef:oe,onClose:()=>H(!1),onAddPasskey:Bd})]})]})]})]})]}),ae.id==="passkey"&&q&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Re,{})}):O.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:O.map(Ne=>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:Ne.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Ne.device_type==="platform"?"This device":"Security key",Ne.last_used_at&&` • Last used ${new Date(Ne.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(J,{onClick:()=>X(Ne.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"}),G===Ne.id&&e.jsx(Mr,{title:`Remove "${Ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Ud(Ne.id),X(null)},onCancel:()=>X(null)})]})]},Ne.id))})}),De<Lt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ae.id))}):e.jsx(xt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},y1=()=>{var D,L;const{deployment:t}=we(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=Gt(),{toast:a}=Yt(),[h,f]=i.useState(""),[c,u]=i.useState(""),[d,p]=i.useState(""),[m,x]=i.useState(!1),[v,b]=i.useState(!1),[k,$]=i.useState(!1),[S,C]=i.useState(""),[z,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),u(r.last_name||""),p(r.username||""),w(r.profile_picture_url||null),x(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const P={};h!==r.first_name&&(P.first_name=h),c!==r.last_name&&(P.last_name=c),d!==r.username&&(P.username=d),Object.keys(P).length>0&&await o(P)}catch(P){a(P.message||"Failed to save profile changes","error")}},[r,o,h,c,d,a]),_=P=>{f(P.target.value)},E=P=>{u(P.target.value)},j=P=>{p(P.target.value)},T=()=>{g()},R=()=>{g()},M=()=>{g()},I=P=>{var A;if((A=P.target.files)!=null&&A[0]){const q=P.target.files[0];w(URL.createObjectURL(q)),setTimeout(async()=>{try{await n(q),r.refetch(),a("Profile picture updated successfully","info")}catch(Y){a(Y.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const N=async()=>{if(!(!r||S!==r.username)){$(!0);try{await s(""),a("Account deleted successfully","info")}catch(P){a(P.message||"Failed to delete account","error")}finally{$(!1),C(""),b(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:z?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,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:[z?e.jsx("img",{src:z,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ko,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),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("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(J,{onClick:()=>{var P;return(P=y.current)==null?void 0:P.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(pn,{size:14}),z?"Change":"Upload"]}),e.jsxs(J,{onClick:async()=>{w(null),y.current&&(y.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(P){a(P.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(jt,{size:14}),"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("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(se,{id:"firstName",type:"text",value:h,onChange:_,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(se,{id:"lastName",type:"text",value:c,onChange:E,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(se,{id:"username",type:"text",value:d,onChange:j,onBlur:M,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:v?"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(J,{onClick:()=>{v?(b(!1),C("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(se,{id:"confirm_username",type:"text",value:S,onChange:P=>C(P.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(J,{onClick:N,disabled:S!==(r==null?void 0:r.username)||k,style:{background:S===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:S===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:S===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:S===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:k?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Id=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:h,children:f,showCloseButton:c})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ze.Header,{showCloseButton:c,children:s||o}),h||f||e.jsx(Pd,{}),a&&e.jsx(ze.Footer,{children:a})]})})}),w1=l.div`
4289
4289
  position: relative;
4290
4290
  `,j1=l.button`
4291
4291
  display: flex;
@@ -4298,7 +4298,7 @@ cursor: pointer;
4298
4298
  transition: background-color 0.2s ease;
4299
4299
  `,ss=l.div`
4300
4300
  position: relative;
4301
- `,Id=l.div`
4301
+ `,Rd=l.div`
4302
4302
  width: 36px;
4303
4303
  height: 36px;
4304
4304
  border-radius: 50%;
@@ -4369,7 +4369,7 @@ cursor: pointer;
4369
4369
  display: flex;
4370
4370
  align-items: center;
4371
4371
  justify-content: space-between;
4372
- `,sc=l(Id)`
4372
+ `,sc=l(Rd)`
4373
4373
  width: 40px;
4374
4374
  height: 40px;
4375
4375
  `,ac=l.div`
@@ -4424,7 +4424,7 @@ cursor: pointer;
4424
4424
  width: 14px;
4425
4425
  height: 14px;
4426
4426
  }
4427
- `,Ks=({showName:t=!0})=>{var y,g,_,E;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=ld({triggerRef:n,isOpen:r,minWidth:380}),h=Zr(!1),{session:f,signOut:c,switchSignIn:u,refetch:d}=Qe(),{navigateToSignIn:p}=rt(),{deployment:m}=ye(),x=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,v=((_=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:_.enabled)??!1,b=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,O;const M=R.target;(I=n.current)!=null&&I.contains(M)||(O=s.current)!=null&&O.contains(M)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const k=()=>{o(!r)},$=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),S=async j=>{try{await c(j),await d(),o(!1)}catch{}},C=async()=>{try{await c(),await d(),o(!1)}catch{}},z=async j=>{try{await u(j),await d(),o(!1)}catch{}},w=()=>{h.open(),o(!1)};return e.jsx(he,{children:e.jsxs(w1,{children:[e.jsxs(j1,{ref:n,onClick:k,children:[e.jsx(ss,{children:e.jsx(Id,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(k1,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&eo.createPortal(e.jsx(he,{children:e.jsx(_1,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const M=T.user.id===(x==null?void 0:x.id),I=R.user.id===(x==null?void 0:x.id);return M&&!I?-1:!M&&I?1:0});return j.map(({user:T,id:R},M)=>{const I=T.id===(x==null?void 0:x.id),O=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(tc,{$isClickable:O,onClick:O?()=>z(R):void 0,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):$(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(ec,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>S(R),children:[e.jsx(Ft,{}),"Sign out"]})]})]}),M===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(tc,{$isClickable:!1,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(ec,{children:x.primary_email_address.email})]})]}),e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>{var j;return S(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Ft,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ic,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(cc,{onClick:()=>p(),children:[e.jsx(it,{}),"Add new account"]})}),b&&e.jsx(ic,{children:e.jsxs(cc,{onClick:C,children:[e.jsx(Ft,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Pd,{isOpen:h.isOpen,onClose:h.close})]})})},C1=l.div`
4427
+ `,Ks=({showName:t=!0})=>{var y,g,_,E;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=dd({triggerRef:n,isOpen:r,minWidth:380}),h=Zr(!1),{session:f,signOut:c,switchSignIn:u,refetch:d}=Qe(),{navigateToSignIn:p}=rt(),{deployment:m}=we(),x=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,v=((_=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:_.enabled)??!1,b=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,O;const M=R.target;(I=n.current)!=null&&I.contains(M)||(O=s.current)!=null&&O.contains(M)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const k=()=>{o(!r)},$=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),S=async j=>{try{await c(j),await d(),o(!1)}catch{}},C=async()=>{try{await c(),await d(),o(!1)}catch{}},z=async j=>{try{await u(j),await d(),o(!1)}catch{}},w=()=>{h.open(),o(!1)};return e.jsx(fe,{children:e.jsxs(w1,{children:[e.jsxs(j1,{ref:n,onClick:k,children:[e.jsx(ss,{children:e.jsx(Rd,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(k1,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&eo.createPortal(e.jsx(fe,{children:e.jsx(_1,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const M=T.user.id===(x==null?void 0:x.id),I=R.user.id===(x==null?void 0:x.id);return M&&!I?-1:!M&&I?1:0});return j.map(({user:T,id:R},M)=>{const I=T.id===(x==null?void 0:x.id),O=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(tc,{$isClickable:O,onClick:O?()=>z(R):void 0,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):$(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(ec,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>S(R),children:[e.jsx(Ft,{}),"Sign out"]})]})]}),M===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(tc,{$isClickable:!1,children:[e.jsxs(rc,{children:[e.jsx(ss,{children:e.jsx(sc,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(oc,{children:[e.jsx(nc,{children:e.jsx(Ji,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(ec,{children:x.primary_email_address.email})]})]}),e.jsxs(ac,{children:[e.jsxs(Lo,{onClick:w,children:[e.jsx(hr,{}),"Manage account"]}),e.jsxs(Lo,{$destructive:!0,onClick:()=>{var j;return S(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Ft,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(ic,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(cc,{onClick:()=>p(),children:[e.jsx(it,{}),"Add new account"]})}),b&&e.jsx(ic,{children:e.jsxs(cc,{onClick:C,children:[e.jsx(Ft,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Id,{isOpen:h.isOpen,onClose:h.close})]})})},C1=l.div`
4428
4428
  padding: var(--space-md) var(--space-lg);
4429
4429
  background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
4430
4430
  transition: all 0.2s ease;
@@ -4533,7 +4533,7 @@ cursor: pointer;
4533
4533
  width: 12px;
4534
4534
  height: 12px;
4535
4535
  }
4536
- `;function Rd({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const h=new Date(a),c=new Date().getTime()-h.getTime(),u=Math.floor(c/1e3),d=Math.floor(u/60),p=Math.floor(d/60),m=Math.floor(p/24);return m>7?h.toLocaleDateString():m>0?`${m}d ago`:p>0?`${p}h ago`:d>0?`${d}m ago`:"Just now"};return e.jsxs(C1,{$unread:!t.is_read,onClick:n,children:[e.jsxs(S1,{children:[e.jsxs($1,{children:[e.jsx(E1,{$severity:t.severity}),e.jsx(z1,{children:t.title})]}),e.jsx(M1,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(lt,{})})]}),e.jsx(P1,{children:t.body}),e.jsxs(I1,{children:[e.jsx(R1,{children:s(t.created_at)}),t.action_url&&e.jsx(T1,{children:e.jsxs(O1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(Ns,{})]})})]})]})}const A1=l.div`
4536
+ `;function Td({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const h=new Date(a),c=new Date().getTime()-h.getTime(),u=Math.floor(c/1e3),d=Math.floor(u/60),p=Math.floor(d/60),m=Math.floor(p/24);return m>7?h.toLocaleDateString():m>0?`${m}d ago`:p>0?`${p}h ago`:d>0?`${d}m ago`:"Just now"};return e.jsxs(C1,{$unread:!t.is_read,onClick:n,children:[e.jsxs(S1,{children:[e.jsxs($1,{children:[e.jsx(E1,{$severity:t.severity}),e.jsx(z1,{children:t.title})]}),e.jsx(M1,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(lt,{})})]}),e.jsx(P1,{children:t.body}),e.jsxs(I1,{children:[e.jsx(R1,{children:s(t.created_at)}),t.action_url&&e.jsx(T1,{children:e.jsxs(O1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(Ns,{})]})})]})]})}const A1=l.div`
4537
4537
  position: fixed;
4538
4538
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4539
4539
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4644,7 +4644,7 @@ cursor: pointer;
4644
4644
  color: var(--color-primary-hover);
4645
4645
  text-decoration: underline;
4646
4646
  }
4647
- `,Td=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},h)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(A1,{ref:h,$position:t,children:[e.jsxs(L1,{children:[e.jsx(D1,{children:"Notifications"}),f&&e.jsx(N1,{onClick:s,children:"Mark all as read"})]}),e.jsx(F1,{children:o?e.jsx(B1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(U1,{children:[e.jsx(W1,{children:e.jsx(ph,{})}),e.jsx(V1,{children:"No notifications"}),e.jsx(G1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Rd,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(H1,{children:e.jsx(q1,{href:"/notifications",children:"View all notifications"})})]})}),Y1=l.div`
4647
+ `,Md=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},h)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(A1,{ref:h,$position:t,children:[e.jsxs(L1,{children:[e.jsx(D1,{children:"Notifications"}),f&&e.jsx(N1,{onClick:s,children:"Mark all as read"})]}),e.jsx(F1,{children:o?e.jsx(B1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(U1,{children:[e.jsx(W1,{children:e.jsx(hh,{})}),e.jsx(V1,{children:"No notifications"}),e.jsx(G1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Td,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(H1,{children:e.jsx(q1,{href:"/notifications",children:"View all notifications"})})]})}),Y1=l.div`
4648
4648
  position: relative;
4649
4649
  `,Z1=l.div`
4650
4650
  width: 40px;
@@ -4707,11 +4707,11 @@ cursor: pointer;
4707
4707
  justify-content: center;
4708
4708
  border: 2px solid var(--color-background);
4709
4709
  box-shadow: 0 1px 3px var(--color-shadow);
4710
- `;function Md({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,h]=i.useState(!1),[f,c]=i.useState(),u=i.useRef(null),d=i.useRef(null),p={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:b,markAllAsRead:k,deleteNotification:$}=Qc(p);return i.useEffect(()=>{if(!a)return;const S=setTimeout(()=>{const C=z=>{var y,g;const w=z.target;(y=u.current)!=null&&y.contains(w)||(g=d.current)!=null&&g.contains(w)||h(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},50);return()=>{clearTimeout(S)}},[a]),i.useEffect(()=>{if(a&&u.current){const S=u.current.getBoundingClientRect(),C=400,z=600,w=window.innerWidth,y=window.innerHeight,g=w-S.left,_=y-S.bottom,E=S.top;let j,T;g>=C?j=S.left:T=w-S.right;let R,M;_>=z+8?R=S.bottom+8:E>=z+8?M=y-S.top+8:R=S.bottom+8,c({top:R,bottom:M,left:j,right:T})}else c(void 0)},[a]),e.jsx(he,{children:e.jsxs(Y1,{ref:u,className:t,children:[e.jsx(Z1,{children:e.jsxs(K1,{onClick:()=>h(!a),children:[e.jsx(fh,{size:16}),r&&m>0&&e.jsx(Q1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&eo.createPortal(e.jsx(he,{children:e.jsx(Td,{ref:d,position:f,notifications:x,loading:v,onMarkAsRead:b,onMarkAllAsRead:k,onDelete:$})}),document.body)]})})}const X1=l.div`
4710
+ `;function Od({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,h]=i.useState(!1),[f,c]=i.useState(),u=i.useRef(null),d=i.useRef(null),p={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:b,markAllAsRead:k,deleteNotification:$}=Qc(p);return i.useEffect(()=>{if(!a)return;const S=setTimeout(()=>{const C=z=>{var y,g;const w=z.target;(y=u.current)!=null&&y.contains(w)||(g=d.current)!=null&&g.contains(w)||h(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},50);return()=>{clearTimeout(S)}},[a]),i.useEffect(()=>{if(a&&u.current){const S=u.current.getBoundingClientRect(),C=400,z=600,w=window.innerWidth,y=window.innerHeight,g=w-S.left,_=y-S.bottom,E=S.top;let j,T;g>=C?j=S.left:T=w-S.right;let R,M;_>=z+8?R=S.bottom+8:E>=z+8?M=y-S.top+8:R=S.bottom+8,c({top:R,bottom:M,left:j,right:T})}else c(void 0)},[a]),e.jsx(fe,{children:e.jsxs(Y1,{ref:u,className:t,children:[e.jsx(Z1,{children:e.jsxs(K1,{onClick:()=>h(!a),children:[e.jsx(gh,{size:16}),r&&m>0&&e.jsx(Q1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&eo.createPortal(e.jsx(fe,{children:e.jsx(Md,{ref:d,position:f,notifications:x,loading:v,onMarkAsRead:b,onMarkAllAsRead:k,onDelete:$})}),document.body)]})})}const X1=l.div`
4711
4711
  display: flex;
4712
4712
  align-items: center;
4713
4713
  gap: 8px;
4714
- `,J1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(X1,{children:[r&&e.jsx(Md,{}),e.jsx(Ks,{showName:t})]}),eb=({children:t})=>{var a;const{session:r,loading:o}=Qe(),{deployment:n}=ye(),{navigateToAccountSelection:s}=rt();return i.useEffect(()=>{var h;o||(h=r==null?void 0:r.signins)!=null&&h.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},tb=({children:t})=>{var n;const{loading:r,session:o}=Qe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Od=Ht`
4714
+ `,J1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(X1,{children:[r&&e.jsx(Od,{}),e.jsx(Ks,{showName:t})]}),eb=({children:t})=>{var a;const{session:r,loading:o}=Qe(),{deployment:n}=we(),{navigateToAccountSelection:s}=rt();return i.useEffect(()=>{var h;o||(h=r==null?void 0:r.signins)!=null&&h.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},tb=({children:t})=>{var n;const{loading:r,session:o}=Qe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Ad=Ht`
4715
4715
  0% {
4716
4716
  background-position: -1000px 0;
4717
4717
  }
@@ -4907,7 +4907,7 @@ cursor: pointer;
4907
4907
  var(--color-background-hover) 100%
4908
4908
  );
4909
4909
  background-size: 1000px 100%;
4910
- animation: ${Od} 2s infinite linear;
4910
+ animation: ${Ad} 2s infinite linear;
4911
4911
  `,pb=l.div`
4912
4912
  flex: 1;
4913
4913
  display: flex;
@@ -4924,7 +4924,7 @@ cursor: pointer;
4924
4924
  var(--color-background-hover) 100%
4925
4925
  );
4926
4926
  background-size: 1000px 100%;
4927
- animation: ${Od} 2s infinite linear;
4927
+ animation: ${Ad} 2s infinite linear;
4928
4928
  `,hb=l.p`
4929
4929
  margin-top: var(--space-lg);
4930
4930
  text-align: center;
@@ -4940,7 +4940,7 @@ cursor: pointer;
4940
4940
  &:hover {
4941
4941
  color: var(--color-primary-hover);
4942
4942
  }
4943
- `,gb=({onAccountSelect:t,showAddAccount:r=!0})=>{var z,w,y,g,_;const{session:o,loading:n,switchSignIn:s,signOut:a}=Qe(),{deployment:h}=ye(),{navigateToSignIn:f,navigate:c}=rt(),[u,d]=i.useState(null),[p,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],b=((w=(z=h==null?void 0:h.auth_settings)==null?void 0:z.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||v.length||f()},[n,v,f]);const k=E=>E.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),$=async E=>{var j;if(!(E===(x==null?void 0:x.id)||p)){m(E);try{if(await s(E),t)t(E),m(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(T){console.error("Failed to switch account:",T),m(null)}}},S=async(E,j)=>{E.stopPropagation(),d(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{d(null)}},C=()=>{var j;let E=new URLSearchParams(window.location.search).get("redirect_uri");E||(E=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),f(E)};return n?e.jsx(he,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",((y=h==null?void 0:h.ui_settings)==null?void 0:y.app_name)||"App"]})]}),e.jsx(dc,{children:[1,2].map(E=>e.jsxs(db,{children:[e.jsx(ub,{}),e.jsxs(pb,{children:[e.jsx(fc,{}),e.jsx(fc,{$width:"small"})]})]},E))})]})}):v.length?e.jsx(he,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",(g=h==null?void 0:h.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(dc,{children:[v.map(({user:E,id:j})=>{var I,O,N,D,L;if(!E)return null;const T=j===(x==null?void 0:x.id),R=p===j,M=`${E.first_name||""} ${E.last_name||""}`.trim();return e.jsxs(ob,{$isActive:T,$isSwitching:R,onClick:()=>$(j),children:[e.jsx(nb,{children:E.has_profile_picture?e.jsx("img",{src:E.profile_picture_url,alt:M}):k(M||((I=E.primary_email_address)==null?void 0:I.email)||((O=E.primary_phone_number)==null?void 0:O.phone_number)||E.username||"U")}),e.jsxs(sb,{children:[e.jsx(ab,{children:M||((N=E.primary_email_address)==null?void 0:N.email)||((D=E.primary_phone_number)==null?void 0:D.phone_number)||E.username||"User"}),e.jsx(ib,{children:((L=E.primary_email_address)==null?void 0:L.email)||E.username})]}),!R&&e.jsxs(cb,{onClick:P=>S(P,j),$isLoading:u===j,disabled:u===j,children:[u===j?e.jsx(yt,{size:12}):e.jsx(Ft,{size:12}),u===j?"Signing out...":"Sign out"]})]},j)}),r&&b&&e.jsxs(lb,{onClick:C,children:[e.jsx(it,{}),"Add another account"]})]}),e.jsxs(hb,{children:["Don't have an account?"," ",e.jsx(fb,{children:e.jsx(ht,{to:`${(_=h.ui_settings)==null?void 0:_.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},mb=()=>{const{navigateToSignIn:t}=rt();return i.useEffect(()=>{t()},[t]),null},xb=()=>{const{navigateToSignUp:t}=rt();return i.useEffect(()=>{t()},[t]),null},vb=l.div`
4943
+ `,gb=({onAccountSelect:t,showAddAccount:r=!0})=>{var z,w,y,g,_;const{session:o,loading:n,switchSignIn:s,signOut:a}=Qe(),{deployment:h}=we(),{navigateToSignIn:f,navigate:c}=rt(),[u,d]=i.useState(null),[p,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],b=((w=(z=h==null?void 0:h.auth_settings)==null?void 0:z.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||v.length||f()},[n,v,f]);const k=E=>E.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),$=async E=>{var j;if(!(E===(x==null?void 0:x.id)||p)){m(E);try{if(await s(E),t)t(E),m(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(T){console.error("Failed to switch account:",T),m(null)}}},S=async(E,j)=>{E.stopPropagation(),d(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{d(null)}},C=()=>{var j;let E=new URLSearchParams(window.location.search).get("redirect_uri");E||(E=(j=h.ui_settings)==null?void 0:j.after_signin_redirect_url),f(E)};return n?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",((y=h==null?void 0:h.ui_settings)==null?void 0:y.app_name)||"App"]})]}),e.jsx(dc,{children:[1,2].map(E=>e.jsxs(db,{children:[e.jsx(ub,{}),e.jsxs(pb,{children:[e.jsx(fc,{}),e.jsx(fc,{$width:"small"})]})]},E))})]})}):v.length?e.jsx(fe,{children:e.jsxs(lc,{children:[e.jsx(Oe,{}),e.jsxs(uc,{children:[e.jsx(pc,{children:"Choose an account"}),e.jsxs(hc,{children:["to continue to ",(g=h==null?void 0:h.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(dc,{children:[v.map(({user:E,id:j})=>{var I,O,N,D,L;if(!E)return null;const T=j===(x==null?void 0:x.id),R=p===j,M=`${E.first_name||""} ${E.last_name||""}`.trim();return e.jsxs(ob,{$isActive:T,$isSwitching:R,onClick:()=>$(j),children:[e.jsx(nb,{children:E.has_profile_picture?e.jsx("img",{src:E.profile_picture_url,alt:M}):k(M||((I=E.primary_email_address)==null?void 0:I.email)||((O=E.primary_phone_number)==null?void 0:O.phone_number)||E.username||"U")}),e.jsxs(sb,{children:[e.jsx(ab,{children:M||((N=E.primary_email_address)==null?void 0:N.email)||((D=E.primary_phone_number)==null?void 0:D.phone_number)||E.username||"User"}),e.jsx(ib,{children:((L=E.primary_email_address)==null?void 0:L.email)||E.username})]}),!R&&e.jsxs(cb,{onClick:P=>S(P,j),$isLoading:u===j,disabled:u===j,children:[u===j?e.jsx(yt,{size:12}):e.jsx(Ft,{size:12}),u===j?"Signing out...":"Sign out"]})]},j)}),r&&b&&e.jsxs(lb,{onClick:C,children:[e.jsx(it,{}),"Add another account"]})]}),e.jsxs(hb,{children:["Don't have an account?"," ",e.jsx(fb,{children:e.jsx(ht,{to:`${(_=h.ui_settings)==null?void 0:_.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},mb=()=>{const{navigateToSignIn:t}=rt();return i.useEffect(()=>{t()},[t]),null},xb=()=>{const{navigateToSignUp:t}=rt();return i.useEffect(()=>{t()},[t]),null},vb=l.div`
4944
4944
  width: 100%;
4945
4945
  height: 500px;
4946
4946
  background: var(--color-background);
@@ -5148,10 +5148,10 @@ cursor: pointer;
5148
5148
  margin: 0 auto;
5149
5149
  padding: 6px 16px;
5150
5150
  font-size: 13px;
5151
- `,Eb=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{workspaces:n}=Wt(),{switchOrganization:s,switchWorkspace:a}=Qe(),{deployment:h}=ye(),[f,c]=i.useState(null),[u,d]=i.useState("orgList"),[p,m]=i.useState(null),x=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,v=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,b=i.useRef(!1);i.useEffect(()=>{if(!(b.current||!t)){if(b.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",u,x);const k=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),$=async M=>{if(x){m(M.id),d("workspaceList");return}c(M.id);try{await s(M.id)}finally{c(null)}},S=async M=>{c(M.id);try{await a(M.id)}finally{c(null)}},C=async M=>{await r(),x&&M&&(m(M.id),d("createWorkspace"))},z=()=>{},w=async()=>{m(null),d("orgList")},y=(T=t==null?void 0:t.find(M=>M.organization.id===p))==null?void 0:T.organization,g=p?n==null?void 0:n.filter(M=>M.organization.id===p):[];if(o)return null;if(u==="createOrg")return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:C,onCancel:()=>d("orgList")})});if(u==="createWorkspace"&&p)return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Gs,{organizationId:p,onSuccess:z,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const _=u==="workspaceList",E=_?"Select a workspace":"Select an organization",j=_?`Choose a workspace in ${(y==null?void 0:y.name)||""}`:`to continue to ${((R=h==null?void 0:h.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(vb,{children:[e.jsxs(bb,{children:[e.jsxs("div",{children:[e.jsx(Oe,{}),e.jsxs(Cb,{children:[e.jsx(Sb,{children:E}),e.jsx($b,{children:j})]})]}),e.jsx(Ks,{showName:!0})]}),e.jsxs(yb,{children:[e.jsxs(wb,{children:[e.jsxs(jb,{children:[e.jsx(kb,{children:_?"Workspaces":"Your organizations"}),_&&e.jsxs(_b,{onClick:w,children:[e.jsx(ro,{}),"Go back"]})]}),e.jsx(zb,{children:_?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(M=>{var O,N,D;const I=((O=M.eligibility_restriction)==null?void 0:O.type)!=="none"&&((N=M.eligibility_restriction)==null?void 0:N.type)!==void 0;return e.jsxs(gc,{onClick:()=>!I&&S(M),disabled:f===M.id||I,style:{opacity:I?.7:1},children:[e.jsx(mc,{children:M.image_url?e.jsx(xc,{src:M.image_url,alt:M.name}):k(M.name).charAt(0)}),e.jsxs(vc,{children:[e.jsx(bc,{children:M.name}),e.jsxs(yc,{children:[e.jsx(Qo,{}),"Workspace"]})]}),e.jsx(wc,{children:e.jsx($s,{})}),I&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(D=M.eligibility_restriction)==null?void 0:D.message]})]},M.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No workspaces yet"}),e.jsxs(Cc,{children:["Create your first workspace for"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(Sc,{onClick:()=>d("createWorkspace"),children:[e.jsx(it,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(M=>{var Y,B,H;const I=M.organization,O=n==null?void 0:n.filter(G=>G.organization.id===I.id),N=(O==null?void 0:O.length)||0,D=I.member_count,L=M.roles[0].name,P=M.roles.length-1,A=P>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${P}`:L.charAt(0).toUpperCase()+L.slice(1),q=((Y=M.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((B=M.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(gc,{onClick:()=>!q&&$(I),disabled:f===I.id||q,style:{opacity:q?.7:1},children:[e.jsx(mc,{children:I.image_url?e.jsx(xc,{src:I.image_url,alt:I.name}):k(I.name)}),e.jsxs(vc,{children:[e.jsx(bc,{children:I.name}),e.jsx(yc,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),N," workspace",N!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(xh,{}),A," • ",D," member",D!==1?"s":""]})})]}),e.jsx(wc,{children:e.jsx($s,{})}),q&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(H=M.eligibility_restriction)==null?void 0:H.message]})]},I.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No organizations yet"}),e.jsx(Cc,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Sc,{onClick:()=>d("createOrg"),children:[e.jsx(it,{}),"Create organization"]})]})})]}),_&&g&&g.length>0&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new workspace"]}),!_&&t&&t.length>0&&v&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new organization"]})]})]})},Pb=l(ze.Content)`
5151
+ `,Eb=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ot(),{workspaces:n}=Wt(),{switchOrganization:s,switchWorkspace:a}=Qe(),{deployment:h}=we(),[f,c]=i.useState(null),[u,d]=i.useState("orgList"),[p,m]=i.useState(null),x=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,v=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,b=i.useRef(!1);i.useEffect(()=>{if(!(b.current||!t)){if(b.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",u,x);const k=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),$=async M=>{if(x){m(M.id),d("workspaceList");return}c(M.id);try{await s(M.id)}finally{c(null)}},S=async M=>{c(M.id);try{await a(M.id)}finally{c(null)}},C=async M=>{await r(),x&&M&&(m(M.id),d("createWorkspace"))},z=()=>{},w=async()=>{m(null),d("orgList")},y=(T=t==null?void 0:t.find(M=>M.organization.id===p))==null?void 0:T.organization,g=p?n==null?void 0:n.filter(M=>M.organization.id===p):[];if(o)return null;if(u==="createOrg")return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(xn,{onSuccess:C,onCancel:()=>d("orgList")})});if(u==="createWorkspace"&&p)return e.jsx(ze.Body,{style:{padding:0},children:e.jsx(Gs,{organizationId:p,onSuccess:z,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const _=u==="workspaceList",E=_?"Select a workspace":"Select an organization",j=_?`Choose a workspace in ${(y==null?void 0:y.name)||""}`:`to continue to ${((R=h==null?void 0:h.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(vb,{children:[e.jsxs(bb,{children:[e.jsxs("div",{children:[e.jsx(Oe,{}),e.jsxs(Cb,{children:[e.jsx(Sb,{children:E}),e.jsx($b,{children:j})]})]}),e.jsx(Ks,{showName:!0})]}),e.jsxs(yb,{children:[e.jsxs(wb,{children:[e.jsxs(jb,{children:[e.jsx(kb,{children:_?"Workspaces":"Your organizations"}),_&&e.jsxs(_b,{onClick:w,children:[e.jsx(ro,{}),"Go back"]})]}),e.jsx(zb,{children:_?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(M=>{var O,N,D;const I=((O=M.eligibility_restriction)==null?void 0:O.type)!=="none"&&((N=M.eligibility_restriction)==null?void 0:N.type)!==void 0;return e.jsxs(gc,{onClick:()=>!I&&S(M),disabled:f===M.id||I,style:{opacity:I?.7:1},children:[e.jsx(mc,{children:M.image_url?e.jsx(xc,{src:M.image_url,alt:M.name}):k(M.name).charAt(0)}),e.jsxs(vc,{children:[e.jsx(bc,{children:M.name}),e.jsxs(yc,{children:[e.jsx(Qo,{}),"Workspace"]})]}),e.jsx(wc,{children:e.jsx($s,{})}),I&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(D=M.eligibility_restriction)==null?void 0:D.message]})]},M.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No workspaces yet"}),e.jsxs(Cc,{children:["Create your first workspace for"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(Sc,{onClick:()=>d("createWorkspace"),children:[e.jsx(it,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(M=>{var Y,B,H;const I=M.organization,O=n==null?void 0:n.filter(G=>G.organization.id===I.id),N=(O==null?void 0:O.length)||0,D=I.member_count,L=M.roles[0].name,P=M.roles.length-1,A=P>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${P}`:L.charAt(0).toUpperCase()+L.slice(1),q=((Y=M.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((B=M.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(gc,{onClick:()=>!q&&$(I),disabled:f===I.id||q,style:{opacity:q?.7:1},children:[e.jsx(mc,{children:I.image_url?e.jsx(xc,{src:I.image_url,alt:I.name}):k(I.name)}),e.jsxs(vc,{children:[e.jsx(bc,{children:I.name}),e.jsx(yc,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Qo,{}),N," workspace",N!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(vh,{}),A," • ",D," member",D!==1?"s":""]})})]}),e.jsx(wc,{children:e.jsx($s,{})}),q&&e.jsxs(jc,{children:[e.jsx(jt,{size:14}),(H=M.eligibility_restriction)==null?void 0:H.message]})]},I.id)}):e.jsxs(kc,{children:[e.jsx(_c,{children:"No organizations yet"}),e.jsx(Cc,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Sc,{onClick:()=>d("createOrg"),children:[e.jsx(it,{}),"Create organization"]})]})})]}),_&&g&&g.length>0&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new workspace"]}),!_&&t&&t.length>0&&v&&e.jsxs(J,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:f!==null,children:[e.jsx(it,{size:12}),"Create new organization"]})]})]})},Pb=l(ze.Content)`
5152
5152
  padding: 0;
5153
5153
  max-width: 90vw;
5154
- `,Ib=({children:t})=>{var b,k,$,S;const{loading:r,session:o}=Qe(),{activeOrganization:n}=st(),{activeWorkspace:s,loading:a}=Vt(),{workspaces:h}=Wt(),{deployment:f}=ye(),{organizationMemberships:c}=Ot(),u=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(C=>C.organization.id===(n==null?void 0:n.id)),p=h==null?void 0:h.find(C=>{var z;return C.id===((z=o==null?void 0:o.active_signin)==null?void 0:z.active_workspace_membership_id)}),m=((b=d==null?void 0:d.eligibility_restriction)==null?void 0:b.type)!=="none"&&((k=d==null?void 0:d.eligibility_restriction)==null?void 0:k.type)!==void 0,x=(($=p==null?void 0:p.eligibility_restriction)==null?void 0:$.type)!=="none"&&((S=p==null?void 0:p.eligibility_restriction)==null?void 0:S.type)!==void 0;return r||u&&a?null:(m||x||!n?!1:u?s?h==null?void 0:h.some(z=>z.id===s.id&&z.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(he,{children:e.jsx(ze,{isOpen:!0,children:e.jsx(ze.Overlay,{children:e.jsx(Pb,{style:{width:"850px"},children:e.jsx(Eb,{})})})})})},Rb=l.div`
5154
+ `,Ib=({children:t})=>{var b,k,$,S;const{loading:r,session:o}=Qe(),{activeOrganization:n}=st(),{activeWorkspace:s,loading:a}=Vt(),{workspaces:h}=Wt(),{deployment:f}=we(),{organizationMemberships:c}=Ot(),u=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(C=>C.organization.id===(n==null?void 0:n.id)),p=h==null?void 0:h.find(C=>{var z;return C.id===((z=o==null?void 0:o.active_signin)==null?void 0:z.active_workspace_membership_id)}),m=((b=d==null?void 0:d.eligibility_restriction)==null?void 0:b.type)!=="none"&&((k=d==null?void 0:d.eligibility_restriction)==null?void 0:k.type)!==void 0,x=(($=p==null?void 0:p.eligibility_restriction)==null?void 0:$.type)!=="none"&&((S=p==null?void 0:p.eligibility_restriction)==null?void 0:S.type)!==void 0;return r||u&&a?null:(m||x||!n?!1:u?s?h==null?void 0:h.some(z=>z.id===s.id&&z.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(fe,{children:e.jsx(ze,{isOpen:!0,children:e.jsx(ze.Overlay,{children:e.jsx(Pb,{style:{width:"850px"},children:e.jsx(Eb,{})})})})})},Rb=l.div`
5155
5155
  display: flex;
5156
5156
  gap: 8px;
5157
5157
  flex-wrap: wrap;
@@ -5302,7 +5302,7 @@ cursor: pointer;
5302
5302
  `,as=l.div`
5303
5303
  display: flex;
5304
5304
  justify-content: ${t=>t.$isUser?"flex-end":"flex-start"};
5305
- `,Ad=l.div`
5305
+ `,Ld=l.div`
5306
5306
  max-width: 85%;
5307
5307
  padding: 10px 14px;
5308
5308
  border-radius: 12px;
@@ -5349,7 +5349,7 @@ cursor: pointer;
5349
5349
  opacity: 1;
5350
5350
  }
5351
5351
  }
5352
- `,Zb=l(Ad)`
5352
+ `,Zb=l(Ld)`
5353
5353
  opacity: 0.7;
5354
5354
  position: relative;
5355
5355
  display: inline-block;
@@ -5706,7 +5706,7 @@ cursor: pointer;
5706
5706
  align-items: center;
5707
5707
  justify-content: center;
5708
5708
  overflow: hidden;
5709
- `,Ld=l.button`
5709
+ `,Dd=l.button`
5710
5710
  height: 32px;
5711
5711
  padding: 0 12px;
5712
5712
  border-radius: 8px;
@@ -5746,7 +5746,7 @@ cursor: pointer;
5746
5746
  &:active:not(:disabled) {
5747
5747
  transform: scale(0.98);
5748
5748
  }
5749
- `,Do=l(Ld)`
5749
+ `,Do=l(Dd)`
5750
5750
  width: 32px;
5751
5751
  padding: 0;
5752
5752
  `,uy=l.img`
@@ -5833,7 +5833,7 @@ cursor: pointer;
5833
5833
  &:hover .expand-icon {
5834
5834
  opacity: 1;
5835
5835
  }
5836
- `,my=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:h,onZoom:f,onReset:c,onWheel:u,onMouseDown:d,onMouseMove:p,onMouseUp:m})=>{const[x,v]=i.useState(!1),b=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const k=document.body.style.overflow;document.body.style.overflow="hidden";const $=z=>{(z.ctrlKey||z.metaKey)&&z.preventDefault()},S=z=>{z.preventDefault()},C=z=>{z.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",S,{passive:!1}),document.addEventListener("gesturechange",C,{passive:!1}),()=>{document.body.style.overflow=k,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",S),document.removeEventListener("gesturechange",C)}}},[t]),!x||!t||!r?null:eo.createPortal(e.jsx(he,{children:e.jsx(ly,{ref:b,$isOpen:!0,onClick:k=>{k.target===k.currentTarget&&a()},children:e.jsxs(dy,{onClick:k=>k.stopPropagation(),onWheel:k=>{k.preventDefault(),k.stopPropagation(),u(k)},onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:[e.jsx(uy,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:d,draggable:!1}),e.jsx(Do,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(lt,{size:14})}),e.jsxs(py,{children:[e.jsxs(hy,{children:[e.jsx(Do,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(df,{size:14})}),e.jsxs(fy,{children:[Math.round(o*100),"%"]}),e.jsx(Do,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(cf,{size:14})}),e.jsx(Do,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Uh,{size:14})})]}),e.jsxs(Ld,{$variant:"primary",onClick:h,title:"Download image",children:[e.jsx(pn,{size:14}),"Download"]})]})]})})}),document.body)};function Dd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:h}=rn(),f=a==null?void 0:a.id;if(!f)return e.jsx(he,{style:{height:"100%",width:"100%"},children:e.jsx($c,{children:e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,u=!0,d="Start a conversation by typing a message below",[p,m]=i.useState(""),[x,v]=i.useState(!1),[b,k]=i.useState(null),[$,S]=i.useState([]),[C,z]=i.useState([]),[w,y]=i.useState(null),[g,_]=i.useState(1),[E,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[M,I]=i.useState({x:0,y:0}),O=i.useRef(null),N=i.useRef(null),{messages:D,pendingMessage:L,pendingImages:P,connectionState:A,isConnected:q,isExecuting:Y,executionStatus:B,isWaitingForInput:H,sendMessage:G,submitUserInput:X,cancelExecution:oe}=Xc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var V;(V=O.current)==null||V.scrollIntoView({behavior:"smooth"})},[D]),i.useEffect(()=>{var V;if(H){const F=D.slice().reverse().find(ne=>{var be;return((be=ne.metadata)==null?void 0:be.type)==="user_input_request"});(V=F==null?void 0:F.metadata)!=null&&V.userInputRequest&&k(F.metadata.userInputRequest)}else k(null),S([])},[H,D]);const te=V=>{if(V.preventDefault(),!!q)if(H&&b){let F=p.trim();b.input_type==="multiselect"&&(F=$.join(",")),F&&(X(F),m(""),S([]))}else!Y&&p.trim()&&(G(p,C.length>0?C:void 0),m(""),z([]))},ce=V=>{const F=V.target.files;F&&(Array.from(F).forEach(ne=>{if(ne.type.startsWith("image/")){const be=new FileReader;be.onload=Me=>{var Ce;if((Ce=Me.target)!=null&&Ce.result){const Ve=Me.target.result.split(",")[1];z(Le=>[...Le,{mime_type:ne.type,data:Ve}])}},be.readAsDataURL(ne)}}),N.current&&(N.current.value=""))},Q=V=>{z(F=>F.filter((ne,be)=>be!==V))},me=V=>{y(V),_(1),R({x:0,y:0})},ve=()=>{y(null),_(1),R({x:0,y:0}),j(!1)},de=V=>{const F=document.createElement("a");F.href=V,F.download=`image-${Date.now()}.png`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},U=V=>{_(F=>{const ne=F+V;return Math.min(Math.max(ne,.5),3)})},le=V=>{V.preventDefault(),V.stopPropagation();const F=V.deltaY>0?-.1:.1;U(F)},K=V=>{g>1&&(j(!0),I({x:V.clientX-T.x,y:V.clientY-T.y}))},Z=V=>{E&&g>1&&R({x:V.clientX-M.x,y:V.clientY-M.y})},re=()=>{j(!1)},fe=()=>A.status===Rt.CONNECTING?"Connecting...":A.status===Rt.ERROR?"Connection error":A.status===Rt.DISCONNECTED||!q?"Disconnected":H?"Waiting for your input...":Y?"Working...":"Ready",ue=()=>{if(!H||!b)return"Ask anything";switch(b.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},ee=()=>!H||!b?!1:["select","multiselect","boolean","date"].includes(b.input_type||"");return e.jsxs(he,{style:{height:"100%",width:"100%"},children:[e.jsxs($c,{children:[e.jsxs(Lb,{children:[e.jsxs(Db,{children:[t&&e.jsx(Nb,{onClick:()=>{r?r():h(null)},children:e.jsx(ro,{size:20})}),e.jsxs(Fb,{children:[e.jsx(Bb,{children:e.jsx(Tn,{size:20})}),e.jsxs(Ub,{children:[e.jsx(Vb,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Wb,{$status:fe()}),e.jsx(Gb,{$status:fe(),children:fe()})]})]})]})]}),B!==He.IDLE&&e.jsx(Hb,{$status:B,children:B.replace("_"," ")})]}),e.jsx(qb,{children:D.length===0&&u?e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[D.map((V,F)=>{var ne,be,Me,Ce;if(((ne=V.metadata)==null?void 0:ne.type)==="user_input_request"&&V.metadata.userInputRequest){const Se=V.metadata.userInputRequest,Ve=!Se.input_type||Se.input_type==="text"||Se.input_type==="number",Le=H&&(b==null?void 0:b.input_type)===Se.input_type;return e.jsx(as,{$isUser:!1,children:e.jsxs(Qb,{children:[e.jsx("div",{className:"question",children:Se.question}),Se.context&&Se.context.trim()&&e.jsx("div",{className:"context",children:Se.context}),!Ve&&e.jsxs("div",{className:"controls",children:[Se.input_type==="select"&&Se.options&&e.jsxs("select",{value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le,children:[e.jsx("option",{value:"",children:"Choose an option..."}),Se.options.map(Ae=>e.jsx("option",{value:Ae,children:Ae},Ae))]}),Se.input_type==="multiselect"&&Se.options&&e.jsx("div",{className:"checkbox-group",children:Se.options.map(Ae=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Le&&$.includes(Ae),onChange:xe=>{xe.target.checked?S([...$,Ae]):S($.filter(ge=>ge!==Ae))},disabled:!Le}),e.jsx("span",{children:Ae})]},Ae))}),Se.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Le&&p==="true",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Le&&p==="false",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"No"})]})]}),Se.input_type==="date"&&e.jsx("input",{type:"date",value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le})]}),e.jsx("div",{className:"instruction",children:Le?Ve?"Type your response below":Se.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},V.id)}if(((be=V.metadata)==null?void 0:be.type)==="log"){const Se=D[F-1],Ve=D[F+1],Le=((Me=Se==null?void 0:Se.metadata)==null?void 0:Me.type)==="log",Ae=((Ce=Ve==null?void 0:Ve.metadata)==null?void 0:Ce.type)==="log",xe=Le||Ae,ge=!Le&&Ae,_e=Le&&!Ae;return e.jsx(Kb,{$isGrouped:xe,$isFirstInGroup:ge,$isLastInGroup:_e,children:e.jsx("div",{className:"log-content",children:V.content})},V.id)}return!V.content&&(!V.images||V.images.length===0)?null:e.jsx(as,{$isUser:V.role==="user",children:e.jsxs(Ad,{$isUser:V.role==="user",children:[e.jsx("div",{children:V.content}),V.images&&V.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:V.images.map((Se,Ve)=>{const Le=Se.url||`data:${Se.mime_type};base64,${Se.data}`;return e.jsxs(gy,{onClick:()=>me(Le),title:"Click to preview",children:[e.jsx("img",{src:Le,alt:`Image ${Ve+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Eh,{size:14})})]},Ve)})}),V.isStreaming&&e.jsx(Yb,{})]})},V.id)}),L&&e.jsx(as,{$isUser:!0,children:e.jsxs(Zb,{$isUser:!0,children:[e.jsx("div",{children:L}),P&&P.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:P.map((V,F)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Image ${F+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},F))})]})}),e.jsx("div",{ref:O})]})}),C.length>0&&e.jsx(oy,{children:C.map((V,F)=>e.jsxs(ny,{children:[e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Upload ${F+1}`}),e.jsx(sy,{type:"button",onClick:()=>Q(F),children:e.jsx(lt,{size:12})})]},F))}),e.jsx(Xb,{onSubmit:te,children:e.jsxs(Jb,{children:[e.jsxs(ey,{children:[e.jsx(ty,{value:p,onChange:V=>m(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),te(V))},placeholder:ue(),disabled:!q||Y&&!H||ee(),rows:1}),e.jsx(ry,{children:e.jsxs(iy,{type:"button",disabled:!q||Y,onClick:()=>{var V;return(V=N.current)==null?void 0:V.click()},children:[e.jsx(Gh,{size:16}),"Attach"]})}),e.jsx(ay,{ref:N,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(cy,{type:Y?"button":"submit",disabled:!q||!H&&!Y&&!p.trim(),onClick:Y?oe:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:Y&&x?"var(--color-error)":void 0},children:Y?x?e.jsx(lt,{size:14}):e.jsx(yt,{size:14,className:"animate-spin"}):e.jsx(Fs,{size:14})})]})})]}),e.jsx(my,{isOpen:!!w,imageUrl:w,zoomLevel:g,dragPosition:T,isDragging:E,onClose:ve,onDownload:()=>w&&de(w),onZoom:U,onReset:()=>{_(1),R({x:0,y:0})},onWheel:le,onMouseDown:K,onMouseMove:Z,onMouseUp:re})]})}const xy=l.div`
5836
+ `,my=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:h,onZoom:f,onReset:c,onWheel:u,onMouseDown:d,onMouseMove:p,onMouseUp:m})=>{const[x,v]=i.useState(!1),b=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const k=document.body.style.overflow;document.body.style.overflow="hidden";const $=z=>{(z.ctrlKey||z.metaKey)&&z.preventDefault()},S=z=>{z.preventDefault()},C=z=>{z.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",S,{passive:!1}),document.addEventListener("gesturechange",C,{passive:!1}),()=>{document.body.style.overflow=k,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",S),document.removeEventListener("gesturechange",C)}}},[t]),!x||!t||!r?null:eo.createPortal(e.jsx(fe,{children:e.jsx(ly,{ref:b,$isOpen:!0,onClick:k=>{k.target===k.currentTarget&&a()},children:e.jsxs(dy,{onClick:k=>k.stopPropagation(),onWheel:k=>{k.preventDefault(),k.stopPropagation(),u(k)},onMouseMove:p,onMouseUp:m,onMouseLeave:m,children:[e.jsx(uy,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:d,draggable:!1}),e.jsx(Do,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(lt,{size:14})}),e.jsxs(py,{children:[e.jsxs(hy,{children:[e.jsx(Do,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(uf,{size:14})}),e.jsxs(fy,{children:[Math.round(o*100),"%"]}),e.jsx(Do,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(lf,{size:14})}),e.jsx(Do,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Wh,{size:14})})]}),e.jsxs(Dd,{$variant:"primary",onClick:h,title:"Download image",children:[e.jsx(pn,{size:14}),"Download"]})]})]})})}),document.body)};function Nd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:h}=rn(),f=a==null?void 0:a.id;if(!f)return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx($c,{children:e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,u=!0,d="Start a conversation by typing a message below",[p,m]=i.useState(""),[x,v]=i.useState(!1),[b,k]=i.useState(null),[$,S]=i.useState([]),[C,z]=i.useState([]),[w,y]=i.useState(null),[g,_]=i.useState(1),[E,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[M,I]=i.useState({x:0,y:0}),O=i.useRef(null),N=i.useRef(null),{messages:D,pendingMessage:L,pendingImages:P,connectionState:A,isConnected:q,isExecuting:Y,executionStatus:B,isWaitingForInput:H,sendMessage:G,submitUserInput:X,cancelExecution:oe}=Xc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var V;(V=O.current)==null||V.scrollIntoView({behavior:"smooth"})},[D]),i.useEffect(()=>{var V;if(H){const F=D.slice().reverse().find(ne=>{var be;return((be=ne.metadata)==null?void 0:be.type)==="user_input_request"});(V=F==null?void 0:F.metadata)!=null&&V.userInputRequest&&k(F.metadata.userInputRequest)}else k(null),S([])},[H,D]);const te=V=>{if(V.preventDefault(),!!q)if(H&&b){let F=p.trim();b.input_type==="multiselect"&&(F=$.join(",")),F&&(X(F),m(""),S([]))}else!Y&&p.trim()&&(G(p,C.length>0?C:void 0),m(""),z([]))},ce=V=>{const F=V.target.files;F&&(Array.from(F).forEach(ne=>{if(ne.type.startsWith("image/")){const be=new FileReader;be.onload=Me=>{var Ce;if((Ce=Me.target)!=null&&Ce.result){const Ve=Me.target.result.split(",")[1];z(Le=>[...Le,{mime_type:ne.type,data:Ve}])}},be.readAsDataURL(ne)}}),N.current&&(N.current.value=""))},Q=V=>{z(F=>F.filter((ne,be)=>be!==V))},me=V=>{y(V),_(1),R({x:0,y:0})},xe=()=>{y(null),_(1),R({x:0,y:0}),j(!1)},de=V=>{const F=document.createElement("a");F.href=V,F.download=`image-${Date.now()}.png`,document.body.appendChild(F),F.click(),document.body.removeChild(F)},U=V=>{_(F=>{const ne=F+V;return Math.min(Math.max(ne,.5),3)})},le=V=>{V.preventDefault(),V.stopPropagation();const F=V.deltaY>0?-.1:.1;U(F)},K=V=>{g>1&&(j(!0),I({x:V.clientX-T.x,y:V.clientY-T.y}))},Z=V=>{E&&g>1&&R({x:V.clientX-M.x,y:V.clientY-M.y})},re=()=>{j(!1)},ge=()=>A.status===Rt.CONNECTING?"Connecting...":A.status===Rt.ERROR?"Connection error":A.status===Rt.DISCONNECTED||!q?"Disconnected":H?"Waiting for your input...":Y?"Working...":"Ready",ue=()=>{if(!H||!b)return"Ask anything";switch(b.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},ee=()=>!H||!b?!1:["select","multiselect","boolean","date"].includes(b.input_type||"");return e.jsxs(fe,{style:{height:"100%",width:"100%"},children:[e.jsxs($c,{children:[e.jsxs(Lb,{children:[e.jsxs(Db,{children:[t&&e.jsx(Nb,{onClick:()=>{r?r():h(null)},children:e.jsx(ro,{size:20})}),e.jsxs(Fb,{children:[e.jsx(Bb,{children:e.jsx(Tn,{size:20})}),e.jsxs(Ub,{children:[e.jsx(Vb,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Wb,{$status:ge()}),e.jsx(Gb,{$status:ge(),children:ge()})]})]})]})]}),B!==He.IDLE&&e.jsx(Hb,{$status:B,children:B.replace("_"," ")})]}),e.jsx(qb,{children:D.length===0&&u?e.jsxs(zc,{children:[e.jsx(Tn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[D.map((V,F)=>{var ne,be,Me,Ce;if(((ne=V.metadata)==null?void 0:ne.type)==="user_input_request"&&V.metadata.userInputRequest){const Se=V.metadata.userInputRequest,Ve=!Se.input_type||Se.input_type==="text"||Se.input_type==="number",Le=H&&(b==null?void 0:b.input_type)===Se.input_type;return e.jsx(as,{$isUser:!1,children:e.jsxs(Qb,{children:[e.jsx("div",{className:"question",children:Se.question}),Se.context&&Se.context.trim()&&e.jsx("div",{className:"context",children:Se.context}),!Ve&&e.jsxs("div",{className:"controls",children:[Se.input_type==="select"&&Se.options&&e.jsxs("select",{value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le,children:[e.jsx("option",{value:"",children:"Choose an option..."}),Se.options.map(Ae=>e.jsx("option",{value:Ae,children:Ae},Ae))]}),Se.input_type==="multiselect"&&Se.options&&e.jsx("div",{className:"checkbox-group",children:Se.options.map(Ae=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Le&&$.includes(Ae),onChange:ve=>{ve.target.checked?S([...$,Ae]):S($.filter(pe=>pe!==Ae))},disabled:!Le}),e.jsx("span",{children:Ae})]},Ae))}),Se.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Le&&p==="true",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Le&&p==="false",onChange:Ae=>m(Ae.target.value),disabled:!Le}),e.jsx("span",{children:"No"})]})]}),Se.input_type==="date"&&e.jsx("input",{type:"date",value:Le?p:"",onChange:Ae=>m(Ae.target.value),disabled:!Le})]}),e.jsx("div",{className:"instruction",children:Le?Ve?"Type your response below":Se.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},V.id)}if(((be=V.metadata)==null?void 0:be.type)==="log"){const Se=D[F-1],Ve=D[F+1],Le=((Me=Se==null?void 0:Se.metadata)==null?void 0:Me.type)==="log",Ae=((Ce=Ve==null?void 0:Ve.metadata)==null?void 0:Ce.type)==="log",ve=Le||Ae,pe=!Le&&Ae,ye=Le&&!Ae;return e.jsx(Kb,{$isGrouped:ve,$isFirstInGroup:pe,$isLastInGroup:ye,children:e.jsx("div",{className:"log-content",children:V.content})},V.id)}return!V.content&&(!V.images||V.images.length===0)?null:e.jsx(as,{$isUser:V.role==="user",children:e.jsxs(Ld,{$isUser:V.role==="user",children:[e.jsx("div",{children:V.content}),V.images&&V.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:V.images.map((Se,Ve)=>{const Le=Se.url||`data:${Se.mime_type};base64,${Se.data}`;return e.jsxs(gy,{onClick:()=>me(Le),title:"Click to preview",children:[e.jsx("img",{src:Le,alt:`Image ${Ve+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Ph,{size:14})})]},Ve)})}),V.isStreaming&&e.jsx(Yb,{})]})},V.id)}),L&&e.jsx(as,{$isUser:!0,children:e.jsxs(Zb,{$isUser:!0,children:[e.jsx("div",{children:L}),P&&P.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:P.map((V,F)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Image ${F+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},F))})]})}),e.jsx("div",{ref:O})]})}),C.length>0&&e.jsx(oy,{children:C.map((V,F)=>e.jsxs(ny,{children:[e.jsx("img",{src:V.data?`data:${V.mime_type};base64,${V.data}`:"#",alt:`Upload ${F+1}`}),e.jsx(sy,{type:"button",onClick:()=>Q(F),children:e.jsx(lt,{size:12})})]},F))}),e.jsx(Xb,{onSubmit:te,children:e.jsxs(Jb,{children:[e.jsxs(ey,{children:[e.jsx(ty,{value:p,onChange:V=>m(V.target.value),onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),te(V))},placeholder:ue(),disabled:!q||Y&&!H||ee(),rows:1}),e.jsx(ry,{children:e.jsxs(iy,{type:"button",disabled:!q||Y,onClick:()=>{var V;return(V=N.current)==null?void 0:V.click()},children:[e.jsx(Hh,{size:16}),"Attach"]})}),e.jsx(ay,{ref:N,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(cy,{type:Y?"button":"submit",disabled:!q||!H&&!Y&&!p.trim(),onClick:Y?oe:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:Y&&x?"var(--color-error)":void 0},children:Y?x?e.jsx(lt,{size:14}):e.jsx(yt,{size:14,className:"animate-spin"}):e.jsx(Fs,{size:14})})]})})]}),e.jsx(my,{isOpen:!!w,imageUrl:w,zoomLevel:g,dragPosition:T,isDragging:E,onClose:xe,onDownload:()=>w&&de(w),onZoom:U,onReset:()=>{_(1),R({x:0,y:0})},onWheel:le,onMouseDown:K,onMouseMove:Z,onMouseUp:re})]})}const xy=l.div`
5837
5837
  height: 100%;
5838
5838
  display: flex;
5839
5839
  flex-direction: column;
@@ -6028,7 +6028,7 @@ cursor: pointer;
6028
6028
  background: var(--color-border);
6029
6029
  border-radius: var(--radius-sm);
6030
6030
  opacity: 0.6;
6031
- `;function Nd({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:h,setShowHistory:f}=rn(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),u=x=>{const v={},b=new Date,k=new Date(b.getFullYear(),b.getMonth(),b.getDate()),$=new Date(k);$.setDate($.getDate()-1);const S=new Date(k);return S.setDate(S.getDate()-7),x.forEach(C=>{const z=new Date(C.last_activity_at);let w;z>=k?w="Today":z>=$?w="Yesterday":z>=S?w="This Week":w="Older",v[w]||(v[w]=[]),v[w].push(C)}),v},d=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await h(v)}catch(b){console.error("Failed to delete session:",b)}},p=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=u(c);return e.jsx(he,{style:{height:"100%",width:"100%"},children:e.jsxs(xy,{children:[e.jsxs(vy,{children:[t&&e.jsx(by,{onClick:()=>f(!1),children:e.jsx(ro,{size:20})}),e.jsx(yy,{children:"Conversation History"})]}),e.jsx(wy,{children:e.jsx(jy,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(ky,{children:s?e.jsx(My,{children:[1,2,3,4,5].map(x=>e.jsxs(Oy,{children:[e.jsx(Ay,{}),e.jsxs(Ly,{children:[e.jsx(Dy,{}),e.jsx(Ny,{})]})]},x))}):c.length===0?e.jsxs(Ty,{children:[e.jsx(Da,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(_y,{children:[e.jsx(Cy,{children:x}),v.map(b=>e.jsxs(Sy,{onClick:()=>a(b),children:[e.jsx($y,{children:e.jsx(Da,{size:18})}),e.jsxs(zy,{children:[e.jsx(Ey,{children:b.title}),e.jsxs(Py,{children:[e.jsx("span",{children:p(b.last_activity_at)}),b.status!=="idle"&&e.jsx(Iy,{$status:b.status,children:b.status.replace("_"," ")})]})]}),e.jsx(Ry,{onClick:k=>d(k,b.id),children:e.jsx(fn,{size:16})})]},b.id))]},x))})]})})}const Fy=l.div`
6031
+ `;function Fd({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:h,setShowHistory:f}=rn(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),u=x=>{const v={},b=new Date,k=new Date(b.getFullYear(),b.getMonth(),b.getDate()),$=new Date(k);$.setDate($.getDate()-1);const S=new Date(k);return S.setDate(S.getDate()-7),x.forEach(C=>{const z=new Date(C.last_activity_at);let w;z>=k?w="Today":z>=$?w="Yesterday":z>=S?w="This Week":w="Older",v[w]||(v[w]=[]),v[w].push(C)}),v},d=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await h(v)}catch(b){console.error("Failed to delete session:",b)}},p=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=u(c);return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsxs(xy,{children:[e.jsxs(vy,{children:[t&&e.jsx(by,{onClick:()=>f(!1),children:e.jsx(ro,{size:20})}),e.jsx(yy,{children:"Conversation History"})]}),e.jsx(wy,{children:e.jsx(jy,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(ky,{children:s?e.jsx(My,{children:[1,2,3,4,5].map(x=>e.jsxs(Oy,{children:[e.jsx(Ay,{}),e.jsxs(Ly,{children:[e.jsx(Dy,{}),e.jsx(Ny,{})]})]},x))}):c.length===0?e.jsxs(Ty,{children:[e.jsx(Da,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(_y,{children:[e.jsx(Cy,{children:x}),v.map(b=>e.jsxs(Sy,{onClick:()=>a(b),children:[e.jsx($y,{children:e.jsx(Da,{size:18})}),e.jsxs(zy,{children:[e.jsx(Ey,{children:b.title}),e.jsxs(Py,{children:[e.jsx("span",{children:p(b.last_activity_at)}),b.status!=="idle"&&e.jsx(Iy,{$status:b.status,children:b.status.replace("_"," ")})]})]}),e.jsx(Ry,{onClick:k=>d(k,b.id),children:e.jsx(fn,{size:16})})]},b.id))]},x))})]})})}const Fy=l.div`
6032
6032
  height: 100%;
6033
6033
  display: flex;
6034
6034
  flex-direction: column;
@@ -6186,5 +6186,5 @@ cursor: pointer;
6186
6186
  display: flex;
6187
6187
  flex-direction: column;
6188
6188
  gap: var(--space-xs);
6189
- `;function r2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:h,setShowHistory:f}=rn(),c=async()=>{try{r(!0),await h()}finally{r(!1)}},u=d=>{try{const p=new Date(d),x=new Date().getTime()-p.getTime(),v=Math.floor(x/6e4),b=Math.floor(v/60),k=Math.floor(b/24);return k>0?`${k}d ago`:b>0?`${b}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return s?e.jsx(Nd,{showBackButton:!0}):n?e.jsx(Dd,{showBackButton:!0}):e.jsx(he,{style:{height:"100%",width:"100%"},children:e.jsx(Fy,{children:e.jsxs(By,{children:[e.jsx(Uy,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Wy,{children:"Hi there! 👋"}),e.jsx(Vy,{children:"How can I help you today?"}),e.jsx(Gy,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(Hy,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(Qy,{children:[e.jsxs(Xy,{children:[e.jsx(Jy,{children:"Recent Chats"}),e.jsx(e2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(t2,{children:o.slice(0,2).map(d=>e.jsx(qy,{onClick:()=>a(d),children:e.jsxs(Ky,{children:[e.jsx(Yy,{children:d.title}),e.jsxs(Zy,{children:[e.jsx("span",{children:u(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const o2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},n2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=ox;exports.AgentConversation=Dd;exports.AgentConversationHistory=Nd;exports.AgentConversationHub=r2;exports.AgentConversationProvider=ku;exports.AuthFormImage=Oe;exports.ChannelSelector=Ab;exports.CreateOrganizationForm=xn;exports.CreateWorkspaceDialog=sd;exports.CreateWorkspaceForm=Gs;exports.DeploymentInitialized=Ju;exports.DeploymentInitializing=ep;exports.DeploymentProvider=Vd;exports.Dialog=ze;exports.DialogTrigger=sg;exports.Dropdown=ft;exports.DropdownDivider=mn;exports.DropdownItem=Be;exports.DropdownItems=gt;exports.DropdownTrigger=mt;exports.Form=wt;exports.FormGroup=pe;exports.Input=se;exports.Label=ie;exports.MagicLinkVerification=Km;exports.ManageAccount=Ed;exports.ManageAccountDialog=Pd;exports.ManageOrganization=rd;exports.ManageWorkspace=id;exports.ManageWorkspaceDialog=cd;exports.NavigateToSignIn=mb;exports.NavigateToSignUp=xb;exports.NavigationLink=ht;exports.NotificationBell=Md;exports.NotificationItem=Rd;exports.NotificationPopover=Td;exports.OAuthProvider=Bc;exports.ORG_ADMIN_PERMISSIONS=dd;exports.ORG_MANAGEMENT_PERMISSIONS=ud;exports.OTPInput=qt;exports.OrganizationSwitcher=gd;exports.PhoneNumberInput=oo;exports.PhoneVerification=Yl;exports.ProfileCompletion=Kl;exports.RequireActiveTenancy=Ib;exports.SSOCallback=Bm;exports.SignInForm=wm;exports.SignUpForm=Vf;exports.SignedIn=eb;exports.SignedInAccounts=gb;exports.SignedOut=tb;exports.SimpleDialog=ng;exports.Spinner=Re;exports.Switch=mr;exports.TwoFactorMethodSelector=ql;exports.TwoFactorVerification=Zl;exports.UserButton=Ks;exports.UserControls=J1;exports.WORKSPACE_ADMIN_PERMISSIONS=pd;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=hd;exports.WaitlistForm=Am;exports.canManageOrganization=fd;exports.canManageWorkspace=Es;exports.clearTokenCache=Mt;exports.fetchChannelCounts=qu;exports.hasIncompleteProfile=Qm;exports.hasOrgPermission=qs;exports.hasWorkspacePermission=Ys;exports.isExternalUrl=o2;exports.isOrgAdmin=ov;exports.isSafeUrl=n2;exports.isWorkspaceAdmin=nv;exports.redirectToProfileCompletion=Xm;exports.useActiveOrganization=st;exports.useActiveTenancy=Gu;exports.useActiveWorkspace=Vt;exports.useAgentConversation=Xc;exports.useAgentConversationContext=rn;exports.useChannelCounts=Xu;exports.useClient=Ke;exports.useConversationSessions=Nc;exports.useDeployment=ye;exports.useForgotPassword=Zc;exports.useInvitation=Jc;exports.useMagicLinkParams=Yc;exports.useMagicLinkVerification=qc;exports.useNavigation=rt;exports.useNotificationStream=Kc;exports.useNotifications=Qc;exports.useOrganizationList=on;exports.useOrganizationMemberships=Ot;exports.useSSOCallback=Hc;exports.useSession=Qe;exports.useSignIn=Uc;exports.useSignInWithStrategy=zr;exports.useSignUp=Wc;exports.useUser=Gt;exports.useUserSignins=Vc;exports.useWaitlist=Gc;exports.useWorkspaceList=Wt;exports.useWorkspaceMemberships=nn;Object.keys(da).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>da[t]})});
6189
+ `;function r2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:h,setShowHistory:f}=rn(),c=async()=>{try{r(!0),await h()}finally{r(!1)}},u=d=>{try{const p=new Date(d),x=new Date().getTime()-p.getTime(),v=Math.floor(x/6e4),b=Math.floor(v/60),k=Math.floor(b/24);return k>0?`${k}d ago`:b>0?`${b}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return s?e.jsx(Fd,{showBackButton:!0}):n?e.jsx(Nd,{showBackButton:!0}):e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(Fy,{children:e.jsxs(By,{children:[e.jsx(Uy,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Wy,{children:"Hi there! 👋"}),e.jsx(Vy,{children:"How can I help you today?"}),e.jsx(Gy,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(Hy,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(Qy,{children:[e.jsxs(Xy,{children:[e.jsx(Jy,{children:"Recent Chats"}),e.jsx(e2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(t2,{children:o.slice(0,2).map(d=>e.jsx(qy,{onClick:()=>a(d),children:e.jsxs(Ky,{children:[e.jsx(Yy,{children:d.title}),e.jsxs(Zy,{children:[e.jsx("span",{children:u(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const o2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},n2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=ox;exports.AgentConversation=Nd;exports.AgentConversationHistory=Fd;exports.AgentConversationHub=r2;exports.AgentConversationProvider=_u;exports.AuthFormImage=Oe;exports.ChannelSelector=Ab;exports.CreateOrganizationForm=xn;exports.CreateWorkspaceDialog=ad;exports.CreateWorkspaceForm=Gs;exports.DeploymentInitialized=ep;exports.DeploymentInitializing=tp;exports.DeploymentProvider=Gd;exports.Dialog=ze;exports.DialogTrigger=ag;exports.Dropdown=ft;exports.DropdownDivider=mn;exports.DropdownItem=Be;exports.DropdownItems=gt;exports.DropdownTrigger=mt;exports.Form=wt;exports.FormGroup=he;exports.Input=se;exports.Label=ie;exports.MagicLinkVerification=Km;exports.ManageAccount=Pd;exports.ManageAccountDialog=Id;exports.ManageOrganization=od;exports.ManageWorkspace=cd;exports.ManageWorkspaceDialog=ld;exports.NavigateToSignIn=mb;exports.NavigateToSignUp=xb;exports.NavigationLink=ht;exports.NotificationBell=Od;exports.NotificationItem=Td;exports.NotificationPopover=Md;exports.OAuthProvider=Bc;exports.ORG_ADMIN_PERMISSIONS=ud;exports.ORG_MANAGEMENT_PERMISSIONS=pd;exports.OTPInput=qt;exports.OrganizationSwitcher=md;exports.PhoneNumberInput=oo;exports.PhoneVerification=Yl;exports.ProfileCompletion=Kl;exports.RequireActiveTenancy=Ib;exports.SSOCallback=Bm;exports.SignInForm=wm;exports.SignUpForm=Gf;exports.SignedIn=eb;exports.SignedInAccounts=gb;exports.SignedOut=tb;exports.SimpleDialog=sg;exports.Spinner=Re;exports.Switch=mr;exports.TwoFactorMethodSelector=ql;exports.TwoFactorVerification=Zl;exports.UserButton=Ks;exports.UserControls=J1;exports.WORKSPACE_ADMIN_PERMISSIONS=hd;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=fd;exports.WaitlistForm=Am;exports.canManageOrganization=gd;exports.canManageWorkspace=Es;exports.clearTokenCache=Mt;exports.fetchChannelCounts=Yu;exports.hasIncompleteProfile=Qm;exports.hasOrgPermission=qs;exports.hasWorkspacePermission=Ys;exports.isExternalUrl=o2;exports.isOrgAdmin=ov;exports.isSafeUrl=n2;exports.isWorkspaceAdmin=nv;exports.redirectToProfileCompletion=Xm;exports.useActiveOrganization=st;exports.useActiveTenancy=Hu;exports.useActiveWorkspace=Vt;exports.useAgentConversation=Xc;exports.useAgentConversationContext=rn;exports.useChannelCounts=Ju;exports.useClient=Ke;exports.useConversationSessions=Nc;exports.useDeployment=we;exports.useForgotPassword=Zc;exports.useInvitation=Jc;exports.useMagicLinkParams=Yc;exports.useMagicLinkVerification=qc;exports.useNavigation=rt;exports.useNotificationStream=Kc;exports.useNotifications=Qc;exports.useOrganizationList=on;exports.useOrganizationMemberships=Ot;exports.useSSOCallback=Hc;exports.useSession=Qe;exports.useSignIn=Uc;exports.useSignInWithStrategy=zr;exports.useSignUp=Wc;exports.useUser=Gt;exports.useUserSignins=Vc;exports.useWaitlist=Gc;exports.useWorkspaceList=Wt;exports.useWorkspaceMemberships=nn;Object.keys(da).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>da[t]})});
6190
6190
  //# sourceMappingURL=index.cjs.js.map