@wacht/jsx 1.0.0-beta.34 → 1.0.0-beta.35

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
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Xs;function Du(){return Xs||(Xs=1,process.env.NODE_ENV!=="production"&&(function(){function e(v,w){return v===w&&(v!==0||1/v===1/w)||v!==v&&w!==w}function r(v,w){p||s.startTransition===void 0||(p=!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 x=w();if(!m){var b=w();i(x,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}b=h({inst:{value:x,getSnapshot:w}});var E=b[0].inst,j=b[1];return u(function(){E.value=x,E.getSnapshot=w,a(E)&&j({inst:E})},[v,x,w]),d(function(){return a(E)&&j({inst:E}),v(function(){a(E)&&j({inst:E})})},[v]),f(x),x}function a(v){var w=v.getSnapshot;v=v.value;try{var x=w();return!i(v,x)}catch{return!0}}function n(v,w){return w()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=c,i=typeof Object.is=="function"?Object.is:e,h=s.useState,d=s.useEffect,u=s.useLayoutEffect,f=s.useDebugValue,p=!1,m=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;Nn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:g,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Nn}var ei;function Nu(){return ei||(ei=1,process.env.NODE_ENV==="production"?Ta.exports=Vu():Ta.exports=Du()),Ta.exports}var Ho=Nu();const s0=0,i0=1,c0=2,ti=3;var ri=Object.prototype.hasOwnProperty;function Vo(e,r){var a,n;if(e===r)return!0;if(e&&r&&(a=e.constructor)===r.constructor){if(a===Date)return e.getTime()===r.getTime();if(a===RegExp)return e.toString()===r.toString();if(a===Array){if((n=e.length)===r.length)for(;n--&&Vo(e[n],r[n]););return n===-1}if(!a||typeof e=="object"){n=0;for(a in e)if(ri.call(e,a)&&++n&&!ri.call(r,a)||!(a in r)||!Vo(e[a],r[a]))return!1;return Object.keys(r).length===n}}return e!==e&&r!==r}const Tt=new WeakMap,Wt=()=>{},pt=Wt(),Do=Object,Ee=e=>e===pt,$t=e=>typeof e=="function",ar=(e,r)=>({...e,...r}),l0=e=>$t(e.then),Un={},Fa={},xs="undefined",Aa=typeof window!=xs,No=typeof document!=xs,Uu=Aa&&"Deno"in window,Bu=()=>Aa&&typeof window.requestAnimationFrame!=xs,er=(e,r)=>{const a=Tt.get(e);return[()=>!Ee(r)&&e.get(r)||Un,n=>{if(!Ee(r)){const s=e.get(r);r in Fa||(Fa[r]=s),a[5](r,ar(s,n),s||Un)}},a[6],()=>!Ee(r)&&r in Fa?Fa[r]:!Ee(r)&&e.get(r)||Un]};let Uo=!0;const Wu=()=>Uo,[Bo,Wo]=Aa&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Wt,Wt],Gu=()=>{const e=No&&document.visibilityState;return Ee(e)||e!=="hidden"},qu=e=>(No&&document.addEventListener("visibilitychange",e),Bo("focus",e),()=>{No&&document.removeEventListener("visibilitychange",e),Wo("focus",e)}),Ku=e=>{const r=()=>{Uo=!0,e()},a=()=>{Uo=!1};return Bo("online",r),Bo("offline",a),()=>{Wo("online",r),Wo("offline",a)}},Yu={isOnline:Wu,isVisible:Gu},Qu={initFocus:qu,initReconnect:Ku},ai=!c.useId,Kr=!Aa||Uu,Ju=e=>Bu()?window.requestAnimationFrame(e):setTimeout(e,1),pn=Kr?c.useEffect:c.useLayoutEffect,Bn=typeof navigator<"u"&&navigator.connection,ni=!Kr&&Bn&&(["slow-2g","2g"].includes(Bn.effectiveType)||Bn.saveData),Ia=new WeakMap,Xu=e=>Do.prototype.toString.call(e),Wn=(e,r)=>e===`[object ${r}]`;let e2=0;const Go=e=>{const r=typeof e,a=Xu(e),n=Wn(a,"Date"),s=Wn(a,"RegExp"),i=Wn(a,"Object");let h,d;if(Do(e)===e&&!n&&!s){if(h=Ia.get(e),h)return h;if(h=++e2+"~",Ia.set(e,h),Array.isArray(e)){for(h="@",d=0;d<e.length;d++)h+=Go(e[d])+",";Ia.set(e,h)}if(i){h="#";const u=Do.keys(e).sort();for(;!Ee(d=u.pop());)Ee(e[d])||(h+=d+":"+Go(e[d])+",");Ia.set(e,h)}}else h=n?e.toJSON():r=="symbol"?e.toString():r=="string"?JSON.stringify(e):""+e;return h},ka=e=>{if($t(e))try{e=e()}catch{e=""}const r=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Go(e):"",[e,r]};let t2=0;const qo=()=>++t2;async function d0(...e){const[r,a,n,s]=e,i=ar({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let h=i.populateCache;const d=i.rollbackOnError;let u=i.optimisticData;const f=g=>typeof d=="function"?d(g):d!==!1,p=i.throwOnError;if($t(a)){const g=a,v=[],w=r.keys();for(const x of w)!/^\$(inf|sub)\$/.test(x)&&g(r.get(x)._k)&&v.push(x);return Promise.all(v.map(m))}return m(a);async function m(g){const[v]=ka(g);if(!v)return;const[w,x]=er(r,v),[b,E,j,S]=Tt.get(r),C=()=>{const $=b[v];return($t(i.revalidate)?i.revalidate(w().data,g):i.revalidate!==!1)&&(delete j[v],delete S[v],$&&$[0])?$[0](c0).then(()=>w().data):w().data};if(e.length<3)return C();let _=n,k,y=!1;const M=qo();E[v]=[M,0];const A=!Ee(u),F=w(),I=F.data,R=F._c,T=Ee(R)?I:R;if(A&&(u=$t(u)?u(T,I):u,x({data:u,_c:T})),$t(_))try{_=_(T)}catch($){k=$,y=!0}if(_&&l0(_))if(_=await _.catch($=>{k=$,y=!0}),M!==E[v][0]){if(y)throw k;return _}else y&&A&&f(k)&&(h=!0,x({data:T,_c:pt}));if(h&&!y)if($t(h)){const $=h(_,T);x({data:$,error:pt,_c:pt})}else x({data:_,error:pt,_c:pt});if(E[v][1]=qo(),Promise.resolve(C()).then(()=>{x({_c:pt})}),y){if(p)throw k;return}return _}}const oi=(e,r)=>{for(const a in e)e[a][0]&&e[a][0](r)},r2=(e,r)=>{if(!Tt.has(e)){const a=ar(Qu,r),n=Object.create(null),s=d0.bind(pt,e);let i=Wt;const h=Object.create(null),d=(p,m)=>{const g=h[p]||[];return h[p]=g,g.push(m),()=>g.splice(g.indexOf(m),1)},u=(p,m,g)=>{e.set(p,m);const v=h[p];if(v)for(const w of v)w(m,g)},f=()=>{if(!Tt.has(e)&&(Tt.set(e,[n,Object.create(null),Object.create(null),Object.create(null),s,u,d]),!Kr)){const p=a.initFocus(setTimeout.bind(pt,oi.bind(pt,n,s0))),m=a.initReconnect(setTimeout.bind(pt,oi.bind(pt,n,i0)));i=()=>{p&&p(),m&&m(),Tt.delete(e)}}};return f(),[e,s,f,i]}return[e,Tt.get(e)[4]]},a2=(e,r,a,n,s)=>{const i=a.errorRetryCount,h=s.retryCount,d=~~((Math.random()+.5)*(1<<(h<8?h:8)))*a.errorRetryInterval;!Ee(i)&&h>i||setTimeout(n,d,s)},n2=Vo,[bs,Gr]=r2(new Map),o2=ar({onLoadingSlow:Wt,onSuccess:Wt,onError:Wt,onErrorRetry:a2,onDiscarded:Wt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ni?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ni?5e3:3e3,compare:n2,isPaused:()=>!1,cache:bs,mutate:Gr,fallback:{}},Yu),s2=(e,r)=>{const a=ar(e,r);if(r){const{use:n,fallback:s}=e,{use:i,fallback:h}=r;n&&i&&(a.use=n.concat(i)),s&&h&&(a.fallback=ar(s,h))}return a},i2=c.createContext({}),u0="$inf$",p0=Aa&&window.__SWR_DEVTOOLS_USE__,c2=p0?window.__SWR_DEVTOOLS_USE__:[],l2=()=>{p0&&(window.__SWR_DEVTOOLS_REACT__=c)},h0=e=>$t(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],f0=()=>{const e=c.useContext(i2);return c.useMemo(()=>ar(o2,e),[e])},d2=e=>(r,a,n)=>e(r,a&&((...i)=>{const[h]=ka(r),[,,,d]=Tt.get(bs);if(h.startsWith(u0))return a(...i);const u=d[h];return Ee(u)?a(...i):(delete d[h],u)}),n),u2=c2.concat(d2),p2=e=>function(...a){const n=f0(),[s,i,h]=h0(a),d=s2(n,h);let u=e;const{use:f}=d,p=(f||[]).concat(u2);for(let m=p.length;m--;)u=p[m](u);return u(s,i||d.fetcher||null,d)},h2=(e,r,a)=>{const n=r[e]||(r[e]=[]);return n.push(a),()=>{const s=n.indexOf(a);s>=0&&(n[s]=n[n.length-1],n.pop())}},f2=(e,r)=>(...a)=>{const[n,s,i]=h0(a),h=(i.use||[]).concat(r);return e(n,s,{...i,use:h})};l2();const Gn=c.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(r=>{e.status="fulfilled",e.value=r},r=>{e.status="rejected",e.reason=r}),e}}),qn={dedupe:!0},si=Promise.resolve(pt),m2=()=>Wt,g2=(e,r,a)=>{const{cache:n,compare:s,suspense:i,fallbackData:h,revalidateOnMount:d,revalidateIfStale:u,refreshInterval:f,refreshWhenHidden:p,refreshWhenOffline:m,keepPreviousData:g,strictServerPrefetchWarning:v}=a,[w,x,b,E]=Tt.get(n),[j,S]=ka(e),C=c.useRef(!1),_=c.useRef(!1),k=c.useRef(j),y=c.useRef(r),M=c.useRef(a),A=()=>M.current,F=()=>A().isVisible()&&A().isOnline(),[I,R,T,$]=er(n,j),z=c.useRef({}).current,H=Ee(h)?Ee(a.fallback)?pt:a.fallback[j]:h,P=(J,le)=>{for(const oe in z){const G=oe;if(G==="data"){if(!s(J[G],le[G])&&(!Ee(J[G])||!s(ce,le[G])))return!1}else if(le[G]!==J[G])return!1}return!0},O=!C.current,Z=c.useMemo(()=>{const J=I(),le=$(),oe=q=>{const de=ar(q);return delete de._k,(()=>{if(!j||!r||A().isPaused())return!1;if(O&&!Ee(d))return d;const We=Ee(H)?de.data:H;return Ee(We)||u})()?{isValidating:!0,isLoading:!0,...de}:de},G=oe(J),pe=J===le?G:oe(le);let fe=G;return[()=>{const q=oe(I());return P(q,fe)?(fe.data=q.data,fe.isLoading=q.isLoading,fe.isValidating=q.isValidating,fe.error=q.error,fe):(fe=q,q)},()=>pe]},[n,j]),L=Ho.useSyncExternalStore(c.useCallback(J=>T(j,(le,oe)=>{P(oe,le)||J()}),[n,j]),Z[0],Z[1]),W=w[j]&&w[j].length>0,D=L.data,B=Ee(D)?H&&l0(H)?Gn(H):H:D,Y=L.error,X=c.useRef(B),ce=g?Ee(D)?Ee(X.current)?B:X.current:D:B,me=j&&Ee(B),te=c.useRef(null);!Kr&&Ho.useSyncExternalStore(m2,()=>(te.current=!1,te),()=>(te.current=!0,te));const xe=te.current;v&&xe&&!i&&me&&console.warn(`Missing pre-initiated data for serialized key "${j}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const re=!j||!r||A().isPaused()||W&&!Ee(Y)?!1:O&&!Ee(d)?d:i?Ee(B)?!1:u:Ee(B)||u,U=O&&re,Qe=Ee(L.isValidating)?U:L.isValidating,Te=Ee(L.isLoading)?U:L.isLoading,Ve=c.useCallback(async J=>{const le=y.current;if(!j||!le||_.current||A().isPaused())return!1;let oe,G,pe=!0;const fe=J||{},q=!b[j]||!fe.dedupe,de=()=>ai?!_.current&&j===k.current&&C.current:j===k.current,Be={isValidating:!1,isLoading:!1},We=()=>{R(Be)},Q=()=>{const he=b[j];he&&he[1]===G&&delete b[j]},se={isValidating:!0};Ee(I().data)&&(se.isLoading=!0);try{if(q&&(R(se),a.loadingTimeout&&Ee(I().data)&&setTimeout(()=>{pe&&de()&&A().onLoadingSlow(j,a)},a.loadingTimeout),b[j]=[le(S),qo()]),[oe,G]=b[j],oe=await oe,q&&setTimeout(Q,a.dedupingInterval),!b[j]||b[j][1]!==G)return q&&de()&&A().onDiscarded(j),!1;Be.error=pt;const he=x[j];if(!Ee(he)&&(G<=he[0]||G<=he[1]||he[1]===0))return We(),q&&de()&&A().onDiscarded(j),!1;const je=I().data;Be.data=s(je,oe)?je:oe,q&&de()&&A().onSuccess(oe,j,a)}catch(he){Q();const je=A(),{shouldRetryOnError:ke}=je;je.isPaused()||(Be.error=he,q&&de()&&(je.onError(he,j,je),(ke===!0||$t(ke)&&ke(he))&&(!A().revalidateOnFocus||!A().revalidateOnReconnect||F())&&je.onErrorRetry(he,j,je,Ge=>{const dt=w[j];dt&&dt[0]&&dt[0](ti,Ge)},{retryCount:(fe.retryCount||0)+1,dedupe:!0})))}return pe=!1,We(),!0},[j,n]),Ue=c.useCallback((...J)=>d0(n,k.current,...J),[]);if(pn(()=>{y.current=r,M.current=a,Ee(D)||(X.current=D)}),pn(()=>{if(!j)return;const J=Ve.bind(pt,qn);let le=0;A().revalidateOnFocus&&(le=Date.now()+A().focusThrottleInterval);const G=h2(j,w,(pe,fe={})=>{if(pe==s0){const q=Date.now();A().revalidateOnFocus&&q>le&&F()&&(le=q+A().focusThrottleInterval,J())}else if(pe==i0)A().revalidateOnReconnect&&F()&&J();else{if(pe==c0)return Ve();if(pe==ti)return Ve(fe)}});return _.current=!1,k.current=j,C.current=!0,R({_k:S}),re&&(b[j]||(Ee(B)||Kr?J():Ju(J))),()=>{_.current=!0,G()}},[j]),pn(()=>{let J;function le(){const G=$t(f)?f(I().data):f;G&&J!==-1&&(J=setTimeout(oe,G))}function oe(){!I().error&&(p||A().isVisible())&&(m||A().isOnline())?Ve(qn).then(le):le()}return le(),()=>{J&&(clearTimeout(J),J=-1)}},[f,p,m,j]),c.useDebugValue(ce),i){if(!ai&&Kr&&me)throw new Error("Fallback data is required when using Suspense in SSR.");me&&(y.current=r,M.current=a,_.current=!1);const J=E[j],le=!Ee(J)&&me?Ue(J):si;if(Gn(le),!Ee(Y)&&me)throw Y;const oe=me?Ve(qn):si;!Ee(ce)&&me&&(oe.status="fulfilled",oe.value=!0),Gn(oe)}return{mutate:Ue,get data(){return z.data=!0,ce},get error(){return z.error=!0,Y},get isValidating(){return z.isValidating=!0,Qe},get isLoading(){return z.isLoading=!0,Te}}},$e=p2(g2),yt=()=>{const{adapter:e,deployment:r}=Ae(),a=e.useNavigate(),n=(u,f)=>{a?a(u,f):window.location.href=u},s=u=>{if(u)return u;const p=new URLSearchParams(window.location.search).get("redirect_uri");return p||window.location.href};return{navigate:n,navigateToSignIn:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`${r.ui_settings.sign_in_page_url}?${p.toString()}`,{replace:!0})},navigateToAccountSelection:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`https://${r.frontend_host}?${p.toString()}`,{replace:!0})},navigateToSignUp:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`${r.ui_settings.sign_up_page_url}?${p.toString()}`,{replace:!0})}}};async function v2(e){const r=await e("/session",{method:"GET"});return(await V(r)).data}async function x2(e,r){const a=await e(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(a)}async function b2(e,r){const a=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await e(a,{method:"POST"});return V(n)}async function w2(e,r){const a=await e(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(a)}async function y2(e,r){const a=await e(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(a)}async function j2(e,r){const a=await e(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return V(a)}const Ko=new Map,ga=new Map;function Mt(){Ko.clear(),ga.clear()}async function _2(e,r){const a=await e(`/session/token${r?`?template=${r}`:""}`);return V(a)}function ot(){const{client:e,loading:r}=_e(),{deployment:a}=Ae(),{navigate:n}=yt(),{cache:s}=f0(),{data:i,error:h,mutate:d,isLoading:u}=$e(r?null:"/session",()=>v2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=c.useCallback(async()=>{await d(void 0,{revalidate:!0})},[d]),p=c.useCallback(async(m="default")=>{if(!i)throw new Error("no session");const g=Ko.get(m);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";ga.get(m)||ga.set(m,_2(e,m));const v=await ga.get(m);return ga.delete(m),Ko.set(m,v.data),v.data.token},[e,i==null?void 0:i.active_signin]);return r||!i||u?{loading:!0,error:h,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:f}:{loading:u,error:h,session:i,switchSignIn:async m=>{await x2(e,m),Mt(),await Gr("/me/organization-memberships",void 0,{revalidate:!1}),await Gr("/me/workspace-memberships",void 0,{revalidate:!1}),await d(void 0,{revalidate:!0}),await Gr("/me/organization-memberships"),await Gr("/me/workspace-memberships")},signOut:async m=>{await b2(e,m);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const w=Array.from(s.keys());for(const x of w){let b=!1;(g.includes(x)||typeof x=="string"&&v.some(E=>x.startsWith(E)))&&(b=!0),b&&s.delete(x)}}Mt(),await d(void 0,{revalidate:!0}),a!=null&&a.ui_settings&&(m&&a.ui_settings.after_sign_out_one_page_url?n(a.ui_settings.after_sign_out_one_page_url):!m&&a.ui_settings.after_sign_out_all_page_url&&n(a.ui_settings.after_sign_out_all_page_url))},switchOrganization:async m=>{await w2(e,m),Mt(),await d(void 0,{revalidate:!0})},switchWorkspace:async m=>{await y2(e,m),Mt(),await d(void 0,{revalidate:!0})},exchangeTicket:async m=>{await j2(e,m),Mt(),await d(void 0,{revalidate:!0})},getToken:p,refetch:f}}const It=()=>{const{organizationMemberships:e,refetch:r,loading:a}=Kt(),{client:n}=_e(),{refetch:s}=ot(),i=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/roles`,{method:"GET"}))).data,[n]),h=c.useCallback(async(O,Z)=>{const L=new URLSearchParams;return Z&&(L.set("page",Z.page.toString()),L.set("limit",Z.limit.toString()),Z.search&&L.set("search",Z.search)),(await V(await n(`/organizations/${O.id}/members?${L.toString()}`,{method:"GET"}))).data},[n]),d=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/invitations`,{method:"GET"}))).data,[n]),u=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/domains`,{method:"GET"}))).data,[n]),f=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/members/${Z.id}/remove`,{method:"POST"})},[n]),p=c.useCallback(async O=>{const Z=new FormData;Z.append("name",O.name),O.image&&Z.append("image",O.image),O.description&&Z.append("description",O.description);const L=await V(await n("/organizations",{method:"POST",body:Z}));return Mt(),await r(),await s(),L},[s,r,n]),m=c.useCallback(async(O,Z)=>{const L=Object.entries(Z).reduce((D,[B,Y])=>(Y!=null&&(Array.isArray(Y)?Y.forEach(X=>D.append(B,X)):D.append(B,Y)),D),new FormData),W=await V(await n(`/organizations/${O.id}/update`,{method:"POST",body:L}));return await r(),W},[r,n]),g=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/roles/${Z.id}/remove`,{method:"POST"})},[n]),v=c.useCallback(async(O,Z)=>{const L=new FormData;return L.append("domain",Z.fqdn),await V(await n(`/organizations/${O.id}/domains`,{method:"POST",body:L}))},[n]),w=c.useCallback(async(O,Z)=>await V(await n(`/organizations/${O.id}/domains/${Z.id}/verify`,{method:"POST"})),[n]),x=c.useCallback(async(O,Z)=>await V(await n(`/organizations/${O.id}/domains/${Z.id}/delete`,{method:"POST"})),[n]),b=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/enterprise-connections`,{method:"GET"}))).data,[n]),E=c.useCallback(async(O,Z)=>{const L=new FormData;return L.append("protocol",Z.protocol),Z.domain_id&&L.append("domain_id",Z.domain_id),Z.idp_entity_id&&L.append("idp_entity_id",Z.idp_entity_id),Z.idp_sso_url&&L.append("idp_sso_url",Z.idp_sso_url),Z.idp_certificate&&L.append("idp_certificate",Z.idp_certificate),Z.oidc_client_id&&L.append("oidc_client_id",Z.oidc_client_id),Z.oidc_client_secret&&L.append("oidc_client_secret",Z.oidc_client_secret),Z.oidc_issuer_url&&L.append("oidc_issuer_url",Z.oidc_issuer_url),Z.oidc_scopes&&L.append("oidc_scopes",Z.oidc_scopes),Z.jit_enabled!==void 0&&L.append("jit_enabled",String(Z.jit_enabled)),Z.attribute_mapping&&L.append("attribute_mapping",JSON.stringify(Z.attribute_mapping)),(await V(await n(`/organizations/${O.id}/enterprise-connections`,{method:"POST",body:L}))).data},[n]),j=c.useCallback(async(O,Z,L)=>{const W=new FormData;return L.domain_id&&W.append("domain_id",L.domain_id),L.idp_entity_id&&W.append("idp_entity_id",L.idp_entity_id),L.idp_sso_url&&W.append("idp_sso_url",L.idp_sso_url),L.idp_certificate&&W.append("idp_certificate",L.idp_certificate),L.oidc_client_id&&W.append("oidc_client_id",L.oidc_client_id),L.oidc_client_secret&&W.append("oidc_client_secret",L.oidc_client_secret),L.oidc_issuer_url&&W.append("oidc_issuer_url",L.oidc_issuer_url),L.oidc_scopes&&W.append("oidc_scopes",L.oidc_scopes),L.attribute_mapping&&W.append("attribute_mapping",JSON.stringify(L.attribute_mapping)),(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/update`,{method:"POST",body:W}))).data},[n]),S=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/enterprise-connections/${Z}/delete`,{method:"POST"})},[n]),C=c.useCallback(async(O,Z)=>{const L=new FormData;return L.append("protocol",Z.protocol),Z.idp_entity_id&&L.append("idp_entity_id",Z.idp_entity_id),Z.idp_sso_url&&L.append("idp_sso_url",Z.idp_sso_url),Z.idp_certificate&&L.append("idp_certificate",Z.idp_certificate),Z.oidc_issuer_url&&L.append("oidc_issuer_url",Z.oidc_issuer_url),Z.oidc_client_id&&L.append("oidc_client_id",Z.oidc_client_id),Z.oidc_client_secret&&L.append("oidc_client_secret",Z.oidc_client_secret),(await V(await n(`/organizations/${O.id}/enterprise-connections/test`,{method:"POST",body:L}))).data},[n]),_=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/test`,{method:"POST"}))).data,[n]),k=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token`,{method:"POST"}))).data,[n]),y=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token`,{method:"GET"}))).data,[n]),M=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token/revoke`,{method:"POST"})},[n]),A=c.useCallback(async(O,Z)=>{const L=new FormData;return L.append("name",Z.name),Z.permissions&&Z.permissions.forEach((D,B)=>{L.append(`permissions[${B}]`,D)}),await V(await n(`/organizations/${O.id}/roles`,{method:"POST",body:L}))},[n]),F=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/leave`,{method:"POST"}))).data,[n]),I=c.useCallback(async O=>{const Z=await V(await n(`/organizations/${O.id}/delete`,{method:"POST"}));return Mt(),await r(),await s(),Z.data},[n,r,s]),R=c.useCallback(async(O,Z,L)=>(await V(await n(`/organizations/${O.id}/members/${Z.id}/roles/${L.id}/add`,{method:"POST"}))).data,[n]),T=c.useCallback(async(O,Z,L)=>(await V(await n(`/organizations/${O.id}/members/${Z.id}/roles/${L.id}/remove`,{method:"POST"}))).data,[n]),$=c.useCallback(async(O,Z)=>{var D,B;const L=new FormData;return L.append("email",Z.email),L.append("role_id",Z.organizationRole.id),(D=Z.workspace)!=null&&D.id&&L.append("workspace_id",Z.workspace.id),(B=Z.workspaceRole)!=null&&B.id&&L.append("workspace_role_id",Z.workspaceRole.id),(await V(await n(`/organizations/${O.id}/invitations`,{method:"POST",body:L}))).data},[n]),z=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/invitations/${Z.id}/discard`,{method:"POST"}))).data,[n]),H=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/invitations/${Z.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:c.useMemo(()=>e==null?void 0:e.map(O=>O.organization),[e]),loading:a,error:null,refetch:r,leaveOrganization:F,getOrganizationRoles:i,getOrganizationMembers:h,removeOrganizationMember:f,createOrganization:p,getOrganizationInvitations:d,getOrganizationDomains:u,addOrganizationDomain:v,verifyOrganizationDomain:w,removeOrganizationDomain:x,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:T,inviteOrganizationMember:$,discardOrganizationInvitation:z,resendOrganizationInvitation:H,updateOrganization:m,addRole:A,removeOrganizationRoles:g,deleteOrganization:I,getEnterpriseConnections:b,createEnterpriseConnection:E,updateEnterpriseConnection:j,deleteEnterpriseConnection:S,testEnterpriseConnectionConfig:C,testEnterpriseConnection:_,generateSCIMToken:k,getSCIMToken:y,revokeSCIMToken:M}},or=()=>{const{loading:e,error:r,refetch:a,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:i,removeOrganizationMember:h,getOrganizationInvitations:d,getOrganizationDomains:u,removeOrganizationDomain:f,addOrganizationDomain:p,verifyOrganizationDomain:m,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:v,inviteOrganizationMember:w,discardOrganizationInvitation:x,resendOrganizationInvitation:b,updateOrganization:E,removeOrganizationRoles:j,getEnterpriseConnections:S,createEnterpriseConnection:C,updateEnterpriseConnection:_,deleteEnterpriseConnection:k,testEnterpriseConnectionConfig:y,testEnterpriseConnection:M,generateSCIMToken:A,getSCIMToken:F,revokeSCIMToken:I}=It(),{session:R,error:T,loading:$}=ot(),{organizationMemberships:z}=Kt(),H=c.useMemo(()=>(z==null?void 0:z.find(q=>{var de;return q.id===((de=R==null?void 0:R.active_signin)==null?void 0:de.active_organization_membership_id)}))||null,[z,R]),P=c.useMemo(()=>(H==null?void 0:H.organization)||null,[H]),O=c.useCallback(async q=>P?await E(P,q):[],[P,E]),Z=c.useCallback(async()=>P?await n(P):[],[P,n]),L=c.useCallback(async()=>P?await s(P):[],[P,s]),W=c.useCallback(async q=>P?await h(P,q):[],[P,h]),D=c.useCallback(async q=>P?await j(P,q):void 0,[P,j]),B=c.useCallback(async()=>P?await u(P):[],[P,u]),Y=c.useCallback(async q=>P?await p(P,q):void 0,[P,p]),X=c.useCallback(async q=>P?await m(P,q):void 0,[P,m]),ce=c.useCallback(async q=>P?await f(P,q):void 0,[P,f]),me=c.useCallback(async(q,de)=>P?await g(P,q,de):void 0,[P,g]),te=c.useCallback(async(q,de)=>P?await v(P,q,de):void 0,[P,v]),xe=c.useCallback(async q=>P?await w(P,q):void 0,[P,w]),re=c.useCallback(async q=>P?await x(P,q):void 0,[P,x]),U=c.useCallback(async q=>P?await b(P,q):void 0,[P,b]),Qe=c.useCallback(async()=>{P&&await i(P)},[P,i]),Te=c.useCallback(async()=>P?await d(P):[],[P,d]),Ve=c.useCallback(async()=>P?await S(P):[],[P,S]),Ue=c.useCallback(async q=>{if(P)return await C(P,q)},[P,C]),ve=c.useCallback(async(q,de)=>{if(P)return await _(P,q,de)},[P,_]),J=c.useCallback(async q=>{P&&await k(P,q)},[P,k]),le=c.useCallback(async q=>P?await y(P,q):null,[P,y]),oe=c.useCallback(async q=>P?await M(P,q):null,[P,M]),G=c.useCallback(async q=>{if(P)return await A(P,q)},[P,A]),pe=c.useCallback(async q=>{if(P)return await F(P,q)},[P,F]),fe=c.useCallback(async q=>{P&&await I(P,q)},[P,I]);return $||e?{activeOrganization:null,activeMembership:null,loading:!0,error:T||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:P,activeMembership:H,loading:!1,refetch:a,getRoles:L,updateOrganization:O,getMembers:Z,getDomains:B,addDomain:Y,verifyDomain:X,removeDomain:ce,getInvitations:Te,removeMember:W,leave:Qe,removeRole:D,addMemberRole:me,removeMemberRole:te,inviteMember:xe,discardInvitation:re,resendInvitation:U,getEnterpriseConnections:Ve,createEnterpriseConnection:Ue,updateEnterpriseConnection:ve,deleteEnterpriseConnection:J,testEnterpriseConnectionConfig:le,testEnterpriseConnection:oe,generateSCIMToken:G,getSCIMToken:pe,revokeSCIMToken:fe,error:null}};async function k2(e){return(await V(await e("/me/organization-memberships"))).data}const Kt=()=>{const{client:e,loading:r}=_e(),{data:a,isLoading:n,error:s,mutate:i}=$e(r?null:"/me/organization-memberships",()=>k2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=c.useCallback(async()=>{await i()},[i]);return{organizationMemberships:a,loading:r||n,error:s,refetch:h}};async function C2(e){return(await V(await e("/me/workspace-memberships"))).data}async function S2(e,r){return(await V(await e(`/workspaces/${r}/leave`,{method:"POST"}))).data}const An=()=>{const{client:e,loading:r}=_e(),{deployment:a}=Ae(),{data:n,isLoading:s,error:i,mutate:h}=$e(!r&&(a!=null&&a.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>C2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=c.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]);return{workspaceMemberships:n,loading:r||s,error:i,refetch:d}},sr=()=>{const{workspaceMemberships:e,refetch:r,loading:a,error:n}=An(),{client:s}=_e(),{refetch:i}=ot(),h=c.useMemo(()=>e==null?void 0:e.map(k=>({...k.workspace,organization:k.organization,eligibility_restriction:k.eligibility_restriction})),[e]),d=c.useCallback(async(k,y,M,A)=>{const F=new FormData;F.append("name",y),M&&F.append("image",M),A&&F.append("description",A),F.append("organization_id",k);const I=await V(await s("/workspaces",{method:"POST",body:F}));return Mt(),await r(),I.data},[s,r]),u=c.useCallback(async k=>{const y=await S2(s,k);return Mt(),await r(),await i(),y},[s,r,i]),f=c.useCallback(async(k,y)=>{const M=new FormData;y.name&&M.append("name",y.name),y.description&&M.append("description",y.description),y.image&&M.append("image",y.image),y.enforce_2fa!==void 0&&M.append("enforce_2fa",String(y.enforce_2fa)),y.enable_ip_restriction!==void 0&&M.append("enable_ip_restriction",String(y.enable_ip_restriction)),y.whitelisted_ips&&y.whitelisted_ips.forEach(F=>M.append("whitelisted_ips",F));const A=await V(await s(`/workspaces/${k.id}/update`,{method:"POST",body:M}));return await r(),A.data},[s,r]),p=c.useCallback(async k=>{const y=await V(await s(`/workspaces/${k.id}/delete`,{method:"POST"}));return Mt(),await r(),y.data},[s,r]),m=c.useCallback(async(k,y)=>{const M=new URLSearchParams;return y&&(M.set("page",y.page.toString()),M.set("limit",y.limit.toString()),y.search&&M.set("search",y.search)),(await V(await s(`/workspaces/${k.id}/members?${M.toString()}`,{method:"GET"}))).data},[s]),g=c.useCallback(async k=>(await V(await s(`/workspaces/${k.id}/roles`,{method:"GET"}))).data,[s]),v=c.useCallback(async(k,y,M)=>{const A=new FormData;return A.append("name",y),M.forEach(I=>A.append("permissions",I)),(await V(await s(`/workspaces/${k.id}/roles`,{method:"POST",body:A}))).data},[s]),w=c.useCallback(async(k,y)=>(await V(await s(`/workspaces/${k.id}/roles/${y.id}/delete`,{method:"POST"}))).data,[s]),x=c.useCallback(async(k,y)=>{const M=await V(await s(`/workspaces/${k.id}/members/${y}/remove`,{method:"POST"}));return await r(),M.data},[s,r]),b=c.useCallback(async(k,y,M)=>(await V(await s(`/workspaces/${k.id}/members/${y}/roles/${M}/add`,{method:"POST"}))).data,[s]),E=c.useCallback(async(k,y,M)=>(await V(await s(`/workspaces/${k.id}/members/${y}/roles/${M}/remove`,{method:"POST"}))).data,[s]),j=c.useCallback(async k=>(await V(await s(`/organizations/${k.organization.id}/invitations?workspace_id=${k.id}`,{method:"GET"}))).data,[s]),S=c.useCallback(async(k,y,M)=>{const A=new FormData;return A.append("email",y),A.append("workspace_id",k.id),M&&A.append("workspace_role_id",M),(await V(await s(`/organizations/${k.organization.id}/invitations`,{method:"POST",body:A}))).data},[s]),C=c.useCallback(async(k,y)=>(await V(await s(`/organizations/${k.organization.id}/invitations/${y}/discard`,{method:"POST"}))).data,[s]),_=c.useCallback(async(k,y)=>(await V(await s(`/organizations/${k.organization.id}/invitations/${y}/resend`,{method:"POST"}))).data,[s]);return{workspaces:h||[],loading:a,error:n,refetch:r,leaveWorkspace:u,createWorkspace:d,updateWorkspace:f,deleteWorkspace:p,getWorkspaceMembers:m,getWorkspaceRoles:g,createWorkspaceRole:v,deleteWorkspaceRole:w,removeWorkspaceMember:x,addWorkspaceMemberRole:b,removeWorkspaceMemberRole:E,getWorkspaceInvitations:j,createWorkspaceInvitation:S,discardWorkspaceInvitation:C,resendWorkspaceInvitation:_}},Zt=()=>{const{refetch:e,loading:r,error:a,workspaces:n,leaveWorkspace:s,updateWorkspace:i,deleteWorkspace:h,getWorkspaceMembers:d,getWorkspaceRoles:u,createWorkspaceRole:f,deleteWorkspaceRole:p,removeWorkspaceMember:m,addWorkspaceMemberRole:g,removeWorkspaceMemberRole:v,getWorkspaceInvitations:w,createWorkspaceInvitation:x,discardWorkspaceInvitation:b,resendWorkspaceInvitation:E}=sr(),{workspaceMemberships:j}=An(),{session:S,loading:C,error:_}=ot(),k=c.useMemo(()=>(j==null?void 0:j.find(X=>{var ce;return X.id===((ce=S==null?void 0:S.active_signin)==null?void 0:ce.active_workspace_membership_id)}))||null,[j,S]),y=c.useMemo(()=>(k==null?void 0:k.workspace)||null,[k]),M=c.useCallback(async()=>{if(y)return await s(y.id)},[y,s]),A=c.useCallback(async X=>{if(y)return await i(y,X)},[y,i]),F=c.useCallback(async()=>{if(y)return await h(y)},[y,h]),I=c.useCallback(async X=>y?await d(y,X):{data:[],meta:{total:0,page:1,limit:10}},[y,d]),R=c.useCallback(async()=>y?await u(y):[],[y,u]),T=c.useCallback(async(X,ce)=>{if(y)return await f(y,X,ce)},[y,f]),$=c.useCallback(async X=>{if(y)return await p(y,X)},[y,p]),z=c.useCallback(async X=>{if(y)return await m(y,X)},[y,m]),H=c.useCallback(async(X,ce)=>{if(y)return await g(y,X,ce)},[y,g]),P=c.useCallback(async(X,ce)=>{if(y)return await v(y,X,ce)},[y,v]),O=c.useMemo(()=>(n==null?void 0:n.find(X=>X.id===(y==null?void 0:y.id)))||null,[n,y]),Z=c.useCallback(async()=>O?await w(O):[],[O,w]),L=c.useCallback(async X=>{if(O)return await x(O,X.email,X.workspaceRoleId)},[O,x]),W=c.useCallback(async X=>{if(O)return await b(O,X)},[O,b]),D=c.useCallback(async X=>{if(O)return await E(O,X)},[O,E]),B=r||C,Y=a||_;return B?{activeWorkspace:null,activeMembership:null,loading:!0,error:Y,refetch:e,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:y,activeMembership:k,loading:!1,error:Y,refetch:e,leave:M,updateWorkspace:A,deleteWorkspace:F,getMembers:I,getRoles:R,createRole:T,deleteRole:$,inviteMember:L,removeMember:z,addMemberRole:H,removeMemberRole:P,getInvitations:Z,discardInvitation:W,resendInvitation:D}};function Kn(e){const r=new Uint8Array(e);let a="";for(let n=0;n<r.length;n++)a+=String.fromCharCode(r[n]);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Yn(e){const r=e.replace(/-/g,"+").replace(/_/g,"/"),a=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(a),s=new Uint8Array(n.length);for(let i=0;i<n.length;i++)s[i]=n.charCodeAt(i);return s.buffer}const E2=async e=>(await V(await e("/me"))).data,A2=async e=>(await V(await e("/me/signins"))).data;function ir(){const{client:e,loading:r}=_e(),{data:a,error:n,isLoading:s,mutate:i}=$e(r?null:"/user",()=>E2(e)),h=async O=>{const Z=new FormData;for(const[W,D]of Object.entries(O))D!=null&&D!==""&&Z.append(W,String(D));const L=await V(await e("/me",{method:"POST",body:Z}));return i(),L},d=async()=>await V(await e("/me/email-addresses",{method:"GET"})),u=async O=>await V(await e(`/me/email-addresses/${O}`,{method:"GET"})),f=async O=>{const Z=new FormData;return Z.append("email",O),await V(await e("/me/email-addresses",{method:"POST",body:Z}))},p=async O=>await V(await e(`/me/email-addresses/${O}/delete`,{method:"POST"})),m=async O=>await V(await e(`/me/email-addresses/${O}/prepare-verification`,{method:"POST"})),g=async(O,Z)=>await V(await e(`/me/email-addresses/${O}/attempt-verification?code=${Z}`,{method:"POST"})),v=async(O,Z)=>{const L=new FormData;return L.append("phone_number",O),L.append("country_code",Z),await V(await e("/me/phone-numbers",{method:"POST",body:L}))},w=async O=>await V(await e(`/me/phone-numbers/${O}/delete`,{method:"POST"})),x=async O=>await V(await e(`/me/phone-numbers/${O}/prepare-verification`,{method:"POST"})),b=async(O,Z)=>{const L=new FormData;return L.append("code",Z),await V(await e(`/me/phone-numbers/${O}/attempt-verification`,{method:"POST",body:L}))},E=async O=>{const Z=await V(await e(`/me/phone-numbers/${O}/make-primary`,{method:"POST"}));return i(),Z},j=async O=>await V(await e(`/me/email-addresses/${O}/make-primary`,{method:"POST"})),S=async()=>(await V(await e("/me/authenticator",{method:"POST"}))).data,C=async(O,Z)=>{const L=new FormData;return L.append("authenticator_id",O),Z.forEach(D=>{L.append("codes",D)}),await V(await e("/me/authenticator/attempt-verification",{method:"POST",body:L}))},_=async O=>await V(await e(`/me/authenticator/${O}/delete`,{method:"POST"})),k=async()=>(await V(await e("/me/backup-codes",{method:"POST"}))).data,y=async O=>{const Z=new FormData;return Z.append("file",O),await V(await e("/me/profile-picture",{method:"POST",body:Z}))},M=async()=>(await V(await e("/me/backup-codes/regenerate",{method:"POST"}))).data,A=async(O,Z)=>{const L=new FormData;return L.append("current_password",O),L.append("new_password",Z),await V(await e("/me/update-password",{method:"POST",body:L}))},F=async O=>{const Z=new FormData;Z.append("current_password",O);const L=await V(await e("/me/remove-password",{method:"POST",body:Z}));return i(),L},I=async O=>{const Z=new FormData;return Z.append("password",O),await V(await e("/me/account/delete",{method:"POST",body:Z}))},R=async O=>await V(await e(`/me/social-connections/${O}/disconnect`,{method:"POST"})),T=async({provider:O,redirectUri:Z})=>{var D;const L=new URLSearchParams({provider:O});Z&&L.append("redirect_uri",Z);const W=await V(await e(`/me/init-sso-connection?${L.toString()}`,{method:"POST"}));return"data"in W&&((D=W.data)!=null&&D.oauth_url)&&window.open(W.data.oauth_url,"_blank"),W},$=async()=>await V(await e("/me/passkeys",{method:"GET"})),z=async O=>{var ce,me;const Z=await V(await e("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in Z))return Z;const L=Z.data.options.publicKey,W={challenge:Yn(L.challenge),rp:L.rp,user:{id:Yn(L.user.id),name:L.user.name,displayName:L.user.displayName},pubKeyCredParams:L.pubKeyCredParams,timeout:L.timeout,attestation:L.attestation,authenticatorSelection:L.authenticatorSelection,excludeCredentials:(ce=L.excludeCredentials)==null?void 0:ce.map(te=>({type:te.type,id:Yn(te.id),transports:te.transports}))},D=await navigator.credentials.create({publicKey:W});if(!D)throw new Error("Failed to create credential");const B=D.response,Y={id:D.id,rawId:Kn(D.rawId),type:D.type,response:{clientDataJSON:Kn(B.clientDataJSON),attestationObject:Kn(B.attestationObject),transports:((me=B.getTransports)==null?void 0:me.call(B))||[]}};return await V(await e(`/me/passkeys/register/finish?name=${encodeURIComponent(O||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}))},H=async O=>await V(await e(`/me/passkeys/${O}/delete`,{method:"POST"})),P=async(O,Z)=>await V(await e(`/me/passkeys/${O}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z})}));return{user:{...a,refetch:i},loading:r||s,error:n||null,updateProfile:h,getEmailAddresses:d,getEmailAddress:u,createEmailAddress:f,deleteEmailAddress:p,prepareEmailVerification:m,attemptEmailVerification:g,makeEmailPrimary:j,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:x,attemptPhoneVerification:b,makePhonePrimary:E,setupAuthenticator:S,verifyAuthenticator:C,deleteAuthenticator:_,generateBackupCodes:k,regenerateBackupCodes:M,updateProfilePicture:y,disconnectSocialConnection:R,connectSocialAccount:T,updatePassword:A,removePassword:F,deleteAccount:I,getPasskeys:$,registerPasskey:z,deletePasskey:H,renamePasskey:P}}function m0(){const{client:e,loading:r}=_e(),{data:a,error:n,isLoading:s,mutate:i}=$e(r?null:"/me/signins",()=>A2(e));return{signins:a,error:n||null,removeSignin:async d=>await V(await e(`/me/signins/${d}/signout`,{method:"POST"})),refetch:i,loading:s||r}}function g0(){const{session:e,loading:r}=ot(),{loading:a,organizationMemberships:n}=Kt(),{loading:s,workspaceMemberships:i}=An(),h=c.useMemo(()=>!e||!e.signins||e.signins.length===0?null:(n==null?void 0:n.find(u=>{var f;return u.id===((f=e.active_signin)==null?void 0:f.active_organization_membership_id)}))||null,[n,e]),d=c.useMemo(()=>!e||!e.signins||e.signins.length===0?null:(i==null?void 0:i.find(u=>{var f;return u.id===((f=e.active_signin)==null?void 0:f.active_workspace_membership_id)}))||null,[i,e]);return{loading:r||a||s,orgMembership:h,workspaceMembership:d}}function v0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),s=async i=>{n(!0);try{const h=new FormData;for(const[f,p]of Object.entries(i))p&&h.append(f,p);const d=await e("/waitlist/join",{method:"POST",body:h});return await V(d)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:a,joinWaitlist:s}}function x0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),[s,i]=c.useState(null),[h,d]=c.useState(null),[u,f]=c.useState(null),[p,m]=c.useState(!1),[g,v]=c.useState(null);c.useEffect(()=>{if(p||r)return;const x=new URLSearchParams(window.location.search),b=x.get("code"),E=x.get("state"),j=x.get("error"),S=x.get("error_description");if(!b&&!j){m(!0);const C=new Error("No OAuth callback data found.");i(C);return}if(m(!0),n(!0),j){const C=S||j,_=new Error(`OAuth Error: ${C}`);i(_),n(!1);return}if(b&&E)w(b,E);else{const C=new Error("Missing required OAuth parameters");i(C),n(!1)}},[p,r]);const w=async(x,b)=>{try{let E,j;try{const _=b.split(".");if(_.length!==3)throw new Error("Invalid OAuth state format - missing signature");const k=_[0].replace(/-/g,"+").replace(/_/g,"/"),y=k.length%4?"=".repeat(4-k.length%4):"",A=atob(k+y).split("|")[0];if(A==="sign_in")E="/auth/oauth2/callback",j="GET";else if(A==="connect_social")E="/me/sso-connection-callback",j="POST";else throw new Error(`Unknown OAuth action: ${A}`)}catch(_){const k=_ instanceof Error?_:new Error("Failed to parse OAuth state");i(new Error(`Invalid OAuth callback: ${k.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const S=await e(`${E}?code=${encodeURIComponent(x)}&state=${encodeURIComponent(b)}`,{method:j}),C=await V(S);if("data"in C){const _=C.data.session,k=C.data.redirect_uri||null;if(d(_),f(k),_.signin_attempts&&_.signin_attempts.length>0){const y=_.signin_attempts.at(-1);y&&v(y)}}else{const _=new Error("SSO callback failed");i(_)}}catch(E){const j=E instanceof Error?E:new Error("Unknown error occurred");i(j)}finally{n(!1)}};return{loading:a,error:s,session:h,redirectUri:u,processed:p,signinAttempt:g}}function b0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),[s,i]=c.useState(null);return{loading:r||a,verifyMagicLink:async d=>{if(!d.token||!d.attempt)throw new Error("Invalid magic link parameters");n(!0),i(null);try{const u=new URL("/auth/verify-magic-link",window.location.origin);u.searchParams.set("token",d.token),u.searchParams.set("attempt",d.attempt),d.redirectUri&&u.searchParams.set("redirect_uri",d.redirectUri);const f=await e(u.pathname+u.search,{method:"GET"}),p=await V(f);return n(!1),i(!0),p}catch(u){throw n(!1),i(!1),u}},success:s}}function z2(){const[e,r]=c.useState({});return c.useEffect(()=>{const a=new URLSearchParams(window.location.search);r({token:a.get("token")||void 0,attempt:a.get("attempt")||void 0,redirectUri:a.get("redirect_uri")||void 0})},[]),e}function w0(){const{client:e,loading:r}=_e();return{loading:r,forgotPassword:async i=>{const h=new FormData;h.append("email",i);const d=await e("/auth/forgot-password",{method:"POST",body:h});return await V(d)},verifyOtp:async(i,h)=>{const d=new FormData;d.append("email",i),d.append("otp",h);const u=await e("/auth/forgot-password",{method:"POST",body:d});return await V(u)},resetPassword:async(i,h)=>{const d=new FormData;d.append("token",i),d.append("password",h);const u=await e("/auth/reset-password",{method:"POST",body:d});return await V(u)}}}const $2=()=>{},M2=$2(),Yo=Object,ii=e=>e===M2,L2=e=>typeof e=="function",Za=new WeakMap,R2=e=>Yo.prototype.toString.call(e),Qn=(e,r)=>e===`[object ${r}]`;let P2=0;const Qo=e=>{const r=typeof e,a=R2(e),n=Qn(a,"Date"),s=Qn(a,"RegExp"),i=Qn(a,"Object");let h,d;if(Yo(e)===e&&!n&&!s){if(h=Za.get(e),h)return h;if(h=++P2+"~",Za.set(e,h),Array.isArray(e)){for(h="@",d=0;d<e.length;d++)h+=Qo(e[d])+",";Za.set(e,h)}if(i){h="#";const u=Yo.keys(e).sort();for(;!ii(d=u.pop());)ii(e[d])||(h+=d+":"+Qo(e[d])+",");Za.set(e,h)}}else h=n?e.toJSON():r=="symbol"?e.toString():r=="string"?JSON.stringify(e):""+e;return h},T2=e=>{if(L2(e))try{e=e()}catch{e=""}const r=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Qo(e):"",[e,r]},F2=e=>T2(e?e(0,null):null)[0],Jn=Promise.resolve(),I2=e=>(r,a,n)=>{const s=c.useRef(!1),{cache:i,initialSize:h=1,revalidateAll:d=!1,persistSize:u=!1,revalidateFirstPage:f=!0,revalidateOnMount:p=!1,parallel:m=!1}=n,[,,,g]=Tt.get(bs);let v;try{v=F2(r),v&&(v=u0+v)}catch{}const[w,x,b]=er(i,v),E=c.useCallback(()=>Ee(w()._l)?h:w()._l,[i,v,h]);Ho.useSyncExternalStore(c.useCallback(M=>v?b(v,()=>{M()}):()=>{},[i,v]),E,E);const j=c.useCallback(()=>{const M=w()._l;return Ee(M)?h:M},[v,h]),S=c.useRef(j());pn(()=>{if(!s.current){s.current=!0;return}v&&x({_l:u?S.current:j()})},[v,i]);const C=p&&!s.current,_=e(v,async M=>{const A=w()._i,F=w()._r;x({_r:pt});const I=[],R=j(),[T]=er(i,M),$=T().data,z=[];let H=null;for(let P=0;P<R;++P){const[O,Z]=ka(r(P,m?null:H));if(!O)break;const[L,W]=er(i,O);let D=L().data;const B=d||A||Ee(D)||f&&!P&&!Ee($)||C||$&&!Ee($[P])&&!n.compare($[P],D);if(a&&(typeof F=="function"?F(D,Z):B)){const Y=async()=>{if(!(O in g))D=await a(Z);else{const ce=g[O];delete g[O],D=await ce}W({data:D,_k:Z}),I[P]=D};m?z.push(Y):await Y()}else I[P]=D;m||(H=D)}return m&&await Promise.all(z.map(P=>P())),x({_i:pt}),I},n),k=c.useCallback(function(M,A){const F=typeof A=="boolean"?{revalidate:A}:A||{},I=F.revalidate!==!1;return v?(I&&(Ee(M)?x({_i:!0,_r:F.revalidate}):x({_i:!1,_r:F.revalidate})),arguments.length?_.mutate(M,{...F,revalidate:I}):_.mutate()):Jn},[v,i]),y=c.useCallback(M=>{if(!v)return Jn;const[,A]=er(i,v);let F;if($t(M)?F=M(j()):typeof M=="number"&&(F=M),typeof F!="number")return Jn;A({_l:F}),S.current=F;const I=[],[R]=er(i,v);let T=null;for(let $=0;$<F;++$){const[z]=ka(r($,T)),[H]=er(i,z),P=z?H().data:pt;if(Ee(P))return k(R().data);I.push(P),T=P}return k(I)},[v,i,k,j]);return{size:j(),setSize:y,mutate:k,get data(){return _.data},get error(){return _.error},get isValidating(){return _.isValidating},get isLoading(){return _.isLoading}}},ta=f2($e,I2);function y0({enabled:e=!0,channels:r,organizationIds:a,workspaceIds:n,onNotification:s,onError:i,reconnectDelay:h=1e3,maxReconnectAttempts:d=5}={}){const{session:u,loading:f}=ot(),{deployment:p,loading:m}=Ae(),[g,v]=c.useState(!1),[w,x]=c.useState(null),b=c.useRef(null),E=c.useRef(null),j=c.useRef(0),S=c.useRef(null),C=c.useRef(s),_=c.useRef(i),k=c.useRef(r),y=c.useRef(a),M=c.useRef(n),A=c.useRef(h),F=c.useRef(d);C.current=s,_.current=i,k.current=r,y.current=a,M.current=n,A.current=h,F.current=d;const I=c.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null),S.current&&(clearInterval(S.current),S.current=null),b.current&&(b.current.close(),b.current=null)},[]),R=c.useCallback(async()=>{var O;if(!e||f||m||!u||!p)return;I();const z=new URL(p.backend_host),H=z.protocol==="https:"?"wss:":"ws:",P=new URL("/notifications/stream",`${H}//${z.host}`);if(p.mode==="staging"){const Z=ht(p.backend_host);Z&&P.searchParams.set("__dev_session__",Z)}k.current&&k.current.length>0&&P.searchParams.set("channels",k.current.join(",")),y.current&&y.current.length>0&&P.searchParams.set("organization_ids",y.current.join(",")),M.current&&M.current.length>0&&P.searchParams.set("workspace_ids",M.current.join(","));try{const Z=new WebSocket(P.toString());b.current=Z,Z.onopen=()=>{v(!0),x(null),j.current=0,S.current=setInterval(()=>{Z.readyState===WebSocket.OPEN&&Z.send("ping")},3e4)},Z.onmessage=L=>{var W,D;try{const B=JSON.parse(L.data);if(B.type==="notification"&&B.data)(W=C.current)==null||W.call(C,B.data);else if(B.type==="error"){const Y=B.error||"Unknown error occurred";x(Y),(D=_.current)==null||D.call(_,Y)}else B.type}catch{}},Z.onerror=()=>{var L;x("Connection error occurred"),(L=_.current)==null||L.call(_,"Connection error occurred")},Z.onclose=L=>{var W;if(v(!1),S.current&&(clearInterval(S.current),S.current=null),e&&L.code!==1e3&&j.current<F.current){j.current++;const D=A.current*Math.pow(2,j.current-1);E.current=setTimeout(()=>{R()},D)}else j.current>=F.current&&(x("Max reconnection attempts reached"),(W=_.current)==null||W.call(_,"Max reconnection attempts reached"))}}catch{x("Failed to connect"),(O=_.current)==null||O.call(_,"Failed to connect")}},[e,f,m,u,p,I]);c.useEffect(()=>(R(),()=>{I()}),[R,I]),c.useEffect(()=>{b.current&&b.current.readyState===WebSocket.OPEN&&R()},[r,a,n,R]);const T=c.useCallback(()=>{I(),v(!1)},[I]),$=c.useCallback(()=>{j.current=0,R()},[R]);return{isConnected:g,connectionError:w,disconnect:T,reconnect:$}}function zn(e){if(!e)return"";const r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.cursor&&r.append("cursor",e.cursor),e.scope&&r.append("scope",e.scope),e.channels&&e.channels.length>0&&e.channels.forEach(n=>r.append("channels",n)),e.organization_ids&&e.organization_ids.length>0&&e.organization_ids.forEach(n=>r.append("organization_ids",n)),e.workspace_ids&&e.workspace_ids.length>0&&e.workspace_ids.forEach(n=>r.append("workspace_ids",n)),e.is_read!==void 0&&r.append("is_read",e.is_read.toString()),e.is_archived!==void 0&&r.append("is_archived",e.is_archived.toString()),e.is_starred!==void 0&&r.append("is_starred",e.is_starred.toString()),e.severity&&r.append("severity",e.severity);const a=r.toString();return a?"?"+a:""}async function Z2(e,r){const a=`/notifications${zn(r)}`,n=await e(a,{method:"GET"});return(await V(n)).data}async function O2(e,r){const a=await e(`/notifications/${r}/read`,{method:"POST"});return V(a)}async function H2(e,r){const a=await e(`/notifications/${r}/unread`,{method:"POST"});return V(a)}async function V2(e,r){const a=await e(`/notifications/mark-all-read${zn(r)}`,{method:"POST"});return V(a)}async function D2(e,r){const a=await e(`/notifications/archive-all-read${zn(r)}`,{method:"POST"});return V(a)}async function N2(e,r){const a=await e(`/notifications/${r}/archive`,{method:"POST"});return V(a)}async function U2(e,r){const a=await e(`/notifications/${r}/star`,{method:"POST"});return V(a)}function j0(e){var M;const{client:r,loading:a}=_e(),{data:n,error:s,mutate:i,isLoading:h,size:d,setSize:u,isValidating:f}=ta((A,F)=>{var $;if(a||A>0&&(!F||!F.has_more))return null;const I=A===0||($=F==null?void 0:F.notifications[F.notifications.length-1])==null?void 0:$.id,{onNotification:R,...T}=e||{};return["wacht-notifications",{...T,cursor:I}]},([,A])=>Z2(r,A),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),p=c.useMemo(()=>n?n.flatMap(A=>A.notifications):[],[n]),m=n?(M=n[n.length-1])==null?void 0:M.has_more:!1,g=c.useMemo(()=>{if(e!=null&&e.channels&&e.channels.length>0)return e.channels;switch(e==null?void 0:e.scope){case"organization":return["organization"];case"workspace":return["workspace"];case"current":return["current"];case"all":return["user","organization","workspace"];case"user":return["user"];default:return}},[e==null?void 0:e.channels,e==null?void 0:e.scope]),v=c.useMemo(()=>{var A;return(A=e==null?void 0:e.organization_ids)==null?void 0:A.map(F=>Number(F)).filter(F=>Number.isFinite(F))},[e==null?void 0:e.organization_ids]),w=c.useMemo(()=>{var A;return(A=e==null?void 0:e.workspace_ids)==null?void 0:A.map(F=>Number(F)).filter(F=>Number.isFinite(F))},[e==null?void 0:e.workspace_ids]);y0({enabled:!a&&!!n,channels:g,organizationIds:v,workspaceIds:w,onNotification:c.useCallback(A=>{i(async F=>{var $;if(!F||F.length===0||F.some(z=>z.notifications.some(H=>H.id===A.id.toString())))return F;($=e==null?void 0:e.onNotification)==null||$.call(e,A);const R=F[0];return[{...R,notifications:[{id:A.id.toString(),user_id:A.user_id.toString(),deployment_id:A.deployment_id.toString(),title:A.title,body:A.body,severity:A.severity,ctas:A.ctas,is_read:!1,is_archived:!1,created_at:A.created_at,updated_at:A.created_at},...R.notifications]},...F.slice(1)]},!1)},[i,e]),onError:c.useCallback(()=>{},[])});const x=c.useCallback(async A=>{a||(await i(async F=>F&&F.map(I=>({...I,notifications:I.notifications.map(R=>R.id===A?{...R,is_read:!0}:R)})),!1),await O2(r,A),await i())},[r,a,i]),b=c.useCallback(async A=>{a||(await i(async F=>F&&F.map(I=>({...I,notifications:I.notifications.map(R=>R.id===A?{...R,is_read:!1}:R)})),!1),await H2(r,A),await i())},[r,a,i]),E=c.useCallback(async()=>{a||(await i(async A=>A&&A.map(F=>({...F,notifications:F.notifications.map(I=>({...I,is_read:!0}))})),!1),await V2(r,e),await i())},[r,e,i,a]),j=c.useCallback(async()=>{a||(await i(async A=>A&&A.map(F=>({...F,notifications:F.notifications.filter(I=>!I.is_read)})),!1),await D2(r,e),await i())},[r,e,a,i]),S=c.useCallback(async A=>{a||(await i(async F=>F&&F.map(I=>({...I,notifications:(e==null?void 0:e.is_archived)!==void 0?I.notifications.filter(R=>R.id!==A):I.notifications.map(R=>R.id===A?{...R,is_archived:!R.is_archived}:R)})),!1),await N2(r,A),await i())},[r,a,i,e==null?void 0:e.is_archived]),C=c.useCallback(async A=>{a||(await i(async F=>F&&F.map(I=>({...I,notifications:I.notifications.map(R=>R.id===A?{...R,is_starred:!R.is_starred}:R)})),!1),await U2(r,A),await i())},[r,a,i]),_=c.useCallback(async()=>{f||!m||await u(d+1)},[f,m,u,d]),k=c.useCallback(async()=>{await i()},[i]),y=a||h||d>0&&n&&typeof n[d-1]>"u";return!n||y?{loading:!0,notifications:p,hasMore:m,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:s,refetch:k,loadMore:_}:{loading:!1,error:s,notifications:p,hasMore:m,markAsRead:x,markAllAsRead:E,archiveAllRead:j,archiveNotification:S,starNotification:C,markAsUnread:b,refetch:k,loadMore:_}}async function B2(e,r){const a=`/notifications/scope-unread${zn(r)}`,n=await e(a,{method:"GET"});return(await V(n)).data}function _0(e){const{client:r,loading:a}=_e(),{data:n,error:s,mutate:i}=$e(a?null:["wacht-notifications-unread",e],([,d])=>B2(r,d),{refreshInterval:3e4,revalidateOnFocus:!0}),h=async()=>{await i()};return!n||a?{loading:!0,count:0,error:s,refetch:h}:{loading:!1,count:n.count,error:s,refetch:h}}const Ir={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Ke={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},fr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function W2(e){switch(e.trim()){case fr.IDLE:return Ke.IDLE;case fr.STARTING:case"starting":return Ke.STARTING;case fr.RUNNING:case"running":return Ke.RUNNING;case fr.WAITING_FOR_INPUT:case"waiting_for_input":return Ke.WAITING_FOR_INPUT;case fr.COMPLETED:case"completed":return Ke.COMPLETED;case fr.FAILED:case fr.CANCELLED:case"failed":case"cancelled":return Ke.FAILED;default:return Ke.IDLE}}function Zr(e){return e===Ke.STARTING||e===Ke.RUNNING||e===Ke.WAITING_FOR_INPUT}function Gt(e){return e&&typeof e=="object"?e:null}function Cr(e){return typeof e=="string"?e:null}function G2(e){const r=Gt(e);return(r==null?void 0:r.ConversationMessage)??e}function q2(e){const r=Gt(e);if(!r)return null;const a=Gt(r.content),n=Gt(r.metadata),s=Cr(r.message_type)||Cr(n==null?void 0:n.message_type)||Cr(a==null?void 0:a.type);return{...r,metadata:{...n||{},message_type:s}}}function K2(e){const r=Gt(e.metadata),a=Gt(e.content);return Cr(r==null?void 0:r.message_type)||Cr(a==null?void 0:a.type)}function Y2(e){const r=Gt(e.content);return Cr(r==null?void 0:r.status)}function Q2(e){const r=Gt(e.content),a=Cr(r==null?void 0:r.step);return a==="execution_cancelled"||a==="abort"}function J2(e){const r=Gt(e.content);return(r==null?void 0:r.further_actions_required)===!1}function ci(e){return[...e].sort((r,a)=>new Date(r.timestamp).getTime()-new Date(a.timestamp).getTime())}function X2(e,r){return{id:e,timestamp:new Date().toISOString(),content:{type:"user_message",message:r},metadata:{message_type:"user_message"}}}function ep(e,r){const a=new FormData;a.append("message",e);for(const n of r??[])a.append("files",n);return a}function tp(e,r){const a=new FormData;a.append("request_message_id",e);for(const n of r)a.append("approval_tool_name",n.tool_name),a.append("approval_mode",n.mode);return a}function rp(){const e=new FormData;return e.append("cancel","true"),e}function ap({deployment:e,threadId:r,file:a}){const n=a.url||a.filename;if(!n)return null;if(/^https?:\/\//i.test(n))return n;const s=e.backend_host.replace(/\/$/,"");let i;if(n.startsWith("/ai/threads/"))i=new URL(n,`${s}/`);else{const h=n.includes("/")?n.split("/").pop()??"":n;if(!h)return null;i=new URL(`/ai/threads/${encodeURIComponent(r)}/filesystem/file`,`${s}/`),i.searchParams.set("path",`uploads/${h}`)}if(e.mode==="staging"){const h=ht(e.backend_host);h&&i.searchParams.set("__dev_session__",h)}return i.toString()}const np=5e3,op=5e3;function sp({threadId:e,initialThread:r=null,platformAdapter:a}){var We;const{deployment:n}=Ae(),{client:s}=_e(),[i,h]=c.useState([]),[d,u]=c.useState(null),[f,p]=c.useState(null),[m,g]=c.useState(r),[v,w]=c.useState(Ke.IDLE),[x,b]=c.useState({status:Ir.DISCONNECTED}),[E,j]=c.useState(!0),[S,C]=c.useState(!1),[_,k]=c.useState(!1),[y,M]=c.useState(null),A=c.useRef(null),F=c.useRef(e),I=c.useRef(0),R=c.useRef(Ke.IDLE),T=c.useRef(null),$=c.useCallback(Q=>{h(se=>{const he=[...se],je=he.findIndex(ke=>String(ke.id)===String(Q.id));return je>=0?he[je]=Q:he.push(Q),ci(he)})},[]),z=c.useCallback(({messages:Q,prepend:se,hasMore:he})=>{const je=ci(Q);je.length>0&&(A.current=je[0].id),h(ke=>se?[...je,...ke]:je),he!==void 0&&j(he)},[]),H=c.useCallback(Q=>{R.current=Q,w(Q)},[]),P=c.useCallback(Q=>{I.current=Date.now()+np,H(Q)},[H]),O=c.useCallback(()=>{var Q;I.current>Date.now()&&Zr(R.current)||(H(Ke.IDLE),(Q=T.current)==null||Q.call(T))},[H]),Z=c.useCallback(Q=>{const se=W2(Q),he=Zr(se);!he&&I.current>Date.now()&&Zr(R.current)||(he&&(I.current=0),H(se))},[H]),L=c.useCallback(()=>{u(null),p(null)},[]),W=c.useCallback(Q=>{g(se=>se&&{...se,...Q?{status:Q}:{},last_activity_at:new Date().toISOString()})},[]),D=c.useCallback((Q,se)=>{$(X2(Q,se)),L()},[L,$]),B=c.useCallback(Q=>{const se=q2(Q);if(!se)return;switch(K2(se)){case"system_decision":$(se),Q2(se)&&O();return;case"execution_summary":case"tool_result":case"user_message":$(se);return;case"steer":$(se),J2(se)&&O();return;case"approval_request":I.current=0,H(Ke.WAITING_FOR_INPUT),$(se);return;case"approval_response":$(se),P(Ke.RUNNING);return;case"execution_status":{const je=Y2(se);if(!je)return;Z(je),g(ke=>ke&&{...ke,status:je});return}default:$(se)}},[Z,O,H,P,$]),Y=c.useCallback((Q,se)=>{var he;(he=a==null?void 0:a.onPlatformEvent)==null||he.call(a,Q,se)},[a]),X=c.useRef(B),ce=c.useRef(Y),me=c.useRef(s),te=c.useRef(n);c.useEffect(()=>{X.current=B,ce.current=Y,me.current=s,te.current=n}),c.useEffect(()=>{F.current=e},[e]);const xe=c.useRef(null),re=c.useRef(null),U=c.useRef(0),Qe=10,Te=c.useCallback(async Q=>{if(!e)return;const se=e;Q?C(!0):k(!0),M(null);try{const he=new URLSearchParams({limit:"100"});Q&&he.append("before_id",Q);const je=await s(`/ai/threads/${e}/messages?${he}`,{method:"GET"}),ke=await V(je);ke.data&&F.current===se&&z({messages:ke.data.data,prepend:!!Q,hasMore:ke.data.has_more||!1})}catch(he){F.current===se&&M(he instanceof Error?he:new Error("Failed to fetch messages"))}finally{F.current===se&&(Q?C(!1):k(!1))}},[e,s,z]);c.useEffect(()=>{const Q=te.current;if(!Q||!e)return;const se=()=>{xe.current&&(xe.current.close(),xe.current=null);const he=new URL(`${Q.backend_host}/ai/threads/${encodeURIComponent(e)}/stream`);if(Q.mode==="staging"){const ke=ht(Q.backend_host);ke&&he.searchParams.append("__dev_session__",ke)}const je=new EventSource(he.toString(),{withCredentials:Q.mode!=="staging"});xe.current=je,je.onopen=()=>{if(b({status:Ir.CONNECTED}),U.current>0){const ke=e;setTimeout(()=>{s(`/ai/threads/${ke}/messages?limit=100`,{method:"GET"}).then(async Ge=>{const dt=await V(Ge);dt.data&&F.current===ke&&z({messages:dt.data.data,hasMore:dt.data.has_more||!1})}).catch(()=>{})},100)}U.current=0},je.onerror=()=>{if(b({status:Ir.ERROR}),je.close(),xe.current=null,U.current<Qe){const ke=Math.min(1e3*Math.pow(2,U.current),3e4);re.current=setTimeout(()=>{U.current++,se()},ke)}else b({status:Ir.DISCONNECTED})},je.addEventListener("conversation_message",ke=>{try{const Ge=G2(JSON.parse(ke.data));Ge&&X.current(Ge)}catch{}}),je.addEventListener("platform_event",ke=>{try{const Ge=JSON.parse(ke.data);Ge!=null&&Ge.PlatformEvent?ce.current(Ge.PlatformEvent[0],Ge.PlatformEvent[1]):Ge!=null&&Ge.event_label&&ce.current(Ge.event_label,Ge.event_data)}catch{}})};return se(),()=>{re.current&&(clearTimeout(re.current),re.current=null),xe.current&&(xe.current.close(),xe.current=null)}},[e,s,z]);const Ve=c.useCallback(async()=>{if(!e)return;const Q=e;try{const se=await s(`/ai/threads/${Q}`,{method:"GET"});if(!se.ok)return;const he=await V(se);he.data&&F.current===Q&&(g(he.data),Z(he.data.status),Gr(`wacht-ai-thread:${Q}`,he.data,{revalidate:!1}))}catch{}},[e,s,Z]);c.useEffect(()=>{T.current=Ve},[Ve]),c.useEffect(()=>{if(!e)return;Ve();const Q=window.setInterval(()=>{!Zr(R.current)&&I.current<=Date.now()||Ve()},op);return()=>{window.clearInterval(Q)}},[e,Ve]),c.useEffect(()=>{h([]),g(null),j(!0),C(!1),M(null),k(!!e),b({status:Ir.DISCONNECTED}),A.current=null,I.current=0,R.current=Ke.IDLE,w(Ke.IDLE),L()},[e,L]),c.useEffect(()=>{!r||r.id!==e||g(r)},[r,e]);const Ue=c.useCallback(async(Q,se)=>{var he,je;if(!(!e||!n)){u(Q),se&&se.length>0&&p(se),P(Ke.STARTING);try{const ke=await s(`/ai/threads/${e}/run`,{method:"POST",body:ep(Q,se)});if(ke.ok){const Ge=await V(ke),dt=((he=Ge.data)==null?void 0:he.conversation_id)??null;W(typeof((je=Ge.data)==null?void 0:je.status)=="string"?Ge.data.status:void 0),dt?D(dt,Q):L(),P(Ke.RUNNING)}else I.current=0,H(Ke.IDLE),L()}catch{I.current=0,H(Ke.IDLE),L()}}},[e,n,s,P,H,W,L,D]);c.useEffect(()=>{e&&Te()},[e,Te]);const ve=c.useCallback(async()=>{await Te()},[Te]),J=c.useCallback(async()=>{if(!(S||!E||!A.current)){C(!0);try{await Te(A.current)}finally{C(!1)}}},[S,E,Te]),le=c.useCallback(()=>{h([]),L()},[L]),oe=c.useCallback(async(Q,se)=>{if(!e)return!1;P(Ke.STARTING);try{return(await s(`/ai/threads/${e}/run`,{method:"POST",body:tp(Q,se)})).ok?(W(),P(Ke.RUNNING),!0):(I.current=0,H(Ke.IDLE),!1)}catch{return I.current=0,H(Ke.IDLE),!1}},[e,s,P,H,W]),G=c.useCallback(async()=>{if(!(!e||!Zr(v)))try{await s(`/ai/threads/${e}/run`,{method:"POST",body:rp()}),I.current=0,W(),H(Ke.IDLE)}catch{}},[e,v,s,H,W]),pe=c.useCallback(Q=>!n||!e||!Q?null:ap({deployment:n,threadId:e,file:Q}),[e,n]),fe=c.useCallback(Q=>{const se=pe(Q);if(!se)return;const he=document.createElement("a");he.href=se,he.download=(Q==null?void 0:Q.filename)||"attachment",he.rel="noreferrer",document.body.appendChild(he),he.click(),document.body.removeChild(he)},[pe]),q=((We=m==null?void 0:m.execution_state)==null?void 0:We.pending_approval_request)??null,de=(q==null?void 0:q.request_message_id)??null,Be=m==null?void 0:m.status;return{thread:m,threadState:m,threadStatus:Be,messages:i,pendingMessage:d,pendingFiles:f,connectionState:x,isConnected:x.status===Ir.CONNECTED,hasActiveRun:Zr(v),isRunning:v===Ke.STARTING||v===Ke.RUNNING,executionStatus:v,isWaitingForInput:v===Ke.WAITING_FOR_INPUT,pendingApprovalRequest:q,activeApprovalRequestId:de,hasMoreMessages:E,isLoadingMore:S,messagesLoading:_,messagesError:y,refreshThread:Ve,refreshMessages:ve,sendMessage:Ue,submitApprovalResponse:oe,clearMessages:le,loadMoreMessages:J,cancelExecution:G,resolveMessageFileUrl:pe,downloadMessageFile:fe}}function ip(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>{const C=await r("/ai/session",{method:"GET"});if(!C.ok)throw C.status===401||C.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await V(C)).data},[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-agent-session":null,g,{revalidateOnFocus:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(e)}`,{method:"GET"})).ok?(u.current=!0,n(!0)):d(new Error("Failed to exchange ticket"))}catch(_){d(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=!h&&(e?a:!0)&&(!w||w.message!=="NO_SESSION"),j=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:E,sessionLoading:s||m&&x,sessionError:j,sessionId:(v==null?void 0:v.session_id)||null,actor:(v==null?void 0:v.actor)||null,agents:(v==null?void 0:v.agents)||[],ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()}}}const li={exists:!1,files:[]};function Oa(e,r,a){const s=(e||[]).filter(i=>i.id!==r.id);return!a&&r.archived_at?s:[r,...s]}function cp(e,r){return r===void 0?"":`?${new URLSearchParams({[e]:String(r)}).toString()}`}function k0(e,r){const a=new URLSearchParams({path:e});return r&&a.set("include_archived","true"),`?${a.toString()}`}function C0(e,r){const a=new URLSearchParams;e&&a.set("path",e),r&&a.set("include_archived","true");const n=a.toString();return n?`?${n}`:""}function lp(e){const r=e.split("/").pop()||e,a=r.lastIndexOf(".");return a<0||a===r.length-1?"":r.slice(a+1).toLowerCase()}function dp(e,r){const a=lp(r),n=new Set(["doc","docx","ppt","pptx","xls","xlsx","pdf","zip","gz","tar","7z","rar","jar","war","bin"]),s=new Set(["txt","md","mdx","markdown","json","jsonc","js","jsx","ts","tsx","mts","cts","mjs","cjs","py","rb","php","java","kt","kts","go","rs","c","cc","cpp","cxx","h","hpp","swift","sh","bash","zsh","fish","ps1","sql","html","htm","css","scss","less","xml","svg","yaml","yml","toml","ini","cfg","conf","env","log"]);return n.has(a)?!1:s.has(a)?!0:e.startsWith("text/")||e.includes("json")||e.includes("javascript")||e.includes("typescript")||e.includes("python")||e.includes("xml")||e.includes("yaml")}function st(e,r,a){if(a!=null){if(typeof a=="string"){e.set(r,a);return}if(typeof a=="boolean"||typeof a=="number"){e.set(r,String(a));return}}}function up(e,r,a){a&&e.set(r,JSON.stringify(a))}function di(e){const r=new FormData;return st(r,"name",e.name),st(r,"agent_id","agent_id"in e?e.agent_id:void 0),st(r,"description",e.description),st(r,"status",e.status),r}function pp(e){const r=new FormData;if(st(r,"title",e.title),st(r,"agent_id",e.agent_id),st(r,"system_instructions",e.system_instructions),st(r,"thread_purpose",e.thread_purpose),st(r,"responsibility",e.responsibility),st(r,"reusable",e.reusable),st(r,"accepts_assignments",e.accepts_assignments),up(r,"metadata",e.metadata),Array.isArray(e.capability_tags))for(const a of e.capability_tags)r.append("capability_tags",a);return r}function S0(e){const r=new FormData;return st(r,"title",e.title),st(r,"agent_id",e.agent_id),st(r,"system_instructions",e.system_instructions),r}function E0(e,r=[]){const a=new FormData;st(a,"title",e.title),st(a,"description",e.description),st(a,"status",e.status),st(a,"schedule_kind",e.schedule_kind),st(a,"next_run_at",e.next_run_at),st(a,"interval_seconds",e.interval_seconds),"clear_schedule"in e&&st(a,"clear_schedule",e.clear_schedule);for(const n of r)a.append("files",n);return a}function hp(e={}){const{client:r}=_e(),{includeArchived:a=!1,enabled:n=!0}=e,s=n?`wacht-ai-actor-projects:${a}`:null,i=c.useCallback(async()=>{const v=await r(`/ai/projects${cp("include_archived",a)}`);return(await V(v)).data},[r,a]),{data:h,error:d,mutate:u}=$e(s,i,{revalidateOnFocus:!1}),f=c.useCallback(async v=>{const w=await r("/ai/projects",{method:"POST",body:di(v)}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]),p=c.useCallback(async(v,w)=>{const x=await r(`/ai/projects/${v}/update`,{method:"POST",body:di(w)}),b=await V(x);return await u(E=>Oa(E,b.data,a),{revalidate:!0}),b},[r,a,u]),m=c.useCallback(async v=>{const w=await r(`/ai/projects/${v}/archive`,{method:"POST",body:new URLSearchParams}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]),g=c.useCallback(async v=>{const w=await r(`/ai/projects/${v}/unarchive`,{method:"POST",body:new URLSearchParams}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]);return{projects:h||[],loading:!h&&!d,error:d,createProject:f,updateProject:p,archiveProject:m,unarchiveProject:g,refetch:async()=>{await u()}}}function fp(e={}){const{client:r}=_e(),{enabled:a=!0,query:n="",limit:s=12}=e,i=n.trim(),h=a?`wacht-ai-actor-project-search:${i}:${s}`:null,d=c.useCallback(async()=>{const m=new URLSearchParams({limit:String(s)});i&&m.set("q",i);const g=await r(`/ai/projects/search?${m.toString()}`);return(await V(g)).data},[r,s,i]),{data:u,error:f,mutate:p}=$e(h,d,{revalidateOnFocus:!1});return{projects:(u==null?void 0:u.data)||[],loading:!u&&!f,error:f,hasMore:(u==null?void 0:u.has_more)||!1,nextCursor:u==null?void 0:u.next_cursor,refetch:async()=>{await p()}}}function mp(e,r={}){const{client:a}=_e(),{includeArchived:n=!1,enabled:s=!0}=r,i=s&&e?`wacht-ai-threads:${e}:${n}`:null,h=c.useCallback(async()=>{if(!e)return{data:[],has_more:!1,next_cursor:""};const x=new URLSearchParams({limit:"100"});n&&x.set("include_archived","true");const b=await a(`/ai/projects/${e}/threads?${x.toString()}`);return(await V(b)).data},[e,a,n]),{data:d,error:u,mutate:f}=$e(i,h,{revalidateOnFocus:!1}),p=c.useCallback(async(x,b)=>{const E=await a(`/ai/projects/${x}/threads`,{method:"POST",body:pp(b)}),j=await V(E);return x===e&&await f(),j},[e,a,f]),m=c.useCallback(async x=>{if(!e)throw new Error("projectId is required");return p(e,x)},[e,p]),g=c.useCallback(async(x,b)=>{const E=await a(`/ai/threads/${x}/update`,{method:"POST",body:S0(b)}),j=await V(E);return await f(),j},[a,f]),v=c.useCallback(async x=>{const b=await a(`/ai/threads/${x}/archive`,{method:"POST",body:new URLSearchParams}),E=await V(b);return await f(),E},[a,f]),w=c.useCallback(async x=>{const b=await a(`/ai/threads/${x}/unarchive`,{method:"POST",body:new URLSearchParams}),E=await V(b);return await f(),E},[a,f]);return{threads:(d==null?void 0:d.data)||[],loading:!d&&!u,error:u,hasMore:(d==null?void 0:d.has_more)||!1,nextCursor:(d==null?void 0:d.next_cursor)||"",createThread:m,createThreadForProject:p,updateThread:g,archiveThread:v,unarchiveThread:w,refetch:async()=>{await f()}}}function gp(e,r={}){var v,w;const{client:a}=_e(),{includeArchived:n=!1,archivedOnly:s=!1,enabled:i=!0,query:h="",limit:d=10}=r,u=h.trim(),f=ta((x,b)=>{if(!i||!e||x>0&&b&&!b.has_more)return null;const E=x===0||b==null?void 0:b.next_cursor;return["wacht-ai-project-thread-feed",e,s?"archived-only":n?"with-archived":"active-only",u,d,E||""]},async([,x,b,E,j,S])=>{const C=new URLSearchParams({limit:String(j)});b==="with-archived"?C.set("include_archived","true"):b==="archived-only"&&(C.set("include_archived","true"),C.set("archived_only","true")),E&&C.set("q",String(E)),S&&C.set("cursor",String(S));const _=await a(`/ai/projects/${x}/threads?${C.toString()}`);return(await V(_)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0}),p=c.useMemo(()=>{var x;return((x=f.data)==null?void 0:x.flatMap(b=>b.data||[]))||[]},[f.data]),m=f.data&&((v=f.data[f.data.length-1])==null?void 0:v.has_more)||!1,g=f.isValidating&&!!f.data&&f.size>(((w=f.data)==null?void 0:w.length)||0);return{threads:p,loading:!f.data&&!f.error,error:f.error||null,hasMore:m,loadingMore:g,loadMore:async()=>{!m||g||await f.setSize(x=>x+1)},refetch:async()=>{await f.mutate()}}}function vp(e={}){const{client:r}=_e(),{enabled:a=!0,query:n="",limit:s=16}=e,i=n.trim(),h=a?`wacht-ai-actor-thread-search:${i}:${s}`:null,d=c.useCallback(async()=>{const m=new URLSearchParams({limit:String(s)});i&&m.set("q",i);const g=await r(`/ai/threads/search?${m.toString()}`);return(await V(g)).data},[r,s,i]),{data:u,error:f,mutate:p}=$e(h,d,{revalidateOnFocus:!1});return{threads:(u==null?void 0:u.data)||[],loading:!u&&!f,error:f,hasMore:(u==null?void 0:u.has_more)||!1,nextCursor:u==null?void 0:u.next_cursor,refetch:async()=>{await p()}}}function xp(e,r=!0){const{client:a}=_e(),n=r&&e?`wacht-ai-thread:${e}`:null,s=c.useCallback(async()=>{if(!e)return null;const f=await a(`/ai/threads/${e}`);return(await V(f)).data},[e,a]),i=$e(n,s,{revalidateOnFocus:!1}),h=c.useCallback(async f=>{if(!e)throw new Error("threadId is required");const p=await a(`/ai/threads/${e}/update`,{method:"POST",body:S0(f)}),m=await V(p);return await i.mutate(),m},[e,a,i]),d=c.useCallback(async()=>{if(!e)throw new Error("threadId is required");const f=await a(`/ai/threads/${e}/archive`,{method:"POST",body:new URLSearchParams}),p=await V(f);return await i.mutate(),p},[e,a,i]),u=c.useCallback(async()=>{if(!e)throw new Error("threadId is required");const f=await a(`/ai/threads/${e}/unarchive`,{method:"POST",body:new URLSearchParams}),p=await V(f);return await i.mutate(),p},[e,a,i]);return{thread:i.data||null,loading:!i.data&&!i.error,error:i.error||null,updateThread:h,archiveThread:d,unarchiveThread:u,refetch:async()=>{await i.mutate()}}}function bp(e,r=!0){const{client:a}=_e(),n=r&&e?`wacht-ai-thread-filesystem:${e}`:null,s=c.useCallback(async d=>{if(!e)throw new Error("threadId is required");const u=await a(`/ai/threads/${e}/filesystem/file${k0(d)}`);if(!u.ok)throw new Error("Failed to load file");const f=await u.blob(),p=(u.headers.get("content-type")||"application/octet-stream").split(";")[0].trim().toLowerCase(),m=dp(p,d);let g;return m&&(g=await f.text()),{path:d,name:d.split("/").pop()||"file",mime_type:p,is_text:m,size_bytes:f.size,truncated:!1,content:g,blob:f}},[e,a]),i=c.useCallback(async d=>{if(!e)return li;const u=await a(`/ai/threads/${e}/filesystem${C0(d)}`);return(await V(u)).data},[e,a]),h=$e(n,()=>i(),{revalidateOnFocus:!1});return{filesystem:h.data||li,filesystemLoading:!h.data&&!h.error,filesystemError:h.error||null,getFile:s,listDirectory:i,refetch:async()=>{await h.mutate()}}}function wp(e,r={}){var f,p;const{client:a}=_e(),{enabled:n=!0,limit:s=40}=r,i=ta((m,g)=>{if(!n||!e||m>0&&g&&!g.has_more)return null;const v=m===0||g==null?void 0:g.next_cursor;return["wacht-ai-thread-assignments",e,s,v||""]},async([,m,g,v])=>{const w=new URLSearchParams({limit:String(g)});v&&w.set("cursor",String(v));const x=await a(`/ai/threads/${m}/assignments?${w.toString()}`);return(await V(x)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),h=c.useMemo(()=>{var m;return((m=i.data)==null?void 0:m.flatMap(g=>g.data||[]))||[]},[i.data]),d=i.data&&((f=i.data[i.data.length-1])==null?void 0:f.has_more)||!1,u=i.isValidating&&!!i.data&&i.size>(((p=i.data)==null?void 0:p.length)||0);return{assignments:h,loading:!i.data&&!i.error,error:i.error||null,hasMore:d,loadingMore:u,loadMore:async()=>{!d||u||await i.setSize(m=>m+1)},refetch:async()=>{await i.mutate()}}}function yp(e={},r){const a=new URLSearchParams;e.statuses&&e.statuses.length>0&&a.set("status",e.statuses.join(",")),e.includeArchived&&a.set("include_archived","true"),e.archivedOnly&&a.set("archived_only","true"),e.limit&&a.set("limit",String(e.limit)),r&&a.set("cursor",r);const n=a.toString();return n?`?${n}`:""}function jp(e,r=!0,a={}){var w,x,b;const{client:n}=_e(),s=((w=a.statuses)==null?void 0:w.join(","))||"all",i=a.archivedOnly?"archived-only":a.includeArchived?"with-archived":"active-only",h=a.limit||60,d=ta((E,j)=>{if(!r||!e||E>0&&j&&!j.has_more)return null;const S=E===0||j==null?void 0:j.next_cursor;return["wacht-ai-project-tasks",e,s,i,h,S||""]},async([,E,,,,j])=>{const S=await n(`/ai/projects/${E}/board/items${yp(a,j||void 0)}`);return(await V(S)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),u=c.useMemo(()=>{var E;return((E=d.data)==null?void 0:E.flatMap(j=>j.data||[]))||[]},[d.data]),f=d.data&&((x=d.data[d.data.length-1])==null?void 0:x.has_more)||!1,p=d.isValidating&&!!d.data&&d.size>(((b=d.data)==null?void 0:b.length)||0),m=c.useCallback(async(E,j=[])=>{if(!e)throw new Error("projectId is required");const S=await n(`/ai/projects/${e}/board/items`,{method:"POST",body:E0(E,j)}),C=await V(S);return await d.mutate(),C},[e,n,d]),g=c.useCallback(async E=>{if(!e)throw new Error("projectId is required");const j=await n(`/ai/projects/${e}/board/items/${E}/archive`,{method:"POST",body:new URLSearchParams}),S=await V(j);return await d.mutate(),S},[e,n,d]),v=c.useCallback(async E=>{if(!e)throw new Error("projectId is required");const j=await n(`/ai/projects/${e}/board/items/${E}/unarchive`,{method:"POST",body:new URLSearchParams}),S=await V(j);return await d.mutate(),S},[e,n,d]);return{tasks:u,loading:!d.data&&!d.error,error:d.error||null,hasMore:f,loadingMore:p,loadMore:async()=>{!f||p||await d.setSize(E=>E+1)},createTask:m,archiveTask:g,unarchiveTask:v,refetch:async()=>{await d.mutate()}}}function _p(e,r,a=!0,n={}){var y,M;const{client:s}=_e(),i=n.includeArchived?"with-archived":"active-only",h=n.includeArchived?"?include_archived=true":"",d=a&&e&&r?`wacht-ai-board-item:${e}:${r}:${i}`:null,u=a&&e&&r?`wacht-ai-board-item-workspace:${e}:${r}:${i}`:null,f=c.useCallback(async()=>{if(!e||!r)return null;const A=await s(`/ai/projects/${e}/board/items/${r}${h}`);return(await V(A)).data},[e,r,s,h]),p=$e(d,f,{revalidateOnFocus:!1,refreshInterval:5e3}),m=ta((A,F)=>{if(!a||!e||!r||A>0&&F&&!F.has_more)return null;const I=A===0||F==null?void 0:F.next_cursor;return["wacht-ai-board-item-assignments",e,r,i,I||""]},async([,A,F,,I])=>{const R=new URLSearchParams({limit:"40"});n.includeArchived&&R.set("include_archived","true"),I&&R.set("cursor",String(I));const T=await s(`/ai/projects/${A}/board/items/${F}/assignments?${R.toString()}`);return(await V(T)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),g=c.useCallback(async()=>{if(!e||!r)return{exists:!1,files:[]};const A=await s(`/ai/projects/${e}/board/items/${r}/filesystem${h}`);return(await V(A)).data},[e,r,s,h]),v=$e(u,g,{revalidateOnFocus:!1,refreshInterval:5e3}),w=c.useCallback(async(A,F=[])=>{if(!e||!r)throw new Error("projectId and itemId are required");const I=await s(`/ai/projects/${e}/board/items/${r}/update`,{method:"POST",body:E0(A,F)}),R=await V(I);return await p.mutate(),await v.mutate(),R},[e,r,s,p,v]),x=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const A=await s(`/ai/projects/${e}/board/items/${r}/archive`,{method:"POST",body:new URLSearchParams}),F=await V(A);return await p.mutate(),F},[e,r,s,p]),b=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const A=await s(`/ai/projects/${e}/board/items/${r}/unarchive`,{method:"POST",body:new URLSearchParams}),F=await V(A);return await p.mutate(),F},[e,r,s,p]),E=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const A=await s(`/ai/projects/${e}/board/items/${r}/cancel`,{method:"POST",body:new URLSearchParams}),F=await V(A);return await p.mutate(),await m.mutate(),F},[e,r,s,p,m]),j=c.useCallback(async A=>{if(!e||!r)throw new Error("projectId and itemId are required");const F=await s(`/ai/projects/${e}/board/items/${r}/filesystem/file${k0(A,n.includeArchived)}`);return await V(F)},[e,r,s,n.includeArchived]),S=c.useCallback(async A=>{if(!e||!r)throw new Error("projectId and itemId are required");const F=await s(`/ai/projects/${e}/board/items/${r}/filesystem${C0(A,n.includeArchived)}`);return await V(F)},[e,r,s,n.includeArchived]),C=c.useMemo(()=>{var A;return((A=m.data)==null?void 0:A.flatMap(F=>F.data||[]))||[]},[m.data]),_=m.data&&((y=m.data[m.data.length-1])==null?void 0:y.has_more)||!1,k=m.isValidating&&!!m.data&&m.size>(((M=m.data)==null?void 0:M.length)||0);return{item:p.data||null,assignments:C,assignmentsHasMore:_,assignmentsLoadingMore:k,loadMoreAssignments:async()=>{!_||k||await m.setSize(A=>A+1)},taskWorkspace:v.data||{exists:!1,files:[]},taskWorkspaceLoading:!v.data&&!v.error,taskWorkspaceError:v.error||null,loading:!p.data&&!p.error||!m.data&&!m.error,error:p.error||m.error||null,updateItem:w,archiveItem:x,unarchiveItem:b,cancelItem:E,getTaskWorkspaceFile:j,listTaskWorkspaceDirectory:S,refetch:async()=>{await p.mutate(),await m.mutate(),await v.mutate()},refetchAssignments:async()=>{await m.mutate()},refetchTaskWorkspace:async()=>{await v.mutate()}}}function kp(e,r=!0){var v;const{client:a}=_e(),{data:n,error:s,mutate:i,isLoading:h,size:d,setSize:u,isValidating:f}=ta((w,x)=>{if(!r||!e||w>0&&(!x||!x.has_more))return null;const b=w===0||x==null?void 0:x.next_cursor;return["wacht-ai-thread-graphs",e,b]},async([,w,x])=>{const b=new URLSearchParams;b.set("limit","10"),x&&b.set("cursor",String(x));const E=await a(`/ai/threads/${w}/task-graphs?${b.toString()}`),S=(await V(E)).data||{data:[],limit:10,has_more:!1};return{...S,data:(S.data||[]).map(C=>({...C,nodes:Array.isArray(C.nodes)?C.nodes:[],edges:Array.isArray(C.edges)?C.edges:[],summary:C.summary||null}))}},{revalidateOnFocus:!1,refreshInterval:5e3,revalidateFirstPage:!0,revalidateAll:!1,persistSize:!0}),p=c.useMemo(()=>n?n.flatMap(w=>w.data||[]):[],[n]),m=n&&((v=n[n.length-1])==null?void 0:v.has_more)||!1,g=f&&!!n&&d>((n==null?void 0:n.length)||0);return{graphs:p,latestGraph:p[0]||null,has_more:m,loadingMore:g,loading:h,error:s,loadMore:async()=>{!m||g||await u(d+1)},refetch:async()=>{await i()}}}function Cp(e=!0){const{client:r}=_e(),a=e?"wacht-ai-actor-mcp-servers":null,n=c.useCallback(async()=>{const p=await r("/ai/mcp-servers");return(await V(p)).data},[r]),{data:s,error:i,mutate:h,isLoading:d}=$e(a,n,{revalidateOnFocus:!1}),u=c.useCallback(async p=>{const m=await r(`/ai/mcp-servers/${p}/connect`,{method:"POST",body:new URLSearchParams});return V(m)},[r]),f=c.useCallback(async p=>{const m=await r(`/ai/mcp-servers/${p}/disconnect`,{method:"POST",body:new URLSearchParams}),g=await V(m);return await h(),g},[r,h]);return{servers:s??[],loading:d,error:i,connect:u,disconnect:f,refetch:async()=>{await h()}}}function Sp(e=!0){const{client:r}=_e(),a=e?"wacht-ai-external-agent-connections":null,n=c.useCallback(async()=>{const p=await r("/ai/external-connections");return(await V(p)).data},[r]),{data:s,error:i,mutate:h,isLoading:d}=$e(a,n,{revalidateOnFocus:!1}),u=c.useCallback(async(p,m,g)=>{const v=await r(`/ai/external-connections/${encodeURIComponent(p)}/${encodeURIComponent(m)}/connect`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({return_url:(g==null?void 0:g.returnUrl)??""})}),w=await V(v);return await h(),w.data},[r,h]),f=c.useCallback(async(p,m)=>{const g=await r(`/ai/external-connections/${encodeURIComponent(p)}/${encodeURIComponent(m)}`,{method:"DELETE"}),v=await V(g);return await h(),v.data},[r,h]);return{connections:s??[],loading:d,error:i,connect:u,disconnect:f,refetch:async()=>{await h()}}}function A0(e){const r=new URLSearchParams;return r.append("url",e.url),e.description&&r.append("description",e.description),e.subscribed_events&&e.subscribed_events.forEach(a=>r.append("subscribed_events",a)),e.subscriptions&&e.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(e.subscriptions)),e.headers&&Object.entries(e.headers).forEach(([a,n])=>{r.append(`headers[${a}]`,n)}),e.rate_limit_config&&(r.append("rate_limit[duration_ms]",e.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",e.rate_limit_config.max_requests.toString())),r}function Ep(e){const r=new URLSearchParams;return e.url&&r.append("url",e.url),e.description!==void 0&&r.append("description",e.description||""),e.subscribed_events&&e.subscribed_events.forEach(a=>r.append("subscribed_events",a)),e.subscriptions&&e.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(e.subscriptions)),e.headers&&Object.entries(e.headers).forEach(([a,n])=>{r.append(`headers[${a}]`,n)}),e.is_active!==void 0&&r.append("is_active",e.is_active.toString()),e.rate_limit_config&&(r.append("rate_limit[duration_ms]",e.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",e.rate_limit_config.max_requests.toString())),r}function Ap(e){const r=new URLSearchParams;return r.append("event_name",e.event_name),r.append("payload",JSON.stringify(e.payload||{})),r}function zp(e){const r=new URLSearchParams;return(e.delivery_ids||[]).forEach(n=>r.append("delivery_ids",n)),e.start_date&&r.append("start_date",e.start_date),e.end_date&&r.append("end_date",e.end_date),e.status&&r.append("status",e.status),e.event_name&&r.append("event_name",e.event_name),e.endpoint_id&&r.append("endpoint_id",e.endpoint_id),e.idempotency_key&&r.append("idempotency_key",e.idempotency_key),r}const za={"Content-Type":"application/x-www-form-urlencoded"};async function St(e,r){const a=await V(e);if(!a||!("data"in a))throw new Error(r);return a}async function $p(e){const r=await e("/webhook/session",{method:"GET"});if(!r.ok)throw r.status===401||r.status===403?new Error("NO_SESSION"):new Error("Failed to fetch webhook app session");return(await St(r,"Failed to fetch webhook app session")).data}async function Mp(e,r){if(!(await e(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"})).ok)throw new Error("Failed to exchange ticket")}async function Lp(e,r){const a=A0(r),n=await e("/webhook/endpoints",{method:"POST",headers:za,body:a.toString()});return St(n,"Failed to create webhook endpoint")}async function Rp(e,r,a){const n=Ep(a),s=await e(`/webhook/endpoints/${r}`,{method:"PUT",headers:za,body:n.toString()});return St(s,"Failed to update webhook endpoint")}async function Pp(e,r){const a=await e(`/webhook/endpoints/${r}`,{method:"DELETE"});return St(a,"Failed to delete webhook endpoint")}async function Tp(e,r,a){const n=Ap(a),s=await e(`/webhook/endpoints/${r}/test`,{method:"POST",headers:za,body:n.toString()});return St(s,"Failed to test webhook endpoint")}async function Fp(e){const r=await e("/webhook/rotate-secret",{method:"POST"});return St(r,"Failed to rotate signing secret")}async function Ip(e,r){const a=new URLSearchParams;for(const s of r.failure_notification_emails)a.append("failure_notification_emails",s);const n=await e("/webhook/settings",{method:"PUT",headers:za,body:a.toString()});return St(n,"Failed to update webhook settings")}async function Zp(e,r){const a=zp(r),n=await e("/webhook/deliveries/replay",{method:"POST",headers:za,body:a.toString()});return St(n,"Failed to replay webhook delivery")}async function Op(e,r){const a=await e(`/webhook/deliveries/${r}`,{method:"GET"});return St(a,"Failed to fetch delivery details")}async function Hp(e,{taskId:r}){const a=await e(`/webhook/deliveries/replay/${r}`,{method:"GET"});return St(a,"Failed to fetch replay task status")}async function Vp(e,r){const a=(r==null?void 0:r.limit)??50,n=(r==null?void 0:r.offset)??0,s=await e(`/webhook/deliveries/replay?limit=${a}&offset=${n}`,{method:"GET"});return St(s,"Failed to fetch replay tasks")}async function Dp(e,{taskId:r}){const a=await e(`/webhook/deliveries/replay/${r}/cancel`,{method:"POST"});return St(a,"Failed to cancel replay task")}function Np(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>$p(r),[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-webhook-app-session":null,g,{revalidateOnFocus:!1,shouldRetryOnError:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{await Mp(r,e),u.current=!0,n(!0)}catch(H){d(H instanceof Error?H:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=c.useCallback(async z=>Lp(r,z),[r]),j=c.useCallback(async(z,H)=>Rp(r,z,H),[r]),S=c.useCallback(async z=>Pp(r,z),[r]),C=c.useCallback(async(z,H)=>Tp(r,z,H),[r]),_=c.useCallback(async()=>Fp(r),[r]),k=c.useCallback(async z=>Zp(r,z),[r]),y=c.useCallback(async z=>Ip(r,z),[r]),M=c.useCallback(async z=>Op(r,z),[r]),A=c.useCallback(async z=>Hp(r,z),[r]),F=c.useCallback(async z=>Vp(r,z),[r]),I=c.useCallback(async z=>Dp(r,z),[r]),R=!w||w.message!=="NO_SESSION",T=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:R,sessionLoading:s||m&&x,sessionError:T,sessionId:(v==null?void 0:v.session_id)||null,webhookApp:(v==null?void 0:v.webhook_app)||null,ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()},createEndpoint:E,updateEndpoint:j,deleteEndpoint:S,testEndpoint:C,rotateSecret:_,updateSettings:y,replayDelivery:k,fetchReplayTaskStatus:A,fetchReplayTasks:F,cancelReplayTask:I,fetchDeliveryDetail:M}}function Up(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/stats",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-stats",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{stats:a||null,loading:s,error:n,refetch:()=>i()}}function Bp(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/endpoints",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-endpoints",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{endpoints:a||[],loading:s,error:n,refetch:()=>i()}}function Wp(){const{client:e}=_e();return{createEndpoint:c.useCallback(async a=>{const n=A0(a),s=await e("/webhook/endpoints",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()});return await V(s)},[e]),loading:!1,error:null}}function Gp(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/events",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-events",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{events:a||[],loading:s,error:n,refetch:()=>i()}}function qp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.status&&d.set("status",e.status),e.event_name&&d.set("event_name",e.event_name),e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor);const u=await r(`/webhook/deliveries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.endpoint_id,e.status,e.event_name,e.limit,e.cursor]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.status&&d.set("status",e.status),e.event_name&&d.set("event_name",e.event_name),e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),`wacht-webhook-deliveries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{deliveries:(n==null?void 0:n.data)||[],has_more:(n==null?void 0:n.has_more)||!1,next_cursor:n==null?void 0:n.next_cursor,loading:i,error:s,refetch:()=>h()}}function Kp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.fields&&e.fields.length>0&&d.set("fields",e.fields.join(","));const u=await r(`/webhook/analytics?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.endpoint_id,e.fields]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.fields&&e.fields.length>0&&d.set("fields",e.fields.join(",")),`wacht-webhook-analytics?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:n||null,loading:i,error:s,refetch:()=>h()}}function Yp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id);const u=await r(`/webhook/analytics/timeseries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.interval,e.endpoint_id]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),`wacht-webhook-timeseries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(n==null?void 0:n.data)||[],interval:(n==null?void 0:n.interval)||"hour",loading:i,error:s,refetch:()=>h()}}function Qp(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>{const C=await r("/api-auth/session",{method:"GET"});if(!C.ok)throw C.status===401||C.status===403?new Error("NO_SESSION"):new Error("Failed to fetch API auth app session");return(await V(C)).data},[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-api-auth-app-session":null,g,{revalidateOnFocus:!1,shouldRetryOnError:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(e)}`,{method:"GET"})).ok?(u.current=!0,n(!0)):d(new Error("Failed to exchange ticket"))}catch(_){d(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=!w||w.message!=="NO_SESSION",j=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:E,sessionLoading:s||m&&x,sessionError:j,sessionId:(v==null?void 0:v.session_id)||null,apiAuthApp:(v==null?void 0:v.api_auth_app)||null,ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()}}}function Jp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const p=new URLSearchParams;e.status&&p.set("status",e.status);const m=await r(`/api-auth/keys${p.toString()?`?${p.toString()}`:""}`,{method:"GET"});return(await V(m)).data},[r,e.status]),{data:n,error:s,isLoading:i,mutate:h}=$e(`wacht-api-auth-keys:${e.status||"all"}`,a,{revalidateOnFocus:!1,shouldRetryOnError:!1}),d=c.useCallback(async p=>{const m=new URLSearchParams;m.set("name",p.name),p.expires_at&&m.set("expires_at",p.expires_at);const g=await r("/api-auth/keys",{method:"POST",body:m}),v=await V(g);return await h(),v},[r,h]),u=c.useCallback(async p=>{const m=await r(`/api-auth/keys/${p.key_id}/rotate`,{method:"POST"}),g=await V(m);return await h(),g},[r,h]),f=c.useCallback(async p=>{const m=new URLSearchParams;p.reason&&m.set("reason",p.reason);const g=await r(`/api-auth/keys/${p.key_id}/revoke`,{method:"POST",body:m}),v=await V(g);return await h(),v},[r,h]);return{keys:n||[],createKey:d,rotateKey:u,revokeKey:f,loading:i,error:s,refetch:()=>h()}}function Xp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),e.outcome&&d.set("outcome",e.outcome),e.key_id&&d.set("key_id",e.key_id),e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date);const u=await r(`/api-auth/audit/logs?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.limit,e.cursor,e.outcome,e.key_id,e.start_date,e.end_date]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),e.outcome&&d.set("outcome",e.outcome),e.key_id&&d.set("key_id",e.key_id),e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),`wacht-api-auth-audit-logs?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{logs:(n==null?void 0:n.data)||[],limit:(n==null?void 0:n.limit)||e.limit||0,has_more:(n==null?void 0:n.has_more)||!1,next_cursor:n==null?void 0:n.next_cursor,loading:i,error:s,refetch:()=>h()}}function eh(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.key_id&&d.set("key_id",e.key_id),e.include_top_keys&&d.set("include_top_keys","true"),e.include_top_paths&&d.set("include_top_paths","true"),e.include_blocked_reasons&&d.set("include_blocked_reasons","true"),e.include_rate_limits&&d.set("include_rate_limits","true"),e.top_limit&&d.set("top_limit",e.top_limit.toString());const u=await r(`/api-auth/audit/analytics?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.key_id,e.include_top_keys,e.include_top_paths,e.include_blocked_reasons,e.include_rate_limits,e.top_limit]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.key_id&&d.set("key_id",e.key_id),e.include_top_keys&&d.set("include_top_keys","true"),e.include_top_paths&&d.set("include_top_paths","true"),e.include_blocked_reasons&&d.set("include_blocked_reasons","true"),e.include_rate_limits&&d.set("include_rate_limits","true"),e.top_limit&&d.set("top_limit",e.top_limit.toString()),`wacht-api-auth-audit-analytics?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:n||null,loading:i,error:s,refetch:()=>h()}}function th(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.key_id&&d.set("key_id",e.key_id);const u=await r(`/api-auth/audit/timeseries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.interval,e.key_id]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.key_id&&d.set("key_id",e.key_id),`wacht-api-auth-audit-timeseries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(n==null?void 0:n.data)||[],interval:(n==null?void 0:n.interval)||e.interval||"hour",loading:i,error:s,refetch:()=>h()}}const z0=()=>{const{client:e}=_e(),[r,a]=c.useState(!1),[n,s]=c.useState(null),[i,h]=c.useState(null),d=c.useCallback(async f=>{a(!0),s(null),h(null);try{const p=new FormData;p.append("token",f);const m=await e("/organizations/invitations/accept",{method:"POST",body:p}),v=(await V(m)).data;return h(v),v.error_code&&s(v.message||"Failed to accept invitation"),v}catch(p){const m=p.message||"Failed to accept invitation";s(m);const g={error_code:"NETWORK_ERROR",message:m};return h(g),g}finally{a(!1)}},[e]),u=c.useCallback(()=>{s(null),h(null)},[]);return{acceptInvitation:d,invitationData:i,loading:r,error:n,reset:u}},rh=({children:e})=>{const{loading:r}=Ae();return r?null:t.jsx(t.Fragment,{children:e})},ah=({children:e})=>{const{loading:r}=Ae();return r?t.jsx(t.Fragment,{children:e}):null};function nh(e){var r=Object.create(null);return function(a){return r[a]===void 0&&(r[a]=e(a)),r[a]}}var oh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,sh=nh(function(e){return oh.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),Xe="-ms-",ya="-moz-",Ne="-webkit-",$0="comm",$n="rule",ws="decl",ih="@import",ch="@namespace",M0="@keyframes",lh="@layer",L0=Math.abs,ys=String.fromCharCode,Jo=Object.assign;function dh(e,r){return ut(e,0)^45?(((r<<2^ut(e,0))<<2^ut(e,1))<<2^ut(e,2))<<2^ut(e,3):0}function R0(e){return e.trim()}function Ut(e,r){return(e=r.exec(e))?e[0]:e}function Le(e,r,a){return e.replace(r,a)}function hn(e,r,a){return e.indexOf(r,a)}function ut(e,r){return e.charCodeAt(r)|0}function Lr(e,r,a){return e.slice(r,a)}function zt(e){return e.length}function P0(e){return e.length}function va(e,r){return r.push(e),e}function uh(e,r){return e.map(r).join("")}function ui(e,r){return e.filter(function(a){return!Ut(a,r)})}var Mn=1,Qr=1,T0=0,Ct=0,it=0,ra="";function Ln(e,r,a,n,s,i,h,d){return{value:e,root:r,parent:a,type:n,props:s,children:i,line:Mn,column:Qr,length:h,return:"",siblings:d}}function Xt(e,r){return Jo(Ln("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function Or(e){for(;e.root;)e=Xt(e.root,{children:[e]});va(e,e.siblings)}function ph(){return it}function hh(){return it=Ct>0?ut(ra,--Ct):0,Qr--,it===10&&(Qr=1,Mn--),it}function Lt(){return it=Ct<T0?ut(ra,Ct++):0,Qr++,it===10&&(Qr=1,Mn++),it}function tr(){return ut(ra,Ct)}function fn(){return Ct}function Rn(e,r){return Lr(ra,e,r)}function Ca(e){switch(e){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 fh(e){return Mn=Qr=1,T0=zt(ra=e),Ct=0,[]}function mh(e){return ra="",e}function Xn(e){return R0(Rn(Ct-1,Xo(e===91?e+2:e===40?e+1:e)))}function gh(e){for(;(it=tr())&&it<33;)Lt();return Ca(e)>2||Ca(it)>3?"":" "}function vh(e,r){for(;--r&&Lt()&&!(it<48||it>102||it>57&&it<65||it>70&&it<97););return Rn(e,fn()+(r<6&&tr()==32&&Lt()==32))}function Xo(e){for(;Lt();)switch(it){case e:return Ct;case 34:case 39:e!==34&&e!==39&&Xo(it);break;case 40:e===41&&Xo(e);break;case 92:Lt();break}return Ct}function xh(e,r){for(;Lt()&&e+it!==57;)if(e+it===84&&tr()===47)break;return"/*"+Rn(r,Ct-1)+"*"+ys(e===47?e:Lt())}function bh(e){for(;!Ca(tr());)Lt();return Rn(e,Ct)}function wh(e){return mh(mn("",null,null,null,[""],e=fh(e),0,[0],e))}function mn(e,r,a,n,s,i,h,d,u){for(var f=0,p=0,m=h,g=0,v=0,w=0,x=1,b=1,E=1,j=0,S="",C=s,_=i,k=n,y=S;b;)switch(w=j,j=Lt()){case 40:if(w!=108&&ut(y,m-1)==58){hn(y+=Le(Xn(j),"&","&\f"),"&\f",L0(f?d[f-1]:0))!=-1&&(E=-1);break}case 34:case 39:case 91:y+=Xn(j);break;case 9:case 10:case 13:case 32:y+=gh(w);break;case 92:y+=vh(fn()-1,7);continue;case 47:switch(tr()){case 42:case 47:va(yh(xh(Lt(),fn()),r,a,u),u),(Ca(w||1)==5||Ca(tr()||1)==5)&&zt(y)&&Lr(y,-1,void 0)!==" "&&(y+=" ");break;default:y+="/"}break;case 123*x:d[f++]=zt(y)*E;case 125*x:case 59:case 0:switch(j){case 0:case 125:b=0;case 59+p:E==-1&&(y=Le(y,/\f/g,"")),v>0&&(zt(y)-m||x===0&&w===47)&&va(v>32?hi(y+";",n,a,m-1,u):hi(Le(y," ","")+";",n,a,m-2,u),u);break;case 59:y+=";";default:if(va(k=pi(y,r,a,f,p,s,d,S,C=[],_=[],m,i),i),j===123)if(p===0)mn(y,r,k,k,C,i,m,d,_);else{switch(g){case 99:if(ut(y,3)===110)break;case 108:if(ut(y,2)===97)break;default:p=0;case 100:case 109:case 115:}p?mn(e,k,k,n&&va(pi(e,k,k,0,0,s,d,S,s,C=[],m,_),_),s,_,m,d,n?C:_):mn(y,k,k,k,[""],_,0,d,_)}}f=p=v=0,x=E=1,S=y="",m=h;break;case 58:m=1+zt(y),v=w;default:if(x<1){if(j==123)--x;else if(j==125&&x++==0&&hh()==125)continue}switch(y+=ys(j),j*x){case 38:E=p>0?1:(y+="\f",-1);break;case 44:d[f++]=(zt(y)-1)*E,E=1;break;case 64:tr()===45&&(y+=Xn(Lt())),g=tr(),p=m=zt(S=y+=bh(fn())),j++;break;case 45:w===45&&zt(y)==2&&(x=0)}}return i}function pi(e,r,a,n,s,i,h,d,u,f,p,m){for(var g=s-1,v=s===0?i:[""],w=P0(v),x=0,b=0,E=0;x<n;++x)for(var j=0,S=Lr(e,g+1,g=L0(b=h[x])),C=e;j<w;++j)(C=R0(b>0?v[j]+" "+S:Le(S,/&\f/g,v[j])))&&(u[E++]=C);return Ln(e,r,a,s===0?$n:d,u,f,p,m)}function yh(e,r,a,n){return Ln(e,r,a,$0,ys(ph()),Lr(e,2,-2),0,n)}function hi(e,r,a,n,s){return Ln(e,r,a,ws,Lr(e,0,n),Lr(e,n+1,-1),n,s)}function F0(e,r,a){switch(dh(e,r)){case 5103:return Ne+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Ne+e+e;case 4855:return Ne+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return ya+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ne+e+ya+e+Xe+e+e;case 5936:switch(ut(e,r+11)){case 114:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ne+e+Xe+e+e;case 6165:return Ne+e+Xe+"flex-"+e+e;case 5187:return Ne+e+Le(e,/(\w+).+(:[^]+)/,Ne+"box-$1$2"+Xe+"flex-$1$2")+e;case 5443:return Ne+e+Xe+"flex-item-"+Le(e,/flex-|-self/g,"")+(Ut(e,/flex-|baseline/)?"":Xe+"grid-row-"+Le(e,/flex-|-self/g,""))+e;case 4675:return Ne+e+Xe+"flex-line-pack"+Le(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ne+e+Xe+Le(e,"shrink","negative")+e;case 5292:return Ne+e+Xe+Le(e,"basis","preferred-size")+e;case 6060:return Ne+"box-"+Le(e,"-grow","")+Ne+e+Xe+Le(e,"grow","positive")+e;case 4554:return Ne+Le(e,/([^-])(transform)/g,"$1"+Ne+"$2")+e;case 6187:return Le(Le(Le(e,/(zoom-|grab)/,Ne+"$1"),/(image-set)/,Ne+"$1"),e,"")+e;case 5495:case 3959:return Le(e,/(image-set\([^]*)/,Ne+"$1$`$1");case 4968:return Le(Le(e,/(.+:)(flex-)?(.*)/,Ne+"box-pack:$3"+Xe+"flex-pack:$3"),/space-between/,"justify")+Ne+e+e;case 4200:if(!Ut(e,/flex-|baseline/))return Xe+"grid-column-align"+Lr(e,r)+e;break;case 2592:case 3360:return Xe+Le(e,"template-","")+e;case 4384:case 3616:return a&&a.some(function(n,s){return r=s,Ut(n.props,/grid-\w+-end/)})?~hn(e+(a=a[r].value),"span",0)?e:Xe+Le(e,"-start","")+e+Xe+"grid-row-span:"+(~hn(a,"span",0)?Ut(a,/\d+/):+Ut(a,/\d+/)-+Ut(e,/\d+/))+";":Xe+Le(e,"-start","")+e;case 4896:case 4128:return a&&a.some(function(n){return Ut(n.props,/grid-\w+-start/)})?e:Xe+Le(Le(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Le(e,/(.+)-inline(.+)/,Ne+"$1$2")+e;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(zt(e)-1-r>6)switch(ut(e,r+1)){case 109:if(ut(e,r+4)!==45)break;case 102:return Le(e,/(.+:)(.+)-([^]+)/,"$1"+Ne+"$2-$3$1"+ya+(ut(e,r+3)==108?"$3":"$2-$3"))+e;case 115:return~hn(e,"stretch",0)?F0(Le(e,"stretch","fill-available"),r,a)+e:e}break;case 5152:case 5920:return Le(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,i,h,d,u,f){return Xe+s+":"+i+f+(h?Xe+s+"-span:"+(d?u:+u-+i)+f:"")+e});case 4949:if(ut(e,r+6)===121)return Le(e,":",":"+Ne)+e;break;case 6444:switch(ut(e,ut(e,14)===45?18:11)){case 120:return Le(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ne+(ut(e,14)===45?"inline-":"")+"box$3$1"+Ne+"$2$3$1"+Xe+"$2box$3")+e;case 100:return Le(e,":",":"+Xe)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Le(e,"scroll-","scroll-snap-")+e}return e}function yn(e,r){for(var a="",n=0;n<e.length;n++)a+=r(e[n],n,e,r)||"";return a}function jh(e,r,a,n){switch(e.type){case lh:if(e.children.length)break;case ih:case ch:case ws:return e.return=e.return||e.value;case $0:return"";case M0:return e.return=e.value+"{"+yn(e.children,n)+"}";case $n:if(!zt(e.value=e.props.join(",")))return""}return zt(a=yn(e.children,n))?e.return=e.value+"{"+a+"}":""}function _h(e){var r=P0(e);return function(a,n,s,i){for(var h="",d=0;d<r;d++)h+=e[d](a,n,s,i)||"";return h}}function kh(e){return function(r){r.root||(r=r.return)&&e(r)}}function Ch(e,r,a,n){if(e.length>-1&&!e.return)switch(e.type){case ws:e.return=F0(e.value,e.length,a);return;case M0:return yn([Xt(e,{value:Le(e.value,"@","@"+Ne)})],n);case $n:if(e.length)return uh(a=e.props,function(s){switch(Ut(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Or(Xt(e,{props:[Le(s,/:(read-\w+)/,":"+ya+"$1")]})),Or(Xt(e,{props:[s]})),Jo(e,{props:ui(a,n)});break;case"::placeholder":Or(Xt(e,{props:[Le(s,/:(plac\w+)/,":"+Ne+"input-$1")]})),Or(Xt(e,{props:[Le(s,/:(plac\w+)/,":"+ya+"$1")]})),Or(Xt(e,{props:[Le(s,/:(plac\w+)/,Xe+"input-$1")]})),Or(Xt(e,{props:[s]})),Jo(e,{props:ui(a,n)});break}return""})}}var eo,to;const Rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",I0="active",Z0="data-styled-version",Pn="6.4.1",js=`/*!sc*/
18
+ */var Xs;function Du(){return Xs||(Xs=1,process.env.NODE_ENV!=="production"&&(function(){function e(v,w){return v===w&&(v!==0||1/v===1/w)||v!==v&&w!==w}function r(v,w){p||s.startTransition===void 0||(p=!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 x=w();if(!m){var b=w();i(x,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),m=!0)}b=h({inst:{value:x,getSnapshot:w}});var E=b[0].inst,j=b[1];return u(function(){E.value=x,E.getSnapshot=w,a(E)&&j({inst:E})},[v,x,w]),d(function(){return a(E)&&j({inst:E}),v(function(){a(E)&&j({inst:E})})},[v]),f(x),x}function a(v){var w=v.getSnapshot;v=v.value;try{var x=w();return!i(v,x)}catch{return!0}}function n(v,w){return w()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=c,i=typeof Object.is=="function"?Object.is:e,h=s.useState,d=s.useEffect,u=s.useLayoutEffect,f=s.useDebugValue,p=!1,m=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;Nn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:g,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Nn}var ei;function Nu(){return ei||(ei=1,process.env.NODE_ENV==="production"?Ta.exports=Vu():Ta.exports=Du()),Ta.exports}var Ho=Nu();const s0=0,i0=1,c0=2,ti=3;var ri=Object.prototype.hasOwnProperty;function Vo(e,r){var a,n;if(e===r)return!0;if(e&&r&&(a=e.constructor)===r.constructor){if(a===Date)return e.getTime()===r.getTime();if(a===RegExp)return e.toString()===r.toString();if(a===Array){if((n=e.length)===r.length)for(;n--&&Vo(e[n],r[n]););return n===-1}if(!a||typeof e=="object"){n=0;for(a in e)if(ri.call(e,a)&&++n&&!ri.call(r,a)||!(a in r)||!Vo(e[a],r[a]))return!1;return Object.keys(r).length===n}}return e!==e&&r!==r}const Tt=new WeakMap,Wt=()=>{},pt=Wt(),Do=Object,Ee=e=>e===pt,$t=e=>typeof e=="function",ar=(e,r)=>({...e,...r}),l0=e=>$t(e.then),Un={},Fa={},xs="undefined",Aa=typeof window!=xs,No=typeof document!=xs,Uu=Aa&&"Deno"in window,Bu=()=>Aa&&typeof window.requestAnimationFrame!=xs,er=(e,r)=>{const a=Tt.get(e);return[()=>!Ee(r)&&e.get(r)||Un,n=>{if(!Ee(r)){const s=e.get(r);r in Fa||(Fa[r]=s),a[5](r,ar(s,n),s||Un)}},a[6],()=>!Ee(r)&&r in Fa?Fa[r]:!Ee(r)&&e.get(r)||Un]};let Uo=!0;const Wu=()=>Uo,[Bo,Wo]=Aa&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Wt,Wt],Gu=()=>{const e=No&&document.visibilityState;return Ee(e)||e!=="hidden"},qu=e=>(No&&document.addEventListener("visibilitychange",e),Bo("focus",e),()=>{No&&document.removeEventListener("visibilitychange",e),Wo("focus",e)}),Ku=e=>{const r=()=>{Uo=!0,e()},a=()=>{Uo=!1};return Bo("online",r),Bo("offline",a),()=>{Wo("online",r),Wo("offline",a)}},Yu={isOnline:Wu,isVisible:Gu},Qu={initFocus:qu,initReconnect:Ku},ai=!c.useId,Kr=!Aa||Uu,Ju=e=>Bu()?window.requestAnimationFrame(e):setTimeout(e,1),pn=Kr?c.useEffect:c.useLayoutEffect,Bn=typeof navigator<"u"&&navigator.connection,ni=!Kr&&Bn&&(["slow-2g","2g"].includes(Bn.effectiveType)||Bn.saveData),Ia=new WeakMap,Xu=e=>Do.prototype.toString.call(e),Wn=(e,r)=>e===`[object ${r}]`;let e2=0;const Go=e=>{const r=typeof e,a=Xu(e),n=Wn(a,"Date"),s=Wn(a,"RegExp"),i=Wn(a,"Object");let h,d;if(Do(e)===e&&!n&&!s){if(h=Ia.get(e),h)return h;if(h=++e2+"~",Ia.set(e,h),Array.isArray(e)){for(h="@",d=0;d<e.length;d++)h+=Go(e[d])+",";Ia.set(e,h)}if(i){h="#";const u=Do.keys(e).sort();for(;!Ee(d=u.pop());)Ee(e[d])||(h+=d+":"+Go(e[d])+",");Ia.set(e,h)}}else h=n?e.toJSON():r=="symbol"?e.toString():r=="string"?JSON.stringify(e):""+e;return h},ka=e=>{if($t(e))try{e=e()}catch{e=""}const r=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Go(e):"",[e,r]};let t2=0;const qo=()=>++t2;async function d0(...e){const[r,a,n,s]=e,i=ar({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let h=i.populateCache;const d=i.rollbackOnError;let u=i.optimisticData;const f=g=>typeof d=="function"?d(g):d!==!1,p=i.throwOnError;if($t(a)){const g=a,v=[],w=r.keys();for(const x of w)!/^\$(inf|sub)\$/.test(x)&&g(r.get(x)._k)&&v.push(x);return Promise.all(v.map(m))}return m(a);async function m(g){const[v]=ka(g);if(!v)return;const[w,x]=er(r,v),[b,E,j,S]=Tt.get(r),C=()=>{const $=b[v];return($t(i.revalidate)?i.revalidate(w().data,g):i.revalidate!==!1)&&(delete j[v],delete S[v],$&&$[0])?$[0](c0).then(()=>w().data):w().data};if(e.length<3)return C();let _=n,k,y=!1;const M=qo();E[v]=[M,0];const A=!Ee(u),I=w(),P=I.data,L=I._c,T=Ee(L)?P:L;if(A&&(u=$t(u)?u(T,P):u,x({data:u,_c:T})),$t(_))try{_=_(T)}catch($){k=$,y=!0}if(_&&l0(_))if(_=await _.catch($=>{k=$,y=!0}),M!==E[v][0]){if(y)throw k;return _}else y&&A&&f(k)&&(h=!0,x({data:T,_c:pt}));if(h&&!y)if($t(h)){const $=h(_,T);x({data:$,error:pt,_c:pt})}else x({data:_,error:pt,_c:pt});if(E[v][1]=qo(),Promise.resolve(C()).then(()=>{x({_c:pt})}),y){if(p)throw k;return}return _}}const oi=(e,r)=>{for(const a in e)e[a][0]&&e[a][0](r)},r2=(e,r)=>{if(!Tt.has(e)){const a=ar(Qu,r),n=Object.create(null),s=d0.bind(pt,e);let i=Wt;const h=Object.create(null),d=(p,m)=>{const g=h[p]||[];return h[p]=g,g.push(m),()=>g.splice(g.indexOf(m),1)},u=(p,m,g)=>{e.set(p,m);const v=h[p];if(v)for(const w of v)w(m,g)},f=()=>{if(!Tt.has(e)&&(Tt.set(e,[n,Object.create(null),Object.create(null),Object.create(null),s,u,d]),!Kr)){const p=a.initFocus(setTimeout.bind(pt,oi.bind(pt,n,s0))),m=a.initReconnect(setTimeout.bind(pt,oi.bind(pt,n,i0)));i=()=>{p&&p(),m&&m(),Tt.delete(e)}}};return f(),[e,s,f,i]}return[e,Tt.get(e)[4]]},a2=(e,r,a,n,s)=>{const i=a.errorRetryCount,h=s.retryCount,d=~~((Math.random()+.5)*(1<<(h<8?h:8)))*a.errorRetryInterval;!Ee(i)&&h>i||setTimeout(n,d,s)},n2=Vo,[bs,Gr]=r2(new Map),o2=ar({onLoadingSlow:Wt,onSuccess:Wt,onError:Wt,onErrorRetry:a2,onDiscarded:Wt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ni?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ni?5e3:3e3,compare:n2,isPaused:()=>!1,cache:bs,mutate:Gr,fallback:{}},Yu),s2=(e,r)=>{const a=ar(e,r);if(r){const{use:n,fallback:s}=e,{use:i,fallback:h}=r;n&&i&&(a.use=n.concat(i)),s&&h&&(a.fallback=ar(s,h))}return a},i2=c.createContext({}),u0="$inf$",p0=Aa&&window.__SWR_DEVTOOLS_USE__,c2=p0?window.__SWR_DEVTOOLS_USE__:[],l2=()=>{p0&&(window.__SWR_DEVTOOLS_REACT__=c)},h0=e=>$t(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(e[1]===null?e[2]:e[1])||{}],f0=()=>{const e=c.useContext(i2);return c.useMemo(()=>ar(o2,e),[e])},d2=e=>(r,a,n)=>e(r,a&&((...i)=>{const[h]=ka(r),[,,,d]=Tt.get(bs);if(h.startsWith(u0))return a(...i);const u=d[h];return Ee(u)?a(...i):(delete d[h],u)}),n),u2=c2.concat(d2),p2=e=>function(...a){const n=f0(),[s,i,h]=h0(a),d=s2(n,h);let u=e;const{use:f}=d,p=(f||[]).concat(u2);for(let m=p.length;m--;)u=p[m](u);return u(s,i||d.fetcher||null,d)},h2=(e,r,a)=>{const n=r[e]||(r[e]=[]);return n.push(a),()=>{const s=n.indexOf(a);s>=0&&(n[s]=n[n.length-1],n.pop())}},f2=(e,r)=>(...a)=>{const[n,s,i]=h0(a),h=(i.use||[]).concat(r);return e(n,s,{...i,use:h})};l2();const Gn=c.use||(e=>{switch(e.status){case"pending":throw e;case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e.status="pending",e.then(r=>{e.status="fulfilled",e.value=r},r=>{e.status="rejected",e.reason=r}),e}}),qn={dedupe:!0},si=Promise.resolve(pt),m2=()=>Wt,g2=(e,r,a)=>{const{cache:n,compare:s,suspense:i,fallbackData:h,revalidateOnMount:d,revalidateIfStale:u,refreshInterval:f,refreshWhenHidden:p,refreshWhenOffline:m,keepPreviousData:g,strictServerPrefetchWarning:v}=a,[w,x,b,E]=Tt.get(n),[j,S]=ka(e),C=c.useRef(!1),_=c.useRef(!1),k=c.useRef(j),y=c.useRef(r),M=c.useRef(a),A=()=>M.current,I=()=>A().isVisible()&&A().isOnline(),[P,L,T,$]=er(n,j),z=c.useRef({}).current,H=Ee(h)?Ee(a.fallback)?pt:a.fallback[j]:h,F=(J,le)=>{for(const oe in z){const G=oe;if(G==="data"){if(!s(J[G],le[G])&&(!Ee(J[G])||!s(ce,le[G])))return!1}else if(le[G]!==J[G])return!1}return!0},O=!C.current,Z=c.useMemo(()=>{const J=P(),le=$(),oe=q=>{const de=ar(q);return delete de._k,(()=>{if(!j||!r||A().isPaused())return!1;if(O&&!Ee(d))return d;const We=Ee(H)?de.data:H;return Ee(We)||u})()?{isValidating:!0,isLoading:!0,...de}:de},G=oe(J),pe=J===le?G:oe(le);let fe=G;return[()=>{const q=oe(P());return F(q,fe)?(fe.data=q.data,fe.isLoading=q.isLoading,fe.isValidating=q.isValidating,fe.error=q.error,fe):(fe=q,q)},()=>pe]},[n,j]),R=Ho.useSyncExternalStore(c.useCallback(J=>T(j,(le,oe)=>{F(oe,le)||J()}),[n,j]),Z[0],Z[1]),W=w[j]&&w[j].length>0,D=R.data,B=Ee(D)?H&&l0(H)?Gn(H):H:D,Y=R.error,X=c.useRef(B),ce=g?Ee(D)?Ee(X.current)?B:X.current:D:B,me=j&&Ee(B),te=c.useRef(null);!Kr&&Ho.useSyncExternalStore(m2,()=>(te.current=!1,te),()=>(te.current=!0,te));const xe=te.current;v&&xe&&!i&&me&&console.warn(`Missing pre-initiated data for serialized key "${j}" during server-side rendering. Data fetching should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const re=!j||!r||A().isPaused()||W&&!Ee(Y)?!1:O&&!Ee(d)?d:i?Ee(B)?!1:u:Ee(B)||u,U=O&&re,Qe=Ee(R.isValidating)?U:R.isValidating,Te=Ee(R.isLoading)?U:R.isLoading,Ve=c.useCallback(async J=>{const le=y.current;if(!j||!le||_.current||A().isPaused())return!1;let oe,G,pe=!0;const fe=J||{},q=!b[j]||!fe.dedupe,de=()=>ai?!_.current&&j===k.current&&C.current:j===k.current,Be={isValidating:!1,isLoading:!1},We=()=>{L(Be)},Q=()=>{const he=b[j];he&&he[1]===G&&delete b[j]},se={isValidating:!0};Ee(P().data)&&(se.isLoading=!0);try{if(q&&(L(se),a.loadingTimeout&&Ee(P().data)&&setTimeout(()=>{pe&&de()&&A().onLoadingSlow(j,a)},a.loadingTimeout),b[j]=[le(S),qo()]),[oe,G]=b[j],oe=await oe,q&&setTimeout(Q,a.dedupingInterval),!b[j]||b[j][1]!==G)return q&&de()&&A().onDiscarded(j),!1;Be.error=pt;const he=x[j];if(!Ee(he)&&(G<=he[0]||G<=he[1]||he[1]===0))return We(),q&&de()&&A().onDiscarded(j),!1;const je=P().data;Be.data=s(je,oe)?je:oe,q&&de()&&A().onSuccess(oe,j,a)}catch(he){Q();const je=A(),{shouldRetryOnError:ke}=je;je.isPaused()||(Be.error=he,q&&de()&&(je.onError(he,j,je),(ke===!0||$t(ke)&&ke(he))&&(!A().revalidateOnFocus||!A().revalidateOnReconnect||I())&&je.onErrorRetry(he,j,je,Ge=>{const dt=w[j];dt&&dt[0]&&dt[0](ti,Ge)},{retryCount:(fe.retryCount||0)+1,dedupe:!0})))}return pe=!1,We(),!0},[j,n]),Ue=c.useCallback((...J)=>d0(n,k.current,...J),[]);if(pn(()=>{y.current=r,M.current=a,Ee(D)||(X.current=D)}),pn(()=>{if(!j)return;const J=Ve.bind(pt,qn);let le=0;A().revalidateOnFocus&&(le=Date.now()+A().focusThrottleInterval);const G=h2(j,w,(pe,fe={})=>{if(pe==s0){const q=Date.now();A().revalidateOnFocus&&q>le&&I()&&(le=q+A().focusThrottleInterval,J())}else if(pe==i0)A().revalidateOnReconnect&&I()&&J();else{if(pe==c0)return Ve();if(pe==ti)return Ve(fe)}});return _.current=!1,k.current=j,C.current=!0,L({_k:S}),re&&(b[j]||(Ee(B)||Kr?J():Ju(J))),()=>{_.current=!0,G()}},[j]),pn(()=>{let J;function le(){const G=$t(f)?f(P().data):f;G&&J!==-1&&(J=setTimeout(oe,G))}function oe(){!P().error&&(p||A().isVisible())&&(m||A().isOnline())?Ve(qn).then(le):le()}return le(),()=>{J&&(clearTimeout(J),J=-1)}},[f,p,m,j]),c.useDebugValue(ce),i){if(!ai&&Kr&&me)throw new Error("Fallback data is required when using Suspense in SSR.");me&&(y.current=r,M.current=a,_.current=!1);const J=E[j],le=!Ee(J)&&me?Ue(J):si;if(Gn(le),!Ee(Y)&&me)throw Y;const oe=me?Ve(qn):si;!Ee(ce)&&me&&(oe.status="fulfilled",oe.value=!0),Gn(oe)}return{mutate:Ue,get data(){return z.data=!0,ce},get error(){return z.error=!0,Y},get isValidating(){return z.isValidating=!0,Qe},get isLoading(){return z.isLoading=!0,Te}}},$e=p2(g2),yt=()=>{const{adapter:e,deployment:r}=Ae(),a=e.useNavigate(),n=(u,f)=>{a?a(u,f):window.location.href=u},s=u=>{if(u)return u;const p=new URLSearchParams(window.location.search).get("redirect_uri");return p||window.location.href};return{navigate:n,navigateToSignIn:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`${r.ui_settings.sign_in_page_url}?${p.toString()}`,{replace:!0})},navigateToAccountSelection:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`https://${r.frontend_host}?${p.toString()}`,{replace:!0})},navigateToSignUp:u=>{if(!r)return;const f=s(u),p=new URLSearchParams;p.set("redirect_uri",f),(r==null?void 0:r.mode)==="staging"&&p.set("__dev_session__",ht(r.backend_host)??""),n(`${r.ui_settings.sign_up_page_url}?${p.toString()}`,{replace:!0})}}};async function v2(e){const r=await e("/session",{method:"GET"});return(await V(r)).data}async function x2(e,r){const a=await e(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(a)}async function b2(e,r){const a=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await e(a,{method:"POST"});return V(n)}async function w2(e,r){const a=await e(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(a)}async function y2(e,r){const a=await e(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(a)}async function j2(e,r){const a=await e(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return V(a)}const Ko=new Map,ga=new Map;function Mt(){Ko.clear(),ga.clear()}async function _2(e,r){const a=await e(`/session/token${r?`?template=${r}`:""}`);return V(a)}function ot(){const{client:e,loading:r}=_e(),{deployment:a}=Ae(),{navigate:n}=yt(),{cache:s}=f0(),{data:i,error:h,mutate:d,isLoading:u}=$e(r?null:"/session",()=>v2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=c.useCallback(async()=>{await d(void 0,{revalidate:!0})},[d]),p=c.useCallback(async(m="default")=>{if(!i)throw new Error("no session");const g=Ko.get(m);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";ga.get(m)||ga.set(m,_2(e,m));const v=await ga.get(m);return ga.delete(m),Ko.set(m,v.data),v.data.token},[e,i==null?void 0:i.active_signin]);return r||!i||u?{loading:!0,error:h,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:f}:{loading:u,error:h,session:i,switchSignIn:async m=>{await x2(e,m),Mt(),await Gr("/me/organization-memberships",void 0,{revalidate:!1}),await Gr("/me/workspace-memberships",void 0,{revalidate:!1}),await d(void 0,{revalidate:!0}),await Gr("/me/organization-memberships"),await Gr("/me/workspace-memberships")},signOut:async m=>{await b2(e,m);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const w=Array.from(s.keys());for(const x of w){let b=!1;(g.includes(x)||typeof x=="string"&&v.some(E=>x.startsWith(E)))&&(b=!0),b&&s.delete(x)}}Mt(),await d(void 0,{revalidate:!0}),a!=null&&a.ui_settings&&(m&&a.ui_settings.after_sign_out_one_page_url?n(a.ui_settings.after_sign_out_one_page_url):!m&&a.ui_settings.after_sign_out_all_page_url&&n(a.ui_settings.after_sign_out_all_page_url))},switchOrganization:async m=>{await w2(e,m),Mt(),await d(void 0,{revalidate:!0})},switchWorkspace:async m=>{await y2(e,m),Mt(),await d(void 0,{revalidate:!0})},exchangeTicket:async m=>{await j2(e,m),Mt(),await d(void 0,{revalidate:!0})},getToken:p,refetch:f}}const It=()=>{const{organizationMemberships:e,refetch:r,loading:a}=Kt(),{client:n}=_e(),{refetch:s}=ot(),i=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/roles`,{method:"GET"}))).data,[n]),h=c.useCallback(async(O,Z)=>{const R=new URLSearchParams;return Z&&(R.set("page",Z.page.toString()),R.set("limit",Z.limit.toString()),Z.search&&R.set("search",Z.search)),(await V(await n(`/organizations/${O.id}/members?${R.toString()}`,{method:"GET"}))).data},[n]),d=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/invitations`,{method:"GET"}))).data,[n]),u=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/domains`,{method:"GET"}))).data,[n]),f=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/members/${Z.id}/remove`,{method:"POST"})},[n]),p=c.useCallback(async O=>{const Z=new FormData;Z.append("name",O.name),O.image&&Z.append("image",O.image),O.description&&Z.append("description",O.description);const R=await V(await n("/organizations",{method:"POST",body:Z}));return Mt(),await r(),await s(),R},[s,r,n]),m=c.useCallback(async(O,Z)=>{const R=Object.entries(Z).reduce((D,[B,Y])=>(Y!=null&&(Array.isArray(Y)?Y.forEach(X=>D.append(B,X)):D.append(B,Y)),D),new FormData),W=await V(await n(`/organizations/${O.id}/update`,{method:"POST",body:R}));return await r(),W},[r,n]),g=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/roles/${Z.id}/remove`,{method:"POST"})},[n]),v=c.useCallback(async(O,Z)=>{const R=new FormData;return R.append("domain",Z.fqdn),await V(await n(`/organizations/${O.id}/domains`,{method:"POST",body:R}))},[n]),w=c.useCallback(async(O,Z)=>await V(await n(`/organizations/${O.id}/domains/${Z.id}/verify`,{method:"POST"})),[n]),x=c.useCallback(async(O,Z)=>await V(await n(`/organizations/${O.id}/domains/${Z.id}/delete`,{method:"POST"})),[n]),b=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/enterprise-connections`,{method:"GET"}))).data,[n]),E=c.useCallback(async(O,Z)=>{const R=new FormData;return R.append("protocol",Z.protocol),Z.domain_id&&R.append("domain_id",Z.domain_id),Z.idp_entity_id&&R.append("idp_entity_id",Z.idp_entity_id),Z.idp_sso_url&&R.append("idp_sso_url",Z.idp_sso_url),Z.idp_certificate&&R.append("idp_certificate",Z.idp_certificate),Z.oidc_client_id&&R.append("oidc_client_id",Z.oidc_client_id),Z.oidc_client_secret&&R.append("oidc_client_secret",Z.oidc_client_secret),Z.oidc_issuer_url&&R.append("oidc_issuer_url",Z.oidc_issuer_url),Z.oidc_scopes&&R.append("oidc_scopes",Z.oidc_scopes),Z.jit_enabled!==void 0&&R.append("jit_enabled",String(Z.jit_enabled)),Z.attribute_mapping&&R.append("attribute_mapping",JSON.stringify(Z.attribute_mapping)),(await V(await n(`/organizations/${O.id}/enterprise-connections`,{method:"POST",body:R}))).data},[n]),j=c.useCallback(async(O,Z,R)=>{const W=new FormData;return R.domain_id&&W.append("domain_id",R.domain_id),R.idp_entity_id&&W.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&W.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&W.append("idp_certificate",R.idp_certificate),R.oidc_client_id&&W.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&W.append("oidc_client_secret",R.oidc_client_secret),R.oidc_issuer_url&&W.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_scopes&&W.append("oidc_scopes",R.oidc_scopes),R.attribute_mapping&&W.append("attribute_mapping",JSON.stringify(R.attribute_mapping)),(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/update`,{method:"POST",body:W}))).data},[n]),S=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/enterprise-connections/${Z}/delete`,{method:"POST"})},[n]),C=c.useCallback(async(O,Z)=>{const R=new FormData;return R.append("protocol",Z.protocol),Z.idp_entity_id&&R.append("idp_entity_id",Z.idp_entity_id),Z.idp_sso_url&&R.append("idp_sso_url",Z.idp_sso_url),Z.idp_certificate&&R.append("idp_certificate",Z.idp_certificate),Z.oidc_issuer_url&&R.append("oidc_issuer_url",Z.oidc_issuer_url),Z.oidc_client_id&&R.append("oidc_client_id",Z.oidc_client_id),Z.oidc_client_secret&&R.append("oidc_client_secret",Z.oidc_client_secret),(await V(await n(`/organizations/${O.id}/enterprise-connections/test`,{method:"POST",body:R}))).data},[n]),_=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/test`,{method:"POST"}))).data,[n]),k=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token`,{method:"POST"}))).data,[n]),y=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token`,{method:"GET"}))).data,[n]),M=c.useCallback(async(O,Z)=>{await n(`/organizations/${O.id}/enterprise-connections/${Z}/scim/token/revoke`,{method:"POST"})},[n]),A=c.useCallback(async(O,Z)=>{const R=new FormData;return R.append("name",Z.name),Z.permissions&&Z.permissions.forEach((D,B)=>{R.append(`permissions[${B}]`,D)}),await V(await n(`/organizations/${O.id}/roles`,{method:"POST",body:R}))},[n]),I=c.useCallback(async O=>(await V(await n(`/organizations/${O.id}/leave`,{method:"POST"}))).data,[n]),P=c.useCallback(async O=>{const Z=await V(await n(`/organizations/${O.id}/delete`,{method:"POST"}));return Mt(),await r(),await s(),Z.data},[n,r,s]),L=c.useCallback(async(O,Z,R)=>(await V(await n(`/organizations/${O.id}/members/${Z.id}/roles/${R.id}/add`,{method:"POST"}))).data,[n]),T=c.useCallback(async(O,Z,R)=>(await V(await n(`/organizations/${O.id}/members/${Z.id}/roles/${R.id}/remove`,{method:"POST"}))).data,[n]),$=c.useCallback(async(O,Z)=>{var D,B;const R=new FormData;return R.append("email",Z.email),R.append("role_id",Z.organizationRole.id),(D=Z.workspace)!=null&&D.id&&R.append("workspace_id",Z.workspace.id),(B=Z.workspaceRole)!=null&&B.id&&R.append("workspace_role_id",Z.workspaceRole.id),(await V(await n(`/organizations/${O.id}/invitations`,{method:"POST",body:R}))).data},[n]),z=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/invitations/${Z.id}/discard`,{method:"POST"}))).data,[n]),H=c.useCallback(async(O,Z)=>(await V(await n(`/organizations/${O.id}/invitations/${Z.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:c.useMemo(()=>e==null?void 0:e.map(O=>O.organization),[e]),loading:a,error:null,refetch:r,leaveOrganization:I,getOrganizationRoles:i,getOrganizationMembers:h,removeOrganizationMember:f,createOrganization:p,getOrganizationInvitations:d,getOrganizationDomains:u,addOrganizationDomain:v,verifyOrganizationDomain:w,removeOrganizationDomain:x,addRoleToOrganizationMember:L,removeRoleFromOrganizationMember:T,inviteOrganizationMember:$,discardOrganizationInvitation:z,resendOrganizationInvitation:H,updateOrganization:m,addRole:A,removeOrganizationRoles:g,deleteOrganization:P,getEnterpriseConnections:b,createEnterpriseConnection:E,updateEnterpriseConnection:j,deleteEnterpriseConnection:S,testEnterpriseConnectionConfig:C,testEnterpriseConnection:_,generateSCIMToken:k,getSCIMToken:y,revokeSCIMToken:M}},or=()=>{const{loading:e,error:r,refetch:a,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:i,removeOrganizationMember:h,getOrganizationInvitations:d,getOrganizationDomains:u,removeOrganizationDomain:f,addOrganizationDomain:p,verifyOrganizationDomain:m,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:v,inviteOrganizationMember:w,discardOrganizationInvitation:x,resendOrganizationInvitation:b,updateOrganization:E,removeOrganizationRoles:j,getEnterpriseConnections:S,createEnterpriseConnection:C,updateEnterpriseConnection:_,deleteEnterpriseConnection:k,testEnterpriseConnectionConfig:y,testEnterpriseConnection:M,generateSCIMToken:A,getSCIMToken:I,revokeSCIMToken:P}=It(),{session:L,error:T,loading:$}=ot(),{organizationMemberships:z}=Kt(),H=c.useMemo(()=>(z==null?void 0:z.find(q=>{var de;return q.id===((de=L==null?void 0:L.active_signin)==null?void 0:de.active_organization_membership_id)}))||null,[z,L]),F=c.useMemo(()=>(H==null?void 0:H.organization)||null,[H]),O=c.useCallback(async q=>F?await E(F,q):[],[F,E]),Z=c.useCallback(async()=>F?await n(F):[],[F,n]),R=c.useCallback(async()=>F?await s(F):[],[F,s]),W=c.useCallback(async q=>F?await h(F,q):[],[F,h]),D=c.useCallback(async q=>F?await j(F,q):void 0,[F,j]),B=c.useCallback(async()=>F?await u(F):[],[F,u]),Y=c.useCallback(async q=>F?await p(F,q):void 0,[F,p]),X=c.useCallback(async q=>F?await m(F,q):void 0,[F,m]),ce=c.useCallback(async q=>F?await f(F,q):void 0,[F,f]),me=c.useCallback(async(q,de)=>F?await g(F,q,de):void 0,[F,g]),te=c.useCallback(async(q,de)=>F?await v(F,q,de):void 0,[F,v]),xe=c.useCallback(async q=>F?await w(F,q):void 0,[F,w]),re=c.useCallback(async q=>F?await x(F,q):void 0,[F,x]),U=c.useCallback(async q=>F?await b(F,q):void 0,[F,b]),Qe=c.useCallback(async()=>{F&&await i(F)},[F,i]),Te=c.useCallback(async()=>F?await d(F):[],[F,d]),Ve=c.useCallback(async()=>F?await S(F):[],[F,S]),Ue=c.useCallback(async q=>{if(F)return await C(F,q)},[F,C]),ve=c.useCallback(async(q,de)=>{if(F)return await _(F,q,de)},[F,_]),J=c.useCallback(async q=>{F&&await k(F,q)},[F,k]),le=c.useCallback(async q=>F?await y(F,q):null,[F,y]),oe=c.useCallback(async q=>F?await M(F,q):null,[F,M]),G=c.useCallback(async q=>{if(F)return await A(F,q)},[F,A]),pe=c.useCallback(async q=>{if(F)return await I(F,q)},[F,I]),fe=c.useCallback(async q=>{F&&await P(F,q)},[F,P]);return $||e?{activeOrganization:null,activeMembership:null,loading:!0,error:T||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:F,activeMembership:H,loading:!1,refetch:a,getRoles:R,updateOrganization:O,getMembers:Z,getDomains:B,addDomain:Y,verifyDomain:X,removeDomain:ce,getInvitations:Te,removeMember:W,leave:Qe,removeRole:D,addMemberRole:me,removeMemberRole:te,inviteMember:xe,discardInvitation:re,resendInvitation:U,getEnterpriseConnections:Ve,createEnterpriseConnection:Ue,updateEnterpriseConnection:ve,deleteEnterpriseConnection:J,testEnterpriseConnectionConfig:le,testEnterpriseConnection:oe,generateSCIMToken:G,getSCIMToken:pe,revokeSCIMToken:fe,error:null}};async function k2(e){return(await V(await e("/me/organization-memberships"))).data}const Kt=()=>{const{client:e,loading:r}=_e(),{data:a,isLoading:n,error:s,mutate:i}=$e(r?null:"/me/organization-memberships",()=>k2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=c.useCallback(async()=>{await i()},[i]);return{organizationMemberships:a,loading:r||n,error:s,refetch:h}};async function C2(e){return(await V(await e("/me/workspace-memberships"))).data}async function S2(e,r){return(await V(await e(`/workspaces/${r}/leave`,{method:"POST"}))).data}const An=()=>{const{client:e,loading:r}=_e(),{deployment:a}=Ae(),{data:n,isLoading:s,error:i,mutate:h}=$e(!r&&(a!=null&&a.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>C2(e),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=c.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]);return{workspaceMemberships:n,loading:r||s,error:i,refetch:d}},sr=()=>{const{workspaceMemberships:e,refetch:r,loading:a,error:n}=An(),{client:s}=_e(),{refetch:i}=ot(),h=c.useMemo(()=>e==null?void 0:e.map(k=>({...k.workspace,organization:k.organization,eligibility_restriction:k.eligibility_restriction})),[e]),d=c.useCallback(async(k,y,M,A)=>{const I=new FormData;I.append("name",y),M&&I.append("image",M),A&&I.append("description",A),I.append("organization_id",k);const P=await V(await s("/workspaces",{method:"POST",body:I}));return Mt(),await r(),P.data},[s,r]),u=c.useCallback(async k=>{const y=await S2(s,k);return Mt(),await r(),await i(),y},[s,r,i]),f=c.useCallback(async(k,y)=>{const M=new FormData;y.name&&M.append("name",y.name),y.description&&M.append("description",y.description),y.image&&M.append("image",y.image),y.enforce_2fa!==void 0&&M.append("enforce_2fa",String(y.enforce_2fa)),y.enable_ip_restriction!==void 0&&M.append("enable_ip_restriction",String(y.enable_ip_restriction)),y.whitelisted_ips&&y.whitelisted_ips.forEach(I=>M.append("whitelisted_ips",I));const A=await V(await s(`/workspaces/${k.id}/update`,{method:"POST",body:M}));return await r(),A.data},[s,r]),p=c.useCallback(async k=>{const y=await V(await s(`/workspaces/${k.id}/delete`,{method:"POST"}));return Mt(),await r(),y.data},[s,r]),m=c.useCallback(async(k,y)=>{const M=new URLSearchParams;return y&&(M.set("page",y.page.toString()),M.set("limit",y.limit.toString()),y.search&&M.set("search",y.search)),(await V(await s(`/workspaces/${k.id}/members?${M.toString()}`,{method:"GET"}))).data},[s]),g=c.useCallback(async k=>(await V(await s(`/workspaces/${k.id}/roles`,{method:"GET"}))).data,[s]),v=c.useCallback(async(k,y,M)=>{const A=new FormData;return A.append("name",y),M.forEach(P=>A.append("permissions",P)),(await V(await s(`/workspaces/${k.id}/roles`,{method:"POST",body:A}))).data},[s]),w=c.useCallback(async(k,y)=>(await V(await s(`/workspaces/${k.id}/roles/${y.id}/delete`,{method:"POST"}))).data,[s]),x=c.useCallback(async(k,y)=>{const M=await V(await s(`/workspaces/${k.id}/members/${y}/remove`,{method:"POST"}));return await r(),M.data},[s,r]),b=c.useCallback(async(k,y,M)=>(await V(await s(`/workspaces/${k.id}/members/${y}/roles/${M}/add`,{method:"POST"}))).data,[s]),E=c.useCallback(async(k,y,M)=>(await V(await s(`/workspaces/${k.id}/members/${y}/roles/${M}/remove`,{method:"POST"}))).data,[s]),j=c.useCallback(async k=>(await V(await s(`/organizations/${k.organization.id}/invitations?workspace_id=${k.id}`,{method:"GET"}))).data,[s]),S=c.useCallback(async(k,y,M)=>{const A=new FormData;return A.append("email",y),A.append("workspace_id",k.id),M&&A.append("workspace_role_id",M),(await V(await s(`/organizations/${k.organization.id}/invitations`,{method:"POST",body:A}))).data},[s]),C=c.useCallback(async(k,y)=>(await V(await s(`/organizations/${k.organization.id}/invitations/${y}/discard`,{method:"POST"}))).data,[s]),_=c.useCallback(async(k,y)=>(await V(await s(`/organizations/${k.organization.id}/invitations/${y}/resend`,{method:"POST"}))).data,[s]);return{workspaces:h||[],loading:a,error:n,refetch:r,leaveWorkspace:u,createWorkspace:d,updateWorkspace:f,deleteWorkspace:p,getWorkspaceMembers:m,getWorkspaceRoles:g,createWorkspaceRole:v,deleteWorkspaceRole:w,removeWorkspaceMember:x,addWorkspaceMemberRole:b,removeWorkspaceMemberRole:E,getWorkspaceInvitations:j,createWorkspaceInvitation:S,discardWorkspaceInvitation:C,resendWorkspaceInvitation:_}},Zt=()=>{const{refetch:e,loading:r,error:a,workspaces:n,leaveWorkspace:s,updateWorkspace:i,deleteWorkspace:h,getWorkspaceMembers:d,getWorkspaceRoles:u,createWorkspaceRole:f,deleteWorkspaceRole:p,removeWorkspaceMember:m,addWorkspaceMemberRole:g,removeWorkspaceMemberRole:v,getWorkspaceInvitations:w,createWorkspaceInvitation:x,discardWorkspaceInvitation:b,resendWorkspaceInvitation:E}=sr(),{workspaceMemberships:j}=An(),{session:S,loading:C,error:_}=ot(),k=c.useMemo(()=>(j==null?void 0:j.find(X=>{var ce;return X.id===((ce=S==null?void 0:S.active_signin)==null?void 0:ce.active_workspace_membership_id)}))||null,[j,S]),y=c.useMemo(()=>(k==null?void 0:k.workspace)||null,[k]),M=c.useCallback(async()=>{if(y)return await s(y.id)},[y,s]),A=c.useCallback(async X=>{if(y)return await i(y,X)},[y,i]),I=c.useCallback(async()=>{if(y)return await h(y)},[y,h]),P=c.useCallback(async X=>y?await d(y,X):{data:[],meta:{total:0,page:1,limit:10}},[y,d]),L=c.useCallback(async()=>y?await u(y):[],[y,u]),T=c.useCallback(async(X,ce)=>{if(y)return await f(y,X,ce)},[y,f]),$=c.useCallback(async X=>{if(y)return await p(y,X)},[y,p]),z=c.useCallback(async X=>{if(y)return await m(y,X)},[y,m]),H=c.useCallback(async(X,ce)=>{if(y)return await g(y,X,ce)},[y,g]),F=c.useCallback(async(X,ce)=>{if(y)return await v(y,X,ce)},[y,v]),O=c.useMemo(()=>(n==null?void 0:n.find(X=>X.id===(y==null?void 0:y.id)))||null,[n,y]),Z=c.useCallback(async()=>O?await w(O):[],[O,w]),R=c.useCallback(async X=>{if(O)return await x(O,X.email,X.workspaceRoleId)},[O,x]),W=c.useCallback(async X=>{if(O)return await b(O,X)},[O,b]),D=c.useCallback(async X=>{if(O)return await E(O,X)},[O,E]),B=r||C,Y=a||_;return B?{activeWorkspace:null,activeMembership:null,loading:!0,error:Y,refetch:e,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:y,activeMembership:k,loading:!1,error:Y,refetch:e,leave:M,updateWorkspace:A,deleteWorkspace:I,getMembers:P,getRoles:L,createRole:T,deleteRole:$,inviteMember:R,removeMember:z,addMemberRole:H,removeMemberRole:F,getInvitations:Z,discardInvitation:W,resendInvitation:D}};function Kn(e){const r=new Uint8Array(e);let a="";for(let n=0;n<r.length;n++)a+=String.fromCharCode(r[n]);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Yn(e){const r=e.replace(/-/g,"+").replace(/_/g,"/"),a=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(a),s=new Uint8Array(n.length);for(let i=0;i<n.length;i++)s[i]=n.charCodeAt(i);return s.buffer}const E2=async e=>(await V(await e("/me"))).data,A2=async e=>(await V(await e("/me/signins"))).data;function ir(){const{client:e,loading:r}=_e(),{data:a,error:n,isLoading:s,mutate:i}=$e(r?null:"/user",()=>E2(e)),h=async O=>{const Z=new FormData;for(const[W,D]of Object.entries(O))D!=null&&D!==""&&Z.append(W,String(D));const R=await V(await e("/me",{method:"POST",body:Z}));return i(),R},d=async()=>await V(await e("/me/email-addresses",{method:"GET"})),u=async O=>await V(await e(`/me/email-addresses/${O}`,{method:"GET"})),f=async O=>{const Z=new FormData;return Z.append("email",O),await V(await e("/me/email-addresses",{method:"POST",body:Z}))},p=async O=>await V(await e(`/me/email-addresses/${O}/delete`,{method:"POST"})),m=async O=>await V(await e(`/me/email-addresses/${O}/prepare-verification`,{method:"POST"})),g=async(O,Z)=>await V(await e(`/me/email-addresses/${O}/attempt-verification?code=${Z}`,{method:"POST"})),v=async(O,Z)=>{const R=new FormData;return R.append("phone_number",O),R.append("country_code",Z),await V(await e("/me/phone-numbers",{method:"POST",body:R}))},w=async O=>await V(await e(`/me/phone-numbers/${O}/delete`,{method:"POST"})),x=async O=>await V(await e(`/me/phone-numbers/${O}/prepare-verification`,{method:"POST"})),b=async(O,Z)=>{const R=new FormData;return R.append("code",Z),await V(await e(`/me/phone-numbers/${O}/attempt-verification`,{method:"POST",body:R}))},E=async O=>{const Z=await V(await e(`/me/phone-numbers/${O}/make-primary`,{method:"POST"}));return i(),Z},j=async O=>await V(await e(`/me/email-addresses/${O}/make-primary`,{method:"POST"})),S=async()=>(await V(await e("/me/authenticator",{method:"POST"}))).data,C=async(O,Z)=>{const R=new FormData;return R.append("authenticator_id",O),Z.forEach(D=>{R.append("codes",D)}),await V(await e("/me/authenticator/attempt-verification",{method:"POST",body:R}))},_=async O=>await V(await e(`/me/authenticator/${O}/delete`,{method:"POST"})),k=async()=>(await V(await e("/me/backup-codes",{method:"POST"}))).data,y=async O=>{const Z=new FormData;return Z.append("file",O),await V(await e("/me/profile-picture",{method:"POST",body:Z}))},M=async()=>(await V(await e("/me/backup-codes/regenerate",{method:"POST"}))).data,A=async(O,Z)=>{const R=new FormData;return R.append("current_password",O),R.append("new_password",Z),await V(await e("/me/update-password",{method:"POST",body:R}))},I=async O=>{const Z=new FormData;Z.append("current_password",O);const R=await V(await e("/me/remove-password",{method:"POST",body:Z}));return i(),R},P=async O=>{const Z=new FormData;return Z.append("password",O),await V(await e("/me/account/delete",{method:"POST",body:Z}))},L=async O=>await V(await e(`/me/social-connections/${O}/disconnect`,{method:"POST"})),T=async({provider:O,redirectUri:Z})=>{var D;const R=new URLSearchParams({provider:O});Z&&R.append("redirect_uri",Z);const W=await V(await e(`/me/init-sso-connection?${R.toString()}`,{method:"POST"}));return"data"in W&&((D=W.data)!=null&&D.oauth_url)&&window.open(W.data.oauth_url,"_blank"),W},$=async()=>await V(await e("/me/passkeys",{method:"GET"})),z=async O=>{var ce,me;const Z=await V(await e("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in Z))return Z;const R=Z.data.options.publicKey,W={challenge:Yn(R.challenge),rp:R.rp,user:{id:Yn(R.user.id),name:R.user.name,displayName:R.user.displayName},pubKeyCredParams:R.pubKeyCredParams,timeout:R.timeout,attestation:R.attestation,authenticatorSelection:R.authenticatorSelection,excludeCredentials:(ce=R.excludeCredentials)==null?void 0:ce.map(te=>({type:te.type,id:Yn(te.id),transports:te.transports}))},D=await navigator.credentials.create({publicKey:W});if(!D)throw new Error("Failed to create credential");const B=D.response,Y={id:D.id,rawId:Kn(D.rawId),type:D.type,response:{clientDataJSON:Kn(B.clientDataJSON),attestationObject:Kn(B.attestationObject),transports:((me=B.getTransports)==null?void 0:me.call(B))||[]}};return await V(await e(`/me/passkeys/register/finish?name=${encodeURIComponent(O||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)}))},H=async O=>await V(await e(`/me/passkeys/${O}/delete`,{method:"POST"})),F=async(O,Z)=>await V(await e(`/me/passkeys/${O}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z})}));return{user:{...a,refetch:i},loading:r||s,error:n||null,updateProfile:h,getEmailAddresses:d,getEmailAddress:u,createEmailAddress:f,deleteEmailAddress:p,prepareEmailVerification:m,attemptEmailVerification:g,makeEmailPrimary:j,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:x,attemptPhoneVerification:b,makePhonePrimary:E,setupAuthenticator:S,verifyAuthenticator:C,deleteAuthenticator:_,generateBackupCodes:k,regenerateBackupCodes:M,updateProfilePicture:y,disconnectSocialConnection:L,connectSocialAccount:T,updatePassword:A,removePassword:I,deleteAccount:P,getPasskeys:$,registerPasskey:z,deletePasskey:H,renamePasskey:F}}function m0(){const{client:e,loading:r}=_e(),{data:a,error:n,isLoading:s,mutate:i}=$e(r?null:"/me/signins",()=>A2(e));return{signins:a,error:n||null,removeSignin:async d=>await V(await e(`/me/signins/${d}/signout`,{method:"POST"})),refetch:i,loading:s||r}}function g0(){const{session:e,loading:r}=ot(),{loading:a,organizationMemberships:n}=Kt(),{loading:s,workspaceMemberships:i}=An(),h=c.useMemo(()=>!e||!e.signins||e.signins.length===0?null:(n==null?void 0:n.find(u=>{var f;return u.id===((f=e.active_signin)==null?void 0:f.active_organization_membership_id)}))||null,[n,e]),d=c.useMemo(()=>!e||!e.signins||e.signins.length===0?null:(i==null?void 0:i.find(u=>{var f;return u.id===((f=e.active_signin)==null?void 0:f.active_workspace_membership_id)}))||null,[i,e]);return{loading:r||a||s,orgMembership:h,workspaceMembership:d}}function v0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),s=async i=>{n(!0);try{const h=new FormData;for(const[f,p]of Object.entries(i))p&&h.append(f,p);const d=await e("/waitlist/join",{method:"POST",body:h});return await V(d)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:a,joinWaitlist:s}}function x0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),[s,i]=c.useState(null),[h,d]=c.useState(null),[u,f]=c.useState(null),[p,m]=c.useState(!1),[g,v]=c.useState(null);c.useEffect(()=>{if(p||r)return;const x=new URLSearchParams(window.location.search),b=x.get("code"),E=x.get("state"),j=x.get("error"),S=x.get("error_description");if(!b&&!j){m(!0);const C=new Error("No OAuth callback data found.");i(C);return}if(m(!0),n(!0),j){const C=S||j,_=new Error(`OAuth Error: ${C}`);i(_),n(!1);return}if(b&&E)w(b,E);else{const C=new Error("Missing required OAuth parameters");i(C),n(!1)}},[p,r]);const w=async(x,b)=>{try{let E,j;try{const _=b.split(".");if(_.length!==3)throw new Error("Invalid OAuth state format - missing signature");const k=_[0].replace(/-/g,"+").replace(/_/g,"/"),y=k.length%4?"=".repeat(4-k.length%4):"",A=atob(k+y).split("|")[0];if(A==="sign_in")E="/auth/oauth2/callback",j="GET";else if(A==="connect_social")E="/me/sso-connection-callback",j="POST";else throw new Error(`Unknown OAuth action: ${A}`)}catch(_){const k=_ instanceof Error?_:new Error("Failed to parse OAuth state");i(new Error(`Invalid OAuth callback: ${k.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const S=await e(`${E}?code=${encodeURIComponent(x)}&state=${encodeURIComponent(b)}`,{method:j}),C=await V(S);if("data"in C){const _=C.data.session,k=C.data.redirect_uri||null;if(d(_),f(k),_.signin_attempts&&_.signin_attempts.length>0){const y=_.signin_attempts.at(-1);y&&v(y)}}else{const _=new Error("SSO callback failed");i(_)}}catch(E){const j=E instanceof Error?E:new Error("Unknown error occurred");i(j)}finally{n(!1)}};return{loading:a,error:s,session:h,redirectUri:u,processed:p,signinAttempt:g}}function b0(){const{client:e,loading:r}=_e(),[a,n]=c.useState(!1),[s,i]=c.useState(null);return{loading:r||a,verifyMagicLink:async d=>{if(!d.token||!d.attempt)throw new Error("Invalid magic link parameters");n(!0),i(null);try{const u=new URL("/auth/verify-magic-link",window.location.origin);u.searchParams.set("token",d.token),u.searchParams.set("attempt",d.attempt),d.redirectUri&&u.searchParams.set("redirect_uri",d.redirectUri);const f=await e(u.pathname+u.search,{method:"GET"}),p=await V(f);return n(!1),i(!0),p}catch(u){throw n(!1),i(!1),u}},success:s}}function z2(){const[e,r]=c.useState({});return c.useEffect(()=>{const a=new URLSearchParams(window.location.search);r({token:a.get("token")||void 0,attempt:a.get("attempt")||void 0,redirectUri:a.get("redirect_uri")||void 0})},[]),e}function w0(){const{client:e,loading:r}=_e();return{loading:r,forgotPassword:async i=>{const h=new FormData;h.append("email",i);const d=await e("/auth/forgot-password",{method:"POST",body:h});return await V(d)},verifyOtp:async(i,h)=>{const d=new FormData;d.append("email",i),d.append("otp",h);const u=await e("/auth/forgot-password",{method:"POST",body:d});return await V(u)},resetPassword:async(i,h)=>{const d=new FormData;d.append("token",i),d.append("password",h);const u=await e("/auth/reset-password",{method:"POST",body:d});return await V(u)}}}const $2=()=>{},M2=$2(),Yo=Object,ii=e=>e===M2,L2=e=>typeof e=="function",Za=new WeakMap,R2=e=>Yo.prototype.toString.call(e),Qn=(e,r)=>e===`[object ${r}]`;let P2=0;const Qo=e=>{const r=typeof e,a=R2(e),n=Qn(a,"Date"),s=Qn(a,"RegExp"),i=Qn(a,"Object");let h,d;if(Yo(e)===e&&!n&&!s){if(h=Za.get(e),h)return h;if(h=++P2+"~",Za.set(e,h),Array.isArray(e)){for(h="@",d=0;d<e.length;d++)h+=Qo(e[d])+",";Za.set(e,h)}if(i){h="#";const u=Yo.keys(e).sort();for(;!ii(d=u.pop());)ii(e[d])||(h+=d+":"+Qo(e[d])+",");Za.set(e,h)}}else h=n?e.toJSON():r=="symbol"?e.toString():r=="string"?JSON.stringify(e):""+e;return h},T2=e=>{if(L2(e))try{e=e()}catch{e=""}const r=e;return e=typeof e=="string"?e:(Array.isArray(e)?e.length:e)?Qo(e):"",[e,r]},F2=e=>T2(e?e(0,null):null)[0],Jn=Promise.resolve(),I2=e=>(r,a,n)=>{const s=c.useRef(!1),{cache:i,initialSize:h=1,revalidateAll:d=!1,persistSize:u=!1,revalidateFirstPage:f=!0,revalidateOnMount:p=!1,parallel:m=!1}=n,[,,,g]=Tt.get(bs);let v;try{v=F2(r),v&&(v=u0+v)}catch{}const[w,x,b]=er(i,v),E=c.useCallback(()=>Ee(w()._l)?h:w()._l,[i,v,h]);Ho.useSyncExternalStore(c.useCallback(M=>v?b(v,()=>{M()}):()=>{},[i,v]),E,E);const j=c.useCallback(()=>{const M=w()._l;return Ee(M)?h:M},[v,h]),S=c.useRef(j());pn(()=>{if(!s.current){s.current=!0;return}v&&x({_l:u?S.current:j()})},[v,i]);const C=p&&!s.current,_=e(v,async M=>{const A=w()._i,I=w()._r;x({_r:pt});const P=[],L=j(),[T]=er(i,M),$=T().data,z=[];let H=null;for(let F=0;F<L;++F){const[O,Z]=ka(r(F,m?null:H));if(!O)break;const[R,W]=er(i,O);let D=R().data;const B=d||A||Ee(D)||f&&!F&&!Ee($)||C||$&&!Ee($[F])&&!n.compare($[F],D);if(a&&(typeof I=="function"?I(D,Z):B)){const Y=async()=>{if(!(O in g))D=await a(Z);else{const ce=g[O];delete g[O],D=await ce}W({data:D,_k:Z}),P[F]=D};m?z.push(Y):await Y()}else P[F]=D;m||(H=D)}return m&&await Promise.all(z.map(F=>F())),x({_i:pt}),P},n),k=c.useCallback(function(M,A){const I=typeof A=="boolean"?{revalidate:A}:A||{},P=I.revalidate!==!1;return v?(P&&(Ee(M)?x({_i:!0,_r:I.revalidate}):x({_i:!1,_r:I.revalidate})),arguments.length?_.mutate(M,{...I,revalidate:P}):_.mutate()):Jn},[v,i]),y=c.useCallback(M=>{if(!v)return Jn;const[,A]=er(i,v);let I;if($t(M)?I=M(j()):typeof M=="number"&&(I=M),typeof I!="number")return Jn;A({_l:I}),S.current=I;const P=[],[L]=er(i,v);let T=null;for(let $=0;$<I;++$){const[z]=ka(r($,T)),[H]=er(i,z),F=z?H().data:pt;if(Ee(F))return k(L().data);P.push(F),T=F}return k(P)},[v,i,k,j]);return{size:j(),setSize:y,mutate:k,get data(){return _.data},get error(){return _.error},get isValidating(){return _.isValidating},get isLoading(){return _.isLoading}}},ta=f2($e,I2);function y0({enabled:e=!0,channels:r,organizationIds:a,workspaceIds:n,onNotification:s,onError:i,reconnectDelay:h=1e3,maxReconnectAttempts:d=5}={}){const{session:u,loading:f}=ot(),{deployment:p,loading:m}=Ae(),[g,v]=c.useState(!1),[w,x]=c.useState(null),b=c.useRef(null),E=c.useRef(null),j=c.useRef(0),S=c.useRef(null),C=c.useRef(s),_=c.useRef(i),k=c.useRef(r),y=c.useRef(a),M=c.useRef(n),A=c.useRef(h),I=c.useRef(d);C.current=s,_.current=i,k.current=r,y.current=a,M.current=n,A.current=h,I.current=d;const P=c.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null),S.current&&(clearInterval(S.current),S.current=null),b.current&&(b.current.close(),b.current=null)},[]),L=c.useCallback(async()=>{var O;if(!e||f||m||!u||!p)return;P();const z=new URL(p.backend_host),H=z.protocol==="https:"?"wss:":"ws:",F=new URL("/notifications/stream",`${H}//${z.host}`);if(p.mode==="staging"){const Z=ht(p.backend_host);Z&&F.searchParams.set("__dev_session__",Z)}k.current&&k.current.length>0&&F.searchParams.set("channels",k.current.join(",")),y.current&&y.current.length>0&&F.searchParams.set("organization_ids",y.current.join(",")),M.current&&M.current.length>0&&F.searchParams.set("workspace_ids",M.current.join(","));try{const Z=new WebSocket(F.toString());b.current=Z,Z.onopen=()=>{v(!0),x(null),j.current=0,S.current=setInterval(()=>{Z.readyState===WebSocket.OPEN&&Z.send("ping")},3e4)},Z.onmessage=R=>{var W,D;try{const B=JSON.parse(R.data);if(B.type==="notification"&&B.data)(W=C.current)==null||W.call(C,B.data);else if(B.type==="error"){const Y=B.error||"Unknown error occurred";x(Y),(D=_.current)==null||D.call(_,Y)}else B.type}catch{}},Z.onerror=()=>{var R;x("Connection error occurred"),(R=_.current)==null||R.call(_,"Connection error occurred")},Z.onclose=R=>{var W;if(v(!1),S.current&&(clearInterval(S.current),S.current=null),e&&R.code!==1e3&&j.current<I.current){j.current++;const D=A.current*Math.pow(2,j.current-1);E.current=setTimeout(()=>{L()},D)}else j.current>=I.current&&(x("Max reconnection attempts reached"),(W=_.current)==null||W.call(_,"Max reconnection attempts reached"))}}catch{x("Failed to connect"),(O=_.current)==null||O.call(_,"Failed to connect")}},[e,f,m,u,p,P]);c.useEffect(()=>(L(),()=>{P()}),[L,P]),c.useEffect(()=>{b.current&&b.current.readyState===WebSocket.OPEN&&L()},[r,a,n,L]);const T=c.useCallback(()=>{P(),v(!1)},[P]),$=c.useCallback(()=>{j.current=0,L()},[L]);return{isConnected:g,connectionError:w,disconnect:T,reconnect:$}}function zn(e){if(!e)return"";const r=new URLSearchParams;e.limit&&r.append("limit",e.limit.toString()),e.cursor&&r.append("cursor",e.cursor),e.scope&&r.append("scope",e.scope),e.channels&&e.channels.length>0&&e.channels.forEach(n=>r.append("channels",n)),e.organization_ids&&e.organization_ids.length>0&&e.organization_ids.forEach(n=>r.append("organization_ids",n)),e.workspace_ids&&e.workspace_ids.length>0&&e.workspace_ids.forEach(n=>r.append("workspace_ids",n)),e.is_read!==void 0&&r.append("is_read",e.is_read.toString()),e.is_archived!==void 0&&r.append("is_archived",e.is_archived.toString()),e.is_starred!==void 0&&r.append("is_starred",e.is_starred.toString()),e.severity&&r.append("severity",e.severity);const a=r.toString();return a?"?"+a:""}async function Z2(e,r){const a=`/notifications${zn(r)}`,n=await e(a,{method:"GET"});return(await V(n)).data}async function O2(e,r){const a=await e(`/notifications/${r}/read`,{method:"POST"});return V(a)}async function H2(e,r){const a=await e(`/notifications/${r}/unread`,{method:"POST"});return V(a)}async function V2(e,r){const a=await e(`/notifications/mark-all-read${zn(r)}`,{method:"POST"});return V(a)}async function D2(e,r){const a=await e(`/notifications/archive-all-read${zn(r)}`,{method:"POST"});return V(a)}async function N2(e,r){const a=await e(`/notifications/${r}/archive`,{method:"POST"});return V(a)}async function U2(e,r){const a=await e(`/notifications/${r}/star`,{method:"POST"});return V(a)}function j0(e){var M;const{client:r,loading:a}=_e(),{data:n,error:s,mutate:i,isLoading:h,size:d,setSize:u,isValidating:f}=ta((A,I)=>{var $;if(a||A>0&&(!I||!I.has_more))return null;const P=A===0||($=I==null?void 0:I.notifications[I.notifications.length-1])==null?void 0:$.id,{onNotification:L,...T}=e||{};return["wacht-notifications",{...T,cursor:P}]},([,A])=>Z2(r,A),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),p=c.useMemo(()=>n?n.flatMap(A=>A.notifications):[],[n]),m=n?(M=n[n.length-1])==null?void 0:M.has_more:!1,g=c.useMemo(()=>{if(e!=null&&e.channels&&e.channels.length>0)return e.channels;switch(e==null?void 0:e.scope){case"organization":return["organization"];case"workspace":return["workspace"];case"current":return["current"];case"all":return["user","organization","workspace"];case"user":return["user"];default:return}},[e==null?void 0:e.channels,e==null?void 0:e.scope]),v=c.useMemo(()=>{var A;return(A=e==null?void 0:e.organization_ids)==null?void 0:A.map(I=>Number(I)).filter(I=>Number.isFinite(I))},[e==null?void 0:e.organization_ids]),w=c.useMemo(()=>{var A;return(A=e==null?void 0:e.workspace_ids)==null?void 0:A.map(I=>Number(I)).filter(I=>Number.isFinite(I))},[e==null?void 0:e.workspace_ids]);y0({enabled:!a&&!!n,channels:g,organizationIds:v,workspaceIds:w,onNotification:c.useCallback(A=>{i(async I=>{var $;if(!I||I.length===0||I.some(z=>z.notifications.some(H=>H.id===A.id.toString())))return I;($=e==null?void 0:e.onNotification)==null||$.call(e,A);const L=I[0];return[{...L,notifications:[{id:A.id.toString(),user_id:A.user_id.toString(),deployment_id:A.deployment_id.toString(),title:A.title,body:A.body,severity:A.severity,ctas:A.ctas,is_read:!1,is_archived:!1,created_at:A.created_at,updated_at:A.created_at},...L.notifications]},...I.slice(1)]},!1)},[i,e]),onError:c.useCallback(()=>{},[])});const x=c.useCallback(async A=>{a||(await i(async I=>I&&I.map(P=>({...P,notifications:P.notifications.map(L=>L.id===A?{...L,is_read:!0}:L)})),!1),await O2(r,A),await i())},[r,a,i]),b=c.useCallback(async A=>{a||(await i(async I=>I&&I.map(P=>({...P,notifications:P.notifications.map(L=>L.id===A?{...L,is_read:!1}:L)})),!1),await H2(r,A),await i())},[r,a,i]),E=c.useCallback(async()=>{a||(await i(async A=>A&&A.map(I=>({...I,notifications:I.notifications.map(P=>({...P,is_read:!0}))})),!1),await V2(r,e),await i())},[r,e,i,a]),j=c.useCallback(async()=>{a||(await i(async A=>A&&A.map(I=>({...I,notifications:I.notifications.filter(P=>!P.is_read)})),!1),await D2(r,e),await i())},[r,e,a,i]),S=c.useCallback(async A=>{a||(await i(async I=>I&&I.map(P=>({...P,notifications:(e==null?void 0:e.is_archived)!==void 0?P.notifications.filter(L=>L.id!==A):P.notifications.map(L=>L.id===A?{...L,is_archived:!L.is_archived}:L)})),!1),await N2(r,A),await i())},[r,a,i,e==null?void 0:e.is_archived]),C=c.useCallback(async A=>{a||(await i(async I=>I&&I.map(P=>({...P,notifications:P.notifications.map(L=>L.id===A?{...L,is_starred:!L.is_starred}:L)})),!1),await U2(r,A),await i())},[r,a,i]),_=c.useCallback(async()=>{f||!m||await u(d+1)},[f,m,u,d]),k=c.useCallback(async()=>{await i()},[i]),y=a||h||d>0&&n&&typeof n[d-1]>"u";return!n||y?{loading:!0,notifications:p,hasMore:m,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:s,refetch:k,loadMore:_}:{loading:!1,error:s,notifications:p,hasMore:m,markAsRead:x,markAllAsRead:E,archiveAllRead:j,archiveNotification:S,starNotification:C,markAsUnread:b,refetch:k,loadMore:_}}async function B2(e,r){const a=`/notifications/scope-unread${zn(r)}`,n=await e(a,{method:"GET"});return(await V(n)).data}function _0(e){const{client:r,loading:a}=_e(),{data:n,error:s,mutate:i}=$e(a?null:["wacht-notifications-unread",e],([,d])=>B2(r,d),{refreshInterval:3e4,revalidateOnFocus:!0}),h=async()=>{await i()};return!n||a?{loading:!0,count:0,error:s,refetch:h}:{loading:!1,count:n.count,error:s,refetch:h}}const Ir={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Ke={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},fr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function W2(e){switch(e.trim()){case fr.IDLE:return Ke.IDLE;case fr.STARTING:case"starting":return Ke.STARTING;case fr.RUNNING:case"running":return Ke.RUNNING;case fr.WAITING_FOR_INPUT:case"waiting_for_input":return Ke.WAITING_FOR_INPUT;case fr.COMPLETED:case"completed":return Ke.COMPLETED;case fr.FAILED:case fr.CANCELLED:case"failed":case"cancelled":return Ke.FAILED;default:return Ke.IDLE}}function Zr(e){return e===Ke.STARTING||e===Ke.RUNNING||e===Ke.WAITING_FOR_INPUT}function Gt(e){return e&&typeof e=="object"?e:null}function Cr(e){return typeof e=="string"?e:null}function G2(e){const r=Gt(e);return(r==null?void 0:r.ConversationMessage)??e}function q2(e){const r=Gt(e);if(!r)return null;const a=Gt(r.content),n=Gt(r.metadata),s=Cr(r.message_type)||Cr(n==null?void 0:n.message_type)||Cr(a==null?void 0:a.type);return{...r,metadata:{...n||{},message_type:s}}}function K2(e){const r=Gt(e.metadata),a=Gt(e.content);return Cr(r==null?void 0:r.message_type)||Cr(a==null?void 0:a.type)}function Y2(e){const r=Gt(e.content);return Cr(r==null?void 0:r.status)}function Q2(e){const r=Gt(e.content),a=Cr(r==null?void 0:r.step);return a==="execution_cancelled"||a==="abort"}function J2(e){const r=Gt(e.content);return(r==null?void 0:r.further_actions_required)===!1}function ci(e){return[...e].sort((r,a)=>new Date(r.timestamp).getTime()-new Date(a.timestamp).getTime())}function X2(e,r){return{id:e,timestamp:new Date().toISOString(),content:{type:"user_message",message:r},metadata:{message_type:"user_message"}}}function ep(e,r){const a=new FormData;a.append("message",e);for(const n of r??[])a.append("files",n);return a}function tp(e,r){const a=new FormData;a.append("request_message_id",e);for(const n of r)a.append("approval_tool_name",n.tool_name),a.append("approval_mode",n.mode);return a}function rp(){const e=new FormData;return e.append("cancel","true"),e}function ap({deployment:e,threadId:r,file:a}){const n=a.url||a.filename;if(!n)return null;if(/^https?:\/\//i.test(n))return n;const s=e.backend_host.replace(/\/$/,"");let i;if(n.startsWith("/ai/threads/"))i=new URL(n,`${s}/`);else{const h=n.includes("/")?n.split("/").pop()??"":n;if(!h)return null;i=new URL(`/ai/threads/${encodeURIComponent(r)}/filesystem/file`,`${s}/`),i.searchParams.set("path",`uploads/${h}`)}if(e.mode==="staging"){const h=ht(e.backend_host);h&&i.searchParams.set("__dev_session__",h)}return i.toString()}const np=5e3,op=5e3;function sp({threadId:e,initialThread:r=null,platformAdapter:a}){var We;const{deployment:n}=Ae(),{client:s}=_e(),[i,h]=c.useState([]),[d,u]=c.useState(null),[f,p]=c.useState(null),[m,g]=c.useState(r),[v,w]=c.useState(Ke.IDLE),[x,b]=c.useState({status:Ir.DISCONNECTED}),[E,j]=c.useState(!0),[S,C]=c.useState(!1),[_,k]=c.useState(!1),[y,M]=c.useState(null),A=c.useRef(null),I=c.useRef(e),P=c.useRef(0),L=c.useRef(Ke.IDLE),T=c.useRef(null),$=c.useCallback(Q=>{h(se=>{const he=[...se],je=he.findIndex(ke=>String(ke.id)===String(Q.id));return je>=0?he[je]=Q:he.push(Q),ci(he)})},[]),z=c.useCallback(({messages:Q,prepend:se,hasMore:he})=>{const je=ci(Q);je.length>0&&(A.current=je[0].id),h(ke=>se?[...je,...ke]:je),he!==void 0&&j(he)},[]),H=c.useCallback(Q=>{L.current=Q,w(Q)},[]),F=c.useCallback(Q=>{P.current=Date.now()+np,H(Q)},[H]),O=c.useCallback(()=>{var Q;P.current>Date.now()&&Zr(L.current)||(H(Ke.IDLE),(Q=T.current)==null||Q.call(T))},[H]),Z=c.useCallback(Q=>{const se=W2(Q),he=Zr(se);!he&&P.current>Date.now()&&Zr(L.current)||(he&&(P.current=0),H(se))},[H]),R=c.useCallback(()=>{u(null),p(null)},[]),W=c.useCallback(Q=>{g(se=>se&&{...se,...Q?{status:Q}:{},last_activity_at:new Date().toISOString()})},[]),D=c.useCallback((Q,se)=>{$(X2(Q,se)),R()},[R,$]),B=c.useCallback(Q=>{const se=q2(Q);if(!se)return;switch(K2(se)){case"system_decision":$(se),Q2(se)&&O();return;case"execution_summary":case"tool_result":case"user_message":$(se);return;case"steer":$(se),J2(se)&&O();return;case"approval_request":P.current=0,H(Ke.WAITING_FOR_INPUT),$(se);return;case"approval_response":$(se),F(Ke.RUNNING);return;case"execution_status":{const je=Y2(se);if(!je)return;Z(je),g(ke=>ke&&{...ke,status:je});return}default:$(se)}},[Z,O,H,F,$]),Y=c.useCallback((Q,se)=>{var he;(he=a==null?void 0:a.onPlatformEvent)==null||he.call(a,Q,se)},[a]),X=c.useRef(B),ce=c.useRef(Y),me=c.useRef(s),te=c.useRef(n);c.useEffect(()=>{X.current=B,ce.current=Y,me.current=s,te.current=n}),c.useEffect(()=>{I.current=e},[e]);const xe=c.useRef(null),re=c.useRef(null),U=c.useRef(0),Qe=10,Te=c.useCallback(async Q=>{if(!e)return;const se=e;Q?C(!0):k(!0),M(null);try{const he=new URLSearchParams({limit:"100"});Q&&he.append("before_id",Q);const je=await s(`/ai/threads/${e}/messages?${he}`,{method:"GET"}),ke=await V(je);ke.data&&I.current===se&&z({messages:ke.data.data,prepend:!!Q,hasMore:ke.data.has_more||!1})}catch(he){I.current===se&&M(he instanceof Error?he:new Error("Failed to fetch messages"))}finally{I.current===se&&(Q?C(!1):k(!1))}},[e,s,z]);c.useEffect(()=>{const Q=te.current;if(!Q||!e)return;const se=()=>{xe.current&&(xe.current.close(),xe.current=null);const he=new URL(`${Q.backend_host}/ai/threads/${encodeURIComponent(e)}/stream`);if(Q.mode==="staging"){const ke=ht(Q.backend_host);ke&&he.searchParams.append("__dev_session__",ke)}const je=new EventSource(he.toString(),{withCredentials:Q.mode!=="staging"});xe.current=je,je.onopen=()=>{if(b({status:Ir.CONNECTED}),U.current>0){const ke=e;setTimeout(()=>{s(`/ai/threads/${ke}/messages?limit=100`,{method:"GET"}).then(async Ge=>{const dt=await V(Ge);dt.data&&I.current===ke&&z({messages:dt.data.data,hasMore:dt.data.has_more||!1})}).catch(()=>{})},100)}U.current=0},je.onerror=()=>{if(b({status:Ir.ERROR}),je.close(),xe.current=null,U.current<Qe){const ke=Math.min(1e3*Math.pow(2,U.current),3e4);re.current=setTimeout(()=>{U.current++,se()},ke)}else b({status:Ir.DISCONNECTED})},je.addEventListener("conversation_message",ke=>{try{const Ge=G2(JSON.parse(ke.data));Ge&&X.current(Ge)}catch{}}),je.addEventListener("platform_event",ke=>{try{const Ge=JSON.parse(ke.data);Ge!=null&&Ge.PlatformEvent?ce.current(Ge.PlatformEvent[0],Ge.PlatformEvent[1]):Ge!=null&&Ge.event_label&&ce.current(Ge.event_label,Ge.event_data)}catch{}})};return se(),()=>{re.current&&(clearTimeout(re.current),re.current=null),xe.current&&(xe.current.close(),xe.current=null)}},[e,s,z]);const Ve=c.useCallback(async()=>{if(!e)return;const Q=e;try{const se=await s(`/ai/threads/${Q}`,{method:"GET"});if(!se.ok)return;const he=await V(se);he.data&&I.current===Q&&(g(he.data),Z(he.data.status),Gr(`wacht-ai-thread:${Q}`,he.data,{revalidate:!1}))}catch{}},[e,s,Z]);c.useEffect(()=>{T.current=Ve},[Ve]),c.useEffect(()=>{if(!e)return;Ve();const Q=window.setInterval(()=>{!Zr(L.current)&&P.current<=Date.now()||Ve()},op);return()=>{window.clearInterval(Q)}},[e,Ve]),c.useEffect(()=>{h([]),g(null),j(!0),C(!1),M(null),k(!!e),b({status:Ir.DISCONNECTED}),A.current=null,P.current=0,L.current=Ke.IDLE,w(Ke.IDLE),R()},[e,R]),c.useEffect(()=>{!r||r.id!==e||g(r)},[r,e]);const Ue=c.useCallback(async(Q,se)=>{var he,je;if(!(!e||!n)){u(Q),se&&se.length>0&&p(se),F(Ke.STARTING);try{const ke=await s(`/ai/threads/${e}/run`,{method:"POST",body:ep(Q,se)});if(ke.ok){const Ge=await V(ke),dt=((he=Ge.data)==null?void 0:he.conversation_id)??null;W(typeof((je=Ge.data)==null?void 0:je.status)=="string"?Ge.data.status:void 0),dt?D(dt,Q):R(),F(Ke.RUNNING)}else P.current=0,H(Ke.IDLE),R()}catch{P.current=0,H(Ke.IDLE),R()}}},[e,n,s,F,H,W,R,D]);c.useEffect(()=>{e&&Te()},[e,Te]);const ve=c.useCallback(async()=>{await Te()},[Te]),J=c.useCallback(async()=>{if(!(S||!E||!A.current)){C(!0);try{await Te(A.current)}finally{C(!1)}}},[S,E,Te]),le=c.useCallback(()=>{h([]),R()},[R]),oe=c.useCallback(async(Q,se)=>{if(!e)return!1;F(Ke.STARTING);try{return(await s(`/ai/threads/${e}/run`,{method:"POST",body:tp(Q,se)})).ok?(W(),F(Ke.RUNNING),!0):(P.current=0,H(Ke.IDLE),!1)}catch{return P.current=0,H(Ke.IDLE),!1}},[e,s,F,H,W]),G=c.useCallback(async()=>{if(!(!e||!Zr(v)))try{await s(`/ai/threads/${e}/run`,{method:"POST",body:rp()}),P.current=0,W(),H(Ke.IDLE)}catch{}},[e,v,s,H,W]),pe=c.useCallback(Q=>!n||!e||!Q?null:ap({deployment:n,threadId:e,file:Q}),[e,n]),fe=c.useCallback(Q=>{const se=pe(Q);if(!se)return;const he=document.createElement("a");he.href=se,he.download=(Q==null?void 0:Q.filename)||"attachment",he.rel="noreferrer",document.body.appendChild(he),he.click(),document.body.removeChild(he)},[pe]),q=((We=m==null?void 0:m.execution_state)==null?void 0:We.pending_approval_request)??null,de=(q==null?void 0:q.request_message_id)??null,Be=m==null?void 0:m.status;return{thread:m,threadState:m,threadStatus:Be,messages:i,pendingMessage:d,pendingFiles:f,connectionState:x,isConnected:x.status===Ir.CONNECTED,hasActiveRun:Zr(v),isRunning:v===Ke.STARTING||v===Ke.RUNNING,executionStatus:v,isWaitingForInput:v===Ke.WAITING_FOR_INPUT,pendingApprovalRequest:q,activeApprovalRequestId:de,hasMoreMessages:E,isLoadingMore:S,messagesLoading:_,messagesError:y,refreshThread:Ve,refreshMessages:ve,sendMessage:Ue,submitApprovalResponse:oe,clearMessages:le,loadMoreMessages:J,cancelExecution:G,resolveMessageFileUrl:pe,downloadMessageFile:fe}}function ip(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>{const C=await r("/ai/session",{method:"GET"});if(!C.ok)throw C.status===401||C.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await V(C)).data},[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-agent-session":null,g,{revalidateOnFocus:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(e)}`,{method:"GET"})).ok?(u.current=!0,n(!0)):d(new Error("Failed to exchange ticket"))}catch(_){d(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=!h&&(e?a:!0)&&(!w||w.message!=="NO_SESSION"),j=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:E,sessionLoading:s||m&&x,sessionError:j,sessionId:(v==null?void 0:v.session_id)||null,actor:(v==null?void 0:v.actor)||null,agents:(v==null?void 0:v.agents)||[],ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()}}}const li={exists:!1,files:[]};function Oa(e,r,a){const s=(e||[]).filter(i=>i.id!==r.id);return!a&&r.archived_at?s:[r,...s]}function cp(e,r){return r===void 0?"":`?${new URLSearchParams({[e]:String(r)}).toString()}`}function k0(e,r){const a=new URLSearchParams({path:e});return r&&a.set("include_archived","true"),`?${a.toString()}`}function C0(e,r){const a=new URLSearchParams;e&&a.set("path",e),r&&a.set("include_archived","true");const n=a.toString();return n?`?${n}`:""}function lp(e){const r=e.split("/").pop()||e,a=r.lastIndexOf(".");return a<0||a===r.length-1?"":r.slice(a+1).toLowerCase()}function dp(e,r){const a=lp(r),n=new Set(["doc","docx","ppt","pptx","xls","xlsx","pdf","zip","gz","tar","7z","rar","jar","war","bin"]),s=new Set(["txt","md","mdx","markdown","json","jsonc","js","jsx","ts","tsx","mts","cts","mjs","cjs","py","rb","php","java","kt","kts","go","rs","c","cc","cpp","cxx","h","hpp","swift","sh","bash","zsh","fish","ps1","sql","html","htm","css","scss","less","xml","svg","yaml","yml","toml","ini","cfg","conf","env","log"]);return n.has(a)?!1:s.has(a)?!0:e.startsWith("text/")||e.includes("json")||e.includes("javascript")||e.includes("typescript")||e.includes("python")||e.includes("xml")||e.includes("yaml")}function st(e,r,a){if(a!=null){if(typeof a=="string"){e.set(r,a);return}if(typeof a=="boolean"||typeof a=="number"){e.set(r,String(a));return}}}function up(e,r,a){a&&e.set(r,JSON.stringify(a))}function di(e){const r=new FormData;return st(r,"name",e.name),st(r,"agent_id","agent_id"in e?e.agent_id:void 0),st(r,"description",e.description),st(r,"status",e.status),r}function pp(e){const r=new FormData;if(st(r,"title",e.title),st(r,"agent_id",e.agent_id),st(r,"system_instructions",e.system_instructions),st(r,"thread_purpose",e.thread_purpose),st(r,"responsibility",e.responsibility),st(r,"reusable",e.reusable),st(r,"accepts_assignments",e.accepts_assignments),up(r,"metadata",e.metadata),Array.isArray(e.capability_tags))for(const a of e.capability_tags)r.append("capability_tags",a);return r}function S0(e){const r=new FormData;return st(r,"title",e.title),st(r,"agent_id",e.agent_id),st(r,"system_instructions",e.system_instructions),r}function E0(e,r=[]){const a=new FormData;st(a,"title",e.title),st(a,"description",e.description),st(a,"status",e.status),st(a,"schedule_kind",e.schedule_kind),st(a,"next_run_at",e.next_run_at),st(a,"interval_seconds",e.interval_seconds),"clear_schedule"in e&&st(a,"clear_schedule",e.clear_schedule);for(const n of r)a.append("files",n);return a}function hp(e={}){const{client:r}=_e(),{includeArchived:a=!1,enabled:n=!0}=e,s=n?`wacht-ai-actor-projects:${a}`:null,i=c.useCallback(async()=>{const v=await r(`/ai/projects${cp("include_archived",a)}`);return(await V(v)).data},[r,a]),{data:h,error:d,mutate:u}=$e(s,i,{revalidateOnFocus:!1}),f=c.useCallback(async v=>{const w=await r("/ai/projects",{method:"POST",body:di(v)}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]),p=c.useCallback(async(v,w)=>{const x=await r(`/ai/projects/${v}/update`,{method:"POST",body:di(w)}),b=await V(x);return await u(E=>Oa(E,b.data,a),{revalidate:!0}),b},[r,a,u]),m=c.useCallback(async v=>{const w=await r(`/ai/projects/${v}/archive`,{method:"POST",body:new URLSearchParams}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]),g=c.useCallback(async v=>{const w=await r(`/ai/projects/${v}/unarchive`,{method:"POST",body:new URLSearchParams}),x=await V(w);return await u(b=>Oa(b,x.data,a),{revalidate:!0}),x},[r,a,u]);return{projects:h||[],loading:!h&&!d,error:d,createProject:f,updateProject:p,archiveProject:m,unarchiveProject:g,refetch:async()=>{await u()}}}function fp(e={}){const{client:r}=_e(),{enabled:a=!0,query:n="",limit:s=12}=e,i=n.trim(),h=a?`wacht-ai-actor-project-search:${i}:${s}`:null,d=c.useCallback(async()=>{const m=new URLSearchParams({limit:String(s)});i&&m.set("q",i);const g=await r(`/ai/projects/search?${m.toString()}`);return(await V(g)).data},[r,s,i]),{data:u,error:f,mutate:p}=$e(h,d,{revalidateOnFocus:!1});return{projects:(u==null?void 0:u.data)||[],loading:!u&&!f,error:f,hasMore:(u==null?void 0:u.has_more)||!1,nextCursor:u==null?void 0:u.next_cursor,refetch:async()=>{await p()}}}function mp(e,r={}){const{client:a}=_e(),{includeArchived:n=!1,enabled:s=!0}=r,i=s&&e?`wacht-ai-threads:${e}:${n}`:null,h=c.useCallback(async()=>{if(!e)return{data:[],has_more:!1,next_cursor:""};const x=new URLSearchParams({limit:"100"});n&&x.set("include_archived","true");const b=await a(`/ai/projects/${e}/threads?${x.toString()}`);return(await V(b)).data},[e,a,n]),{data:d,error:u,mutate:f}=$e(i,h,{revalidateOnFocus:!1}),p=c.useCallback(async(x,b)=>{const E=await a(`/ai/projects/${x}/threads`,{method:"POST",body:pp(b)}),j=await V(E);return x===e&&await f(),j},[e,a,f]),m=c.useCallback(async x=>{if(!e)throw new Error("projectId is required");return p(e,x)},[e,p]),g=c.useCallback(async(x,b)=>{const E=await a(`/ai/threads/${x}/update`,{method:"POST",body:S0(b)}),j=await V(E);return await f(),j},[a,f]),v=c.useCallback(async x=>{const b=await a(`/ai/threads/${x}/archive`,{method:"POST",body:new URLSearchParams}),E=await V(b);return await f(),E},[a,f]),w=c.useCallback(async x=>{const b=await a(`/ai/threads/${x}/unarchive`,{method:"POST",body:new URLSearchParams}),E=await V(b);return await f(),E},[a,f]);return{threads:(d==null?void 0:d.data)||[],loading:!d&&!u,error:u,hasMore:(d==null?void 0:d.has_more)||!1,nextCursor:(d==null?void 0:d.next_cursor)||"",createThread:m,createThreadForProject:p,updateThread:g,archiveThread:v,unarchiveThread:w,refetch:async()=>{await f()}}}function gp(e,r={}){var v,w;const{client:a}=_e(),{includeArchived:n=!1,archivedOnly:s=!1,enabled:i=!0,query:h="",limit:d=10}=r,u=h.trim(),f=ta((x,b)=>{if(!i||!e||x>0&&b&&!b.has_more)return null;const E=x===0||b==null?void 0:b.next_cursor;return["wacht-ai-project-thread-feed",e,s?"archived-only":n?"with-archived":"active-only",u,d,E||""]},async([,x,b,E,j,S])=>{const C=new URLSearchParams({limit:String(j)});b==="with-archived"?C.set("include_archived","true"):b==="archived-only"&&(C.set("include_archived","true"),C.set("archived_only","true")),E&&C.set("q",String(E)),S&&C.set("cursor",String(S));const _=await a(`/ai/projects/${x}/threads?${C.toString()}`);return(await V(_)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0}),p=c.useMemo(()=>{var x;return((x=f.data)==null?void 0:x.flatMap(b=>b.data||[]))||[]},[f.data]),m=f.data&&((v=f.data[f.data.length-1])==null?void 0:v.has_more)||!1,g=f.isValidating&&!!f.data&&f.size>(((w=f.data)==null?void 0:w.length)||0);return{threads:p,loading:!f.data&&!f.error,error:f.error||null,hasMore:m,loadingMore:g,loadMore:async()=>{!m||g||await f.setSize(x=>x+1)},refetch:async()=>{await f.mutate()}}}function vp(e={}){const{client:r}=_e(),{enabled:a=!0,query:n="",limit:s=16}=e,i=n.trim(),h=a?`wacht-ai-actor-thread-search:${i}:${s}`:null,d=c.useCallback(async()=>{const m=new URLSearchParams({limit:String(s)});i&&m.set("q",i);const g=await r(`/ai/threads/search?${m.toString()}`);return(await V(g)).data},[r,s,i]),{data:u,error:f,mutate:p}=$e(h,d,{revalidateOnFocus:!1});return{threads:(u==null?void 0:u.data)||[],loading:!u&&!f,error:f,hasMore:(u==null?void 0:u.has_more)||!1,nextCursor:u==null?void 0:u.next_cursor,refetch:async()=>{await p()}}}function xp(e,r=!0){const{client:a}=_e(),n=r&&e?`wacht-ai-thread:${e}`:null,s=c.useCallback(async()=>{if(!e)return null;const p=await a(`/ai/threads/${e}`);return(await V(p)).data},[e,a]),i=$e(n,s,{revalidateOnFocus:!1}),h=c.useCallback(async p=>{if(!e)throw new Error("threadId is required");const m=await a(`/ai/threads/${e}/update`,{method:"POST",body:S0(p)}),g=await V(m);return await i.mutate(),g},[e,a,i]),d=c.useCallback(async()=>{if(!e)throw new Error("threadId is required");const p=await a(`/ai/threads/${e}/archive`,{method:"POST",body:new URLSearchParams}),m=await V(p);return await i.mutate(),m},[e,a,i]),u=c.useCallback(async()=>{if(!e)throw new Error("threadId is required");const p=await a(`/ai/threads/${e}/unarchive`,{method:"POST",body:new URLSearchParams}),m=await V(p);return await i.mutate(),m},[e,a,i]),f=c.useCallback(async p=>{if(!e)throw new Error("threadId is required");await a(`/ai/threads/${e}/messages/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})},[e,a]);return{thread:i.data||null,loading:!i.data&&!i.error,error:i.error||null,updateThread:h,archiveThread:d,unarchiveThread:u,submitAnswer:f,refetch:async()=>{await i.mutate()}}}function bp(e,r=!0){const{client:a}=_e(),n=r&&e?`wacht-ai-thread-filesystem:${e}`:null,s=c.useCallback(async d=>{if(!e)throw new Error("threadId is required");const u=await a(`/ai/threads/${e}/filesystem/file${k0(d)}`);if(!u.ok)throw new Error("Failed to load file");const f=await u.blob(),p=(u.headers.get("content-type")||"application/octet-stream").split(";")[0].trim().toLowerCase(),m=dp(p,d);let g;return m&&(g=await f.text()),{path:d,name:d.split("/").pop()||"file",mime_type:p,is_text:m,size_bytes:f.size,truncated:!1,content:g,blob:f}},[e,a]),i=c.useCallback(async d=>{if(!e)return li;const u=await a(`/ai/threads/${e}/filesystem${C0(d)}`);return(await V(u)).data},[e,a]),h=$e(n,()=>i(),{revalidateOnFocus:!1});return{filesystem:h.data||li,filesystemLoading:!h.data&&!h.error,filesystemError:h.error||null,getFile:s,listDirectory:i,refetch:async()=>{await h.mutate()}}}function wp(e,r={}){var f,p;const{client:a}=_e(),{enabled:n=!0,limit:s=40}=r,i=ta((m,g)=>{if(!n||!e||m>0&&g&&!g.has_more)return null;const v=m===0||g==null?void 0:g.next_cursor;return["wacht-ai-thread-assignments",e,s,v||""]},async([,m,g,v])=>{const w=new URLSearchParams({limit:String(g)});v&&w.set("cursor",String(v));const x=await a(`/ai/threads/${m}/assignments?${w.toString()}`);return(await V(x)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),h=c.useMemo(()=>{var m;return((m=i.data)==null?void 0:m.flatMap(g=>g.data||[]))||[]},[i.data]),d=i.data&&((f=i.data[i.data.length-1])==null?void 0:f.has_more)||!1,u=i.isValidating&&!!i.data&&i.size>(((p=i.data)==null?void 0:p.length)||0);return{assignments:h,loading:!i.data&&!i.error,error:i.error||null,hasMore:d,loadingMore:u,loadMore:async()=>{!d||u||await i.setSize(m=>m+1)},refetch:async()=>{await i.mutate()}}}function yp(e={},r){const a=new URLSearchParams;e.statuses&&e.statuses.length>0&&a.set("status",e.statuses.join(",")),e.includeArchived&&a.set("include_archived","true"),e.archivedOnly&&a.set("archived_only","true"),e.limit&&a.set("limit",String(e.limit)),r&&a.set("cursor",r);const n=a.toString();return n?`?${n}`:""}function jp(e,r=!0,a={}){var w,x,b;const{client:n}=_e(),s=((w=a.statuses)==null?void 0:w.join(","))||"all",i=a.archivedOnly?"archived-only":a.includeArchived?"with-archived":"active-only",h=a.limit||60,d=ta((E,j)=>{if(!r||!e||E>0&&j&&!j.has_more)return null;const S=E===0||j==null?void 0:j.next_cursor;return["wacht-ai-project-tasks",e,s,i,h,S||""]},async([,E,,,,j])=>{const S=await n(`/ai/projects/${E}/board/items${yp(a,j||void 0)}`);return(await V(S)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),u=c.useMemo(()=>{var E;return((E=d.data)==null?void 0:E.flatMap(j=>j.data||[]))||[]},[d.data]),f=d.data&&((x=d.data[d.data.length-1])==null?void 0:x.has_more)||!1,p=d.isValidating&&!!d.data&&d.size>(((b=d.data)==null?void 0:b.length)||0),m=c.useCallback(async(E,j=[])=>{if(!e)throw new Error("projectId is required");const S=await n(`/ai/projects/${e}/board/items`,{method:"POST",body:E0(E,j)}),C=await V(S);return await d.mutate(),C},[e,n,d]),g=c.useCallback(async E=>{if(!e)throw new Error("projectId is required");const j=await n(`/ai/projects/${e}/board/items/${E}/archive`,{method:"POST",body:new URLSearchParams}),S=await V(j);return await d.mutate(),S},[e,n,d]),v=c.useCallback(async E=>{if(!e)throw new Error("projectId is required");const j=await n(`/ai/projects/${e}/board/items/${E}/unarchive`,{method:"POST",body:new URLSearchParams}),S=await V(j);return await d.mutate(),S},[e,n,d]);return{tasks:u,loading:!d.data&&!d.error,error:d.error||null,hasMore:f,loadingMore:p,loadMore:async()=>{!f||p||await d.setSize(E=>E+1)},createTask:m,archiveTask:g,unarchiveTask:v,refetch:async()=>{await d.mutate()}}}function _p(e,r,a=!0,n={}){var M,A;const{client:s}=_e(),i=n.includeArchived?"with-archived":"active-only",h=n.includeArchived?"?include_archived=true":"",d=a&&e&&r?`wacht-ai-board-item:${e}:${r}:${i}`:null,u=a&&e&&r?`wacht-ai-board-item-workspace:${e}:${r}:${i}`:null,f=c.useCallback(async()=>{if(!e||!r)return null;const I=await s(`/ai/projects/${e}/board/items/${r}${h}`);return(await V(I)).data},[e,r,s,h]),p=$e(d,f,{revalidateOnFocus:!1,refreshInterval:5e3}),m=ta((I,P)=>{if(!a||!e||!r||I>0&&P&&!P.has_more)return null;const L=I===0||P==null?void 0:P.next_cursor;return["wacht-ai-board-item-assignments",e,r,i,L||""]},async([,I,P,,L])=>{const T=new URLSearchParams({limit:"40"});n.includeArchived&&T.set("include_archived","true"),L&&T.set("cursor",String(L));const $=await s(`/ai/projects/${I}/board/items/${P}/assignments?${T.toString()}`);return(await V($)).data},{revalidateOnFocus:!1,revalidateFirstPage:!0,persistSize:!0,refreshInterval:5e3}),g=c.useCallback(async()=>{if(!e||!r)return{exists:!1,files:[]};const I=await s(`/ai/projects/${e}/board/items/${r}/filesystem${h}`);return(await V(I)).data},[e,r,s,h]),v=$e(u,g,{revalidateOnFocus:!1,refreshInterval:5e3}),w=c.useCallback(async(I,P=[])=>{if(!e||!r)throw new Error("projectId and itemId are required");const L=await s(`/ai/projects/${e}/board/items/${r}/update`,{method:"POST",body:E0(I,P)}),T=await V(L);return await p.mutate(),await v.mutate(),T},[e,r,s,p,v]),x=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const I=await s(`/ai/projects/${e}/board/items/${r}/archive`,{method:"POST",body:new URLSearchParams}),P=await V(I);return await p.mutate(),P},[e,r,s,p]),b=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const I=await s(`/ai/projects/${e}/board/items/${r}/unarchive`,{method:"POST",body:new URLSearchParams}),P=await V(I);return await p.mutate(),P},[e,r,s,p]),E=c.useCallback(async()=>{if(!e||!r)throw new Error("projectId and itemId are required");const I=await s(`/ai/projects/${e}/board/items/${r}/cancel`,{method:"POST",body:new URLSearchParams}),P=await V(I);return await p.mutate(),await m.mutate(),P},[e,r,s,p,m]),j=c.useCallback(async I=>{if(!e||!r)throw new Error("projectId and itemId are required");const P=await s(`/ai/projects/${e}/board/items/${r}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),L=await V(P);return await p.mutate(),L},[e,r,s,p]),S=c.useCallback(async I=>{if(!e||!r)throw new Error("projectId and itemId are required");const P=await s(`/ai/projects/${e}/board/items/${r}/filesystem/file${k0(I,n.includeArchived)}`);return await V(P)},[e,r,s,n.includeArchived]),C=c.useCallback(async I=>{if(!e||!r)throw new Error("projectId and itemId are required");const P=await s(`/ai/projects/${e}/board/items/${r}/filesystem${C0(I,n.includeArchived)}`);return await V(P)},[e,r,s,n.includeArchived]),_=c.useMemo(()=>{var I;return((I=m.data)==null?void 0:I.flatMap(P=>P.data||[]))||[]},[m.data]),k=m.data&&((M=m.data[m.data.length-1])==null?void 0:M.has_more)||!1,y=m.isValidating&&!!m.data&&m.size>(((A=m.data)==null?void 0:A.length)||0);return{item:p.data||null,assignments:_,assignmentsHasMore:k,assignmentsLoadingMore:y,loadMoreAssignments:async()=>{!k||y||await m.setSize(I=>I+1)},taskWorkspace:v.data||{exists:!1,files:[]},taskWorkspaceLoading:!v.data&&!v.error,taskWorkspaceError:v.error||null,loading:!p.data&&!p.error||!m.data&&!m.error,error:p.error||m.error||null,updateItem:w,archiveItem:x,unarchiveItem:b,cancelItem:E,submitAnswer:j,getTaskWorkspaceFile:S,listTaskWorkspaceDirectory:C,refetch:async()=>{await p.mutate(),await m.mutate(),await v.mutate()},refetchAssignments:async()=>{await m.mutate()},refetchTaskWorkspace:async()=>{await v.mutate()}}}function kp(e,r=!0){var v;const{client:a}=_e(),{data:n,error:s,mutate:i,isLoading:h,size:d,setSize:u,isValidating:f}=ta((w,x)=>{if(!r||!e||w>0&&(!x||!x.has_more))return null;const b=w===0||x==null?void 0:x.next_cursor;return["wacht-ai-thread-graphs",e,b]},async([,w,x])=>{const b=new URLSearchParams;b.set("limit","10"),x&&b.set("cursor",String(x));const E=await a(`/ai/threads/${w}/task-graphs?${b.toString()}`),S=(await V(E)).data||{data:[],limit:10,has_more:!1};return{...S,data:(S.data||[]).map(C=>({...C,nodes:Array.isArray(C.nodes)?C.nodes:[],edges:Array.isArray(C.edges)?C.edges:[],summary:C.summary||null}))}},{revalidateOnFocus:!1,refreshInterval:5e3,revalidateFirstPage:!0,revalidateAll:!1,persistSize:!0}),p=c.useMemo(()=>n?n.flatMap(w=>w.data||[]):[],[n]),m=n&&((v=n[n.length-1])==null?void 0:v.has_more)||!1,g=f&&!!n&&d>((n==null?void 0:n.length)||0);return{graphs:p,latestGraph:p[0]||null,has_more:m,loadingMore:g,loading:h,error:s,loadMore:async()=>{!m||g||await u(d+1)},refetch:async()=>{await i()}}}function Cp(e=!0){const{client:r}=_e(),a=e?"wacht-ai-actor-mcp-servers":null,n=c.useCallback(async()=>{const p=await r("/ai/mcp-servers");return(await V(p)).data},[r]),{data:s,error:i,mutate:h,isLoading:d}=$e(a,n,{revalidateOnFocus:!1}),u=c.useCallback(async p=>{const m=await r(`/ai/mcp-servers/${p}/connect`,{method:"POST",body:new URLSearchParams});return V(m)},[r]),f=c.useCallback(async p=>{const m=await r(`/ai/mcp-servers/${p}/disconnect`,{method:"POST",body:new URLSearchParams}),g=await V(m);return await h(),g},[r,h]);return{servers:s??[],loading:d,error:i,connect:u,disconnect:f,refetch:async()=>{await h()}}}function Sp(e=!0){const{client:r}=_e(),a=e?"wacht-ai-external-agent-connections":null,n=c.useCallback(async()=>{const p=await r("/ai/external-connections");return(await V(p)).data},[r]),{data:s,error:i,mutate:h,isLoading:d}=$e(a,n,{revalidateOnFocus:!1}),u=c.useCallback(async(p,m,g)=>{const v=await r(`/ai/external-connections/${encodeURIComponent(p)}/${encodeURIComponent(m)}/connect`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({return_url:(g==null?void 0:g.returnUrl)??""})}),w=await V(v);return await h(),w.data},[r,h]),f=c.useCallback(async(p,m)=>{const g=await r(`/ai/external-connections/${encodeURIComponent(p)}/${encodeURIComponent(m)}`,{method:"DELETE"}),v=await V(g);return await h(),v.data},[r,h]);return{connections:s??[],loading:d,error:i,connect:u,disconnect:f,refetch:async()=>{await h()}}}function A0(e){const r=new URLSearchParams;return r.append("url",e.url),e.description&&r.append("description",e.description),e.subscribed_events&&e.subscribed_events.forEach(a=>r.append("subscribed_events",a)),e.subscriptions&&e.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(e.subscriptions)),e.headers&&Object.entries(e.headers).forEach(([a,n])=>{r.append(`headers[${a}]`,n)}),e.rate_limit_config&&(r.append("rate_limit[duration_ms]",e.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",e.rate_limit_config.max_requests.toString())),r}function Ep(e){const r=new URLSearchParams;return e.url&&r.append("url",e.url),e.description!==void 0&&r.append("description",e.description||""),e.subscribed_events&&e.subscribed_events.forEach(a=>r.append("subscribed_events",a)),e.subscriptions&&e.subscriptions.length>0&&r.append("subscriptions",JSON.stringify(e.subscriptions)),e.headers&&Object.entries(e.headers).forEach(([a,n])=>{r.append(`headers[${a}]`,n)}),e.is_active!==void 0&&r.append("is_active",e.is_active.toString()),e.rate_limit_config&&(r.append("rate_limit[duration_ms]",e.rate_limit_config.duration_ms.toString()),r.append("rate_limit[max_requests]",e.rate_limit_config.max_requests.toString())),r}function Ap(e){const r=new URLSearchParams;return r.append("event_name",e.event_name),r.append("payload",JSON.stringify(e.payload||{})),r}function zp(e){const r=new URLSearchParams;return(e.delivery_ids||[]).forEach(n=>r.append("delivery_ids",n)),e.start_date&&r.append("start_date",e.start_date),e.end_date&&r.append("end_date",e.end_date),e.status&&r.append("status",e.status),e.event_name&&r.append("event_name",e.event_name),e.endpoint_id&&r.append("endpoint_id",e.endpoint_id),e.idempotency_key&&r.append("idempotency_key",e.idempotency_key),r}const za={"Content-Type":"application/x-www-form-urlencoded"};async function St(e,r){const a=await V(e);if(!a||!("data"in a))throw new Error(r);return a}async function $p(e){const r=await e("/webhook/session",{method:"GET"});if(!r.ok)throw r.status===401||r.status===403?new Error("NO_SESSION"):new Error("Failed to fetch webhook app session");return(await St(r,"Failed to fetch webhook app session")).data}async function Mp(e,r){if(!(await e(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"})).ok)throw new Error("Failed to exchange ticket")}async function Lp(e,r){const a=A0(r),n=await e("/webhook/endpoints",{method:"POST",headers:za,body:a.toString()});return St(n,"Failed to create webhook endpoint")}async function Rp(e,r,a){const n=Ep(a),s=await e(`/webhook/endpoints/${r}`,{method:"PUT",headers:za,body:n.toString()});return St(s,"Failed to update webhook endpoint")}async function Pp(e,r){const a=await e(`/webhook/endpoints/${r}`,{method:"DELETE"});return St(a,"Failed to delete webhook endpoint")}async function Tp(e,r,a){const n=Ap(a),s=await e(`/webhook/endpoints/${r}/test`,{method:"POST",headers:za,body:n.toString()});return St(s,"Failed to test webhook endpoint")}async function Fp(e){const r=await e("/webhook/rotate-secret",{method:"POST"});return St(r,"Failed to rotate signing secret")}async function Ip(e,r){const a=new URLSearchParams;for(const s of r.failure_notification_emails)a.append("failure_notification_emails",s);const n=await e("/webhook/settings",{method:"PUT",headers:za,body:a.toString()});return St(n,"Failed to update webhook settings")}async function Zp(e,r){const a=zp(r),n=await e("/webhook/deliveries/replay",{method:"POST",headers:za,body:a.toString()});return St(n,"Failed to replay webhook delivery")}async function Op(e,r){const a=await e(`/webhook/deliveries/${r}`,{method:"GET"});return St(a,"Failed to fetch delivery details")}async function Hp(e,{taskId:r}){const a=await e(`/webhook/deliveries/replay/${r}`,{method:"GET"});return St(a,"Failed to fetch replay task status")}async function Vp(e,r){const a=(r==null?void 0:r.limit)??50,n=(r==null?void 0:r.offset)??0,s=await e(`/webhook/deliveries/replay?limit=${a}&offset=${n}`,{method:"GET"});return St(s,"Failed to fetch replay tasks")}async function Dp(e,{taskId:r}){const a=await e(`/webhook/deliveries/replay/${r}/cancel`,{method:"POST"});return St(a,"Failed to cancel replay task")}function Np(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>$p(r),[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-webhook-app-session":null,g,{revalidateOnFocus:!1,shouldRetryOnError:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{await Mp(r,e),u.current=!0,n(!0)}catch(H){d(H instanceof Error?H:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=c.useCallback(async z=>Lp(r,z),[r]),j=c.useCallback(async(z,H)=>Rp(r,z,H),[r]),S=c.useCallback(async z=>Pp(r,z),[r]),C=c.useCallback(async(z,H)=>Tp(r,z,H),[r]),_=c.useCallback(async()=>Fp(r),[r]),k=c.useCallback(async z=>Zp(r,z),[r]),y=c.useCallback(async z=>Ip(r,z),[r]),M=c.useCallback(async z=>Op(r,z),[r]),A=c.useCallback(async z=>Hp(r,z),[r]),I=c.useCallback(async z=>Vp(r,z),[r]),P=c.useCallback(async z=>Dp(r,z),[r]),L=!w||w.message!=="NO_SESSION",T=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:L,sessionLoading:s||m&&x,sessionError:T,sessionId:(v==null?void 0:v.session_id)||null,webhookApp:(v==null?void 0:v.webhook_app)||null,ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()},createEndpoint:E,updateEndpoint:j,deleteEndpoint:S,testEndpoint:C,rotateSecret:_,updateSettings:y,replayDelivery:k,fetchReplayTaskStatus:A,fetchReplayTasks:I,cancelReplayTask:P,fetchDeliveryDetail:M}}function Up(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/stats",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-stats",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{stats:a||null,loading:s,error:n,refetch:()=>i()}}function Bp(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/endpoints",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-endpoints",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{endpoints:a||[],loading:s,error:n,refetch:()=>i()}}function Wp(){const{client:e}=_e();return{createEndpoint:c.useCallback(async a=>{const n=A0(a),s=await e("/webhook/endpoints",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()});return await V(s)},[e]),loading:!1,error:null}}function Gp(){const{client:e}=_e(),r=c.useCallback(async()=>{const h=await e("/webhook/events",{method:"GET"});return(await V(h)).data},[e]),{data:a,error:n,isLoading:s,mutate:i}=$e("wacht-webhook-events",r,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{events:a||[],loading:s,error:n,refetch:()=>i()}}function qp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.status&&d.set("status",e.status),e.event_name&&d.set("event_name",e.event_name),e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor);const u=await r(`/webhook/deliveries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.endpoint_id,e.status,e.event_name,e.limit,e.cursor]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.status&&d.set("status",e.status),e.event_name&&d.set("event_name",e.event_name),e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),`wacht-webhook-deliveries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{deliveries:(n==null?void 0:n.data)||[],has_more:(n==null?void 0:n.has_more)||!1,next_cursor:n==null?void 0:n.next_cursor,loading:i,error:s,refetch:()=>h()}}function Kp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.fields&&e.fields.length>0&&d.set("fields",e.fields.join(","));const u=await r(`/webhook/analytics?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.endpoint_id,e.fields]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),e.fields&&e.fields.length>0&&d.set("fields",e.fields.join(",")),`wacht-webhook-analytics?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:n||null,loading:i,error:s,refetch:()=>h()}}function Yp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id);const u=await r(`/webhook/analytics/timeseries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.interval,e.endpoint_id]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.endpoint_id&&d.set("endpoint_id",e.endpoint_id),`wacht-webhook-timeseries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(n==null?void 0:n.data)||[],interval:(n==null?void 0:n.interval)||"hour",loading:i,error:s,refetch:()=>h()}}function Qp(e){const{client:r}=_e(),[a,n]=c.useState(!e),[s,i]=c.useState(!!e),[h,d]=c.useState(null),u=c.useRef(!1),f=c.useRef(!1),p=c.useRef(null),m=a,g=c.useCallback(async()=>{const C=await r("/api-auth/session",{method:"GET"});if(!C.ok)throw C.status===401||C.status===403?new Error("NO_SESSION"):new Error("Failed to fetch API auth app session");return(await V(C)).data},[r]),{data:v,error:w,isLoading:x,mutate:b}=$e(m?"wacht-api-auth-app-session":null,g,{revalidateOnFocus:!1,shouldRetryOnError:!1});c.useEffect(()=>{if(!e||u.current||f.current||p.current===e)return;p.current=e,(async()=>{f.current=!0,i(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(e)}`,{method:"GET"})).ok?(u.current=!0,n(!0)):d(new Error("Failed to exchange ticket"))}catch(_){d(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{i(!1),f.current=!1}})()},[e,r]);const E=!w||w.message!=="NO_SESSION",j=h||(w&&w.message!=="NO_SESSION"?w:null);return{hasSession:E,sessionLoading:s||m&&x,sessionError:j,sessionId:(v==null?void 0:v.session_id)||null,apiAuthApp:(v==null?void 0:v.api_auth_app)||null,ticketExchanged:a,ticketLoading:s,refetch:async()=>{await b()}}}function Jp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const p=new URLSearchParams;e.status&&p.set("status",e.status);const m=await r(`/api-auth/keys${p.toString()?`?${p.toString()}`:""}`,{method:"GET"});return(await V(m)).data},[r,e.status]),{data:n,error:s,isLoading:i,mutate:h}=$e(`wacht-api-auth-keys:${e.status||"all"}`,a,{revalidateOnFocus:!1,shouldRetryOnError:!1}),d=c.useCallback(async p=>{const m=new URLSearchParams;m.set("name",p.name),p.expires_at&&m.set("expires_at",p.expires_at);const g=await r("/api-auth/keys",{method:"POST",body:m}),v=await V(g);return await h(),v},[r,h]),u=c.useCallback(async p=>{const m=await r(`/api-auth/keys/${p.key_id}/rotate`,{method:"POST"}),g=await V(m);return await h(),g},[r,h]),f=c.useCallback(async p=>{const m=new URLSearchParams;p.reason&&m.set("reason",p.reason);const g=await r(`/api-auth/keys/${p.key_id}/revoke`,{method:"POST",body:m}),v=await V(g);return await h(),v},[r,h]);return{keys:n||[],createKey:d,rotateKey:u,revokeKey:f,loading:i,error:s,refetch:()=>h()}}function Xp(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),e.outcome&&d.set("outcome",e.outcome),e.key_id&&d.set("key_id",e.key_id),e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date);const u=await r(`/api-auth/audit/logs?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.limit,e.cursor,e.outcome,e.key_id,e.start_date,e.end_date]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.limit&&d.set("limit",e.limit.toString()),e.cursor&&d.set("cursor",e.cursor),e.outcome&&d.set("outcome",e.outcome),e.key_id&&d.set("key_id",e.key_id),e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),`wacht-api-auth-audit-logs?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{logs:(n==null?void 0:n.data)||[],limit:(n==null?void 0:n.limit)||e.limit||0,has_more:(n==null?void 0:n.has_more)||!1,next_cursor:n==null?void 0:n.next_cursor,loading:i,error:s,refetch:()=>h()}}function eh(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.key_id&&d.set("key_id",e.key_id),e.include_top_keys&&d.set("include_top_keys","true"),e.include_top_paths&&d.set("include_top_paths","true"),e.include_blocked_reasons&&d.set("include_blocked_reasons","true"),e.include_rate_limits&&d.set("include_rate_limits","true"),e.top_limit&&d.set("top_limit",e.top_limit.toString());const u=await r(`/api-auth/audit/analytics?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.key_id,e.include_top_keys,e.include_top_paths,e.include_blocked_reasons,e.include_rate_limits,e.top_limit]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.key_id&&d.set("key_id",e.key_id),e.include_top_keys&&d.set("include_top_keys","true"),e.include_top_paths&&d.set("include_top_paths","true"),e.include_blocked_reasons&&d.set("include_blocked_reasons","true"),e.include_rate_limits&&d.set("include_rate_limits","true"),e.top_limit&&d.set("top_limit",e.top_limit.toString()),`wacht-api-auth-audit-analytics?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{analytics:n||null,loading:i,error:s,refetch:()=>h()}}function th(e={}){const{client:r}=_e(),a=c.useCallback(async()=>{const d=new URLSearchParams;e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.key_id&&d.set("key_id",e.key_id);const u=await r(`/api-auth/audit/timeseries?${d.toString()}`,{method:"GET"});return(await V(u)).data},[r,e.start_date,e.end_date,e.interval,e.key_id]),{data:n,error:s,isLoading:i,mutate:h}=$e(()=>{const d=new URLSearchParams;return e.start_date&&d.set("start_date",e.start_date),e.end_date&&d.set("end_date",e.end_date),e.interval&&d.set("interval",e.interval),e.key_id&&d.set("key_id",e.key_id),`wacht-api-auth-audit-timeseries?${d.toString()}`},a,{revalidateOnFocus:!1,shouldRetryOnError:!1});return{timeseries:(n==null?void 0:n.data)||[],interval:(n==null?void 0:n.interval)||e.interval||"hour",loading:i,error:s,refetch:()=>h()}}const z0=()=>{const{client:e}=_e(),[r,a]=c.useState(!1),[n,s]=c.useState(null),[i,h]=c.useState(null),d=c.useCallback(async f=>{a(!0),s(null),h(null);try{const p=new FormData;p.append("token",f);const m=await e("/organizations/invitations/accept",{method:"POST",body:p}),v=(await V(m)).data;return h(v),v.error_code&&s(v.message||"Failed to accept invitation"),v}catch(p){const m=p.message||"Failed to accept invitation";s(m);const g={error_code:"NETWORK_ERROR",message:m};return h(g),g}finally{a(!1)}},[e]),u=c.useCallback(()=>{s(null),h(null)},[]);return{acceptInvitation:d,invitationData:i,loading:r,error:n,reset:u}},rh=({children:e})=>{const{loading:r}=Ae();return r?null:t.jsx(t.Fragment,{children:e})},ah=({children:e})=>{const{loading:r}=Ae();return r?t.jsx(t.Fragment,{children:e}):null};function nh(e){var r=Object.create(null);return function(a){return r[a]===void 0&&(r[a]=e(a)),r[a]}}var oh=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,sh=nh(function(e){return oh.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),Xe="-ms-",ya="-moz-",Ne="-webkit-",$0="comm",$n="rule",ws="decl",ih="@import",ch="@namespace",M0="@keyframes",lh="@layer",L0=Math.abs,ys=String.fromCharCode,Jo=Object.assign;function dh(e,r){return ut(e,0)^45?(((r<<2^ut(e,0))<<2^ut(e,1))<<2^ut(e,2))<<2^ut(e,3):0}function R0(e){return e.trim()}function Ut(e,r){return(e=r.exec(e))?e[0]:e}function Le(e,r,a){return e.replace(r,a)}function hn(e,r,a){return e.indexOf(r,a)}function ut(e,r){return e.charCodeAt(r)|0}function Lr(e,r,a){return e.slice(r,a)}function zt(e){return e.length}function P0(e){return e.length}function va(e,r){return r.push(e),e}function uh(e,r){return e.map(r).join("")}function ui(e,r){return e.filter(function(a){return!Ut(a,r)})}var Mn=1,Qr=1,T0=0,Ct=0,it=0,ra="";function Ln(e,r,a,n,s,i,h,d){return{value:e,root:r,parent:a,type:n,props:s,children:i,line:Mn,column:Qr,length:h,return:"",siblings:d}}function Xt(e,r){return Jo(Ln("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function Or(e){for(;e.root;)e=Xt(e.root,{children:[e]});va(e,e.siblings)}function ph(){return it}function hh(){return it=Ct>0?ut(ra,--Ct):0,Qr--,it===10&&(Qr=1,Mn--),it}function Lt(){return it=Ct<T0?ut(ra,Ct++):0,Qr++,it===10&&(Qr=1,Mn++),it}function tr(){return ut(ra,Ct)}function fn(){return Ct}function Rn(e,r){return Lr(ra,e,r)}function Ca(e){switch(e){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 fh(e){return Mn=Qr=1,T0=zt(ra=e),Ct=0,[]}function mh(e){return ra="",e}function Xn(e){return R0(Rn(Ct-1,Xo(e===91?e+2:e===40?e+1:e)))}function gh(e){for(;(it=tr())&&it<33;)Lt();return Ca(e)>2||Ca(it)>3?"":" "}function vh(e,r){for(;--r&&Lt()&&!(it<48||it>102||it>57&&it<65||it>70&&it<97););return Rn(e,fn()+(r<6&&tr()==32&&Lt()==32))}function Xo(e){for(;Lt();)switch(it){case e:return Ct;case 34:case 39:e!==34&&e!==39&&Xo(it);break;case 40:e===41&&Xo(e);break;case 92:Lt();break}return Ct}function xh(e,r){for(;Lt()&&e+it!==57;)if(e+it===84&&tr()===47)break;return"/*"+Rn(r,Ct-1)+"*"+ys(e===47?e:Lt())}function bh(e){for(;!Ca(tr());)Lt();return Rn(e,Ct)}function wh(e){return mh(mn("",null,null,null,[""],e=fh(e),0,[0],e))}function mn(e,r,a,n,s,i,h,d,u){for(var f=0,p=0,m=h,g=0,v=0,w=0,x=1,b=1,E=1,j=0,S="",C=s,_=i,k=n,y=S;b;)switch(w=j,j=Lt()){case 40:if(w!=108&&ut(y,m-1)==58){hn(y+=Le(Xn(j),"&","&\f"),"&\f",L0(f?d[f-1]:0))!=-1&&(E=-1);break}case 34:case 39:case 91:y+=Xn(j);break;case 9:case 10:case 13:case 32:y+=gh(w);break;case 92:y+=vh(fn()-1,7);continue;case 47:switch(tr()){case 42:case 47:va(yh(xh(Lt(),fn()),r,a,u),u),(Ca(w||1)==5||Ca(tr()||1)==5)&&zt(y)&&Lr(y,-1,void 0)!==" "&&(y+=" ");break;default:y+="/"}break;case 123*x:d[f++]=zt(y)*E;case 125*x:case 59:case 0:switch(j){case 0:case 125:b=0;case 59+p:E==-1&&(y=Le(y,/\f/g,"")),v>0&&(zt(y)-m||x===0&&w===47)&&va(v>32?hi(y+";",n,a,m-1,u):hi(Le(y," ","")+";",n,a,m-2,u),u);break;case 59:y+=";";default:if(va(k=pi(y,r,a,f,p,s,d,S,C=[],_=[],m,i),i),j===123)if(p===0)mn(y,r,k,k,C,i,m,d,_);else{switch(g){case 99:if(ut(y,3)===110)break;case 108:if(ut(y,2)===97)break;default:p=0;case 100:case 109:case 115:}p?mn(e,k,k,n&&va(pi(e,k,k,0,0,s,d,S,s,C=[],m,_),_),s,_,m,d,n?C:_):mn(y,k,k,k,[""],_,0,d,_)}}f=p=v=0,x=E=1,S=y="",m=h;break;case 58:m=1+zt(y),v=w;default:if(x<1){if(j==123)--x;else if(j==125&&x++==0&&hh()==125)continue}switch(y+=ys(j),j*x){case 38:E=p>0?1:(y+="\f",-1);break;case 44:d[f++]=(zt(y)-1)*E,E=1;break;case 64:tr()===45&&(y+=Xn(Lt())),g=tr(),p=m=zt(S=y+=bh(fn())),j++;break;case 45:w===45&&zt(y)==2&&(x=0)}}return i}function pi(e,r,a,n,s,i,h,d,u,f,p,m){for(var g=s-1,v=s===0?i:[""],w=P0(v),x=0,b=0,E=0;x<n;++x)for(var j=0,S=Lr(e,g+1,g=L0(b=h[x])),C=e;j<w;++j)(C=R0(b>0?v[j]+" "+S:Le(S,/&\f/g,v[j])))&&(u[E++]=C);return Ln(e,r,a,s===0?$n:d,u,f,p,m)}function yh(e,r,a,n){return Ln(e,r,a,$0,ys(ph()),Lr(e,2,-2),0,n)}function hi(e,r,a,n,s){return Ln(e,r,a,ws,Lr(e,0,n),Lr(e,n+1,-1),n,s)}function F0(e,r,a){switch(dh(e,r)){case 5103:return Ne+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Ne+e+e;case 4855:return Ne+e.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+e;case 4789:return ya+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ne+e+ya+e+Xe+e+e;case 5936:switch(ut(e,r+11)){case 114:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ne+e+Xe+Le(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ne+e+Xe+e+e;case 6165:return Ne+e+Xe+"flex-"+e+e;case 5187:return Ne+e+Le(e,/(\w+).+(:[^]+)/,Ne+"box-$1$2"+Xe+"flex-$1$2")+e;case 5443:return Ne+e+Xe+"flex-item-"+Le(e,/flex-|-self/g,"")+(Ut(e,/flex-|baseline/)?"":Xe+"grid-row-"+Le(e,/flex-|-self/g,""))+e;case 4675:return Ne+e+Xe+"flex-line-pack"+Le(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ne+e+Xe+Le(e,"shrink","negative")+e;case 5292:return Ne+e+Xe+Le(e,"basis","preferred-size")+e;case 6060:return Ne+"box-"+Le(e,"-grow","")+Ne+e+Xe+Le(e,"grow","positive")+e;case 4554:return Ne+Le(e,/([^-])(transform)/g,"$1"+Ne+"$2")+e;case 6187:return Le(Le(Le(e,/(zoom-|grab)/,Ne+"$1"),/(image-set)/,Ne+"$1"),e,"")+e;case 5495:case 3959:return Le(e,/(image-set\([^]*)/,Ne+"$1$`$1");case 4968:return Le(Le(e,/(.+:)(flex-)?(.*)/,Ne+"box-pack:$3"+Xe+"flex-pack:$3"),/space-between/,"justify")+Ne+e+e;case 4200:if(!Ut(e,/flex-|baseline/))return Xe+"grid-column-align"+Lr(e,r)+e;break;case 2592:case 3360:return Xe+Le(e,"template-","")+e;case 4384:case 3616:return a&&a.some(function(n,s){return r=s,Ut(n.props,/grid-\w+-end/)})?~hn(e+(a=a[r].value),"span",0)?e:Xe+Le(e,"-start","")+e+Xe+"grid-row-span:"+(~hn(a,"span",0)?Ut(a,/\d+/):+Ut(a,/\d+/)-+Ut(e,/\d+/))+";":Xe+Le(e,"-start","")+e;case 4896:case 4128:return a&&a.some(function(n){return Ut(n.props,/grid-\w+-start/)})?e:Xe+Le(Le(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Le(e,/(.+)-inline(.+)/,Ne+"$1$2")+e;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(zt(e)-1-r>6)switch(ut(e,r+1)){case 109:if(ut(e,r+4)!==45)break;case 102:return Le(e,/(.+:)(.+)-([^]+)/,"$1"+Ne+"$2-$3$1"+ya+(ut(e,r+3)==108?"$3":"$2-$3"))+e;case 115:return~hn(e,"stretch",0)?F0(Le(e,"stretch","fill-available"),r,a)+e:e}break;case 5152:case 5920:return Le(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,i,h,d,u,f){return Xe+s+":"+i+f+(h?Xe+s+"-span:"+(d?u:+u-+i)+f:"")+e});case 4949:if(ut(e,r+6)===121)return Le(e,":",":"+Ne)+e;break;case 6444:switch(ut(e,ut(e,14)===45?18:11)){case 120:return Le(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ne+(ut(e,14)===45?"inline-":"")+"box$3$1"+Ne+"$2$3$1"+Xe+"$2box$3")+e;case 100:return Le(e,":",":"+Xe)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Le(e,"scroll-","scroll-snap-")+e}return e}function yn(e,r){for(var a="",n=0;n<e.length;n++)a+=r(e[n],n,e,r)||"";return a}function jh(e,r,a,n){switch(e.type){case lh:if(e.children.length)break;case ih:case ch:case ws:return e.return=e.return||e.value;case $0:return"";case M0:return e.return=e.value+"{"+yn(e.children,n)+"}";case $n:if(!zt(e.value=e.props.join(",")))return""}return zt(a=yn(e.children,n))?e.return=e.value+"{"+a+"}":""}function _h(e){var r=P0(e);return function(a,n,s,i){for(var h="",d=0;d<r;d++)h+=e[d](a,n,s,i)||"";return h}}function kh(e){return function(r){r.root||(r=r.return)&&e(r)}}function Ch(e,r,a,n){if(e.length>-1&&!e.return)switch(e.type){case ws:e.return=F0(e.value,e.length,a);return;case M0:return yn([Xt(e,{value:Le(e.value,"@","@"+Ne)})],n);case $n:if(e.length)return uh(a=e.props,function(s){switch(Ut(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Or(Xt(e,{props:[Le(s,/:(read-\w+)/,":"+ya+"$1")]})),Or(Xt(e,{props:[s]})),Jo(e,{props:ui(a,n)});break;case"::placeholder":Or(Xt(e,{props:[Le(s,/:(plac\w+)/,":"+Ne+"input-$1")]})),Or(Xt(e,{props:[Le(s,/:(plac\w+)/,":"+ya+"$1")]})),Or(Xt(e,{props:[Le(s,/:(plac\w+)/,Xe+"input-$1")]})),Or(Xt(e,{props:[s]})),Jo(e,{props:ui(a,n)});break}return""})}}var eo,to;const Rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",I0="active",Z0="data-styled-version",Pn="6.4.1",js=`/*!sc*/
19
19
  `,ja=typeof window<"u"&&typeof document<"u";function fi(e){if(typeof process<"u"&&process.env!==void 0){const r=process.env[e];if(r!==void 0&&r!=="")return r!=="false"}}const Sh=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:(to=(eo=fi("REACT_APP_SC_DISABLE_SPEEDY"))!==null&&eo!==void 0?eo:fi("SC_DISABLE_SPEEDY"))!==null&&to!==void 0?to:typeof process>"u"||process.env===void 0||process.env.NODE_ENV!=="production"),O0="sc-keyframes-",Eh=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
20
20
 
21
21
  `,2:`Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
@@ -83,7 +83,7 @@ If you need access to the theme in an uncertain composition scenario, \`React.us
83
83
  You may see this warning because you've called styled inside another component.
84
84
  To resolve this only create new StyledComponents outside of any render method and function component.
85
85
  See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
86
- `,n=console.error;try{let s=!0;console.error=(i,...h)=>{mi.test(i)?(s=!1,Ha.delete(a)):n(i,...h)},typeof c.useState=="function"&&c.useState(null),s&&!Ha.has(a)&&(console.warn(a),Ha.add(a))}catch(s){mi.test(s.message)&&Ha.delete(a)}finally{console.error=n}}},_s=Object.freeze([]),Jr=Object.freeze({});function Lh(e,r,a=Jr){return e.theme!==a.theme&&e.theme||r||a.theme}const Rh=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Ph=/(^-|-$)/g;function H0(e){return e.replace(Rh,"-").replace(Ph,"")}const Th=/(a)(d)/gi,gi=e=>String.fromCharCode(e+(e>25?39:97));function ks(e){let r,a="";for(r=Math.abs(e);r>52;r=r/52|0)a=gi(r%52)+a;return(gi(r%52)+a).replace(Th,"$1-$2")}const es=5381,Sr=(e,r)=>{let a=r.length;for(;a;)e=33*e^r.charCodeAt(--a);return e},V0=e=>Sr(es,e);function D0(e){return ks(V0(e)>>>0)}function Cs(e){return process.env.NODE_ENV!=="production"&&typeof e=="string"&&e||e.displayName||e.name||"Component"}function xn(e){return typeof e=="string"&&(process.env.NODE_ENV==="production"||e.charAt(0)===e.charAt(0).toLowerCase())}function Fh(e){return xn(e)?`styled.${e}`:`Styled(${Cs(e)})`}const N0=Symbol.for("react.memo"),Ih=Symbol.for("react.forward_ref"),Zh={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},Oh={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},U0={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Hh={[Ih]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[N0]:U0};function vi(e){return("type"in(r=e)&&r.type.$$typeof)===N0?U0:"$$typeof"in e?Hh[e.$$typeof]:Zh;var r}const Vh=Object.defineProperty,Dh=Object.getOwnPropertyNames,Nh=Object.getOwnPropertySymbols,Uh=Object.getOwnPropertyDescriptor,Bh=Object.getPrototypeOf,Wh=Object.prototype;function B0(e,r,a){if(typeof r!="string"){const n=Bh(r);n&&n!==Wh&&B0(e,n,a);const s=Dh(r).concat(Nh(r)),i=vi(e),h=vi(r);for(let d=0;d<s.length;++d){const u=s[d];if(!(u in Oh||a&&a[u]||h&&u in h||i&&u in i)){const f=Uh(r,u);try{Vh(e,u,f)}catch{}}}}return e}function Tn(e){return typeof e=="function"}function W0(e){return typeof e=="object"&&"styledComponentId"in e}function ba(e,r){return e&&r?e+" "+r:e||r||""}function ts(e,r){return e.join("")}function Pr(e){return e!==null&&typeof e=="object"&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function rs(e,r,a=!1){if(!a&&!Pr(e)&&!Array.isArray(e))return r;if(Array.isArray(r))for(let n=0;n<r.length;n++)e[n]=rs(e[n],r[n]);else if(Pr(r))for(const n in r)e[n]=rs(e[n],r[n]);return e}function Ss(e,r){Object.defineProperty(e,"toString",{value:r})}const Gh=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let r=this._cIndex;if(e>this._cGroup)for(let a=this._cGroup;a<e;a++)r+=this.groupSizes[a];else for(let a=this._cGroup-1;a>=e;a--)r-=this.groupSizes[a];return this._cGroup=e,this._cIndex=r,r}insertRules(e,r){if(e>=this.groupSizes.length){const s=this.groupSizes,i=s.length;let h=i;for(;e>=h;)if(h<<=1,h<0)throw aa(16,`${e}`);this.groupSizes=new Uint32Array(h),this.groupSizes.set(s),this.length=h;for(let d=i;d<h;d++)this.groupSizes[d]=0}let a=this.indexOfGroup(e+1),n=0;for(let s=0,i=r.length;s<i;s++)this.tag.insertRule(a,r[s])&&(this.groupSizes[e]++,a++,n++);n>0&&this._cGroup>e&&(this._cIndex+=n)}clearGroup(e){if(e<this.length){const r=this.groupSizes[e],a=this.indexOfGroup(e),n=a+r;this.groupSizes[e]=0;for(let s=a;s<n;s++)this.tag.deleteRule(a);r>0&&this._cGroup>e&&(this._cIndex-=r)}}getGroup(e){let r="";if(e>=this.length||this.groupSizes[e]===0)return r;const a=this.groupSizes[e],n=this.indexOfGroup(e),s=n+a;for(let i=n;i<s;i++)r+=this.tag.getRule(i)+js;return r}},qh=`style[${Rr}][${Z0}="${Pn}"]`,Kh=new RegExp(`^${Rr}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),xi=e=>typeof ShadowRoot<"u"&&e instanceof ShadowRoot||"host"in e&&e.nodeType===11,as=e=>{if(!e)return document;if(xi(e))return e;if("getRootNode"in e){const r=e.getRootNode();if(xi(r))return r}return document},Yh=(e,r,a)=>{const n=a.split(",");let s;for(let i=0,h=n.length;i<h;i++)(s=n[i])&&e.registerName(r,s)},Qh=(e,r)=>{var a;const n=((a=r.textContent)!==null&&a!==void 0?a:"").split(js),s=[];for(let i=0,h=n.length;i<h;i++){const d=n[i].trim();if(!d)continue;const u=d.match(Kh);if(u){const f=0|parseInt(u[1],10),p=u[2];f!==0&&($h(p,f),Yh(e,p,u[3]),e.getTag().insertRules(f,s)),s.length=0}else s.push(d)}},ro=e=>{const r=as(e.options.target).querySelectorAll(qh);for(let a=0,n=r.length;a<n;a++){const s=r[a];s&&s.getAttribute(Rr)!==I0&&(Qh(e,s),s.parentNode&&s.parentNode.removeChild(s))}};let ca=!1;function Jh(){if(ca!==!1)return ca;if(typeof document<"u"){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return ca=e.nonce||e.getAttribute("content")||void 0;const r=document.head.querySelector('meta[name="sc-nonce"]');if(r)return ca=r.getAttribute("content")||void 0}return ca=typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0}const G0=(e,r)=>{const a=document.head,n=e||a,s=document.createElement("style"),i=(u=>{const f=Array.from(u.querySelectorAll(`style[${Rr}]`));return f[f.length-1]})(n),h=i!==void 0?i.nextSibling:null;s.setAttribute(Rr,I0),s.setAttribute(Z0,Pn);const d=r||Jh();return d&&s.setAttribute("nonce",d),n.insertBefore(s,h),s},Xh=class{constructor(e,r){this.element=G0(e,r),this.element.appendChild(document.createTextNode("")),this.sheet=(a=>{var n;if(a.sheet)return a.sheet;const s=(n=a.getRootNode().styleSheets)!==null&&n!==void 0?n:document.styleSheets;for(let i=0,h=s.length;i<h;i++){const d=s[i];if(d.ownerNode===a)return d}throw aa(17)})(this.element),this.length=0}insertRule(e,r){try{return this.sheet.insertRule(r,e),this.length++,!0}catch{return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const r=this.sheet.cssRules[e];return r&&r.cssText?r.cssText:""}},e8=class{constructor(e,r){this.element=G0(e,r),this.nodes=this.element.childNodes,this.length=0}insertRule(e,r){if(e<=this.length&&e>=0){const a=document.createTextNode(r);return this.element.insertBefore(a,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let bi=ja;const t8={isServer:!ja,useCSSOMInjection:!Sh};class Fn{static registerId(r){return xa(r)}constructor(r=Jr,a={},n){this.options=Object.assign(Object.assign({},t8),r),this.gs=a,this.keyframeIds=new Set,this.names=new Map(n),this.server=!!r.isServer,!this.server&&ja&&bi&&(bi=!1,ro(this)),Ss(this,()=>(s=>{const i=s.getTag(),{length:h}=i;let d="";for(let u=0;u<h;u++){const f=zh(u);if(f===void 0)continue;const p=s.names.get(f);if(p===void 0||!p.size)continue;const m=i.getGroup(u);if(m.length===0)continue;const g=Rr+".g"+u+'[id="'+f+'"]';let v="";for(const w of p)w.length>0&&(v+=w+",");d+=m+g+'{content:"'+v+'"}'+js}return d})(this))}rehydrate(){!this.server&&ja&&ro(this)}reconstructWithOptions(r,a=!0){const n=new Fn(Object.assign(Object.assign({},this.options),r),this.gs,a&&this.names||void 0);return n.keyframeIds=new Set(this.keyframeIds),!this.server&&ja&&r.target!==this.options.target&&as(this.options.target)!==as(r.target)&&ro(n),n}allocateGSInstance(r){return this.gs[r]=(this.gs[r]||0)+1}getTag(){return this.tag||(this.tag=(r=(({useCSSOMInjection:a,target:n,nonce:s})=>a?new Xh(n,s):new e8(n,s))(this.options),new Gh(r)));var r}hasNameForId(r,a){var n,s;return(s=(n=this.names.get(r))===null||n===void 0?void 0:n.has(a))!==null&&s!==void 0&&s}registerName(r,a){xa(r),r.startsWith(O0)&&this.keyframeIds.add(r);const n=this.names.get(r);n?n.add(a):this.names.set(r,new Set([a]))}insertRules(r,a,n){this.registerName(r,a),this.getTag().insertRules(xa(r),n)}clearNames(r){this.names.has(r)&&this.names.get(r).clear()}clearRules(r){this.getTag().clearGroup(xa(r)),this.clearNames(r)}clearTag(){this.tag=void 0}}const q0=new WeakSet,r8={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function a8(e,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||e in r8||e.startsWith("--")?String(r).trim():r+"px"}const kr=47;function wi(e){if(e.charCodeAt(0)===45&&e.charCodeAt(1)===45)return e;let r="";for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);r+=n>=65&&n<=90?"-"+String.fromCharCode(n+32):e[a]}return r.startsWith("ms-")?"-"+r:r}const K0=Symbol.for("sc-keyframes");function ns(e){return typeof e=="object"&&e!==null&&K0 in e}function Y0(e){return Tn(e)&&!(e.prototype&&e.prototype.isReactComponent)}const Q0=e=>e==null||e===!1||e==="",n8=Symbol.for("react.client.reference");function yi(e){return e.$$typeof===n8}function ji(e){const r=e.$$id,a=(r&&r.includes("#")?r.split("#").pop():r)||e.name||"unknown";console.warn(`Interpolating a client component (${a}) as a selector is not supported in server components. The component selector pattern requires access to the component's internal class name, which is not available across the server/client boundary. Use a plain CSS class selector instead.`)}function J0(e,r){for(const a in e){const n=e[a];e.hasOwnProperty(a)&&!Q0(n)&&(Array.isArray(n)&&q0.has(n)||Tn(n)?r.push(wi(a)+":",n,";"):Pr(n)?(r.push(a+" {"),J0(n,r),r.push("}")):r.push(wi(a)+": "+a8(a,n)+";"))}}function Er(e,r,a,n,s=[]){if(Q0(e))return s;const i=typeof e;if(i==="string")return s.push(e),s;if(i==="function"){if(yi(e))return process.env.NODE_ENV!=="production"&&ji(e),s;if(Y0(e)&&r){const h=e(r);return process.env.NODE_ENV==="production"||typeof h!="object"||Array.isArray(h)||ns(h)||Pr(h)||h===null||console.error(`${Cs(e)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),Er(h,r,a,n,s)}return s.push(e),s}if(Array.isArray(e)){for(let h=0;h<e.length;h++)Er(e[h],r,a,n,s);return s}return W0(e)?(s.push(`.${e.styledComponentId}`),s):ns(e)?(a?(e.inject(a,n),s.push(e.getName(n))):s.push(e),s):yi(e)?(process.env.NODE_ENV!=="production"&&ji(e),s):Pr(e)?(J0(e,s),s):(s.push(e.toString()),s)}const o8=V0(Pn);class s8{constructor(r,a,n){this.rules=r,this.componentId=a,this.baseHash=Sr(o8,a),this.baseStyle=n,Fn.registerId(a)}generateAndInjectStyles(r,a,n){let s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,a,n):"";{let i="";for(let h=0;h<this.rules.length;h++){const d=this.rules[h];if(typeof d=="string")i+=d;else if(d)if(Y0(d)){const u=d(r);typeof u=="string"?i+=u:u!=null&&u!==!1&&(process.env.NODE_ENV==="production"||typeof u!="object"||Array.isArray(u)||ns(u)||Pr(u)||console.error(`${Cs(d)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),i+=ts(Er(u,r,a,n)))}else i+=ts(Er(d,r,a,n))}if(i){this.dynamicNameCache||(this.dynamicNameCache=new Map);const h=n.hash?n.hash+i:i;let d=this.dynamicNameCache.get(h);if(!d){if(d=ks(Sr(Sr(this.baseHash,n.hash),i)>>>0),this.dynamicNameCache.size>=200){const u=this.dynamicNameCache.keys().next().value;u!==void 0&&this.dynamicNameCache.delete(u)}this.dynamicNameCache.set(h,d)}if(!a.hasNameForId(this.componentId,d)){const u=n(i,"."+d,void 0,this.componentId);a.insertRules(this.componentId,d,u)}s=ba(s,d)}}return s}}const i8=/&/g;function X0(e,r){let a=0;for(;--r>=0&&e.charCodeAt(r)===92;)a++;return!(1&~a)}function ao(e){const r=e.length;let a="",n=0,s=0,i=0,h=!1,d=!1;for(let u=0;u<r;u++){const f=e.charCodeAt(u);if(i!==0||h||f!==kr||e.charCodeAt(u+1)!==42)if(h)f===42&&e.charCodeAt(u+1)===kr&&(h=!1,u++);else if(f!==34&&f!==39||X0(e,u)){if(i===0)if(f===123)s++;else if(f===125){if(s--,s<0){d=!0;let p=u+1;for(;p<r;){const m=e.charCodeAt(p);if(m===59||m===10)break;p++}p<r&&e.charCodeAt(p)===59&&p++,s=0,u=p-1,n=p;continue}s===0&&(a+=e.substring(n,u+1),n=u+1)}else f===59&&s===0&&(a+=e.substring(n,u+1),n=u+1)}else i===0?i=f:i===f&&(i=0);else h=!0,u++}return d||s!==0||i!==0?(n<r&&s===0&&i===0&&(a+=e.substring(n)),a):e}function ed(e,r){const a=r+" ",n=","+a;for(let s=0;s<e.length;s++){const i=e[s];if(i.type==="rule"){i.value=(a+i.value).replaceAll(",",n);const h=i.props,d=[];for(let u=0;u<h.length;u++)d[u]=a+h[u];i.props=d}Array.isArray(i.children)&&i.type!=="@keyframes"&&ed(i.children,r)}return e}function c8({options:e=Jr,plugins:r=_s}=Jr){let a,n,s;const i=(g,v,w)=>w.startsWith(n)&&w.endsWith(n)&&w.replaceAll(n,"").length>0?`.${a}`:g,h=r.slice();h.push(g=>{g.type===$n&&g.value.includes("&")&&(s||(s=new RegExp(`\\${n}\\b`,"g")),g.props[0]=g.props[0].replace(i8,n).replace(s,i))}),e.prefix&&h.push(Ch),h.push(jh);let d=[];const u=_h(h.concat(kh(g=>d.push(g)))),f=(g,v="",w="",x="&")=>{a=x,n=v,s=void 0;const b=(function(j){const S=j.indexOf("//")!==-1,C=j.indexOf("}")!==-1;if(!S&&!C)return j;if(!S)return ao(j);const _=j.length;let k="",y=0,M=0,A=0,F=0,I=0,R=!1;for(;M<_;){const T=j.charCodeAt(M);if(T!==34&&T!==39||X0(j,M))if(A===0)if(T===kr&&M+1<_&&j.charCodeAt(M+1)===42){for(M+=2;M+1<_&&(j.charCodeAt(M)!==42||j.charCodeAt(M+1)!==kr);)M++;M+=2}else if(T!==40)if(T!==41)if(F>0)M++;else if(T===42&&M+1<_&&j.charCodeAt(M+1)===kr)k+=j.substring(y,M),M+=2,y=M,R=!0;else if(T===kr&&M+1<_&&j.charCodeAt(M+1)===kr){for(k+=j.substring(y,M);M<_&&j.charCodeAt(M)!==10;)M++;y=M,R=!0}else T===123?I++:T===125&&I--,M++;else F>0&&F--,M++;else F++,M++;else M++;else A===0?A=T:A===T&&(A=0),M++}return R?(y<_&&(k+=j.substring(y)),I===0?k:ao(k)):I===0?j:ao(j)})(g);let E=wh(w||v?w+" "+v+" { "+b+" }":b);return e.namespace&&(E=ed(E,e.namespace)),d=[],yn(E,u),d},p=e;let m=es;for(let g=0;g<r.length;g++)r[g].name||aa(15),m=Sr(m,r[g].name);return p!=null&&p.namespace&&(m=Sr(m,p.namespace)),p!=null&&p.prefix&&(m=Sr(m,"p")),f.hash=m!==es?m.toString():"",f}const l8=new Fn,os=c8(),td=c.createContext({shouldForwardProp:void 0,styleSheet:l8,stylis:os,stylisPlugins:void 0});td.Consumer;function d8(){return c.useContext(td)}const rd=c.createContext(void 0);rd.Consumer;const _i=Object.prototype.hasOwnProperty,no={};function u8(e,r){const a=typeof e!="string"?"sc":H0(e);no[a]=(no[a]||0)+1;const n=a+"-"+D0(Pn+a+no[a]);return r?r+"-"+n:n}let oo;function p8(e,r,a){const n=W0(e),s=e,i=!xn(e),{attrs:h=_s,componentId:d=u8(r.displayName,r.parentComponentId),displayName:u=Fh(e)}=r,f=r.displayName&&r.componentId?H0(r.displayName)+"-"+r.componentId:r.componentId||d,p=n&&s.attrs?s.attrs.concat(h).filter(Boolean):h;let{shouldForwardProp:m}=r;if(n&&s.shouldForwardProp){const x=s.shouldForwardProp;if(r.shouldForwardProp){const b=r.shouldForwardProp;m=(E,j)=>x(E,j)&&b(E,j)}else m=x}const g=new s8(a,f,n?s.componentStyle:void 0);function v(x,b){return(function(E,j,S){const{attrs:C,componentStyle:_,defaultProps:k,foldedComponentIds:y,styledComponentId:M,target:A}=E,F=c.useContext(rd),I=d8(),R=E.shouldForwardProp||I.shouldForwardProp;process.env.NODE_ENV!=="production"&&c.useDebugValue&&c.useDebugValue(M);const T=Lh(j,F,k)||Jr;let $,z;{const Z=c.useRef(null),L=Z.current;if(L!==null&&L[1]===T&&L[2]===I.styleSheet&&L[3]===I.stylis&&L[7]===_&&(function(W,D,B){const Y=W,X=D;let ce=0;for(const me in X)if(_i.call(X,me)&&(ce++,Y[me]!==X[me]))return!1;return ce===B})(L[0],j,L[4]))$=L[5],z=L[6];else{$=(function(D,B,Y){const X=Object.assign(Object.assign({},B),{className:void 0,theme:Y}),ce=D.length>1;for(let me=0;me<D.length;me++){const te=D[me],xe=Tn(te)?te(ce?Object.assign({},X):X):te;for(const re in xe)re==="className"?X.className=ba(X.className,xe[re]):re==="style"?X.style=Object.assign(Object.assign({},X.style),xe[re]):re in B&&B[re]===void 0||(X[re]=xe[re])}return"className"in B&&typeof B.className=="string"&&(X.className=ba(X.className,B.className)),X})(C,j,T),z=(function(D,B,Y,X){const ce=D.generateAndInjectStyles(B,Y,X);return process.env.NODE_ENV!=="production"&&c.useDebugValue&&c.useDebugValue(ce),ce})(_,$,I.styleSheet,I.stylis);let W=0;for(const D in j)_i.call(j,D)&&W++;Z.current=[j,T,I.styleSheet,I.stylis,W,$,z,_]}}process.env.NODE_ENV!=="production"&&E.warnTooManyClasses&&E.warnTooManyClasses(z);const H=$.as||A,P=(function(Z,L,W,D){const B={};for(const Y in Z)Z[Y]===void 0||Y[0]==="$"||Y==="as"||Y==="theme"&&Z.theme===W||(Y==="forwardedAs"?B.as=Z.forwardedAs:D&&!D(Y,L)||(B[Y]=Z[Y],D||process.env.NODE_ENV!=="development"||sh(Y)||(oo||(oo=new Set)).has(Y)||!xn(L)||L.includes("-")||(oo.add(Y),console.warn(`styled-components: it looks like an unknown prop "${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.)`))));return B})($,H,T,R);let O=ba(y,M);return z&&(O+=" "+z),$.className&&(O+=" "+$.className),P[xn(H)&&H.includes("-")?"class":"className"]=O,S&&(P.ref=S),c.createElement(H,P)})(w,x,b)}v.displayName=u;let w=c.forwardRef(v);return w.attrs=p,w.componentStyle=g,w.displayName=u,w.shouldForwardProp=m,w.foldedComponentIds=n?ba(s.foldedComponentIds,s.styledComponentId):"",w.styledComponentId=f,w.target=n?s.target:e,Object.defineProperty(w,"defaultProps",{get(){return this._foldedDefaultProps},set(x){this._foldedDefaultProps=n?(function(b,...E){for(const j of E)rs(b,j,!0);return b})({},s.defaultProps,x):x}}),process.env.NODE_ENV!=="production"&&(Mh(u,f),w.warnTooManyClasses=((x,b)=>{let E={},j=!1;return S=>{!j&&(E[S]=!0,Object.keys(E).length>=200)&&(console.warn(`Over 200 classes were generated for component ${x}${b?` with the id of "${b}"`:""}.
86
+ `,n=console.error;try{let s=!0;console.error=(i,...h)=>{mi.test(i)?(s=!1,Ha.delete(a)):n(i,...h)},typeof c.useState=="function"&&c.useState(null),s&&!Ha.has(a)&&(console.warn(a),Ha.add(a))}catch(s){mi.test(s.message)&&Ha.delete(a)}finally{console.error=n}}},_s=Object.freeze([]),Jr=Object.freeze({});function Lh(e,r,a=Jr){return e.theme!==a.theme&&e.theme||r||a.theme}const Rh=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Ph=/(^-|-$)/g;function H0(e){return e.replace(Rh,"-").replace(Ph,"")}const Th=/(a)(d)/gi,gi=e=>String.fromCharCode(e+(e>25?39:97));function ks(e){let r,a="";for(r=Math.abs(e);r>52;r=r/52|0)a=gi(r%52)+a;return(gi(r%52)+a).replace(Th,"$1-$2")}const es=5381,Sr=(e,r)=>{let a=r.length;for(;a;)e=33*e^r.charCodeAt(--a);return e},V0=e=>Sr(es,e);function D0(e){return ks(V0(e)>>>0)}function Cs(e){return process.env.NODE_ENV!=="production"&&typeof e=="string"&&e||e.displayName||e.name||"Component"}function xn(e){return typeof e=="string"&&(process.env.NODE_ENV==="production"||e.charAt(0)===e.charAt(0).toLowerCase())}function Fh(e){return xn(e)?`styled.${e}`:`Styled(${Cs(e)})`}const N0=Symbol.for("react.memo"),Ih=Symbol.for("react.forward_ref"),Zh={contextType:!0,defaultProps:!0,displayName:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,propTypes:!0,type:!0},Oh={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},U0={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Hh={[Ih]:{$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},[N0]:U0};function vi(e){return("type"in(r=e)&&r.type.$$typeof)===N0?U0:"$$typeof"in e?Hh[e.$$typeof]:Zh;var r}const Vh=Object.defineProperty,Dh=Object.getOwnPropertyNames,Nh=Object.getOwnPropertySymbols,Uh=Object.getOwnPropertyDescriptor,Bh=Object.getPrototypeOf,Wh=Object.prototype;function B0(e,r,a){if(typeof r!="string"){const n=Bh(r);n&&n!==Wh&&B0(e,n,a);const s=Dh(r).concat(Nh(r)),i=vi(e),h=vi(r);for(let d=0;d<s.length;++d){const u=s[d];if(!(u in Oh||a&&a[u]||h&&u in h||i&&u in i)){const f=Uh(r,u);try{Vh(e,u,f)}catch{}}}}return e}function Tn(e){return typeof e=="function"}function W0(e){return typeof e=="object"&&"styledComponentId"in e}function ba(e,r){return e&&r?e+" "+r:e||r||""}function ts(e,r){return e.join("")}function Pr(e){return e!==null&&typeof e=="object"&&e.constructor.name===Object.name&&!("props"in e&&e.$$typeof)}function rs(e,r,a=!1){if(!a&&!Pr(e)&&!Array.isArray(e))return r;if(Array.isArray(r))for(let n=0;n<r.length;n++)e[n]=rs(e[n],r[n]);else if(Pr(r))for(const n in r)e[n]=rs(e[n],r[n]);return e}function Ss(e,r){Object.defineProperty(e,"toString",{value:r})}const Gh=class{constructor(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e,this._cGroup=0,this._cIndex=0}indexOfGroup(e){if(e===this._cGroup)return this._cIndex;let r=this._cIndex;if(e>this._cGroup)for(let a=this._cGroup;a<e;a++)r+=this.groupSizes[a];else for(let a=this._cGroup-1;a>=e;a--)r-=this.groupSizes[a];return this._cGroup=e,this._cIndex=r,r}insertRules(e,r){if(e>=this.groupSizes.length){const s=this.groupSizes,i=s.length;let h=i;for(;e>=h;)if(h<<=1,h<0)throw aa(16,`${e}`);this.groupSizes=new Uint32Array(h),this.groupSizes.set(s),this.length=h;for(let d=i;d<h;d++)this.groupSizes[d]=0}let a=this.indexOfGroup(e+1),n=0;for(let s=0,i=r.length;s<i;s++)this.tag.insertRule(a,r[s])&&(this.groupSizes[e]++,a++,n++);n>0&&this._cGroup>e&&(this._cIndex+=n)}clearGroup(e){if(e<this.length){const r=this.groupSizes[e],a=this.indexOfGroup(e),n=a+r;this.groupSizes[e]=0;for(let s=a;s<n;s++)this.tag.deleteRule(a);r>0&&this._cGroup>e&&(this._cIndex-=r)}}getGroup(e){let r="";if(e>=this.length||this.groupSizes[e]===0)return r;const a=this.groupSizes[e],n=this.indexOfGroup(e),s=n+a;for(let i=n;i<s;i++)r+=this.tag.getRule(i)+js;return r}},qh=`style[${Rr}][${Z0}="${Pn}"]`,Kh=new RegExp(`^${Rr}\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)`),xi=e=>typeof ShadowRoot<"u"&&e instanceof ShadowRoot||"host"in e&&e.nodeType===11,as=e=>{if(!e)return document;if(xi(e))return e;if("getRootNode"in e){const r=e.getRootNode();if(xi(r))return r}return document},Yh=(e,r,a)=>{const n=a.split(",");let s;for(let i=0,h=n.length;i<h;i++)(s=n[i])&&e.registerName(r,s)},Qh=(e,r)=>{var a;const n=((a=r.textContent)!==null&&a!==void 0?a:"").split(js),s=[];for(let i=0,h=n.length;i<h;i++){const d=n[i].trim();if(!d)continue;const u=d.match(Kh);if(u){const f=0|parseInt(u[1],10),p=u[2];f!==0&&($h(p,f),Yh(e,p,u[3]),e.getTag().insertRules(f,s)),s.length=0}else s.push(d)}},ro=e=>{const r=as(e.options.target).querySelectorAll(qh);for(let a=0,n=r.length;a<n;a++){const s=r[a];s&&s.getAttribute(Rr)!==I0&&(Qh(e,s),s.parentNode&&s.parentNode.removeChild(s))}};let ca=!1;function Jh(){if(ca!==!1)return ca;if(typeof document<"u"){const e=document.head.querySelector('meta[property="csp-nonce"]');if(e)return ca=e.nonce||e.getAttribute("content")||void 0;const r=document.head.querySelector('meta[name="sc-nonce"]');if(r)return ca=r.getAttribute("content")||void 0}return ca=typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0}const G0=(e,r)=>{const a=document.head,n=e||a,s=document.createElement("style"),i=(u=>{const f=Array.from(u.querySelectorAll(`style[${Rr}]`));return f[f.length-1]})(n),h=i!==void 0?i.nextSibling:null;s.setAttribute(Rr,I0),s.setAttribute(Z0,Pn);const d=r||Jh();return d&&s.setAttribute("nonce",d),n.insertBefore(s,h),s},Xh=class{constructor(e,r){this.element=G0(e,r),this.element.appendChild(document.createTextNode("")),this.sheet=(a=>{var n;if(a.sheet)return a.sheet;const s=(n=a.getRootNode().styleSheets)!==null&&n!==void 0?n:document.styleSheets;for(let i=0,h=s.length;i<h;i++){const d=s[i];if(d.ownerNode===a)return d}throw aa(17)})(this.element),this.length=0}insertRule(e,r){try{return this.sheet.insertRule(r,e),this.length++,!0}catch{return!1}}deleteRule(e){this.sheet.deleteRule(e),this.length--}getRule(e){const r=this.sheet.cssRules[e];return r&&r.cssText?r.cssText:""}},e8=class{constructor(e,r){this.element=G0(e,r),this.nodes=this.element.childNodes,this.length=0}insertRule(e,r){if(e<=this.length&&e>=0){const a=document.createTextNode(r);return this.element.insertBefore(a,this.nodes[e]||null),this.length++,!0}return!1}deleteRule(e){this.element.removeChild(this.nodes[e]),this.length--}getRule(e){return e<this.length?this.nodes[e].textContent:""}};let bi=ja;const t8={isServer:!ja,useCSSOMInjection:!Sh};class Fn{static registerId(r){return xa(r)}constructor(r=Jr,a={},n){this.options=Object.assign(Object.assign({},t8),r),this.gs=a,this.keyframeIds=new Set,this.names=new Map(n),this.server=!!r.isServer,!this.server&&ja&&bi&&(bi=!1,ro(this)),Ss(this,()=>(s=>{const i=s.getTag(),{length:h}=i;let d="";for(let u=0;u<h;u++){const f=zh(u);if(f===void 0)continue;const p=s.names.get(f);if(p===void 0||!p.size)continue;const m=i.getGroup(u);if(m.length===0)continue;const g=Rr+".g"+u+'[id="'+f+'"]';let v="";for(const w of p)w.length>0&&(v+=w+",");d+=m+g+'{content:"'+v+'"}'+js}return d})(this))}rehydrate(){!this.server&&ja&&ro(this)}reconstructWithOptions(r,a=!0){const n=new Fn(Object.assign(Object.assign({},this.options),r),this.gs,a&&this.names||void 0);return n.keyframeIds=new Set(this.keyframeIds),!this.server&&ja&&r.target!==this.options.target&&as(this.options.target)!==as(r.target)&&ro(n),n}allocateGSInstance(r){return this.gs[r]=(this.gs[r]||0)+1}getTag(){return this.tag||(this.tag=(r=(({useCSSOMInjection:a,target:n,nonce:s})=>a?new Xh(n,s):new e8(n,s))(this.options),new Gh(r)));var r}hasNameForId(r,a){var n,s;return(s=(n=this.names.get(r))===null||n===void 0?void 0:n.has(a))!==null&&s!==void 0&&s}registerName(r,a){xa(r),r.startsWith(O0)&&this.keyframeIds.add(r);const n=this.names.get(r);n?n.add(a):this.names.set(r,new Set([a]))}insertRules(r,a,n){this.registerName(r,a),this.getTag().insertRules(xa(r),n)}clearNames(r){this.names.has(r)&&this.names.get(r).clear()}clearRules(r){this.getTag().clearGroup(xa(r)),this.clearNames(r)}clearTag(){this.tag=void 0}}const q0=new WeakSet,r8={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexShrink:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};function a8(e,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||e in r8||e.startsWith("--")?String(r).trim():r+"px"}const kr=47;function wi(e){if(e.charCodeAt(0)===45&&e.charCodeAt(1)===45)return e;let r="";for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);r+=n>=65&&n<=90?"-"+String.fromCharCode(n+32):e[a]}return r.startsWith("ms-")?"-"+r:r}const K0=Symbol.for("sc-keyframes");function ns(e){return typeof e=="object"&&e!==null&&K0 in e}function Y0(e){return Tn(e)&&!(e.prototype&&e.prototype.isReactComponent)}const Q0=e=>e==null||e===!1||e==="",n8=Symbol.for("react.client.reference");function yi(e){return e.$$typeof===n8}function ji(e){const r=e.$$id,a=(r&&r.includes("#")?r.split("#").pop():r)||e.name||"unknown";console.warn(`Interpolating a client component (${a}) as a selector is not supported in server components. The component selector pattern requires access to the component's internal class name, which is not available across the server/client boundary. Use a plain CSS class selector instead.`)}function J0(e,r){for(const a in e){const n=e[a];e.hasOwnProperty(a)&&!Q0(n)&&(Array.isArray(n)&&q0.has(n)||Tn(n)?r.push(wi(a)+":",n,";"):Pr(n)?(r.push(a+" {"),J0(n,r),r.push("}")):r.push(wi(a)+": "+a8(a,n)+";"))}}function Er(e,r,a,n,s=[]){if(Q0(e))return s;const i=typeof e;if(i==="string")return s.push(e),s;if(i==="function"){if(yi(e))return process.env.NODE_ENV!=="production"&&ji(e),s;if(Y0(e)&&r){const h=e(r);return process.env.NODE_ENV==="production"||typeof h!="object"||Array.isArray(h)||ns(h)||Pr(h)||h===null||console.error(`${Cs(e)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),Er(h,r,a,n,s)}return s.push(e),s}if(Array.isArray(e)){for(let h=0;h<e.length;h++)Er(e[h],r,a,n,s);return s}return W0(e)?(s.push(`.${e.styledComponentId}`),s):ns(e)?(a?(e.inject(a,n),s.push(e.getName(n))):s.push(e),s):yi(e)?(process.env.NODE_ENV!=="production"&&ji(e),s):Pr(e)?(J0(e,s),s):(s.push(e.toString()),s)}const o8=V0(Pn);class s8{constructor(r,a,n){this.rules=r,this.componentId=a,this.baseHash=Sr(o8,a),this.baseStyle=n,Fn.registerId(a)}generateAndInjectStyles(r,a,n){let s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,a,n):"";{let i="";for(let h=0;h<this.rules.length;h++){const d=this.rules[h];if(typeof d=="string")i+=d;else if(d)if(Y0(d)){const u=d(r);typeof u=="string"?i+=u:u!=null&&u!==!1&&(process.env.NODE_ENV==="production"||typeof u!="object"||Array.isArray(u)||ns(u)||Pr(u)||console.error(`${Cs(d)} is not a styled component and cannot be referred to via component selector. See https://styled-components.com/docs/advanced#referring-to-other-components for more details.`),i+=ts(Er(u,r,a,n)))}else i+=ts(Er(d,r,a,n))}if(i){this.dynamicNameCache||(this.dynamicNameCache=new Map);const h=n.hash?n.hash+i:i;let d=this.dynamicNameCache.get(h);if(!d){if(d=ks(Sr(Sr(this.baseHash,n.hash),i)>>>0),this.dynamicNameCache.size>=200){const u=this.dynamicNameCache.keys().next().value;u!==void 0&&this.dynamicNameCache.delete(u)}this.dynamicNameCache.set(h,d)}if(!a.hasNameForId(this.componentId,d)){const u=n(i,"."+d,void 0,this.componentId);a.insertRules(this.componentId,d,u)}s=ba(s,d)}}return s}}const i8=/&/g;function X0(e,r){let a=0;for(;--r>=0&&e.charCodeAt(r)===92;)a++;return!(1&~a)}function ao(e){const r=e.length;let a="",n=0,s=0,i=0,h=!1,d=!1;for(let u=0;u<r;u++){const f=e.charCodeAt(u);if(i!==0||h||f!==kr||e.charCodeAt(u+1)!==42)if(h)f===42&&e.charCodeAt(u+1)===kr&&(h=!1,u++);else if(f!==34&&f!==39||X0(e,u)){if(i===0)if(f===123)s++;else if(f===125){if(s--,s<0){d=!0;let p=u+1;for(;p<r;){const m=e.charCodeAt(p);if(m===59||m===10)break;p++}p<r&&e.charCodeAt(p)===59&&p++,s=0,u=p-1,n=p;continue}s===0&&(a+=e.substring(n,u+1),n=u+1)}else f===59&&s===0&&(a+=e.substring(n,u+1),n=u+1)}else i===0?i=f:i===f&&(i=0);else h=!0,u++}return d||s!==0||i!==0?(n<r&&s===0&&i===0&&(a+=e.substring(n)),a):e}function ed(e,r){const a=r+" ",n=","+a;for(let s=0;s<e.length;s++){const i=e[s];if(i.type==="rule"){i.value=(a+i.value).replaceAll(",",n);const h=i.props,d=[];for(let u=0;u<h.length;u++)d[u]=a+h[u];i.props=d}Array.isArray(i.children)&&i.type!=="@keyframes"&&ed(i.children,r)}return e}function c8({options:e=Jr,plugins:r=_s}=Jr){let a,n,s;const i=(g,v,w)=>w.startsWith(n)&&w.endsWith(n)&&w.replaceAll(n,"").length>0?`.${a}`:g,h=r.slice();h.push(g=>{g.type===$n&&g.value.includes("&")&&(s||(s=new RegExp(`\\${n}\\b`,"g")),g.props[0]=g.props[0].replace(i8,n).replace(s,i))}),e.prefix&&h.push(Ch),h.push(jh);let d=[];const u=_h(h.concat(kh(g=>d.push(g)))),f=(g,v="",w="",x="&")=>{a=x,n=v,s=void 0;const b=(function(j){const S=j.indexOf("//")!==-1,C=j.indexOf("}")!==-1;if(!S&&!C)return j;if(!S)return ao(j);const _=j.length;let k="",y=0,M=0,A=0,I=0,P=0,L=!1;for(;M<_;){const T=j.charCodeAt(M);if(T!==34&&T!==39||X0(j,M))if(A===0)if(T===kr&&M+1<_&&j.charCodeAt(M+1)===42){for(M+=2;M+1<_&&(j.charCodeAt(M)!==42||j.charCodeAt(M+1)!==kr);)M++;M+=2}else if(T!==40)if(T!==41)if(I>0)M++;else if(T===42&&M+1<_&&j.charCodeAt(M+1)===kr)k+=j.substring(y,M),M+=2,y=M,L=!0;else if(T===kr&&M+1<_&&j.charCodeAt(M+1)===kr){for(k+=j.substring(y,M);M<_&&j.charCodeAt(M)!==10;)M++;y=M,L=!0}else T===123?P++:T===125&&P--,M++;else I>0&&I--,M++;else I++,M++;else M++;else A===0?A=T:A===T&&(A=0),M++}return L?(y<_&&(k+=j.substring(y)),P===0?k:ao(k)):P===0?j:ao(j)})(g);let E=wh(w||v?w+" "+v+" { "+b+" }":b);return e.namespace&&(E=ed(E,e.namespace)),d=[],yn(E,u),d},p=e;let m=es;for(let g=0;g<r.length;g++)r[g].name||aa(15),m=Sr(m,r[g].name);return p!=null&&p.namespace&&(m=Sr(m,p.namespace)),p!=null&&p.prefix&&(m=Sr(m,"p")),f.hash=m!==es?m.toString():"",f}const l8=new Fn,os=c8(),td=c.createContext({shouldForwardProp:void 0,styleSheet:l8,stylis:os,stylisPlugins:void 0});td.Consumer;function d8(){return c.useContext(td)}const rd=c.createContext(void 0);rd.Consumer;const _i=Object.prototype.hasOwnProperty,no={};function u8(e,r){const a=typeof e!="string"?"sc":H0(e);no[a]=(no[a]||0)+1;const n=a+"-"+D0(Pn+a+no[a]);return r?r+"-"+n:n}let oo;function p8(e,r,a){const n=W0(e),s=e,i=!xn(e),{attrs:h=_s,componentId:d=u8(r.displayName,r.parentComponentId),displayName:u=Fh(e)}=r,f=r.displayName&&r.componentId?H0(r.displayName)+"-"+r.componentId:r.componentId||d,p=n&&s.attrs?s.attrs.concat(h).filter(Boolean):h;let{shouldForwardProp:m}=r;if(n&&s.shouldForwardProp){const x=s.shouldForwardProp;if(r.shouldForwardProp){const b=r.shouldForwardProp;m=(E,j)=>x(E,j)&&b(E,j)}else m=x}const g=new s8(a,f,n?s.componentStyle:void 0);function v(x,b){return(function(E,j,S){const{attrs:C,componentStyle:_,defaultProps:k,foldedComponentIds:y,styledComponentId:M,target:A}=E,I=c.useContext(rd),P=d8(),L=E.shouldForwardProp||P.shouldForwardProp;process.env.NODE_ENV!=="production"&&c.useDebugValue&&c.useDebugValue(M);const T=Lh(j,I,k)||Jr;let $,z;{const Z=c.useRef(null),R=Z.current;if(R!==null&&R[1]===T&&R[2]===P.styleSheet&&R[3]===P.stylis&&R[7]===_&&(function(W,D,B){const Y=W,X=D;let ce=0;for(const me in X)if(_i.call(X,me)&&(ce++,Y[me]!==X[me]))return!1;return ce===B})(R[0],j,R[4]))$=R[5],z=R[6];else{$=(function(D,B,Y){const X=Object.assign(Object.assign({},B),{className:void 0,theme:Y}),ce=D.length>1;for(let me=0;me<D.length;me++){const te=D[me],xe=Tn(te)?te(ce?Object.assign({},X):X):te;for(const re in xe)re==="className"?X.className=ba(X.className,xe[re]):re==="style"?X.style=Object.assign(Object.assign({},X.style),xe[re]):re in B&&B[re]===void 0||(X[re]=xe[re])}return"className"in B&&typeof B.className=="string"&&(X.className=ba(X.className,B.className)),X})(C,j,T),z=(function(D,B,Y,X){const ce=D.generateAndInjectStyles(B,Y,X);return process.env.NODE_ENV!=="production"&&c.useDebugValue&&c.useDebugValue(ce),ce})(_,$,P.styleSheet,P.stylis);let W=0;for(const D in j)_i.call(j,D)&&W++;Z.current=[j,T,P.styleSheet,P.stylis,W,$,z,_]}}process.env.NODE_ENV!=="production"&&E.warnTooManyClasses&&E.warnTooManyClasses(z);const H=$.as||A,F=(function(Z,R,W,D){const B={};for(const Y in Z)Z[Y]===void 0||Y[0]==="$"||Y==="as"||Y==="theme"&&Z.theme===W||(Y==="forwardedAs"?B.as=Z.forwardedAs:D&&!D(Y,R)||(B[Y]=Z[Y],D||process.env.NODE_ENV!=="development"||sh(Y)||(oo||(oo=new Set)).has(Y)||!xn(R)||R.includes("-")||(oo.add(Y),console.warn(`styled-components: it looks like an unknown prop "${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.)`))));return B})($,H,T,L);let O=ba(y,M);return z&&(O+=" "+z),$.className&&(O+=" "+$.className),F[xn(H)&&H.includes("-")?"class":"className"]=O,S&&(F.ref=S),c.createElement(H,F)})(w,x,b)}v.displayName=u;let w=c.forwardRef(v);return w.attrs=p,w.componentStyle=g,w.displayName=u,w.shouldForwardProp=m,w.foldedComponentIds=n?ba(s.foldedComponentIds,s.styledComponentId):"",w.styledComponentId=f,w.target=n?s.target:e,Object.defineProperty(w,"defaultProps",{get(){return this._foldedDefaultProps},set(x){this._foldedDefaultProps=n?(function(b,...E){for(const j of E)rs(b,j,!0);return b})({},s.defaultProps,x):x}}),process.env.NODE_ENV!=="production"&&(Mh(u,f),w.warnTooManyClasses=((x,b)=>{let E={},j=!1;return S=>{!j&&(E[S]=!0,Object.keys(E).length>=200)&&(console.warn(`Over 200 classes were generated for component ${x}${b?` with the id of "${b}"`:""}.
87
87
  Consider using the attrs method, together with a style object for frequently changed styles.
88
88
  Example:
89
89
  const Component = styled.div.attrs(props => ({
@@ -396,7 +396,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
396
396
  color: var(--color-secondary-text);
397
397
  cursor: not-allowed;
398
398
  }
399
- `;function lr({length:e=6,onComplete:r,onResend:a,error:n,isSubmitting:s=!1}){const[i,h]=c.useState(new Array(e).fill("")),[d,u]=c.useState(60),[f,p]=c.useState(!1),[m,g]=c.useState(!1),v=c.useRef([]),w=c.useCallback(()=>{const C=setInterval(()=>{u(_=>_<=1?(p(!0),clearInterval(C),0):_-1)},1e3);return C},[]);c.useEffect(()=>{const C=w();return()=>clearInterval(C)},[w]),c.useEffect(()=>{if(n){g(!0);const C=setTimeout(()=>g(!1),450);return()=>clearTimeout(C)}},[n]);const x=async()=>{var C;!f||s||!a||(await a(),p(!1),u(60),h(new Array(e).fill("")),(C=v.current[0])==null||C.focus(),w())},b=(C,_)=>{var A;if(s)return;const k=C.value,y=[...i];y[_]=k.replace(/[^0-9]/g,""),h(y);const M=y.join("");M.length===e&&r(M),k&&_<e-1&&((A=v.current[_+1])==null||A.focus())},E=(C,_)=>{var k;s||C.key==="Backspace"&&!i[_]&&_>0&&((k=v.current[_-1])==null||k.focus())},j=(C,_)=>{var A,F;if(s)return;C.preventDefault();const k=C.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const y=[...i];for(let I=0;I<k.length&&_+I<e;I++)y[_+I]=k[I];if(_===0&&k.length===e)for(let I=0;I<e;I++)y[I]=k[I];h(y);const M=y.join("");if(M.length===e)r(M),(A=v.current[e-1])==null||A.focus();else{const I=y.findIndex((R,T)=>T>=_&&!R);I!==-1&&((F=v.current[I])==null||F.focus())}},S=Math.floor(e/2);return t.jsxs(Hf,{children:[t.jsxs(Vf,{$shake:m,children:[i.slice(0,S).map((C,_)=>t.jsx(Ai,{type:"text",inputMode:"numeric",maxLength:1,value:C,$hasError:!!n,onChange:k=>b(k.target,_),onKeyDown:k=>E(k,_),onPaste:k=>j(k,_),ref:k=>{v.current[_]=k},disabled:s,autoFocus:_===0},_)),t.jsx(Df,{}),i.slice(S).map((C,_)=>{const k=S+_;return t.jsx(Ai,{type:"text",inputMode:"numeric",maxLength:1,value:C,$hasError:!!n,onChange:y=>b(y.target,k),onKeyDown:y=>E(y,k),onPaste:y=>j(y,k),ref:y=>{v.current[k]=y},disabled:s},k)})]}),t.jsxs(Nf,{children:[n&&t.jsx(Uf,{children:n}),a&&(f?t.jsx(Wf,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):t.jsxs(Bf,{children:["Resend code in ",d,"s"]}))]})]})}const s1=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.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"})]}),i1=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.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"}),t.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"}),t.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"}),t.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"})]}),c1=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.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"})}),Gf=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.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"})}),l1=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.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"})}),d1=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.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"}),t.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"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.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"}),t.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"})]}),qf=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.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"})}),u1=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.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"}})]}),Kf={google_oauth:{label:"Continue with Google",icon:t.jsx(i1,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(s1,{})},x_oauth:{label:"Continue with X",icon:t.jsx(c1,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(Gf,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(l1,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(d1,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(qf,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(u1,{})}},Yf=l.div`
399
+ `;function lr({length:e=6,onComplete:r,onResend:a,error:n,isSubmitting:s=!1}){const[i,h]=c.useState(new Array(e).fill("")),[d,u]=c.useState(60),[f,p]=c.useState(!1),[m,g]=c.useState(!1),v=c.useRef([]),w=c.useCallback(()=>{const C=setInterval(()=>{u(_=>_<=1?(p(!0),clearInterval(C),0):_-1)},1e3);return C},[]);c.useEffect(()=>{const C=w();return()=>clearInterval(C)},[w]),c.useEffect(()=>{if(n){g(!0);const C=setTimeout(()=>g(!1),450);return()=>clearTimeout(C)}},[n]);const x=async()=>{var C;!f||s||!a||(await a(),p(!1),u(60),h(new Array(e).fill("")),(C=v.current[0])==null||C.focus(),w())},b=(C,_)=>{var A;if(s)return;const k=C.value,y=[...i];y[_]=k.replace(/[^0-9]/g,""),h(y);const M=y.join("");M.length===e&&r(M),k&&_<e-1&&((A=v.current[_+1])==null||A.focus())},E=(C,_)=>{var k;s||C.key==="Backspace"&&!i[_]&&_>0&&((k=v.current[_-1])==null||k.focus())},j=(C,_)=>{var A,I;if(s)return;C.preventDefault();const k=C.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,e);if(!k.length)return;const y=[...i];for(let P=0;P<k.length&&_+P<e;P++)y[_+P]=k[P];if(_===0&&k.length===e)for(let P=0;P<e;P++)y[P]=k[P];h(y);const M=y.join("");if(M.length===e)r(M),(A=v.current[e-1])==null||A.focus();else{const P=y.findIndex((L,T)=>T>=_&&!L);P!==-1&&((I=v.current[P])==null||I.focus())}},S=Math.floor(e/2);return t.jsxs(Hf,{children:[t.jsxs(Vf,{$shake:m,children:[i.slice(0,S).map((C,_)=>t.jsx(Ai,{type:"text",inputMode:"numeric",maxLength:1,value:C,$hasError:!!n,onChange:k=>b(k.target,_),onKeyDown:k=>E(k,_),onPaste:k=>j(k,_),ref:k=>{v.current[_]=k},disabled:s,autoFocus:_===0},_)),t.jsx(Df,{}),i.slice(S).map((C,_)=>{const k=S+_;return t.jsx(Ai,{type:"text",inputMode:"numeric",maxLength:1,value:C,$hasError:!!n,onChange:y=>b(y.target,k),onKeyDown:y=>E(y,k),onPaste:y=>j(y,k),ref:y=>{v.current[k]=y},disabled:s},k)})]}),t.jsxs(Nf,{children:[n&&t.jsx(Uf,{children:n}),a&&(f?t.jsx(Wf,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):t.jsxs(Bf,{children:["Resend code in ",d,"s"]}))]})]})}const s1=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...e,children:[t.jsx("title",{id:"githubIconTitle",children:"GitHub"}),t.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"})]}),i1=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.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"}),t.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"}),t.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"}),t.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"})]}),c1=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...e,children:t.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"})}),Gf=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.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"})}),l1=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:t.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"})}),d1=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),t.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),t.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"}),t.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"}),t.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),t.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"}),t.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"})]}),qf=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:t.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"})}),u1=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),t.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"}})]}),Kf={google_oauth:{label:"Continue with Google",icon:t.jsx(i1,{})},github_oauth:{label:"Continue with GitHub",icon:t.jsx(s1,{})},x_oauth:{label:"Continue with X",icon:t.jsx(c1,{})},facebook_oauth:{label:"Continue with Facebook",icon:t.jsx(Gf,{})},linkedin_oauth:{label:"Continue with LinkedIn",icon:t.jsx(l1,{})},gitlab_oauth:{label:"Continue with GitLab",icon:t.jsx(d1,{})},apple_oauth:{label:"Continue with Apple",icon:t.jsx(qf,{})},discord_oauth:{label:"Continue with Discord",icon:t.jsx(u1,{})}},Yf=l.div`
400
400
  display: flex;
401
401
  flex-direction: column;
402
402
  gap: var(--space-3u);
@@ -830,7 +830,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
830
830
  border-color: var(--color-border-hover);
831
831
  color: var(--color-card-foreground);
832
832
  }
833
- `;function km(){var B,Y,X,ce,me,te,xe,re,U,Qe,Te,Ve,Ue,ve,J,le;const{loading:e,signUp:r,signupAttempt:a,discardSignupAttempt:n}=o0(),{signIn:s}=wa("oauth"),{deployment:i}=Ae(),{navigate:h}=yt(),{session:d,refetch:u,loading:f}=ot(),[p,m]=c.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,v]=c.useState({}),[w,x]=c.useState(!1),[b,E]=c.useState(void 0),[j,S]=c.useState(null),[C,_]=c.useState(null),[k,y]=c.useState(!1),M=((B=i==null?void 0:i.restrictions)==null?void 0:B.sign_up_mode)==="restricted",A=((Y=i==null?void 0:i.restrictions)==null?void 0:Y.sign_up_mode)==="waitlist",F=((ce=(X=i==null?void 0:i.auth_settings)==null?void 0:X.multi_session_support)==null?void 0:ce.enabled)??!1;c.useEffect(()=>{var oe;if(!f&&(d!=null&&d.active_signin)&&!F&&!k){y(!0);let G=new URLSearchParams(window.location.search).get("redirect_uri");G||(G=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),G&&h(G)}},[d,f,F,i,h,k]),c.useEffect(()=>{var pe;if(!i)return;const G=new URLSearchParams(window.location.search).get("invite_token");if(A&&!G){y(!0);const fe=((pe=i.ui_settings)==null?void 0:pe.waitlist_page_url)||`https://${i.frontend_host}/waitlist`;h(fe);return}G&&!j&&r&&(_(G),r.validateDeploymentInvitation(G).then(fe=>{S(fe),fe.valid&&m(q=>({...q,first_name:fe.first_name||q.first_name,last_name:fe.last_name||q.last_name,email:fe.email||q.email}))}).catch(()=>{v(fe=>({...fe,submit:"Failed to validate invitation."}))}))},[i,A,h,j,r]);const[I,R]=c.useState(!1),[T,$]=c.useState(""),z=oe=>{let{name:G,value:pe}=oe.target;G==="phone_number"?pe=pe.replace(/[^0-9-]/g,""):G==="email"&&(pe=pe.toLowerCase()),m(fe=>({...fe,[G]:pe})),v(fe=>({...fe,[G]:""}))},H=()=>{m({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),R(!1),$(""),n()},P=async oe=>{if(oe.preventDefault(),e||w)return;const G={},pe=/^[a-zA-Z]{3,30}$/,fe=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,q=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,de=/^\d{7,15}$/,Be=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(L!=null&&L.first_name.enabled&&(L!=null&&L.first_name.required&&!p.first_name?G.first_name="First name is required":p.first_name&&!pe.test(p.first_name)&&(G.first_name="Invalid name")),L!=null&&L.last_name.enabled&&(L!=null&&L.last_name.required&&!p.last_name?G.last_name="Last name is required":p.last_name&&!pe.test(p.last_name)&&(G.last_name="Invalid last name")),L!=null&&L.username.enabled&&(L!=null&&L.username.required&&!p.username?G.username="Username is required":p.username&&!fe.test(p.username)&&(G.username="Username must be 3-20 characters")),L!=null&&L.email_address.enabled&&(L!=null&&L.email_address.required&&!p.email?G.email="Email address is required":p.email&&!q.test(p.email)&&(G.email="Invalid email address")),L!=null&&L.phone_number.enabled&&(L!=null&&L.phone_number.required&&!p.phone_number?G.phone_number="Phone number is required":p.phone_number&&!de.test(p.phone_number)&&(G.phone_number="Phone number must contain 7-15 digits")),L!=null&&L.password.enabled&&(p.password?Be.test(p.password)||(G.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):G.password="Password is required"),v(G),!(Object.keys(G).length>0)){x(!0);try{const We={...p};p.phone_number&&b&&(We.phone_country_code=b),C&&(We.invite_token=C),await r.create(We)}catch(We){v({submit:We.message})}finally{x(!1)}}},O=async oe=>{if(!(e||w)){x(!0);try{const pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:fe}=await s.create({provider:oe.provider,redirectUri:pe});fe&&typeof fe=="object"&&"oauth_url"in fe&&(window.location.href=fe.oauth_url)}catch(G){v({submit:G.message})}finally{x(!1)}}},Z=(i==null?void 0:i.social_connections.filter(oe=>oe.enabled))||[],L=i==null?void 0:i.auth_settings,W=!!((me=L==null?void 0:L.first_name)!=null&&me.enabled&&((te=L==null?void 0:L.last_name)!=null&&te.enabled)),D=async oe=>{var pe;if(oe.preventDefault(),e||w)return;x(!0);const G={};if(!T){G.otp="OTP code is required",v(G),x(!1);return}v(G);try{const fe=await r.completeVerification(T);"data"in fe&&((pe=fe.data)!=null&&pe.active_signin)&&await u()}catch{v(fe=>({...fe,submit:"Verification failed. Please try again."}))}finally{x(!1)}};return c.useEffect(()=>{var oe;if(a){if(a.completed){let G=new URLSearchParams(window.location.search).get("redirect_uri");if(G||(G=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signup_redirect_url)||null),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),G){let pe;try{pe=new URL(G)}catch{pe=new URL(G,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&pe.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(pe.toString())}return}if(!I){switch(a.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[a,r,I,i,d,h]),f?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx($i,{children:t.jsx(wt,{size:32})})]})}):k?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx($i,{children:t.jsx(wt,{size:32})})]})}):M?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx(co,{children:t.jsx(lo,{children:"Sign up Restricted!"})}),t.jsx(gm,{children:t.jsx(vm,{children:"New account registration is currently restricted. Please check back later."})}),t.jsx(xm,{children:t.jsxs(bm,{children:["Need assistance?"," ",t.jsx(wm,{href:(xe=i==null?void 0:i.ui_settings)!=null&&xe.sign_in_page_url?`${i.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):t.jsx(ge,{children:t.jsx(Da,{children:I?t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(co,{children:[!((re=i==null?void 0:i.ui_settings)!=null&&re.logo_image_url)&&t.jsx(ym,{children:(a==null?void 0:a.current_step)==="verify_phone"?t.jsx(As,{weight:"light"}):t.jsx(In,{weight:"light"})}),t.jsx(lo,{children:(a==null?void 0:a.current_step)==="verify_phone"?"Check your phone":"Enter the code"}),t.jsx(Mi,{children:(a==null?void 0:a.current_step)==="verify_phone"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email."}),t.jsx(jm,{children:t.jsxs(_m,{type:"button",onClick:H,children:[t.jsx(cs,{weight:"light"}),(a==null?void 0:a.current_step)==="verify_phone"?`+${p.phone_number}`:p.email]})})]}),t.jsxs(Li,{onSubmit:D,noValidate:!0,children:[t.jsx(lr,{onComplete:async oe=>{$(oe)},onResend:async()=>{const oe=(a==null?void 0:a.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:oe})},error:g.otp,isSubmitting:w}),t.jsx(Ri,{type:"submit",disabled:w||e||!T,children:w&&T?t.jsx(zi,{size:16}):`Continue to ${(U=i==null?void 0:i.ui_settings)==null?void 0:U.app_name}`})]}),t.jsxs(Pi,{children:["Having trouble?"," ",t.jsx(Ti,{children:t.jsx(Pt,{to:i.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(co,{children:[t.jsx(lo,{children:"Create your account"}),t.jsx(Mi,{children:j!=null&&j.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ms,{connections:Z,callback:O}),t.jsx(pm,{children:t.jsx(hm,{children:"or"})})]}),t.jsxs(Li,{onSubmit:P,noValidate:!0,children:[(((Qe=L==null?void 0:L.first_name)==null?void 0:Qe.enabled)||((Te=L==null?void 0:L.last_name)==null?void 0:Te.enabled))&&t.jsxs(fm,{$isBothEnabled:W,children:[((Ve=L==null?void 0:L.first_name)==null?void 0:Ve.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"first_name",children:["First name",((Ue=L==null?void 0:L.first_name)==null?void 0:Ue.required)&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:p.first_name,onChange:z,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&t.jsx(mr,{children:g.first_name})]}),((ve=L==null?void 0:L.last_name)==null?void 0:ve.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"last_name",children:["Last name",((J=L==null?void 0:L.last_name)==null?void 0:J.required)&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:p.last_name,onChange:z,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&t.jsx(mr,{children:g.last_name})]})]}),(L==null?void 0:L.username.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"username",children:["Username",L.username.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:p.username,onChange:z,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&t.jsx(mr,{children:g.username})]}),(L==null?void 0:L.email_address.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"email",children:["Email address",L.email_address.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"email",id:"email",name:"email",maxLength:320,value:p.email,onChange:z,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(j==null?void 0:j.valid)&&!!(j!=null&&j.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&t.jsx(mr,{children:g.email})]}),(L==null?void 0:L.phone_number.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"phone_number",children:["Phone number",L.phone_number.required&&t.jsx(Dr,{children:"*"})]}),t.jsx($a,{value:p.phone_number,onChange:z,error:g.phone_number,countryCode:b,setCountryCode:E}),g.phone_number&&t.jsx(mr,{children:g.phone_number})]}),(L==null?void 0:L.password.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"password",children:["Password",L.password.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(mm,{children:t.jsx(ue,{type:"password",id:"password",name:"password",value:p.password,onChange:z,placeholder:"Enter your password","aria-invalid":!!g.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),g.password&&t.jsx(mr,{children:g.password})]}),g.submit&&t.jsx(mr,{children:g.submit}),t.jsx(Ri,{type:"submit",disabled:w||e,children:w?t.jsx(zi,{size:16}):"Continue"})]}),t.jsxs(Pi,{children:["Already have an account?"," ",t.jsx(Ti,{children:t.jsx(Pt,{to:`${(le=i.ui_settings)==null?void 0:le.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const h1=c.createContext(void 0),f1=()=>{const e=c.useContext(h1);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},Cm=l.div`
833
+ `;function km(){var B,Y,X,ce,me,te,xe,re,U,Qe,Te,Ve,Ue,ve,J,le;const{loading:e,signUp:r,signupAttempt:a,discardSignupAttempt:n}=o0(),{signIn:s}=wa("oauth"),{deployment:i}=Ae(),{navigate:h}=yt(),{session:d,refetch:u,loading:f}=ot(),[p,m]=c.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,v]=c.useState({}),[w,x]=c.useState(!1),[b,E]=c.useState(void 0),[j,S]=c.useState(null),[C,_]=c.useState(null),[k,y]=c.useState(!1),M=((B=i==null?void 0:i.restrictions)==null?void 0:B.sign_up_mode)==="restricted",A=((Y=i==null?void 0:i.restrictions)==null?void 0:Y.sign_up_mode)==="waitlist",I=((ce=(X=i==null?void 0:i.auth_settings)==null?void 0:X.multi_session_support)==null?void 0:ce.enabled)??!1;c.useEffect(()=>{var oe;if(!f&&(d!=null&&d.active_signin)&&!I&&!k){y(!0);let G=new URLSearchParams(window.location.search).get("redirect_uri");G||(G=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),G&&h(G)}},[d,f,I,i,h,k]),c.useEffect(()=>{var pe;if(!i)return;const G=new URLSearchParams(window.location.search).get("invite_token");if(A&&!G){y(!0);const fe=((pe=i.ui_settings)==null?void 0:pe.waitlist_page_url)||`https://${i.frontend_host}/waitlist`;h(fe);return}G&&!j&&r&&(_(G),r.validateDeploymentInvitation(G).then(fe=>{S(fe),fe.valid&&m(q=>({...q,first_name:fe.first_name||q.first_name,last_name:fe.last_name||q.last_name,email:fe.email||q.email}))}).catch(()=>{v(fe=>({...fe,submit:"Failed to validate invitation."}))}))},[i,A,h,j,r]);const[P,L]=c.useState(!1),[T,$]=c.useState(""),z=oe=>{let{name:G,value:pe}=oe.target;G==="phone_number"?pe=pe.replace(/[^0-9-]/g,""):G==="email"&&(pe=pe.toLowerCase()),m(fe=>({...fe,[G]:pe})),v(fe=>({...fe,[G]:""}))},H=()=>{m({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),L(!1),$(""),n()},F=async oe=>{if(oe.preventDefault(),e||w)return;const G={},pe=/^[a-zA-Z]{3,30}$/,fe=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,q=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,de=/^\d{7,15}$/,Be=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(R!=null&&R.first_name.enabled&&(R!=null&&R.first_name.required&&!p.first_name?G.first_name="First name is required":p.first_name&&!pe.test(p.first_name)&&(G.first_name="Invalid name")),R!=null&&R.last_name.enabled&&(R!=null&&R.last_name.required&&!p.last_name?G.last_name="Last name is required":p.last_name&&!pe.test(p.last_name)&&(G.last_name="Invalid last name")),R!=null&&R.username.enabled&&(R!=null&&R.username.required&&!p.username?G.username="Username is required":p.username&&!fe.test(p.username)&&(G.username="Username must be 3-20 characters")),R!=null&&R.email_address.enabled&&(R!=null&&R.email_address.required&&!p.email?G.email="Email address is required":p.email&&!q.test(p.email)&&(G.email="Invalid email address")),R!=null&&R.phone_number.enabled&&(R!=null&&R.phone_number.required&&!p.phone_number?G.phone_number="Phone number is required":p.phone_number&&!de.test(p.phone_number)&&(G.phone_number="Phone number must contain 7-15 digits")),R!=null&&R.password.enabled&&(p.password?Be.test(p.password)||(G.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):G.password="Password is required"),v(G),!(Object.keys(G).length>0)){x(!0);try{const We={...p};p.phone_number&&b&&(We.phone_country_code=b),C&&(We.invite_token=C),await r.create(We)}catch(We){v({submit:We.message})}finally{x(!1)}}},O=async oe=>{if(!(e||w)){x(!0);try{const pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:fe}=await s.create({provider:oe.provider,redirectUri:pe});fe&&typeof fe=="object"&&"oauth_url"in fe&&(window.location.href=fe.oauth_url)}catch(G){v({submit:G.message})}finally{x(!1)}}},Z=(i==null?void 0:i.social_connections.filter(oe=>oe.enabled))||[],R=i==null?void 0:i.auth_settings,W=!!((me=R==null?void 0:R.first_name)!=null&&me.enabled&&((te=R==null?void 0:R.last_name)!=null&&te.enabled)),D=async oe=>{var pe;if(oe.preventDefault(),e||w)return;x(!0);const G={};if(!T){G.otp="OTP code is required",v(G),x(!1);return}v(G);try{const fe=await r.completeVerification(T);"data"in fe&&((pe=fe.data)!=null&&pe.active_signin)&&await u()}catch{v(fe=>({...fe,submit:"Verification failed. Please try again."}))}finally{x(!1)}};return c.useEffect(()=>{var oe;if(a){if(a.completed){let G=new URLSearchParams(window.location.search).get("redirect_uri");if(G||(G=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signup_redirect_url)||null),!G&&(i!=null&&i.frontend_host)&&(G=`https://${i.frontend_host}`),G){let pe;try{pe=new URL(G)}catch{pe=new URL(G,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&pe.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(pe.toString())}return}if(!P){switch(a.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}L(!0)}}},[a,r,P,i,d,h]),f?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx($i,{children:t.jsx(wt,{size:32})})]})}):k?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx($i,{children:t.jsx(wt,{size:32})})]})}):M?t.jsx(ge,{children:t.jsxs(Da,{children:[t.jsx(Je,{}),t.jsx(co,{children:t.jsx(lo,{children:"Sign up Restricted!"})}),t.jsx(gm,{children:t.jsx(vm,{children:"New account registration is currently restricted. Please check back later."})}),t.jsx(xm,{children:t.jsxs(bm,{children:["Need assistance?"," ",t.jsx(wm,{href:(xe=i==null?void 0:i.ui_settings)!=null&&xe.sign_in_page_url?`${i.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):t.jsx(ge,{children:t.jsx(Da,{children:P?t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(co,{children:[!((re=i==null?void 0:i.ui_settings)!=null&&re.logo_image_url)&&t.jsx(ym,{children:(a==null?void 0:a.current_step)==="verify_phone"?t.jsx(As,{weight:"light"}):t.jsx(In,{weight:"light"})}),t.jsx(lo,{children:(a==null?void 0:a.current_step)==="verify_phone"?"Check your phone":"Enter the code"}),t.jsx(Mi,{children:(a==null?void 0:a.current_step)==="verify_phone"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email."}),t.jsx(jm,{children:t.jsxs(_m,{type:"button",onClick:H,children:[t.jsx(cs,{weight:"light"}),(a==null?void 0:a.current_step)==="verify_phone"?`+${p.phone_number}`:p.email]})})]}),t.jsxs(Li,{onSubmit:D,noValidate:!0,children:[t.jsx(lr,{onComplete:async oe=>{$(oe)},onResend:async()=>{const oe=(a==null?void 0:a.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:oe})},error:g.otp,isSubmitting:w}),t.jsx(Ri,{type:"submit",disabled:w||e||!T,children:w&&T?t.jsx(zi,{size:16}):`Continue to ${(U=i==null?void 0:i.ui_settings)==null?void 0:U.app_name}`})]}),t.jsxs(Pi,{children:["Having trouble?"," ",t.jsx(Ti,{children:t.jsx(Pt,{to:i.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(co,{children:[t.jsx(lo,{children:"Create your account"}),t.jsx(Mi,{children:j!=null&&j.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ms,{connections:Z,callback:O}),t.jsx(pm,{children:t.jsx(hm,{children:"or"})})]}),t.jsxs(Li,{onSubmit:F,noValidate:!0,children:[(((Qe=R==null?void 0:R.first_name)==null?void 0:Qe.enabled)||((Te=R==null?void 0:R.last_name)==null?void 0:Te.enabled))&&t.jsxs(fm,{$isBothEnabled:W,children:[((Ve=R==null?void 0:R.first_name)==null?void 0:Ve.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"first_name",children:["First name",((Ue=R==null?void 0:R.first_name)==null?void 0:Ue.required)&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:p.first_name,onChange:z,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&t.jsx(mr,{children:g.first_name})]}),((ve=R==null?void 0:R.last_name)==null?void 0:ve.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"last_name",children:["Last name",((J=R==null?void 0:R.last_name)==null?void 0:J.required)&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:p.last_name,onChange:z,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&t.jsx(mr,{children:g.last_name})]})]}),(R==null?void 0:R.username.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"username",children:["Username",R.username.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:p.username,onChange:z,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&t.jsx(mr,{children:g.username})]}),(R==null?void 0:R.email_address.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"email",children:["Email address",R.email_address.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(ue,{type:"email",id:"email",name:"email",maxLength:320,value:p.email,onChange:z,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(j==null?void 0:j.valid)&&!!(j!=null&&j.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&t.jsx(mr,{children:g.email})]}),(R==null?void 0:R.phone_number.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"phone_number",children:["Phone number",R.phone_number.required&&t.jsx(Dr,{children:"*"})]}),t.jsx($a,{value:p.phone_number,onChange:z,error:g.phone_number,countryCode:b,setCountryCode:E}),g.phone_number&&t.jsx(mr,{children:g.phone_number})]}),(R==null?void 0:R.password.enabled)&&t.jsxs(Hr,{children:[t.jsxs(Vr,{htmlFor:"password",children:["Password",R.password.required&&t.jsx(Dr,{children:"*"})]}),t.jsx(mm,{children:t.jsx(ue,{type:"password",id:"password",name:"password",value:p.password,onChange:z,placeholder:"Enter your password","aria-invalid":!!g.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),g.password&&t.jsx(mr,{children:g.password})]}),g.submit&&t.jsx(mr,{children:g.submit}),t.jsx(Ri,{type:"submit",disabled:w||e,children:w?t.jsx(zi,{size:16}):"Continue"})]}),t.jsxs(Pi,{children:["Already have an account?"," ",t.jsx(Ti,{children:t.jsx(Pt,{to:`${(le=i.ui_settings)==null?void 0:le.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const h1=c.createContext(void 0),f1=()=>{const e=c.useContext(h1);if(!e)throw new Error("Dialog components must be used within a Dialog");return e},Cm=l.div`
834
834
  position: fixed;
835
835
  inset: 0;
836
836
  background-color: var(--color-dialog-backdrop);
@@ -1301,7 +1301,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
1301
1301
  &:hover {
1302
1302
  text-decoration: underline;
1303
1303
  }
1304
- `;function p4({onBack:e}){const{deployment:r}=Ae(),{navigate:a}=yt(),[n,s]=c.useState("start"),[i,h]=c.useState(""),[d,u]=c.useState(""),[f,p]=c.useState(""),[m,g]=c.useState(""),[v,w]=c.useState(""),{forgotPassword:x,verifyOtp:b,resetPassword:E}=w0(),[j,S]=c.useState(!1),[C,_]=c.useState(null),k=async F=>{if(F.preventDefault(),!!i){S(!0),_(null);try{await x(i),s("otp")}catch(I){_(I)}finally{S(!1)}}},y=async F=>{if(F.preventDefault(),d.length===6){S(!0),_(null);try{const I=await b(i,d);I.data&&(p(I.data.token),s("reset"))}catch(I){_(I)}finally{S(!1)}}},M=async F=>{var I,R;if(F.preventDefault(),m===v&&!(m.length<8)){S(!0),_(null);try{const T=await E(f,m);if(T.data){const $=T.data,z=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(z&&!z.completed){const H=(I=r==null?void 0:r.ui_settings)==null?void 0:I.sign_in_page_url;if(H){const P=new URL(H,window.location.origin);P.searchParams.set("signin_attempt_id",z.id),a(P.toString())}else e()}else{const H=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";a(H)}}}catch(T){_(T)}finally{S(!1)}}},A=()=>t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsx(Na,{children:t.jsx(Ua,{children:"Forgot Password"})}),t.jsx(l4,{onClick:()=>s("email"),disabled:j,children:"Reset your password"}),t.jsx(d4,{children:t.jsx(u4,{children:"Or, sign in with another method"})}),t.jsx(z1,{}),t.jsxs(Ba,{children:[t.jsxs(da,{children:["Unable to reset password? ",t.jsx(ua,{href:"/contact",children:"Get help"})]}),t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})]})]});return t.jsx(ge,{children:t.jsxs(c4,{children:[n==="start"&&A(),n==="email"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Forgot Password"}),t.jsx(po,{children:"Enter your email address and we'll send you a code to reset your password."})]}),t.jsxs(Ft,{onSubmit:k,noValidate:!0,children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"email",children:"Email Address"}),t.jsx(ue,{type:"email",id:"email",value:i,onChange:F=>h(F.target.value),placeholder:"Enter your email",required:!0})]}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Send Code"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Enter Verification Code"}),t.jsxs(po,{children:["We've sent a 6-digit code to ",i,". Please enter it below."]})]}),t.jsxs(Ft,{onSubmit:y,noValidate:!0,children:[t.jsx(lr,{onComplete:F=>u(F),isSubmitting:j,error:C==null?void 0:C.message,onResend:async()=>{await x(i)}}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j||d.length!==6,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Verify"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Reset Password"}),t.jsx(po,{children:"Create a new password for your account."})]}),t.jsxs(Ft,{onSubmit:M,noValidate:!0,children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"password",children:"New Password"}),t.jsx(ue,{type:"password",id:"password",value:m,onChange:F=>g(F.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"confirmPassword",children:"Confirm New Password"}),t.jsx(ue,{type:"password",id:"confirmPassword",value:v,onChange:F=>w(F.target.value),placeholder:"Confirm new password",required:!0})]}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Reset Password"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const h4=l.div`
1304
+ `;function p4({onBack:e}){const{deployment:r}=Ae(),{navigate:a}=yt(),[n,s]=c.useState("start"),[i,h]=c.useState(""),[d,u]=c.useState(""),[f,p]=c.useState(""),[m,g]=c.useState(""),[v,w]=c.useState(""),{forgotPassword:x,verifyOtp:b,resetPassword:E}=w0(),[j,S]=c.useState(!1),[C,_]=c.useState(null),k=async I=>{if(I.preventDefault(),!!i){S(!0),_(null);try{await x(i),s("otp")}catch(P){_(P)}finally{S(!1)}}},y=async I=>{if(I.preventDefault(),d.length===6){S(!0),_(null);try{const P=await b(i,d);P.data&&(p(P.data.token),s("reset"))}catch(P){_(P)}finally{S(!1)}}},M=async I=>{var P,L;if(I.preventDefault(),m===v&&!(m.length<8)){S(!0),_(null);try{const T=await E(f,m);if(T.data){const $=T.data,z=$.signin_attempts&&$.signin_attempts.length>0?$.signin_attempts[$.signin_attempts.length-1]:null;if(z&&!z.completed){const H=(P=r==null?void 0:r.ui_settings)==null?void 0:P.sign_in_page_url;if(H){const F=new URL(H,window.location.origin);F.searchParams.set("signin_attempt_id",z.id),a(F.toString())}else e()}else{const H=((L=r==null?void 0:r.ui_settings)==null?void 0:L.after_signin_redirect_url)||"/";a(H)}}}catch(T){_(T)}finally{S(!1)}}},A=()=>t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsx(Na,{children:t.jsx(Ua,{children:"Forgot Password"})}),t.jsx(l4,{onClick:()=>s("email"),disabled:j,children:"Reset your password"}),t.jsx(d4,{children:t.jsx(u4,{children:"Or, sign in with another method"})}),t.jsx(z1,{}),t.jsxs(Ba,{children:[t.jsxs(da,{children:["Unable to reset password? ",t.jsx(ua,{href:"/contact",children:"Get help"})]}),t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})]})]});return t.jsx(ge,{children:t.jsxs(c4,{children:[n==="start"&&A(),n==="email"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Forgot Password"}),t.jsx(po,{children:"Enter your email address and we'll send you a code to reset your password."})]}),t.jsxs(Ft,{onSubmit:k,noValidate:!0,children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"email",children:"Email Address"}),t.jsx(ue,{type:"email",id:"email",value:i,onChange:I=>h(I.target.value),placeholder:"Enter your email",required:!0})]}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Send Code"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Enter Verification Code"}),t.jsxs(po,{children:["We've sent a 6-digit code to ",i,". Please enter it below."]})]}),t.jsxs(Ft,{onSubmit:y,noValidate:!0,children:[t.jsx(lr,{onComplete:I=>u(I),isSubmitting:j,error:C==null?void 0:C.message,onResend:async()=>{await x(i)}}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j||d.length!==6,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Verify"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&t.jsxs(t.Fragment,{children:[t.jsx(Je,{}),t.jsxs(Na,{children:[t.jsx(Ua,{children:"Reset Password"}),t.jsx(po,{children:"Create a new password for your account."})]}),t.jsxs(Ft,{onSubmit:M,noValidate:!0,children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"password",children:"New Password"}),t.jsx(ue,{type:"password",id:"password",value:m,onChange:I=>g(I.target.value),placeholder:"Enter new password",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"confirmPassword",children:"Confirm New Password"}),t.jsx(ue,{type:"password",id:"confirmPassword",value:v,onChange:I=>w(I.target.value),placeholder:"Confirm new password",required:!0})]}),C&&t.jsx(ho,{children:C.message}),t.jsx(N,{type:"submit",$fullWidth:!0,disabled:j,style:{marginTop:"var(--space-6u)"},children:j?t.jsx(uo,{size:16}):"Reset Password"})]}),t.jsx(Ba,{children:t.jsx(da,{style:{marginTop:"var(--space-4u)"},children:t.jsx(ua,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const h4=l.div`
1305
1305
  ${Et}
1306
1306
  `,f4=l.div`
1307
1307
  margin-bottom: var(--space-8u);
@@ -1534,7 +1534,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
1534
1534
  }
1535
1535
  `,q4=l(ue)`
1536
1536
  padding: var(--space-4u) var(--space-6u);
1537
- `;function R1({onBack:e,attempt:r,completeVerification:a,prepareVerification:n}){const{deployment:s}=Ae(),[i,h]=c.useState(""),[d,u]=c.useState({}),[f,p]=c.useState(!1),[m,g]=c.useState(null),[v,w]=c.useState(!0),[x,b]=c.useState(!1),[E,j]=c.useState(""),[S,C]=c.useState(!1),{navigate:_}=yt(),k=(r==null?void 0:r.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(D4,{}),available:k.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(N4,{}),available:k.includes("phone_otp"),phoneNumber:E},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(U4,{}),available:k.includes("backup_code")}].filter(R=>R.available),M=async R=>{g(R),w(!1),R==="phone_otp"&&b(!0)},A=async R=>{var T,$;if(r){p(!0);try{const z=await n({strategy:"phone_otp",lastDigits:R});z&&"data"in z&&((T=z.data)!=null&&T.otp_sent)?(($=z.data)!=null&&$.masked_phone&&j(z.data.masked_phone),b(!1)):u({phone:"Phone number verification failed"})}catch(z){u({phone:z.message})}finally{p(!1)}}},F=async(R,T)=>{if(R.preventDefault(),f)return;const $=T||i,z={};if($?m==="authenticator"&&$.length!==6?z.code="Authentication code must be 6 digits":m==="phone_otp"&&$.length!==6&&(z.code="SMS code must be 6 digits"):z.code="Verification code is required",u(z),!(Object.keys(z).length>0)){p(!0);try{await a($)}catch(H){u({submit:H.message})}finally{p(!1)}}},I=R=>{let T=R.target.value;m!=="backup_code"&&(T=T.replace(/\D/g,"").slice(0,6)),h(T),u($=>({...$,code:""}))};return c.useEffect(()=>{var R;if(r.completed){C(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!T&&(s!=null&&s.frontend_host)&&(T=`https://${s.frontend_host}`),T){let $;try{$=new URL(T)}catch{$=new URL(T,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&$.searchParams.set("__dev_session__",ht(s.backend_host)||""),_($.toString())}return}},[r,s]),S?t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsx(W4,{children:t.jsx(wt,{size:32})})]})}):v?y.length===0?t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsxs(Fi,{children:[t.jsx(Ii,{children:"Set Up Two-Factor Authentication"}),t.jsx(Zi,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),t.jsxs(Hi,{children:[e&&t.jsx("div",{children:t.jsx(pa,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(pa,{children:t.jsx(Pt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):t.jsx($1,{methods:y,onSelectMethod:M,onBack:e}):x&&m==="phone_otp"?t.jsx(M1,{onVerify:A,onBack:()=>{b(!1),w(!0),g(null)},loading:f}):t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsxs(Fi,{children:[t.jsx(Ii,{children:"Two-factor authentication"}),t.jsxs(Zi,{children:[m==="authenticator"&&"Enter the 6-digit code from your authenticator app",m==="phone_otp"&&`Enter the 6-digit code sent to your phone ${E}`,m==="backup_code"&&"Enter one of your backup codes"]})]}),t.jsxs(Ft,{onSubmit:F,noValidate:!0,children:[m==="backup_code"?t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"code",children:"Backup code"}),t.jsx(q4,{type:"text",id:"code",name:"code",value:i,onChange:I,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!d.code,autoFocus:!0}),d.code&&t.jsx(Oi,{children:d.code})]}):t.jsx(lr,{onComplete:async R=>{if(h(R),m!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await F(T,R)}},onResend:m==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:E.slice(-4)})}catch(R){u({submit:R.message})}}:void 0,error:d.code,isSubmitting:f}),t.jsxs("div",{children:[d.submit&&t.jsx(Oi,{children:d.submit}),t.jsx(G4,{type:"submit",disabled:f||!i,children:f?t.jsx(B4,{size:16}):"Verify"})]})]}),t.jsxs(Hi,{children:[t.jsx(pa,{onClick:()=>{w(!0),g(null),h(""),u({})},style:{cursor:"pointer"},children:"Try another method"}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(pa,{children:t.jsx(Pt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),e&&t.jsx("div",{style:{marginTop:"var(--space-4u)"},children:t.jsx(pa,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const K4=mt`
1537
+ `;function R1({onBack:e,attempt:r,completeVerification:a,prepareVerification:n}){const{deployment:s}=Ae(),[i,h]=c.useState(""),[d,u]=c.useState({}),[f,p]=c.useState(!1),[m,g]=c.useState(null),[v,w]=c.useState(!0),[x,b]=c.useState(!1),[E,j]=c.useState(""),[S,C]=c.useState(!1),{navigate:_}=yt(),k=(r==null?void 0:r.available_2fa_methods)||[],y=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:t.jsx(D4,{}),available:k.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:t.jsx(N4,{}),available:k.includes("phone_otp"),phoneNumber:E},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:t.jsx(U4,{}),available:k.includes("backup_code")}].filter(L=>L.available),M=async L=>{g(L),w(!1),L==="phone_otp"&&b(!0)},A=async L=>{var T,$;if(r){p(!0);try{const z=await n({strategy:"phone_otp",lastDigits:L});z&&"data"in z&&((T=z.data)!=null&&T.otp_sent)?(($=z.data)!=null&&$.masked_phone&&j(z.data.masked_phone),b(!1)):u({phone:"Phone number verification failed"})}catch(z){u({phone:z.message})}finally{p(!1)}}},I=async(L,T)=>{if(L.preventDefault(),f)return;const $=T||i,z={};if($?m==="authenticator"&&$.length!==6?z.code="Authentication code must be 6 digits":m==="phone_otp"&&$.length!==6&&(z.code="SMS code must be 6 digits"):z.code="Verification code is required",u(z),!(Object.keys(z).length>0)){p(!0);try{await a($)}catch(H){u({submit:H.message})}finally{p(!1)}}},P=L=>{let T=L.target.value;m!=="backup_code"&&(T=T.replace(/\D/g,"").slice(0,6)),h(T),u($=>({...$,code:""}))};return c.useEffect(()=>{var L;if(r.completed){C(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((L=s==null?void 0:s.ui_settings)==null?void 0:L.after_signin_redirect_url)||null),!T&&(s!=null&&s.frontend_host)&&(T=`https://${s.frontend_host}`),T){let $;try{$=new URL(T)}catch{$=new URL(T,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&$.searchParams.set("__dev_session__",ht(s.backend_host)||""),_($.toString())}return}},[r,s]),S?t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsx(W4,{children:t.jsx(wt,{size:32})})]})}):v?y.length===0?t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsxs(Fi,{children:[t.jsx(Ii,{children:"Set Up Two-Factor Authentication"}),t.jsx(Zi,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),t.jsxs(Hi,{children:[e&&t.jsx("div",{children:t.jsx(pa,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(pa,{children:t.jsx(Pt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):t.jsx($1,{methods:y,onSelectMethod:M,onBack:e}):x&&m==="phone_otp"?t.jsx(M1,{onVerify:A,onBack:()=>{b(!1),w(!0),g(null)},loading:f}):t.jsx(ge,{children:t.jsxs(fo,{children:[t.jsx(Je,{}),t.jsxs(Fi,{children:[t.jsx(Ii,{children:"Two-factor authentication"}),t.jsxs(Zi,{children:[m==="authenticator"&&"Enter the 6-digit code from your authenticator app",m==="phone_otp"&&`Enter the 6-digit code sent to your phone ${E}`,m==="backup_code"&&"Enter one of your backup codes"]})]}),t.jsxs(Ft,{onSubmit:I,noValidate:!0,children:[m==="backup_code"?t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"code",children:"Backup code"}),t.jsx(q4,{type:"text",id:"code",name:"code",value:i,onChange:P,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!d.code,autoFocus:!0}),d.code&&t.jsx(Oi,{children:d.code})]}):t.jsx(lr,{onComplete:async L=>{if(h(L),m!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await I(T,L)}},onResend:m==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:E.slice(-4)})}catch(L){u({submit:L.message})}}:void 0,error:d.code,isSubmitting:f}),t.jsxs("div",{children:[d.submit&&t.jsx(Oi,{children:d.submit}),t.jsx(G4,{type:"submit",disabled:f||!i,children:f?t.jsx(B4,{size:16}):"Verify"})]})]}),t.jsxs(Hi,{children:[t.jsx(pa,{onClick:()=>{w(!0),g(null),h(""),u({})},style:{cursor:"pointer"},children:"Try another method"}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(pa,{children:t.jsx(Pt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),e&&t.jsx("div",{style:{marginTop:"var(--space-4u)"},children:t.jsx(pa,{onClick:e,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const K4=mt`
1538
1538
  from { transform: rotate(0deg); }
1539
1539
  to { transform: rotate(360deg); }
1540
1540
  `,Y4=l(wt)`
@@ -1599,7 +1599,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
1599
1599
  transform: rotate(360deg);
1600
1600
  }
1601
1601
  }
1602
- `;function P1({attempt:e,onBack:r,completeProfile:a,completeVerification:n,prepareVerification:s}){var O,Z,L,W,D,B,Y,X,ce;const{deployment:i}=Ae(),{navigate:h}=yt(),[d,u]=c.useState({}),[f,p]=c.useState({}),[m,g]=c.useState("US"),[v,w]=c.useState(!1),[x,b]=c.useState(!1),[E,j]=c.useState(null),[S,C]=c.useState(!1),_=E,k=x,y=async me=>{var te;b(!0),j(null);try{if(await a(me)){C(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((te=i==null?void 0:i.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!re&&(i!=null&&i.frontend_host)&&(re=`https://${i.frontend_host}`),re){let U;try{U=new URL(re)}catch{U=new URL(re,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&U.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(U.toString())}}}catch(xe){const re=xe;throw j(re),re}finally{b(!1)}},M=async me=>{var te;b(!0),j(null);try{if(await n(me)){C(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((te=i==null?void 0:i.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!re&&(i!=null&&i.frontend_host)&&(re=`https://${i.frontend_host}`),re){let U;try{U=new URL(re)}catch{U=new URL(re,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&U.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(U.toString())}}return!0}catch(xe){return j(xe),!1}finally{b(!1)}};if(S||!e)return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsx(X4,{children:t.jsx(wt,{size:32})})]})});const A=e.missing_fields||[],F="Complete Your Profile",I="Please provide the following information to continue",R=i==null?void 0:i.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||v,$=me=>{const{name:te,value:xe}=me.target;u(re=>({...re,[te]:xe})),f[te]&&p(re=>({...re,[te]:""}))},z=()=>{const me={};return A.forEach(te=>{var U,Qe,Te,Ve,Ue;const xe=d[te];let re=!1;switch(te){case"first_name":re=((U=R==null?void 0:R.first_name)==null?void 0:U.enabled)||!1;break;case"last_name":re=((Qe=R==null?void 0:R.last_name)==null?void 0:Qe.enabled)||!1;break;case"username":re=((Te=R==null?void 0:R.username)==null?void 0:Te.enabled)||!1;break;case"phone_number":re=((Ve=R==null?void 0:R.phone_number)==null?void 0:Ve.enabled)||!1;break;case"email_address":re=((Ue=R==null?void 0:R.email_address)==null?void 0:Ue.enabled)||!1;break;default:re=!0}if(re&&(!xe||xe.trim()==="")){const ve=te.replace("_"," ").replace(/\b\w/g,J=>J.toUpperCase());me[te]=`${ve} is required`}}),d.username&&A.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(d.username)||(me.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),d.phone_number&&A.includes("phone_number")&&(/^\d{7,15}$/.test(d.phone_number)||(me.phone_number="Phone number must contain 7-15 digits")),d.email&&A.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(d.email)||(me.email_address="Please enter a valid email address")),p(me),Object.keys(me).length===0},H=async me=>{if(me.preventDefault(),!z())return;const te={...d};d.phone_number&&m&&(te.phone_country_code=m),await y(te)},P=me=>{const te=me.target.value;u(xe=>({...xe,phone_number:te})),f.phone_number&&p(xe=>({...xe,phone_number:""}))};if(T){const me=e.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",xe=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsxs(Vi,{children:[t.jsx(Di,{children:me}),t.jsx(Ni,{children:te})]}),t.jsxs(Ft,{onSubmit:re=>re.preventDefault(),noValidate:!0,children:[t.jsx(lr,{onComplete:M,onResend:async()=>{await s({strategy:xe})},error:_==null?void 0:_.message,isSubmitting:k}),_&&t.jsx(gr,{style:{marginBottom:"var(--space-6u)"},children:_.message})]}),t.jsxs(Ui,{children:[t.jsx("div",{children:t.jsx(Wa,{onClick:()=>w(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(Wa,{children:t.jsx(Pt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsxs(Vi,{children:[t.jsx(Di,{children:F}),t.jsx(Ni,{children:I})]}),t.jsxs(Ft,{onSubmit:H,noValidate:!0,children:[(A.includes("first_name")||A.includes("last_name"))&&(((O=R==null?void 0:R.first_name)==null?void 0:O.enabled)||((Z=R==null?void 0:R.last_name)==null?void 0:Z.enabled))&&t.jsxs(Q4,{$isBothEnabled:!!((L=R==null?void 0:R.first_name)!=null&&L.enabled&&((W=R==null?void 0:R.last_name)!=null&&W.enabled)&&A.includes("first_name")&&A.includes("last_name")),children:[A.includes("first_name")&&((D=R==null?void 0:R.first_name)==null?void 0:D.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",value:d.first_name||"",onChange:$,placeholder:"Enter your first name","aria-invalid":!!f.first_name,disabled:k,autoComplete:"given-name"}),f.first_name&&t.jsx(gr,{children:f.first_name})]}),A.includes("last_name")&&((B=R==null?void 0:R.last_name)==null?void 0:B.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",value:d.last_name||"",onChange:$,placeholder:"Enter your last name","aria-invalid":!!f.last_name,disabled:k,autoComplete:"family-name"}),f.last_name&&t.jsx(gr,{children:f.last_name})]})]}),A.includes("username")&&((Y=R==null?void 0:R.username)==null?void 0:Y.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),t.jsx(ue,{type:"text",id:"username",name:"username",value:d.username||"",onChange:$,placeholder:"Choose a username","aria-invalid":!!f.username,disabled:k,autoComplete:"username"}),f.username&&t.jsx(gr,{children:f.username})]}),A.includes("phone_number")&&((X=R==null?void 0:R.phone_number)==null?void 0:X.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),t.jsx($a,{value:d.phone_number||"",onChange:P,error:f.phone_number,countryCode:m,setCountryCode:g}),f.phone_number&&t.jsx(gr,{children:f.phone_number})]}),A.includes("email_address")&&((ce=R==null?void 0:R.email_address)==null?void 0:ce.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),t.jsx(ue,{type:"email",id:"email",name:"email",value:d.email||"",onChange:$,placeholder:"Enter your email address","aria-invalid":!!f.email_address,disabled:k,autoComplete:"email"}),f.email_address&&t.jsx(gr,{children:f.email_address})]}),_&&t.jsx(gr,{style:{marginBottom:"var(--space-6u)"},children:_.message}),t.jsx(J4,{type:"submit",disabled:k,children:k?t.jsx(Y4,{size:16}):"Continue"})]}),t.jsxs(Ui,{children:[r&&t.jsx("div",{children:t.jsx(Wa,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(Wa,{children:t.jsx(Pt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const eg=l.div`
1602
+ `;function P1({attempt:e,onBack:r,completeProfile:a,completeVerification:n,prepareVerification:s}){var O,Z,R,W,D,B,Y,X,ce;const{deployment:i}=Ae(),{navigate:h}=yt(),[d,u]=c.useState({}),[f,p]=c.useState({}),[m,g]=c.useState("US"),[v,w]=c.useState(!1),[x,b]=c.useState(!1),[E,j]=c.useState(null),[S,C]=c.useState(!1),_=E,k=x,y=async me=>{var te;b(!0),j(null);try{if(await a(me)){C(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((te=i==null?void 0:i.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!re&&(i!=null&&i.frontend_host)&&(re=`https://${i.frontend_host}`),re){let U;try{U=new URL(re)}catch{U=new URL(re,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&U.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(U.toString())}}}catch(xe){const re=xe;throw j(re),re}finally{b(!1)}},M=async me=>{var te;b(!0),j(null);try{if(await n(me)){C(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((te=i==null?void 0:i.ui_settings)==null?void 0:te.after_signin_redirect_url)||null),!re&&(i!=null&&i.frontend_host)&&(re=`https://${i.frontend_host}`),re){let U;try{U=new URL(re)}catch{U=new URL(re,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&U.searchParams.set("__dev_session__",ht(i.backend_host)||""),h(U.toString())}}return!0}catch(xe){return j(xe),!1}finally{b(!1)}};if(S||!e)return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsx(X4,{children:t.jsx(wt,{size:32})})]})});const A=e.missing_fields||[],I="Complete Your Profile",P="Please provide the following information to continue",L=i==null?void 0:i.auth_settings,T=(e==null?void 0:e.current_step)==="verify_phone_otp"||(e==null?void 0:e.current_step)==="verify_email_otp"||v,$=me=>{const{name:te,value:xe}=me.target;u(re=>({...re,[te]:xe})),f[te]&&p(re=>({...re,[te]:""}))},z=()=>{const me={};return A.forEach(te=>{var U,Qe,Te,Ve,Ue;const xe=d[te];let re=!1;switch(te){case"first_name":re=((U=L==null?void 0:L.first_name)==null?void 0:U.enabled)||!1;break;case"last_name":re=((Qe=L==null?void 0:L.last_name)==null?void 0:Qe.enabled)||!1;break;case"username":re=((Te=L==null?void 0:L.username)==null?void 0:Te.enabled)||!1;break;case"phone_number":re=((Ve=L==null?void 0:L.phone_number)==null?void 0:Ve.enabled)||!1;break;case"email_address":re=((Ue=L==null?void 0:L.email_address)==null?void 0:Ue.enabled)||!1;break;default:re=!0}if(re&&(!xe||xe.trim()==="")){const ve=te.replace("_"," ").replace(/\b\w/g,J=>J.toUpperCase());me[te]=`${ve} is required`}}),d.username&&A.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(d.username)||(me.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),d.phone_number&&A.includes("phone_number")&&(/^\d{7,15}$/.test(d.phone_number)||(me.phone_number="Phone number must contain 7-15 digits")),d.email&&A.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(d.email)||(me.email_address="Please enter a valid email address")),p(me),Object.keys(me).length===0},H=async me=>{if(me.preventDefault(),!z())return;const te={...d};d.phone_number&&m&&(te.phone_country_code=m),await y(te)},F=me=>{const te=me.target.value;u(xe=>({...xe,phone_number:te})),f.phone_number&&p(xe=>({...xe,phone_number:""}))};if(T){const me=e.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",te=e.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",xe=e.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsxs(Vi,{children:[t.jsx(Di,{children:me}),t.jsx(Ni,{children:te})]}),t.jsxs(Ft,{onSubmit:re=>re.preventDefault(),noValidate:!0,children:[t.jsx(lr,{onComplete:M,onResend:async()=>{await s({strategy:xe})},error:_==null?void 0:_.message,isSubmitting:k}),_&&t.jsx(gr,{style:{marginBottom:"var(--space-6u)"},children:_.message})]}),t.jsxs(Ui,{children:[t.jsx("div",{children:t.jsx(Wa,{onClick:()=>w(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(Wa,{children:t.jsx(Pt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return t.jsx(ge,{children:t.jsxs(mo,{children:[t.jsx(Je,{}),t.jsxs(Vi,{children:[t.jsx(Di,{children:I}),t.jsx(Ni,{children:P})]}),t.jsxs(Ft,{onSubmit:H,noValidate:!0,children:[(A.includes("first_name")||A.includes("last_name"))&&(((O=L==null?void 0:L.first_name)==null?void 0:O.enabled)||((Z=L==null?void 0:L.last_name)==null?void 0:Z.enabled))&&t.jsxs(Q4,{$isBothEnabled:!!((R=L==null?void 0:L.first_name)!=null&&R.enabled&&((W=L==null?void 0:L.last_name)!=null&&W.enabled)&&A.includes("first_name")&&A.includes("last_name")),children:[A.includes("first_name")&&((D=L==null?void 0:L.first_name)==null?void 0:D.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"first_name",children:["First name ",L.first_name.required&&"*"]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",value:d.first_name||"",onChange:$,placeholder:"Enter your first name","aria-invalid":!!f.first_name,disabled:k,autoComplete:"given-name"}),f.first_name&&t.jsx(gr,{children:f.first_name})]}),A.includes("last_name")&&((B=L==null?void 0:L.last_name)==null?void 0:B.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"last_name",children:["Last name ",L.last_name.required&&"*"]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",value:d.last_name||"",onChange:$,placeholder:"Enter your last name","aria-invalid":!!f.last_name,disabled:k,autoComplete:"family-name"}),f.last_name&&t.jsx(gr,{children:f.last_name})]})]}),A.includes("username")&&((Y=L==null?void 0:L.username)==null?void 0:Y.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"username",children:["Username ",L.username.required&&"*"]}),t.jsx(ue,{type:"text",id:"username",name:"username",value:d.username||"",onChange:$,placeholder:"Choose a username","aria-invalid":!!f.username,disabled:k,autoComplete:"username"}),f.username&&t.jsx(gr,{children:f.username})]}),A.includes("phone_number")&&((X=L==null?void 0:L.phone_number)==null?void 0:X.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"phone_number",children:["Phone number ",L.phone_number.required&&"*"]}),t.jsx($a,{value:d.phone_number||"",onChange:F,error:f.phone_number,countryCode:m,setCountryCode:g}),f.phone_number&&t.jsx(gr,{children:f.phone_number})]}),A.includes("email_address")&&((ce=L==null?void 0:L.email_address)==null?void 0:ce.enabled)&&t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"email",children:["Email address ",L.email_address.required&&"*"]}),t.jsx(ue,{type:"email",id:"email",name:"email",value:d.email||"",onChange:$,placeholder:"Enter your email address","aria-invalid":!!f.email_address,disabled:k,autoComplete:"email"}),f.email_address&&t.jsx(gr,{children:f.email_address})]}),_&&t.jsx(gr,{style:{marginBottom:"var(--space-6u)"},children:_.message}),t.jsx(J4,{type:"submit",disabled:k,children:k?t.jsx(Y4,{size:16}):"Continue"})]}),t.jsxs(Ui,{children:[r&&t.jsx("div",{children:t.jsx(Wa,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),t.jsxs("div",{style:{marginTop:"var(--space-4u)"},children:["Having trouble?"," ",t.jsx(Wa,{children:t.jsx(Pt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const eg=l.div`
1603
1603
  text-align: center;
1604
1604
  margin-bottom: var(--space-12u);
1605
1605
  `,tg=l.div`
@@ -2046,7 +2046,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
2046
2046
  &:hover {
2047
2047
  color: var(--color-primary-hover);
2048
2048
  }
2049
- `;function Mg(){return t.jsx(r4,{children:t.jsx(Lg,{})})}function Lg(){var Ge,dt,dr,ur,Qt,Jt,Nt,pr,hr,bt,ie,ye,Me,De,et,rt,ft,_t,ae,Re,tt,qe,kt;const{deployment:e}=Ae(),{navigate:r}=yt(),{session:a,loading:n,refetch:s,exchangeTicket:i,switchSignIn:h}=ot(),d=((dt=(Ge=e==null?void 0:e.auth_settings)==null?void 0:Ge.multi_session_support)==null?void 0:dt.enabled)??!1,{setEmail:u,otpSent:f,setOtpSent:p,showForgotPassword:m,setShowForgotPassword:g,showOtherOptions:v,setShowOtherOptions:w,enabledSocialsProviders:x,firstFactor:b,setFirstFactor:E,signInStep:j,setSignInStep:S}=A1(),{loading:C,signIn:_,signinAttempt:k,discardSignInAttempt:y,setSignInAttempt:M}=wa("generic"),{signIn:A}=wa("oauth"),{signIn:F}=wa("passkey"),[I,R]=c.useState({email:"",username:"",password:"",phone:""}),[T,$]=c.useState({}),[z,H]=c.useState(!1),[P,O]=c.useState(""),[Z,L]=c.useState("US"),[W,D]=c.useState(!1),[B,Y]=c.useState(null),[X,ce]=c.useState(!1),[me,te]=c.useState(!1),[xe,re]=c.useState(!1),[U,Qe]=c.useState(60),[Te,Ve]=c.useState(!1),[Ue,ve]=c.useState(null),J=[...(a==null?void 0:a.signins)||[]].sort((K,ee)=>{var ne,Fe;return K.id===((ne=a==null?void 0:a.active_signin)==null?void 0:ne.id)?-1:ee.id===((Fe=a==null?void 0:a.active_signin)==null?void 0:Fe.id)?1:0});c.useEffect(()=>{const K=new URLSearchParams(window.location.search),ee=K.get("error"),ne=K.get("error_description");if(ee==="access_denied"&&ne){Y(ne),K.delete("error"),K.delete("error_description");const Fe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Fe)}},[]),c.useEffect(()=>{if(b!=="email_magic_link"||!f)return;Qe(60),Ve(!1);const K=setInterval(()=>{Qe(ee=>ee<=1?(Ve(!0),clearInterval(K),0):ee-1)},1e3);return()=>clearInterval(K)},[b,f]),c.useEffect(()=>{var K,ee,ne,Fe;if(!n&&(a!=null&&a.active_signin)&&!d&&!W&&!X){let Pe=new URLSearchParams(window.location.search).get("redirect_uri");Pe||(Pe=((K=e==null?void 0:e.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!Pe&&(e!=null&&e.frontend_host)&&(Pe=`https://${e.frontend_host}`);const at=(ee=e==null?void 0:e.auth_settings)==null?void 0:ee.passkey;(at==null?void 0:at.enabled)&&(at==null?void 0:at.prompt_registration_on_auth)&&!((Fe=(ne=a.active_signin)==null?void 0:ne.user)!=null&&Fe.has_passkeys)?(ve(Pe),ce(!0)):Pe&&(D(!0),r(Pe))}},[a,n,d,e,r,W]);const le=K=>{let{name:ee,value:ne}=K.target;ee==="phone"?ne=ne.replace(/[^0-9]/g,""):ee==="email"&&(u(ne),ne=ne.toLowerCase()),R(Fe=>({...Fe,[ee]:ne})),$(Fe=>({...Fe,[ee]:""}))},oe=()=>{R({email:"",username:"",password:"",phone:""}),$({}),L("US"),S("identifier")},G=async K=>{if(!K){$({email:"Email address is required"});return}H(!0),$({});try{const ee=await _.identify(K);if(ee.strategy==="sso"&&ee.connection_id){const Fe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Pe=await _.initEnterpriseSso(ee.connection_id,Fe);if(Pe&&Pe.sso_url){D(!0),window.location.href=Pe.sso_url;return}}else if(ee.strategy==="social"&&ee.provider){const ne=x.find(Fe=>Fe.provider===ee.provider);if(ne){const Pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:at}=await A.create({provider:ne.provider,redirectUri:Pe});if(at&&typeof at=="object"&&"oauth_url"in at){D(!0),window.location.href=at.oauth_url;return}}else S("password")}else S("password")}catch(ee){$({submit:ee.message})}finally{W||H(!1)}},pe=async K=>{if(K.preventDefault(),C||z)return;y();const ee={};if(j==="identifier"&&b==="email_password"){if(!I.email){$({email:"Email address is required"});return}await G(I.email);return}if(b==="email_password"?(I.email||(ee.email="Email address is required"),I.password||(ee.password="Password is required")):b==="username_password"?(I.username||(ee.username="Username is required"),I.password||(ee.password="Password is required")):b==="email_otp"||b==="email_magic_link"?I.email||(ee.email="Email address is required"):b==="phone_otp"&&(I.phone?/^\d{7,15}$/.test(I.phone)||(ee.phone="Phone number must contain 7-15 digits"):ee.phone="Phone number is required"),$(ee),Object.keys(ee).length>0)return;let ne="";switch(b){case"email_password":ne="plain_email";break;case"username_password":ne="plain_username";break;case"email_otp":ne="email_otp";break;case"email_magic_link":ne="magic_link";break;case"phone_otp":ne="phone_otp";break}const Fe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";H(!0);try{const Pe={...I,strategy:ne};b==="phone_otp"&&Z&&(Pe.phone_country_code=Z),await _.create(Pe),Fe||H(!1)}catch(Pe){$({submit:Pe.message}),H(!1)}},fe=async K=>{if(K.preventDefault(),C||z)return;const ee={};if(!P){ee.otp="OTP code is required",$(ee);return}H(!0),$({});try{await _.completeVerification(P),p(!1),O("")}catch(ne){$({otp:ne.message||"Verification failed"})}finally{H(!1)}},q=async K=>{if(!(C||z)){H(!0);try{const ne=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Fe}=await A.create({provider:K.provider,redirectUri:ne});Fe&&typeof Fe=="object"&&"oauth_url"in Fe&&(window.location.href=Fe.oauth_url)}catch(ee){$({submit:ee.message})}finally{H(!1)}}},de=async()=>{var K;if(!(C||z)){H(!0),$({});try{const ee=await F.create();if("data"in ee&&ee.data){await s();let ne=new URLSearchParams(window.location.search).get("redirect_uri");ne||(ne=((K=e==null?void 0:e.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!ne&&(e!=null&&e.frontend_host)&&(ne=`https://${e.frontend_host}`),D(!0),ne&&r(ne)}}catch(ee){$({submit:ee.message||"Passkey sign-in failed"})}finally{H(!1)}}},Be=()=>{var ne;let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((ne=e==null?void 0:e.ui_settings)==null?void 0:ne.after_signin_redirect_url)||null),!K&&(e!=null&&e.frontend_host)&&(K=`https://${e.frontend_host}`),!K)return null;let ee;try{ee=new URL(K)}catch{ee=new URL(K,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&ee.searchParams.set("__dev_session__",ht(e.backend_host)||""),ee.toString()},We=async K=>{if(!(C||z)){$({}),H(!0);try{await h(K);const ee=Be();ee&&(D(!0),r(ee))}catch(ee){$({submit:ee.message||"Failed to continue with selected account"})}finally{H(!1)}}},Q=(K,ee)=>`${K||""} ${ee||""}`.trim().split(" ").filter(Boolean).map(ne=>ne[0]).join("").toUpperCase().slice(0,2)||"?",se=c.useRef(!1);if(c.useEffect(()=>{if(n)return;const K=new URLSearchParams(window.location.search),ee=K.get("ticket");if(ee&&!se.current&&!C){se.current=!0,K.delete("ticket");const Fe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Fe),(async()=>{var at;try{H(!0),await i(ee),D(!0);let vt=new URLSearchParams(window.location.search).get("redirect_uri");if(vt||(vt=((at=e==null?void 0:e.ui_settings)==null?void 0:at.after_signin_redirect_url)||null),!vt&&(e!=null&&e.frontend_host)&&(vt=`https://${e.frontend_host}`),vt){let Pa;try{Pa=new URL(vt)}catch{Pa=new URL(vt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Pa.searchParams.set("__dev_session__",ht(e.backend_host)||""),r(Pa.toString())}return}catch(vt){$({submit:vt.message||"Failed to exchange ticket"}),se.current=!1}finally{H(!1)}})();return}const ne=K.get("signin_attempt_id");if(ne&&(a!=null&&a.signin_attempts)&&!k){const Fe=a.signin_attempts.find(Pe=>Pe.id===ne);if(Fe){M(Fe),K.delete("signin_attempt_id");const Pe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe)}}},[a,n,k,M,C]),c.useEffect(()=>{var Fe;if(!k)return;if(k.completed){D(!0);let Pe=new URLSearchParams(window.location.search).get("redirect_uri");if(Pe||(Pe=((Fe=e==null?void 0:e.ui_settings)==null?void 0:Fe.after_signin_redirect_url)||null),!Pe&&(e!=null&&e.frontend_host)&&(Pe=`https://${e.frontend_host}`),Pe){let at;try{at=new URL(Pe)}catch{at=new URL(Pe,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&at.searchParams.set("__dev_session__",ht(e.backend_host)||""),r(at.toString())}return}if(!_||f)return;const ee={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[k.current_step];if(!ee)return;(async()=>{try{await _.prepareVerification({strategy:ee}),H(!1),p(!0)}catch{$({submit:"Failed to send verification. Please try again."}),H(!1)}})()},[k,_,f,p,r,e]),v)return t.jsx(b4,{onBack:()=>w(!1)});if(m)return t.jsx(p4,{onBack:()=>g(!1)});if((k==null?void 0:k.current_step)==="verify_second_factor")return t.jsx(R1,{attempt:k,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),oe(),p(!1)}});if((k==null?void 0:k.current_step)==="complete_profile")return t.jsx(P1,{attempt:k,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),oe(),p(!1)}});if(X){const K=()=>{ce(!1),Ue&&(D(!0),r(Ue))},ee=()=>{ce(!1),Ue&&(D(!0),r(Ue))};return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(T1,{onComplete:K,onSkip:ee})]})})}if(n)return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(Bi,{children:t.jsx(wt,{size:32})})]})});if(W)return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(Bi,{children:t.jsx(wt,{size:32})})]})});const je=(k==null?void 0:k.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(k.current_step)&&f,ke=d&&!je&&J.length>0&&!xe;return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),je?t.jsxs(Wi,{children:[!((dr=e==null?void 0:e.ui_settings)!=null&&dr.logo_image_url)&&t.jsx(_g,{children:b==="phone_otp"?t.jsx(As,{weight:"light"}):t.jsx(In,{weight:"light"})}),t.jsx(Gi,{children:b==="phone_otp"?"Check your phone":b==="email_magic_link"?"Check your inbox":"Enter the code"}),t.jsx(qi,{children:b==="email_magic_link"?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email."}),(b==="email_otp"||b==="email_magic_link")&&I.email&&t.jsx(rc,{children:t.jsxs(ac,{type:"button",onClick:()=>{p(!1),y(),oe()},children:[t.jsx(cs,{weight:"light"}),I.email]})}),b==="phone_otp"&&I.phone&&t.jsx(rc,{children:t.jsxs(ac,{type:"button",onClick:()=>{p(!1),y(),oe()},children:[t.jsx(cs,{weight:"light"}),"+",I.phone]})})]}):t.jsxs(Wi,{children:[t.jsx(Gi,{children:"Sign in to your account"}),t.jsxs(qi,{children:["Please enter your details to continue to"," ",(e==null?void 0:e.ui_settings.app_name)||"App","!"]})]}),B&&t.jsxs(Eg,{children:[t.jsx(Ag,{children:"Access Denied"}),t.jsx(zg,{children:B}),t.jsx($g,{onClick:()=>Y(null),children:"Try again"})]}),ke&&(me?t.jsxs(wg,{children:[t.jsx(yg,{children:"Choose an account"}),J.map(K=>{var ee,ne,Fe,Pe;return t.jsxs(ls,{type:"button",onClick:()=>We(K.id),disabled:z||C,children:[t.jsx(Xi,{children:K.user.has_profile_picture?t.jsx("img",{src:K.user.profile_picture_url,alt:((ee=K.user.primary_email_address)==null?void 0:ee.email)||"account"}):Q(K.user.first_name,K.user.last_name)}),t.jsxs(ec,{children:[t.jsx(tc,{children:K.user.first_name&&K.user.last_name?`${K.user.first_name} ${K.user.last_name}`:K.user.first_name||((Fe=(ne=K.user.primary_email_address)==null?void 0:ne.email)==null?void 0:Fe.split("@")[0])||"Account"}),t.jsx(jg,{children:(Pe=K.user.primary_email_address)==null?void 0:Pe.email})]}),t.jsx(vo,{})]},K.id)}),t.jsxs(ls,{type:"button",onClick:()=>{te(!1),re(!0),oe()},children:[t.jsx(Xi,{children:t.jsx($f,{size:16})}),t.jsx(ec,{children:t.jsx(tc,{children:"Use a different account"})}),t.jsx(vo,{})]})]}):t.jsxs(fg,{type:"button",onClick:()=>We(J[0].id),disabled:z||C,children:[t.jsx(mg,{children:J[0].user.has_profile_picture?t.jsx("img",{src:J[0].user.profile_picture_url,alt:((ur=J[0].user.primary_email_address)==null?void 0:ur.email)||"account"}):Q(J[0].user.first_name,J[0].user.last_name)}),t.jsxs(gg,{children:[t.jsxs(vg,{children:["Welcome back,"," ",J[0].user.first_name||((Jt=(Qt=J[0].user.primary_email_address)==null?void 0:Qt.email)==null?void 0:Jt.split("@")[0])||"back"]}),t.jsx(xg,{children:(Nt=J[0].user.primary_email_address)==null?void 0:Nt.email})]}),t.jsx(bg,{onClick:K=>{K.stopPropagation(),J.length>1?te(!0):(re(!0),oe())},children:"Not you?"})]})),je?b==="email_magic_link"?t.jsxs(t.Fragment,{children:[t.jsx(kg,{children:Te?t.jsx(Sg,{type:"button",onClick:async()=>{Ve(!1),Qe(60);try{await _.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs(Cg,{children:["Resend in ",U,"s"]})}),t.jsxs(go,{children:["Having trouble?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:e.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{style:{gap:"var(--space-7u)"},onSubmit:fe,noValidate:!0,children:[t.jsx(lr,{onComplete:async K=>{if(O(K),K&&K.length===6){H(!0),$({});try{await _.completeVerification(K),p(!1)}catch(ee){$({otp:ee.message||"Verification failed"})}finally{H(!1)}}},onResend:async()=>{const K=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:K})},error:T.otp,isSubmitting:z}),t.jsx(Qi,{type:"submit",$fullWidth:!0,$size:"md",disabled:z||C||!P,style:{margin:0},children:z&&P?t.jsx(Ji,{size:16}):`Continue to ${(kt=e==null?void 0:e.ui_settings)==null?void 0:kt.app_name}`})]}),t.jsxs(go,{children:["Having trouble?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:e.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[x.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ms,{connections:x,callback:q})}),((hr=(pr=e==null?void 0:e.auth_settings)==null?void 0:pr.passkey)==null?void 0:hr.enabled)&&t.jsxs(hg,{type:"button",$fullWidth:!0,$outline:!0,$size:"md",onClick:de,disabled:z,children:[t.jsx(is,{size:16}),"Sign in with Passkey",t.jsx(vo,{})]}),(x.length>0||((ie=(bt=e==null?void 0:e.auth_settings)==null?void 0:bt.passkey)==null?void 0:ie.enabled))&&t.jsx(Ki,{children:t.jsx(Yi,{children:"or"})}),t.jsxs(Ft,{onSubmit:pe,noValidate:!0,children:[(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((Me=(ye=e==null?void 0:e.auth_settings)==null?void 0:ye.email_address)==null?void 0:Me.enabled)&&t.jsxs(Se,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(be,{htmlFor:"email",children:"Email address"}),j==="identifier"&&t.jsx(fa,{style:{fontSize:"var(--font-size-sm)"},onClick:()=>w(!0),children:"Other methods"})]}),j==="password"&&b==="email_password"&&I.email?t.jsxs(lg,{children:[t.jsx(dg,{children:t.jsx(kf,{})}),t.jsx(ug,{children:I.email}),t.jsx(pg,{type:"button",onClick:()=>S("identifier"),children:"Edit"})]}):t.jsx(ue,{type:"email",id:"email",name:"email",value:I.email,onChange:le,placeholder:"Enter your email address","aria-invalid":!!T.email}),T.email&&t.jsx(ha,{children:T.email})]}),b==="username_password"&&((et=(De=e==null?void 0:e.auth_settings)==null?void 0:De.username)==null?void 0:et.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"username",children:"Username"}),t.jsx(ue,{type:"text",id:"username",name:"username",value:I.username,onChange:le,placeholder:"Enter your username","aria-invalid":!!T.username}),T.username&&t.jsx(ha,{children:T.username})]}),b==="phone_otp"&&((ft=(rt=e==null?void 0:e.auth_settings)==null?void 0:rt.phone_number)==null?void 0:ft.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"phone",children:"Phone number"}),t.jsx($a,{value:I.phone,onChange:le,error:T.phone,countryCode:Z,setCountryCode:L}),T.phone&&t.jsx(ha,{children:T.phone})]}),j==="password"&&(b==="email_password"||b==="username_password")&&((ae=(_t=e==null?void 0:e.auth_settings)==null?void 0:_t.password)==null?void 0:ae.enabled)&&t.jsxs(Se,{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx(be,{htmlFor:"password",children:"Password"}),t.jsx(fa,{style:{fontSize:"var(--font-size-sm)"},onClick:()=>g(!0),children:"Forgot password?"})]}),t.jsx(cg,{children:t.jsx(ue,{type:"password",id:"password",name:"password",value:I.password,onChange:le,placeholder:"Enter your password","aria-invalid":!!T.password})}),T.password&&t.jsx(ha,{children:T.password})]}),t.jsxs("div",{children:[T.submit&&t.jsx(ha,{children:T.submit}),t.jsx(Qi,{type:"submit",$fullWidth:!0,$size:"md",disabled:z||C,children:z?t.jsx(Ji,{size:16}):j==="identifier"?"Continue":"Sign in"}),j==="password"&&((tt=(Re=e==null?void 0:e.auth_settings)==null?void 0:Re.auth_factors_enabled)==null?void 0:tt.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{style:{margin:"var(--space-6u) 0 var(--space-5u)"},children:t.jsx(Yi,{children:"or"})}),t.jsx(S1,{type:"button",icon:t.jsx(Id,{}),label:"Sign in with a code",description:"We'll send a 6-digit code to your email",disabled:z,onClick:async()=>{H(!0),$({});try{await _.create({email:I.email,strategy:"email_otp"}),E("email_otp")}catch(K){$({submit:K.message}),H(!1)}}})]})]})]}),t.jsxs(go,{children:["Don't have an account?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:`${(qe=e.ui_settings)==null?void 0:qe.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Rg=mt`
2049
+ `;function Mg(){return t.jsx(r4,{children:t.jsx(Lg,{})})}function Lg(){var Ge,dt,dr,ur,Qt,Jt,Nt,pr,hr,bt,ie,ye,Me,De,et,rt,ft,_t,ae,Re,tt,qe,kt;const{deployment:e}=Ae(),{navigate:r}=yt(),{session:a,loading:n,refetch:s,exchangeTicket:i,switchSignIn:h}=ot(),d=((dt=(Ge=e==null?void 0:e.auth_settings)==null?void 0:Ge.multi_session_support)==null?void 0:dt.enabled)??!1,{setEmail:u,otpSent:f,setOtpSent:p,showForgotPassword:m,setShowForgotPassword:g,showOtherOptions:v,setShowOtherOptions:w,enabledSocialsProviders:x,firstFactor:b,setFirstFactor:E,signInStep:j,setSignInStep:S}=A1(),{loading:C,signIn:_,signinAttempt:k,discardSignInAttempt:y,setSignInAttempt:M}=wa("generic"),{signIn:A}=wa("oauth"),{signIn:I}=wa("passkey"),[P,L]=c.useState({email:"",username:"",password:"",phone:""}),[T,$]=c.useState({}),[z,H]=c.useState(!1),[F,O]=c.useState(""),[Z,R]=c.useState("US"),[W,D]=c.useState(!1),[B,Y]=c.useState(null),[X,ce]=c.useState(!1),[me,te]=c.useState(!1),[xe,re]=c.useState(!1),[U,Qe]=c.useState(60),[Te,Ve]=c.useState(!1),[Ue,ve]=c.useState(null),J=[...(a==null?void 0:a.signins)||[]].sort((K,ee)=>{var ne,Fe;return K.id===((ne=a==null?void 0:a.active_signin)==null?void 0:ne.id)?-1:ee.id===((Fe=a==null?void 0:a.active_signin)==null?void 0:Fe.id)?1:0});c.useEffect(()=>{const K=new URLSearchParams(window.location.search),ee=K.get("error"),ne=K.get("error_description");if(ee==="access_denied"&&ne){Y(ne),K.delete("error"),K.delete("error_description");const Fe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Fe)}},[]),c.useEffect(()=>{if(b!=="email_magic_link"||!f)return;Qe(60),Ve(!1);const K=setInterval(()=>{Qe(ee=>ee<=1?(Ve(!0),clearInterval(K),0):ee-1)},1e3);return()=>clearInterval(K)},[b,f]),c.useEffect(()=>{var K,ee,ne,Fe;if(!n&&(a!=null&&a.active_signin)&&!d&&!W&&!X){let Pe=new URLSearchParams(window.location.search).get("redirect_uri");Pe||(Pe=((K=e==null?void 0:e.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!Pe&&(e!=null&&e.frontend_host)&&(Pe=`https://${e.frontend_host}`);const at=(ee=e==null?void 0:e.auth_settings)==null?void 0:ee.passkey;(at==null?void 0:at.enabled)&&(at==null?void 0:at.prompt_registration_on_auth)&&!((Fe=(ne=a.active_signin)==null?void 0:ne.user)!=null&&Fe.has_passkeys)?(ve(Pe),ce(!0)):Pe&&(D(!0),r(Pe))}},[a,n,d,e,r,W]);const le=K=>{let{name:ee,value:ne}=K.target;ee==="phone"?ne=ne.replace(/[^0-9]/g,""):ee==="email"&&(u(ne),ne=ne.toLowerCase()),L(Fe=>({...Fe,[ee]:ne})),$(Fe=>({...Fe,[ee]:""}))},oe=()=>{L({email:"",username:"",password:"",phone:""}),$({}),R("US"),S("identifier")},G=async K=>{if(!K){$({email:"Email address is required"});return}H(!0),$({});try{const ee=await _.identify(K);if(ee.strategy==="sso"&&ee.connection_id){const Fe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Pe=await _.initEnterpriseSso(ee.connection_id,Fe);if(Pe&&Pe.sso_url){D(!0),window.location.href=Pe.sso_url;return}}else if(ee.strategy==="social"&&ee.provider){const ne=x.find(Fe=>Fe.provider===ee.provider);if(ne){const Pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:at}=await A.create({provider:ne.provider,redirectUri:Pe});if(at&&typeof at=="object"&&"oauth_url"in at){D(!0),window.location.href=at.oauth_url;return}}else S("password")}else S("password")}catch(ee){$({submit:ee.message})}finally{W||H(!1)}},pe=async K=>{if(K.preventDefault(),C||z)return;y();const ee={};if(j==="identifier"&&b==="email_password"){if(!P.email){$({email:"Email address is required"});return}await G(P.email);return}if(b==="email_password"?(P.email||(ee.email="Email address is required"),P.password||(ee.password="Password is required")):b==="username_password"?(P.username||(ee.username="Username is required"),P.password||(ee.password="Password is required")):b==="email_otp"||b==="email_magic_link"?P.email||(ee.email="Email address is required"):b==="phone_otp"&&(P.phone?/^\d{7,15}$/.test(P.phone)||(ee.phone="Phone number must contain 7-15 digits"):ee.phone="Phone number is required"),$(ee),Object.keys(ee).length>0)return;let ne="";switch(b){case"email_password":ne="plain_email";break;case"username_password":ne="plain_username";break;case"email_otp":ne="email_otp";break;case"email_magic_link":ne="magic_link";break;case"phone_otp":ne="phone_otp";break}const Fe=b==="email_otp"||b==="email_magic_link"||b==="phone_otp";H(!0);try{const Pe={...P,strategy:ne};b==="phone_otp"&&Z&&(Pe.phone_country_code=Z),await _.create(Pe),Fe||H(!1)}catch(Pe){$({submit:Pe.message}),H(!1)}},fe=async K=>{if(K.preventDefault(),C||z)return;const ee={};if(!F){ee.otp="OTP code is required",$(ee);return}H(!0),$({});try{await _.completeVerification(F),p(!1),O("")}catch(ne){$({otp:ne.message||"Verification failed"})}finally{H(!1)}},q=async K=>{if(!(C||z)){H(!0);try{const ne=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Fe}=await A.create({provider:K.provider,redirectUri:ne});Fe&&typeof Fe=="object"&&"oauth_url"in Fe&&(window.location.href=Fe.oauth_url)}catch(ee){$({submit:ee.message})}finally{H(!1)}}},de=async()=>{var K;if(!(C||z)){H(!0),$({});try{const ee=await I.create();if("data"in ee&&ee.data){await s();let ne=new URLSearchParams(window.location.search).get("redirect_uri");ne||(ne=((K=e==null?void 0:e.ui_settings)==null?void 0:K.after_signin_redirect_url)||null),!ne&&(e!=null&&e.frontend_host)&&(ne=`https://${e.frontend_host}`),D(!0),ne&&r(ne)}}catch(ee){$({submit:ee.message||"Passkey sign-in failed"})}finally{H(!1)}}},Be=()=>{var ne;let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((ne=e==null?void 0:e.ui_settings)==null?void 0:ne.after_signin_redirect_url)||null),!K&&(e!=null&&e.frontend_host)&&(K=`https://${e.frontend_host}`),!K)return null;let ee;try{ee=new URL(K)}catch{ee=new URL(K,window.location.origin)}return(e==null?void 0:e.mode)==="staging"&&ee.searchParams.set("__dev_session__",ht(e.backend_host)||""),ee.toString()},We=async K=>{if(!(C||z)){$({}),H(!0);try{await h(K);const ee=Be();ee&&(D(!0),r(ee))}catch(ee){$({submit:ee.message||"Failed to continue with selected account"})}finally{H(!1)}}},Q=(K,ee)=>`${K||""} ${ee||""}`.trim().split(" ").filter(Boolean).map(ne=>ne[0]).join("").toUpperCase().slice(0,2)||"?",se=c.useRef(!1);if(c.useEffect(()=>{if(n)return;const K=new URLSearchParams(window.location.search),ee=K.get("ticket");if(ee&&!se.current&&!C){se.current=!0,K.delete("ticket");const Fe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Fe),(async()=>{var at;try{H(!0),await i(ee),D(!0);let vt=new URLSearchParams(window.location.search).get("redirect_uri");if(vt||(vt=((at=e==null?void 0:e.ui_settings)==null?void 0:at.after_signin_redirect_url)||null),!vt&&(e!=null&&e.frontend_host)&&(vt=`https://${e.frontend_host}`),vt){let Pa;try{Pa=new URL(vt)}catch{Pa=new URL(vt,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&Pa.searchParams.set("__dev_session__",ht(e.backend_host)||""),r(Pa.toString())}return}catch(vt){$({submit:vt.message||"Failed to exchange ticket"}),se.current=!1}finally{H(!1)}})();return}const ne=K.get("signin_attempt_id");if(ne&&(a!=null&&a.signin_attempts)&&!k){const Fe=a.signin_attempts.find(Pe=>Pe.id===ne);if(Fe){M(Fe),K.delete("signin_attempt_id");const Pe=K.toString()?`${window.location.pathname}?${K.toString()}`:window.location.pathname;window.history.replaceState({},"",Pe)}}},[a,n,k,M,C]),c.useEffect(()=>{var Fe;if(!k)return;if(k.completed){D(!0);let Pe=new URLSearchParams(window.location.search).get("redirect_uri");if(Pe||(Pe=((Fe=e==null?void 0:e.ui_settings)==null?void 0:Fe.after_signin_redirect_url)||null),!Pe&&(e!=null&&e.frontend_host)&&(Pe=`https://${e.frontend_host}`),Pe){let at;try{at=new URL(Pe)}catch{at=new URL(Pe,window.location.origin)}(e==null?void 0:e.mode)==="staging"&&at.searchParams.set("__dev_session__",ht(e.backend_host)||""),r(at.toString())}return}if(!_||f)return;const ee={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[k.current_step];if(!ee)return;(async()=>{try{await _.prepareVerification({strategy:ee}),H(!1),p(!0)}catch{$({submit:"Failed to send verification. Please try again."}),H(!1)}})()},[k,_,f,p,r,e]),v)return t.jsx(b4,{onBack:()=>w(!1)});if(m)return t.jsx(p4,{onBack:()=>g(!1)});if((k==null?void 0:k.current_step)==="verify_second_factor")return t.jsx(R1,{attempt:k,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),oe(),p(!1)}});if((k==null?void 0:k.current_step)==="complete_profile")return t.jsx(P1,{attempt:k,completeProfile:_.completeProfile,completeVerification:_.completeVerification,prepareVerification:_.prepareVerification,onBack:()=>{y(),oe(),p(!1)}});if(X){const K=()=>{ce(!1),Ue&&(D(!0),r(Ue))},ee=()=>{ce(!1),Ue&&(D(!0),r(Ue))};return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(T1,{onComplete:K,onSkip:ee})]})})}if(n)return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(Bi,{children:t.jsx(wt,{size:32})})]})});if(W)return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),t.jsx(Bi,{children:t.jsx(wt,{size:32})})]})});const je=(k==null?void 0:k.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(k.current_step)&&f,ke=d&&!je&&J.length>0&&!xe;return t.jsx(ge,{children:t.jsxs(Ga,{children:[t.jsx(Je,{}),je?t.jsxs(Wi,{children:[!((dr=e==null?void 0:e.ui_settings)!=null&&dr.logo_image_url)&&t.jsx(_g,{children:b==="phone_otp"?t.jsx(As,{weight:"light"}):t.jsx(In,{weight:"light"})}),t.jsx(Gi,{children:b==="phone_otp"?"Check your phone":b==="email_magic_link"?"Check your inbox":"Enter the code"}),t.jsx(qi,{children:b==="email_magic_link"?"We sent a magic link to your email — click it to sign in instantly.":b==="phone_otp"?"We sent a verification code via SMS.":"We sent a 6-digit code to your email."}),(b==="email_otp"||b==="email_magic_link")&&P.email&&t.jsx(rc,{children:t.jsxs(ac,{type:"button",onClick:()=>{p(!1),y(),oe()},children:[t.jsx(cs,{weight:"light"}),P.email]})}),b==="phone_otp"&&P.phone&&t.jsx(rc,{children:t.jsxs(ac,{type:"button",onClick:()=>{p(!1),y(),oe()},children:[t.jsx(cs,{weight:"light"}),"+",P.phone]})})]}):t.jsxs(Wi,{children:[t.jsx(Gi,{children:"Sign in to your account"}),t.jsxs(qi,{children:["Please enter your details to continue to"," ",(e==null?void 0:e.ui_settings.app_name)||"App","!"]})]}),B&&t.jsxs(Eg,{children:[t.jsx(Ag,{children:"Access Denied"}),t.jsx(zg,{children:B}),t.jsx($g,{onClick:()=>Y(null),children:"Try again"})]}),ke&&(me?t.jsxs(wg,{children:[t.jsx(yg,{children:"Choose an account"}),J.map(K=>{var ee,ne,Fe,Pe;return t.jsxs(ls,{type:"button",onClick:()=>We(K.id),disabled:z||C,children:[t.jsx(Xi,{children:K.user.has_profile_picture?t.jsx("img",{src:K.user.profile_picture_url,alt:((ee=K.user.primary_email_address)==null?void 0:ee.email)||"account"}):Q(K.user.first_name,K.user.last_name)}),t.jsxs(ec,{children:[t.jsx(tc,{children:K.user.first_name&&K.user.last_name?`${K.user.first_name} ${K.user.last_name}`:K.user.first_name||((Fe=(ne=K.user.primary_email_address)==null?void 0:ne.email)==null?void 0:Fe.split("@")[0])||"Account"}),t.jsx(jg,{children:(Pe=K.user.primary_email_address)==null?void 0:Pe.email})]}),t.jsx(vo,{})]},K.id)}),t.jsxs(ls,{type:"button",onClick:()=>{te(!1),re(!0),oe()},children:[t.jsx(Xi,{children:t.jsx($f,{size:16})}),t.jsx(ec,{children:t.jsx(tc,{children:"Use a different account"})}),t.jsx(vo,{})]})]}):t.jsxs(fg,{type:"button",onClick:()=>We(J[0].id),disabled:z||C,children:[t.jsx(mg,{children:J[0].user.has_profile_picture?t.jsx("img",{src:J[0].user.profile_picture_url,alt:((ur=J[0].user.primary_email_address)==null?void 0:ur.email)||"account"}):Q(J[0].user.first_name,J[0].user.last_name)}),t.jsxs(gg,{children:[t.jsxs(vg,{children:["Welcome back,"," ",J[0].user.first_name||((Jt=(Qt=J[0].user.primary_email_address)==null?void 0:Qt.email)==null?void 0:Jt.split("@")[0])||"back"]}),t.jsx(xg,{children:(Nt=J[0].user.primary_email_address)==null?void 0:Nt.email})]}),t.jsx(bg,{onClick:K=>{K.stopPropagation(),J.length>1?te(!0):(re(!0),oe())},children:"Not you?"})]})),je?b==="email_magic_link"?t.jsxs(t.Fragment,{children:[t.jsx(kg,{children:Te?t.jsx(Sg,{type:"button",onClick:async()=>{Ve(!1),Qe(60);try{await _.prepareVerification({strategy:"magic_link"})}catch{}},children:"Resend magic link"}):t.jsxs(Cg,{children:["Resend in ",U,"s"]})}),t.jsxs(go,{children:["Having trouble?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:e.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{style:{gap:"var(--space-7u)"},onSubmit:fe,noValidate:!0,children:[t.jsx(lr,{onComplete:async K=>{if(O(K),K&&K.length===6){H(!0),$({});try{await _.completeVerification(K),p(!1)}catch(ee){$({otp:ee.message||"Verification failed"})}finally{H(!1)}}},onResend:async()=>{const K=b==="email_otp"?"email_otp":"phone_otp";await _.prepareVerification({strategy:K})},error:T.otp,isSubmitting:z}),t.jsx(Qi,{type:"submit",$fullWidth:!0,$size:"md",disabled:z||C||!F,style:{margin:0},children:z&&F?t.jsx(Ji,{size:16}):`Continue to ${(kt=e==null?void 0:e.ui_settings)==null?void 0:kt.app_name}`})]}),t.jsxs(go,{children:["Having trouble?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:e.ui_settings.support_page_url,children:"Get help"})})]})]}):t.jsxs(t.Fragment,{children:[x.length>0&&t.jsx(t.Fragment,{children:t.jsx(Ms,{connections:x,callback:q})}),((hr=(pr=e==null?void 0:e.auth_settings)==null?void 0:pr.passkey)==null?void 0:hr.enabled)&&t.jsxs(hg,{type:"button",$fullWidth:!0,$outline:!0,$size:"md",onClick:de,disabled:z,children:[t.jsx(is,{size:16}),"Sign in with Passkey",t.jsx(vo,{})]}),(x.length>0||((ie=(bt=e==null?void 0:e.auth_settings)==null?void 0:bt.passkey)==null?void 0:ie.enabled))&&t.jsx(Ki,{children:t.jsx(Yi,{children:"or"})}),t.jsxs(Ft,{onSubmit:pe,noValidate:!0,children:[(b==="email_password"||b==="email_otp"||b==="email_magic_link")&&((Me=(ye=e==null?void 0:e.auth_settings)==null?void 0:ye.email_address)==null?void 0:Me.enabled)&&t.jsxs(Se,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(be,{htmlFor:"email",children:"Email address"}),j==="identifier"&&t.jsx(fa,{style:{fontSize:"var(--font-size-sm)"},onClick:()=>w(!0),children:"Other methods"})]}),j==="password"&&b==="email_password"&&P.email?t.jsxs(lg,{children:[t.jsx(dg,{children:t.jsx(kf,{})}),t.jsx(ug,{children:P.email}),t.jsx(pg,{type:"button",onClick:()=>S("identifier"),children:"Edit"})]}):t.jsx(ue,{type:"email",id:"email",name:"email",value:P.email,onChange:le,placeholder:"Enter your email address","aria-invalid":!!T.email}),T.email&&t.jsx(ha,{children:T.email})]}),b==="username_password"&&((et=(De=e==null?void 0:e.auth_settings)==null?void 0:De.username)==null?void 0:et.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"username",children:"Username"}),t.jsx(ue,{type:"text",id:"username",name:"username",value:P.username,onChange:le,placeholder:"Enter your username","aria-invalid":!!T.username}),T.username&&t.jsx(ha,{children:T.username})]}),b==="phone_otp"&&((ft=(rt=e==null?void 0:e.auth_settings)==null?void 0:rt.phone_number)==null?void 0:ft.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"phone",children:"Phone number"}),t.jsx($a,{value:P.phone,onChange:le,error:T.phone,countryCode:Z,setCountryCode:R}),T.phone&&t.jsx(ha,{children:T.phone})]}),j==="password"&&(b==="email_password"||b==="username_password")&&((ae=(_t=e==null?void 0:e.auth_settings)==null?void 0:_t.password)==null?void 0:ae.enabled)&&t.jsxs(Se,{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx(be,{htmlFor:"password",children:"Password"}),t.jsx(fa,{style:{fontSize:"var(--font-size-sm)"},onClick:()=>g(!0),children:"Forgot password?"})]}),t.jsx(cg,{children:t.jsx(ue,{type:"password",id:"password",name:"password",value:P.password,onChange:le,placeholder:"Enter your password","aria-invalid":!!T.password})}),T.password&&t.jsx(ha,{children:T.password})]}),t.jsxs("div",{children:[T.submit&&t.jsx(ha,{children:T.submit}),t.jsx(Qi,{type:"submit",$fullWidth:!0,$size:"md",disabled:z||C,children:z?t.jsx(Ji,{size:16}):j==="identifier"?"Continue":"Sign in"}),j==="password"&&((tt=(Re=e==null?void 0:e.auth_settings)==null?void 0:Re.auth_factors_enabled)==null?void 0:tt.email_otp)&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{style:{margin:"var(--space-6u) 0 var(--space-5u)"},children:t.jsx(Yi,{children:"or"})}),t.jsx(S1,{type:"button",icon:t.jsx(Id,{}),label:"Sign in with a code",description:"We'll send a 6-digit code to your email",disabled:z,onClick:async()=>{H(!0),$({});try{await _.create({email:P.email,strategy:"email_otp"}),E("email_otp")}catch(K){$({submit:K.message}),H(!1)}}})]})]})]}),t.jsxs(go,{children:["Don't have an account?"," ",t.jsx(fa,{children:t.jsx(Pt,{to:`${(qe=e.ui_settings)==null?void 0:qe.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Rg=mt`
2050
2050
  from { transform: rotate(0deg); }
2051
2051
  to { transform: rotate(360deg); }
2052
2052
  `,Pg=l(wt)`
@@ -2128,7 +2128,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
2128
2128
  color: var(--color-primary);
2129
2129
  text-decoration: none;
2130
2130
  cursor: pointer;
2131
- `;function Gg(){var b,E,j,S,C,_,k,y,M,A,F,I;const{deployment:e}=Ae(),{loading:r,joinWaitlist:a}=v0(),[n,s]=c.useState({first_name:"",last_name:"",email:""}),[i,h]=c.useState(!1),[d,u]=c.useState(!1),[f,p]=c.useState(null),m=R=>{if(f)return f.message},g=e==null?void 0:e.auth_settings,v=!!((b=g==null?void 0:g.first_name)!=null&&b.enabled&&((E=g==null?void 0:g.last_name)!=null&&E.enabled)),w=R=>{const{name:T,value:$}=R.target;s(z=>({...z,[T]:$}))},x=async R=>{if(R.preventDefault(),!!g){u(!0),p(null);try{(await a(n)).data&&h(!0)}catch(T){p(T)}finally{u(!1)}}};return i?t.jsx(ge,{children:t.jsx(nc,{children:t.jsxs(Hg,{children:[t.jsx(Vg,{children:t.jsx(ct,{size:32})}),t.jsx(Dg,{children:"You're on the waitlist!"}),t.jsxs(Ng,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):t.jsx(ge,{children:t.jsxs(nc,{children:[t.jsx(Je,{}),t.jsxs(Tg,{children:[t.jsx(Fg,{children:"Join the waitlist"}),t.jsx(Ig,{children:"Be the first to know when we launch!"})]}),t.jsxs(Zg,{onSubmit:x,noValidate:!0,children:[(((j=g==null?void 0:g.first_name)==null?void 0:j.enabled)||((S=g==null?void 0:g.last_name)==null?void 0:S.enabled))&&t.jsxs(Og,{$isBothEnabled:v,children:[((C=g==null?void 0:g.first_name)==null?void 0:C.enabled)&&t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"first_name",children:["First name",((_=g==null?void 0:g.first_name)==null?void 0:_.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",required:(k=g==null?void 0:g.first_name)==null?void 0:k.required,minLength:2,maxLength:50,value:n.first_name,onChange:w,placeholder:"First name","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]}),((y=g==null?void 0:g.last_name)==null?void 0:y.enabled)&&t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"last_name",children:["Last name",((M=g==null?void 0:g.last_name)==null?void 0:M.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",required:(A=g==null?void 0:g.last_name)==null?void 0:A.required,minLength:2,maxLength:50,value:n.last_name,onChange:w,placeholder:"Last name","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]})]}),t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"email",children:["Email address",((F=g==null?void 0:g.email_address)==null?void 0:F.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"email",id:"email",name:"email",required:(I=g==null?void 0:g.email_address)==null?void 0:I.required,value:n.email,onChange:w,placeholder:"Enter your email address","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]}),m()&&t.jsx(qa,{children:m()}),t.jsx(N,{type:"submit",$primary:!0,$fullWidth:!0,disabled:d||r,children:d||r?t.jsx(Pg,{size:16}):"Join waitlist"})]}),t.jsx(Ug,{children:t.jsxs(Bg,{children:["Need assistance? ",t.jsx(Wg,{href:"/contact",children:"Get help"})]})})]})})}const ma=l.div`
2131
+ `;function Gg(){var b,E,j,S,C,_,k,y,M,A,I,P;const{deployment:e}=Ae(),{loading:r,joinWaitlist:a}=v0(),[n,s]=c.useState({first_name:"",last_name:"",email:""}),[i,h]=c.useState(!1),[d,u]=c.useState(!1),[f,p]=c.useState(null),m=L=>{if(f)return f.message},g=e==null?void 0:e.auth_settings,v=!!((b=g==null?void 0:g.first_name)!=null&&b.enabled&&((E=g==null?void 0:g.last_name)!=null&&E.enabled)),w=L=>{const{name:T,value:$}=L.target;s(z=>({...z,[T]:$}))},x=async L=>{if(L.preventDefault(),!!g){u(!0),p(null);try{(await a(n)).data&&h(!0)}catch(T){p(T)}finally{u(!1)}}};return i?t.jsx(ge,{children:t.jsx(nc,{children:t.jsxs(Hg,{children:[t.jsx(Vg,{children:t.jsx(ct,{size:32})}),t.jsx(Dg,{children:"You're on the waitlist!"}),t.jsxs(Ng,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):t.jsx(ge,{children:t.jsxs(nc,{children:[t.jsx(Je,{}),t.jsxs(Tg,{children:[t.jsx(Fg,{children:"Join the waitlist"}),t.jsx(Ig,{children:"Be the first to know when we launch!"})]}),t.jsxs(Zg,{onSubmit:x,noValidate:!0,children:[(((j=g==null?void 0:g.first_name)==null?void 0:j.enabled)||((S=g==null?void 0:g.last_name)==null?void 0:S.enabled))&&t.jsxs(Og,{$isBothEnabled:v,children:[((C=g==null?void 0:g.first_name)==null?void 0:C.enabled)&&t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"first_name",children:["First name",((_=g==null?void 0:g.first_name)==null?void 0:_.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"text",id:"first_name",name:"first_name",required:(k=g==null?void 0:g.first_name)==null?void 0:k.required,minLength:2,maxLength:50,value:n.first_name,onChange:w,placeholder:"First name","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]}),((y=g==null?void 0:g.last_name)==null?void 0:y.enabled)&&t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"last_name",children:["Last name",((M=g==null?void 0:g.last_name)==null?void 0:M.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"text",id:"last_name",name:"last_name",required:(A=g==null?void 0:g.last_name)==null?void 0:A.required,minLength:2,maxLength:50,value:n.last_name,onChange:w,placeholder:"Last name","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]})]}),t.jsxs(xo,{children:[t.jsxs(bo,{htmlFor:"email",children:["Email address",((I=g==null?void 0:g.email_address)==null?void 0:I.required)&&t.jsx(wo,{children:"*"})]}),t.jsx(ue,{type:"email",id:"email",name:"email",required:(P=g==null?void 0:g.email_address)==null?void 0:P.required,value:n.email,onChange:w,placeholder:"Enter your email address","aria-invalid":!!m()}),m()&&t.jsx(qa,{children:m()})]}),m()&&t.jsx(qa,{children:m()}),t.jsx(N,{type:"submit",$primary:!0,$fullWidth:!0,disabled:d||r,children:d||r?t.jsx(Pg,{size:16}):"Join waitlist"})]}),t.jsx(Ug,{children:t.jsxs(Bg,{children:["Need assistance? ",t.jsx(Wg,{href:"/contact",children:"Get help"})]})})]})})}const ma=l.div`
2132
2132
  ${Et}
2133
2133
  `,Ka=l.div`
2134
2134
  text-align: center;
@@ -2574,7 +2574,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
2574
2574
  color: var(--color-foreground-inverse);
2575
2575
  font-size: var(--font-size-sm);
2576
2576
  font-weight: 400;
2577
- `,On=({onSuccess:e,onCancel:r})=>{const[a,n]=c.useState(""),[s,i]=c.useState(""),[h,d]=c.useState(),[u,f]=c.useState(null),[p,m]=c.useState(!1),g=c.useRef(null),{createOrganization:v}=It(),{refetch:w}=ot(),{toast:x}=gt(),b=y=>{n(y)},E=y=>{if(y.target.files&&y.target.files[0]){const M=y.target.files[0];if(M.size>2*1024*1024){x("File size cannot exceed 2MB","error");return}if(!M.type.startsWith("image/")){x("Please select a valid image file","error");return}u&&URL.revokeObjectURL(u),d(M),f(URL.createObjectURL(M))}},j=()=>{var y;(y=g.current)==null||y.click()},S=y=>y.split(" ").map(M=>M[0]).join("").toUpperCase().slice(0,2)||"O";c.useEffect(()=>()=>{u&&URL.revokeObjectURL(u)},[u]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),_=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),k=async()=>{const y=C(a),M=C(s);if(!y){x("Please enter an organization name","error");return}if(!_(y)){x("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(M.length>500){x("Description must be less than 500 characters","error");return}m(!0);try{const A=await v({name:y,description:M,image:h});await w(),e==null||e(A)}catch(A){const F=A.message||"Failed to create organization. Please try again.";x(F,"error")}finally{m(!1)}};return t.jsx(ge,{children:t.jsxs(m6,{children:[t.jsxs(g6,{children:[t.jsxs(I1,{hasImage:!!u,onClick:j,children:[u?t.jsx(x6,{src:u,alt:"Organization logo"}):t.jsx(b6,{children:S(a||"O")}),t.jsx(L6,{children:t.jsx(R6,{children:"Upload Logo"})})]}),t.jsx(M6,{type:"file",ref:g,onChange:E,accept:"image/png, image/jpeg, image/gif",disabled:p}),t.jsx(w6,{children:"Create new organization"}),t.jsx(y6,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),t.jsxs(v6,{children:[t.jsxs(j6,{children:[t.jsx(_6,{children:"Choose your organization name"}),t.jsx(k6,{children:"This is the name of your company or team. You can always change it later."})]}),t.jsxs(C6,{children:[t.jsxs(cc,{children:[t.jsx(lc,{children:"Organization name"}),t.jsx(S6,{type:"text",value:a,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:p})]}),t.jsxs(cc,{children:[t.jsx(lc,{children:"Description (optional)"}),t.jsx(E6,{value:s,onChange:y=>i(y.target.value),placeholder:"What does your organization do?",disabled:p})]})]}),t.jsxs(A6,{children:[r?t.jsxs(z6,{onClick:r,disabled:p,children:[t.jsx(na,{size:16}),"Back"]}):t.jsx("div",{}),t.jsx($6,{onClick:k,disabled:p||!a.trim(),children:p?"Creating...":"Create"})]})]})]})})},Z1=({isOpen:e,onClose:r,onCreated:a})=>{const n=()=>{a==null||a(),r==null||r()};return t.jsx(ge,{children:t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsx(He.Content,{style:{width:"900px",maxWidth:"90vw"},children:t.jsx(He.Body,{style:{padding:0},children:t.jsx(On,{onSuccess:n,onCancel:r})})})})})})},P6=l.div`
2577
+ `,On=({onSuccess:e,onCancel:r})=>{const[a,n]=c.useState(""),[s,i]=c.useState(""),[h,d]=c.useState(),[u,f]=c.useState(null),[p,m]=c.useState(!1),g=c.useRef(null),{createOrganization:v}=It(),{refetch:w}=ot(),{toast:x}=gt(),b=y=>{n(y)},E=y=>{if(y.target.files&&y.target.files[0]){const M=y.target.files[0];if(M.size>2*1024*1024){x("File size cannot exceed 2MB","error");return}if(!M.type.startsWith("image/")){x("Please select a valid image file","error");return}u&&URL.revokeObjectURL(u),d(M),f(URL.createObjectURL(M))}},j=()=>{var y;(y=g.current)==null||y.click()},S=y=>y.split(" ").map(M=>M[0]).join("").toUpperCase().slice(0,2)||"O";c.useEffect(()=>()=>{u&&URL.revokeObjectURL(u)},[u]);const C=y=>y.trim().replace(/[<>\"'&]/g,""),_=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),k=async()=>{const y=C(a),M=C(s);if(!y){x("Please enter an organization name","error");return}if(!_(y)){x("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(M.length>500){x("Description must be less than 500 characters","error");return}m(!0);try{const A=await v({name:y,description:M,image:h});await w(),e==null||e(A)}catch(A){const I=A.message||"Failed to create organization. Please try again.";x(I,"error")}finally{m(!1)}};return t.jsx(ge,{children:t.jsxs(m6,{children:[t.jsxs(g6,{children:[t.jsxs(I1,{hasImage:!!u,onClick:j,children:[u?t.jsx(x6,{src:u,alt:"Organization logo"}):t.jsx(b6,{children:S(a||"O")}),t.jsx(L6,{children:t.jsx(R6,{children:"Upload Logo"})})]}),t.jsx(M6,{type:"file",ref:g,onChange:E,accept:"image/png, image/jpeg, image/gif",disabled:p}),t.jsx(w6,{children:"Create new organization"}),t.jsx(y6,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),t.jsxs(v6,{children:[t.jsxs(j6,{children:[t.jsx(_6,{children:"Choose your organization name"}),t.jsx(k6,{children:"This is the name of your company or team. You can always change it later."})]}),t.jsxs(C6,{children:[t.jsxs(cc,{children:[t.jsx(lc,{children:"Organization name"}),t.jsx(S6,{type:"text",value:a,onChange:y=>b(y.target.value),placeholder:"Acme Inc.",disabled:p})]}),t.jsxs(cc,{children:[t.jsx(lc,{children:"Description (optional)"}),t.jsx(E6,{value:s,onChange:y=>i(y.target.value),placeholder:"What does your organization do?",disabled:p})]})]}),t.jsxs(A6,{children:[r?t.jsxs(z6,{onClick:r,disabled:p,children:[t.jsx(na,{size:16}),"Back"]}):t.jsx("div",{}),t.jsx($6,{onClick:k,disabled:p||!a.trim(),children:p?"Creating...":"Create"})]})]})]})})},Z1=({isOpen:e,onClose:r,onCreated:a})=>{const n=()=>{a==null||a(),r==null||r()};return t.jsx(ge,{children:t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsx(He.Content,{style:{width:"900px",maxWidth:"90vw"},children:t.jsx(He.Body,{style:{padding:0},children:t.jsx(On,{onSuccess:n,onCancel:r})})})})})})},P6=l.div`
2578
2578
  text-align: left;
2579
2579
  position: fixed;
2580
2580
  background: var(--color-popover);
@@ -2741,14 +2741,14 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
2741
2741
  display: flex;
2742
2742
  gap: var(--space-4u);
2743
2743
  flex-wrap: wrap;
2744
- `,q6=({connection:e,onDelete:r,connectionToDelete:a,onConfirmDelete:n,onCancelDelete:s,testConnection:i,generateSCIMToken:h,getSCIMToken:d,revokeSCIMToken:u,toast:f})=>{var F,I,R,T,$;const[p,m]=c.useState(null),[g,v]=c.useState(!1),[w,x]=c.useState(null),[b,E]=c.useState(null),[j,S]=c.useState(!1),[C,_]=c.useState(null);c.useEffect(()=>{d&&e.id&&d(e.id).then(m).catch(()=>{})},[e.id,d]);const k=async()=>{if(i){S(!0),_(null);try{const z=await i(e.id);_(z)}catch(z){_({success:!1,checks:{},errors:{general:z.message||"Test failed"}})}finally{S(!1)}}},y=async()=>{if(h){v(!0);try{const z=await h(e.id);x(z.token),m({exists:!0,token:z}),f("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(z){f(z.message||"Failed to generate token","error")}finally{v(!1)}}},M=async()=>{if(u){v(!0);try{await u(e.id),m({exists:!1,scim_base_url:p==null?void 0:p.scim_base_url}),x(null),f("SCIM token revoked","info")}catch(z){f(z.message||"Failed to revoke token","error")}finally{v(!1)}}},A=(z,H)=>{navigator.clipboard.writeText(z),E(H),setTimeout(()=>E(null),2e3)};return t.jsxs(O6,{children:[t.jsxs(H6,{children:[t.jsxs(V6,{children:[t.jsx(Rt,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx(D6,{children:e.protocol.toUpperCase()})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(N,{onClick:k,disabled:j,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)"},children:j?t.jsx(ze,{size:14}):"Test"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$outline:!0,onClick:()=>r(e.id),style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),a===e.id&&t.jsx(Xr,{title:"Delete this SSO connection?",onConfirm:()=>n(e.id),onCancel:s})]})]})]}),C&&t.jsxs("div",{style:{marginBottom:"var(--space-6u)",padding:"var(--space-4u) var(--space-6u)",background:C.success?"var(--color-success-background)":"var(--color-error-background)",borderRadius:"var(--radius-xs)",fontSize:"var(--font-size-sm)",color:C.success?"var(--color-success)":"var(--color-error)",fontWeight:500},children:[C.success?"✓ Connection is valid":"✗ Connection failed",C.errors&&Object.entries(C.errors).map(([z,H])=>t.jsxs("div",{style:{fontWeight:400,marginTop:"var(--space-2u)"},children:[z.replace(/_/g," "),": ",H]},z))]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"var(--space-2u) var(--space-8u)",fontSize:"var(--font-size-sm)",marginBottom:"var(--space-8u)"},children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.idp_entity_id}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.oidc_issuer_url}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:e.oidc_client_id}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs(B6,{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-6u)"},children:[t.jsxs(W6,{style:{marginBottom:0},children:[t.jsx(Rt,{size:14}),"SCIM Provisioning"]}),t.jsx(G6,{children:!(p!=null&&p.exists)||!((F=p==null?void 0:p.token)!=null&&F.enabled)?t.jsx(N,{onClick:y,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"calc(var(--space-10u) * 6)"},children:g?t.jsx(ze,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(N,{onClick:y,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)"},children:g?t.jsx(ze,{size:14}):"Rotate"}),t.jsx(N,{$outline:!0,onClick:M,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((I=p==null?void 0:p.token)==null?void 0:I.scim_base_url)||w)&&t.jsx("div",{style:{marginBottom:"var(--space-4u)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",minWidth:"var(--size-40u)"},children:"Base URL:"}),t.jsx("code",{style:{fontSize:"var(--font-size-xs)",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((R=p==null?void 0:p.token)==null?void 0:R.scim_base_url)||"Loading..."}),((T=p==null?void 0:p.token)==null?void 0:T.scim_base_url)&&t.jsx(_a,{onClick:()=>A(p.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})}),w&&t.jsxs("div",{style:{marginBottom:"var(--space-4u)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",minWidth:"var(--size-40u)"},children:"Token:"}),t.jsx("code",{style:{fontSize:"var(--font-size-xs)",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:w}),t.jsx(_a,{onClick:()=>A(w,"scim-token"),children:b==="scim-token"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]}),t.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-warning)",marginTop:"var(--space-3u)"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(p==null?void 0:p.exists)&&(($=p==null?void 0:p.token)==null?void 0:$.enabled)&&!w&&t.jsxs("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)"},children:["Token:"," ",t.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-subtle)",padding:"var(--space-1u) var(--space-3u)",borderRadius:"var(--radius-2xs)"},children:[p.token.token_prefix,"..."]}),p.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(p.token.last_used_at).toLocaleDateString()]})]})]})]})},ko=l.h3`
2744
+ `,q6=({connection:e,onDelete:r,connectionToDelete:a,onConfirmDelete:n,onCancelDelete:s,testConnection:i,generateSCIMToken:h,getSCIMToken:d,revokeSCIMToken:u,toast:f})=>{var I,P,L,T,$;const[p,m]=c.useState(null),[g,v]=c.useState(!1),[w,x]=c.useState(null),[b,E]=c.useState(null),[j,S]=c.useState(!1),[C,_]=c.useState(null);c.useEffect(()=>{d&&e.id&&d(e.id).then(m).catch(()=>{})},[e.id,d]);const k=async()=>{if(i){S(!0),_(null);try{const z=await i(e.id);_(z)}catch(z){_({success:!1,checks:{},errors:{general:z.message||"Test failed"}})}finally{S(!1)}}},y=async()=>{if(h){v(!0);try{const z=await h(e.id);x(z.token),m({exists:!0,token:z}),f("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(z){f(z.message||"Failed to generate token","error")}finally{v(!1)}}},M=async()=>{if(u){v(!0);try{await u(e.id),m({exists:!1,scim_base_url:p==null?void 0:p.scim_base_url}),x(null),f("SCIM token revoked","info")}catch(z){f(z.message||"Failed to revoke token","error")}finally{v(!1)}}},A=(z,H)=>{navigator.clipboard.writeText(z),E(H),setTimeout(()=>E(null),2e3)};return t.jsxs(O6,{children:[t.jsxs(H6,{children:[t.jsxs(V6,{children:[t.jsx(Rt,{size:16}),e.protocol==="oidc"?"OIDC SSO":"SAML SSO",t.jsx(D6,{children:e.protocol.toUpperCase()})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(N,{onClick:k,disabled:j,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)"},children:j?t.jsx(ze,{size:14}):"Test"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$outline:!0,onClick:()=>r(e.id),style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),a===e.id&&t.jsx(Xr,{title:"Delete this SSO connection?",onConfirm:()=>n(e.id),onCancel:s})]})]})]}),C&&t.jsxs("div",{style:{marginBottom:"var(--space-6u)",padding:"var(--space-4u) var(--space-6u)",background:C.success?"var(--color-success-background)":"var(--color-error-background)",borderRadius:"var(--radius-xs)",fontSize:"var(--font-size-sm)",color:C.success?"var(--color-success)":"var(--color-error)",fontWeight:500},children:[C.success?"✓ Connection is valid":"✗ Connection failed",C.errors&&Object.entries(C.errors).map(([z,H])=>t.jsxs("div",{style:{fontWeight:400,marginTop:"var(--space-2u)"},children:[z.replace(/_/g," "),": ",H]},z))]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"var(--space-2u) var(--space-8u)",fontSize:"var(--font-size-sm)",marginBottom:"var(--space-8u)"},children:[e.protocol==="saml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.idp_entity_id}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.idp_sso_url})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),t.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:e.oidc_issuer_url}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:e.oidc_client_id}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:e.oidc_scopes||"openid profile email"})]}),t.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),t.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(e.created_at).toLocaleDateString()})]}),t.jsxs(B6,{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-6u)"},children:[t.jsxs(W6,{style:{marginBottom:0},children:[t.jsx(Rt,{size:14}),"SCIM Provisioning"]}),t.jsx(G6,{children:!(p!=null&&p.exists)||!((I=p==null?void 0:p.token)!=null&&I.enabled)?t.jsx(N,{onClick:y,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"calc(var(--space-10u) * 6)"},children:g?t.jsx(ze,{size:14}):"Generate Token"}):t.jsxs(t.Fragment,{children:[t.jsx(N,{onClick:y,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)"},children:g?t.jsx(ze,{size:14}):"Rotate"}),t.jsx(N,{$outline:!0,onClick:M,disabled:g,style:{fontSize:"var(--font-size-sm)",padding:"var(--space-3u) var(--space-7u)",width:"var(--size-40u)",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((P=p==null?void 0:p.token)==null?void 0:P.scim_base_url)||w)&&t.jsx("div",{style:{marginBottom:"var(--space-4u)"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",minWidth:"var(--size-40u)"},children:"Base URL:"}),t.jsx("code",{style:{fontSize:"var(--font-size-xs)",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((L=p==null?void 0:p.token)==null?void 0:L.scim_base_url)||"Loading..."}),((T=p==null?void 0:p.token)==null?void 0:T.scim_base_url)&&t.jsx(_a,{onClick:()=>A(p.token.scim_base_url,"scim-url"),children:b==="scim-url"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})}),w&&t.jsxs("div",{style:{marginBottom:"var(--space-4u)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",minWidth:"var(--size-40u)"},children:"Token:"}),t.jsx("code",{style:{fontSize:"var(--font-size-xs)",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:w}),t.jsx(_a,{onClick:()=>A(w,"scim-token"),children:b==="scim-token"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]}),t.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-warning)",marginTop:"var(--space-3u)"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(p==null?void 0:p.exists)&&(($=p==null?void 0:p.token)==null?void 0:$.enabled)&&!w&&t.jsxs("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)"},children:["Token:"," ",t.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-subtle)",padding:"var(--space-1u) var(--space-3u)",borderRadius:"var(--radius-2xs)"},children:[p.token.token_prefix,"..."]}),p.token.last_used_at&&t.jsxs("span",{children:[" ","· Last used:"," ",new Date(p.token.last_used_at).toLocaleDateString()]})]})]})]})},ko=l.h3`
2745
2745
  margin: 0 0 var(--space-6u) 0;
2746
2746
  font-size: var(--font-size-md);
2747
2747
  font-weight: 600;
2748
2748
  color: var(--color-card-foreground);
2749
2749
  text-transform: uppercase;
2750
2750
  letter-spacing: var(--letter-spacing-tight);
2751
- `,K6=({onCreate:e,organization:r})=>{const{getOrganizationDomains:a,testEnterpriseConnectionConfig:n}=It(),{deployment:s}=Ae(),{toast:i}=gt(),[h,d]=c.useState(!1),[u,f]=c.useState(null),[p,m]=c.useState("saml"),[g,v]=c.useState(null),[w,x]=c.useState(!1),[b,E]=c.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:""}),[j,S]=c.useState(!1),[C,_]=c.useState(null),{data:k=[],isLoading:y}=$e("wacht-org-verified-domains-for-sso-screen",async()=>(await(a==null?void 0:a(r))||[]).filter(H=>H.verified),{revalidateOnFocus:!1}),M=z=>{f(z),m(z.protocol),z.protocol==="saml"?E(H=>{var P,O,Z;return{...H,idp_entity_id:z.placeholders.entityId||"",idp_sso_url:z.placeholders.ssoUrl||"",attr_first_name:((P=z.attributeMapping)==null?void 0:P.first_name)||"",attr_last_name:((O=z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((Z=z.attributeMapping)==null?void 0:Z.email)||""}}):E(H=>{var P,O,Z;return{...H,oidc_issuer_url:z.placeholders.issuerUrl||"",oidc_scopes:z.placeholders.scopes||"openid profile email",attr_first_name:((P=z.attributeMapping)==null?void 0:P.first_name)||"",attr_last_name:((O=z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((Z=z.attributeMapping)==null?void 0:Z.email)||""}})},A=s!=null&&s.backend_host?`${s.backend_host.startsWith("https://")?"":"https://"}${s.backend_host}/auth/sso/oidc/callback`:"",F=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/metadata`:"",I=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/callback`:"",R=(z,H)=>{navigator.clipboard.writeText(z),v(H),setTimeout(()=>v(null),2e3)},T=async z=>{z.preventDefault();const H=P=>P.includes("{")||P.includes("}");if(p==="saml"){if(!b.idp_entity_id||H(b.idp_entity_id)){i("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||H(b.idp_sso_url)){i("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){i("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||H(b.oidc_issuer_url)){i("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||H(b.oidc_client_id)){i("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){i("Please enter the Client Secret","error");return}}d(!0);try{const P={};b.attr_first_name&&(P.first_name=b.attr_first_name),b.attr_last_name&&(P.last_name=b.attr_last_name),b.attr_email&&(P.email=b.attr_email);const O=Object.keys(P).length>0;p==="saml"?await e({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,...O&&{attribute_mapping:P}}):await e({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,...O&&{attribute_mapping:P}})}finally{d(!1)}},$=async()=>{S(!0),_(null);const z=O=>O.includes("{")||O.includes("}"),H={},P={};if(p==="saml"?(b.idp_entity_id?z(b.idp_entity_id)?(P.entity_id_valid=!1,H.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):P.entity_id_valid=!0:(P.entity_id_valid=!1,H.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?z(b.idp_sso_url)?(P.sso_url_valid=!1,H.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):P.sso_url_valid=!0:(P.sso_url_valid=!1,H.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?P.certificate_provided=!0:(P.certificate_provided=!1,H.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?z(b.oidc_issuer_url)?(P.issuer_url_valid=!1,H.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):P.issuer_url_valid=!0:(P.issuer_url_valid=!1,H.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?z(b.oidc_client_id)?(P.client_id_valid=!1,H.client_id_valid="Client ID contains placeholder values - please replace with actual values"):P.client_id_valid=!0:(P.client_id_valid=!1,H.client_id_valid="Client ID is required")),Object.keys(H).length>0){_({success:!1,checks:P,errors:H}),S(!1);return}try{const O=p==="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},Z=await(n==null?void 0:n(r,O));Z&&_(Z)}catch(O){_({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{S(!1)}};return t.jsxs("form",{onSubmit:T,autoComplete:"off",children:[u?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)",padding:"var(--space-6u)",background:"var(--color-primary-background)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-primary)",marginBottom:"var(--space-8u)"},children:[u.logo?t.jsx(_o,{src:u.logo,alt:u.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"var(--font-size-lg)",color:"var(--color-foreground)"},children:u.name}),t.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",textTransform:"uppercase"},children:u.protocol})]}),t.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"var(--font-size-sm)",padding:"var(--space-2u) var(--space-4u)"},children:"Change"})]}):t.jsxs(t.Fragment,{children:[t.jsx(ko,{children:"SAML Providers"}),t.jsx(pc,{children:uc.filter(z=>z.protocol==="saml").map(z=>t.jsxs(hc,{type:"button",$selected:!1,onClick:()=>M(z),children:[z.logo?t.jsx(_o,{src:z.logo,alt:z.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsx(fc,{children:z.name})]},z.id))}),t.jsx(ko,{style:{marginTop:"var(--space-10u)"},children:"OIDC Providers"}),t.jsx(pc,{children:uc.filter(z=>z.protocol==="oidc").map(z=>t.jsxs(hc,{type:"button",$selected:!1,onClick:()=>M(z),children:[z.logo?t.jsx(_o,{src:z.logo,alt:z.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsx(fc,{children:z.name})]},z.id))})]}),u&&t.jsxs(t.Fragment,{children:[t.jsxs(dc,{style:{marginTop:"var(--space-8u)"},children:[t.jsx("div",{style:{marginBottom:"var(--space-6u)",fontWeight:500},children:"Service Provider Details"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:p==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"ACS URL:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:I}),t.jsx(_a,{onClick:()=>R(I,"acs"),children:g==="acs"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"Metadata:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:F}),t.jsx(_a,{onClick:()=>R(F,"metadata"),children:g==="metadata"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"Callback:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:A}),t.jsx(_a,{onClick:()=>R(A,"callback"),children:g==="callback"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})})]}),t.jsxs("div",{style:{marginTop:"var(--space-12u)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-6u)"},children:[t.jsx(ko,{style:{margin:0},children:u?`${u.name} Configuration`:"Configuration"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)"},children:[u&&u.docUrl&&t.jsxs("a",{href:u.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"var(--font-size-sm)",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"var(--space-1u)",alignItems:"center"},children:[t.jsx(hf,{size:12})," Docs"]}),t.jsx(N,{type:"button",$outline:!0,onClick:$,disabled:j||!u,style:{padding:"var(--space-4u) var(--space-8u)"},children:j?t.jsx(ze,{size:16}):"Test Connection"}),t.jsx(N,{type:"submit",disabled:h||k.length===0||!u,style:{width:"auto",padding:"var(--space-4u) var(--space-8u)"},children:h?t.jsx(ze,{size:16}):"Create Connection"})]})]}),C&&(()=>{const z={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 t.jsxs("div",{style:{padding:"var(--space-8u)",marginBottom:"var(--space-8u)",borderRadius:"var(--radius-md)",background:C.success?"var(--color-success-background)":"var(--color-error-background)",border:`var(--border-width-thin) solid ${C.success?"var(--color-success)":"var(--color-error)"}`},children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"var(--space-6u)",fontSize:"var(--font-size-lg)",color:C.success?"var(--color-success)":"var(--color-error)"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:Object.entries(C.checks).map(([H,P])=>{var O;return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-4u)",padding:"var(--space-4u) var(--space-6u)",background:"var(--color-background)",borderRadius:"var(--radius-xs)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx("span",{style:{color:P?"var(--color-success)":"var(--color-error)",fontWeight:600,fontSize:"var(--font-size-lg)",minWidth:"var(--size-8u)"},children:P?"✓":"✗"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"var(--font-size-md)"},children:z[H]||H.replace(/_/g," ").replace(/\b\w/g,Z=>Z.toUpperCase())}),((O=C.errors)==null?void 0:O[H])&&t.jsx("div",{style:{color:"var(--color-error)",fontSize:"var(--font-size-sm)",marginTop:"var(--space-2u)"},children:C.errors[H]})]})]},H)})})]})})(),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"var(--space-8u)"},children:[!u&&t.jsxs(Se,{children:[t.jsx(be,{children:"Protocol *"}),t.jsxs(mc,{value:p,onChange:z=>m(z.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Se,{style:{gridColumn:"1 / -1"},children:[t.jsx(be,{children:"Domain *"}),y?t.jsx("div",{style:{padding:"var(--space-5u)",color:"var(--color-muted)"},children:"Loading domains..."}):k.length===0?t.jsx(dc,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):t.jsxs(mc,{value:b.domain_id,onChange:z=>E({...b,domain_id:z.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),k.map(z=>t.jsx("option",{value:z.id,children:z.fqdn},z.id))]})]}),p==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Se,{children:[t.jsx(be,{children:"IdP Entity ID *"}),t.jsx(ue,{type:"text",value:b.idp_entity_id,onChange:z=>E({...b,idp_entity_id:z.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"IdP SSO URL *"}),t.jsx(ue,{type:"url",value:b.idp_sso_url,onChange:z=>E({...b,idp_sso_url:z.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Se,{style:{gridColumn:"1 / -1"},children:[t.jsx(be,{children:"X.509 Certificate *"}),t.jsx(N6,{value:b.idp_certificate,onChange:z=>E({...b,idp_certificate:z.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Se,{children:[t.jsx(be,{children:"Issuer URL *"}),t.jsx(ue,{type:"url",value:b.oidc_issuer_url,onChange:z=>E({...b,oidc_issuer_url:z.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Client ID *"}),t.jsx(ue,{type:"text",value:b.oidc_client_id,onChange:z=>E({...b,oidc_client_id:z.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Client Secret *"}),t.jsx(ue,{type:"password",value:b.oidc_client_secret,onChange:z=>E({...b,oidc_client_secret:z.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Scopes"}),t.jsx(ue,{type:"text",value:b.oidc_scopes,onChange:z=>E({...b,oidc_scopes:z.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Se,{style:{gridColumn:"1 / -1"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{children:[t.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)",marginTop:"var(--space-2u)"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Tr,{checked:b.jit_enabled,onChange:()=>E({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"var(--space-4u)",marginBottom:"var(--space-12u)"},children:[t.jsxs("div",{onClick:()=>x(!w),style:{display:"flex",alignItems:"center",gap:"var(--space-4u)",cursor:"pointer",color:"var(--color-primary)",fontSize:"var(--font-size-md)",fontWeight:500,marginBottom:w?"var(--space-8u)":"0"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-2xs)"},children:w?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),w&&t.jsxs("div",{style:{padding:"var(--space-8u)",background:"var(--color-background-subtle)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)",marginBottom:"var(--space-6u)"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"var(--space-6u)"},children:[t.jsxs(Se,{children:[t.jsx(be,{children:"First Name Attribute"}),t.jsx(ue,{type:"text",value:b.attr_first_name,onChange:z=>E({...b,attr_first_name:z.target.value}),placeholder:p==="saml"?"givenName":"given_name"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Last Name Attribute"}),t.jsx(ue,{type:"text",value:b.attr_last_name,onChange:z=>E({...b,attr_last_name:z.target.value}),placeholder:p==="saml"?"surname":"family_name"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Email Attribute"}),t.jsx(ue,{type:"text",value:b.attr_email,onChange:z=>E({...b,attr_email:z.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})};mt`
2751
+ `,K6=({onCreate:e,organization:r})=>{const{getOrganizationDomains:a,testEnterpriseConnectionConfig:n}=It(),{deployment:s}=Ae(),{toast:i}=gt(),[h,d]=c.useState(!1),[u,f]=c.useState(null),[p,m]=c.useState("saml"),[g,v]=c.useState(null),[w,x]=c.useState(!1),[b,E]=c.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:""}),[j,S]=c.useState(!1),[C,_]=c.useState(null),{data:k=[],isLoading:y}=$e("wacht-org-verified-domains-for-sso-screen",async()=>(await(a==null?void 0:a(r))||[]).filter(H=>H.verified),{revalidateOnFocus:!1}),M=z=>{f(z),m(z.protocol),z.protocol==="saml"?E(H=>{var F,O,Z;return{...H,idp_entity_id:z.placeholders.entityId||"",idp_sso_url:z.placeholders.ssoUrl||"",attr_first_name:((F=z.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((O=z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((Z=z.attributeMapping)==null?void 0:Z.email)||""}}):E(H=>{var F,O,Z;return{...H,oidc_issuer_url:z.placeholders.issuerUrl||"",oidc_scopes:z.placeholders.scopes||"openid profile email",attr_first_name:((F=z.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((O=z.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((Z=z.attributeMapping)==null?void 0:Z.email)||""}})},A=s!=null&&s.backend_host?`${s.backend_host.startsWith("https://")?"":"https://"}${s.backend_host}/auth/sso/oidc/callback`:"",I=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/metadata`:"",P=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/callback`:"",L=(z,H)=>{navigator.clipboard.writeText(z),v(H),setTimeout(()=>v(null),2e3)},T=async z=>{z.preventDefault();const H=F=>F.includes("{")||F.includes("}");if(p==="saml"){if(!b.idp_entity_id||H(b.idp_entity_id)){i("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!b.idp_sso_url||H(b.idp_sso_url)){i("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!b.idp_certificate){i("Please provide the X.509 Certificate","error");return}}else{if(!b.oidc_issuer_url||H(b.oidc_issuer_url)){i("Please enter a valid Issuer URL (no placeholders)","error");return}if(!b.oidc_client_id||H(b.oidc_client_id)){i("Please enter a valid Client ID (no placeholders)","error");return}if(!b.oidc_client_secret){i("Please enter the Client Secret","error");return}}d(!0);try{const F={};b.attr_first_name&&(F.first_name=b.attr_first_name),b.attr_last_name&&(F.last_name=b.attr_last_name),b.attr_email&&(F.email=b.attr_email);const O=Object.keys(F).length>0;p==="saml"?await e({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,...O&&{attribute_mapping:F}}):await e({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,...O&&{attribute_mapping:F}})}finally{d(!1)}},$=async()=>{S(!0),_(null);const z=O=>O.includes("{")||O.includes("}"),H={},F={};if(p==="saml"?(b.idp_entity_id?z(b.idp_entity_id)?(F.entity_id_valid=!1,H.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):F.entity_id_valid=!0:(F.entity_id_valid=!1,H.entity_id_valid="IdP Entity ID is required"),b.idp_sso_url?z(b.idp_sso_url)?(F.sso_url_valid=!1,H.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):F.sso_url_valid=!0:(F.sso_url_valid=!1,H.sso_url_valid="IdP SSO URL is required"),b.idp_certificate?F.certificate_provided=!0:(F.certificate_provided=!1,H.certificate_provided="X.509 Certificate is required")):(b.oidc_issuer_url?z(b.oidc_issuer_url)?(F.issuer_url_valid=!1,H.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):F.issuer_url_valid=!0:(F.issuer_url_valid=!1,H.issuer_url_valid="Issuer URL is required"),b.oidc_client_id?z(b.oidc_client_id)?(F.client_id_valid=!1,H.client_id_valid="Client ID contains placeholder values - please replace with actual values"):F.client_id_valid=!0:(F.client_id_valid=!1,H.client_id_valid="Client ID is required")),Object.keys(H).length>0){_({success:!1,checks:F,errors:H}),S(!1);return}try{const O=p==="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},Z=await(n==null?void 0:n(r,O));Z&&_(Z)}catch(O){_({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{S(!1)}};return t.jsxs("form",{onSubmit:T,autoComplete:"off",children:[u?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)",padding:"var(--space-6u)",background:"var(--color-primary-background)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-primary)",marginBottom:"var(--space-8u)"},children:[u.logo?t.jsx(_o,{src:u.logo,alt:u.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"var(--font-size-lg)",color:"var(--color-foreground)"},children:u.name}),t.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-muted)",textTransform:"uppercase"},children:u.protocol})]}),t.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"var(--font-size-sm)",padding:"var(--space-2u) var(--space-4u)"},children:"Change"})]}):t.jsxs(t.Fragment,{children:[t.jsx(ko,{children:"SAML Providers"}),t.jsx(pc,{children:uc.filter(z=>z.protocol==="saml").map(z=>t.jsxs(hc,{type:"button",$selected:!1,onClick:()=>M(z),children:[z.logo?t.jsx(_o,{src:z.logo,alt:z.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsx(fc,{children:z.name})]},z.id))}),t.jsx(ko,{style:{marginTop:"var(--space-10u)"},children:"OIDC Providers"}),t.jsx(pc,{children:uc.filter(z=>z.protocol==="oidc").map(z=>t.jsxs(hc,{type:"button",$selected:!1,onClick:()=>M(z),children:[z.logo?t.jsx(_o,{src:z.logo,alt:z.name}):t.jsx("div",{style:{height:"var(--size-12u)",width:"var(--size-12u)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-background)",borderRadius:"var(--radius-2xs)",padding:"var(--space-1u)"},children:t.jsx(Rt,{size:18,color:"var(--color-muted)"})}),t.jsx(fc,{children:z.name})]},z.id))})]}),u&&t.jsxs(t.Fragment,{children:[t.jsxs(dc,{style:{marginTop:"var(--space-8u)"},children:[t.jsx("div",{style:{marginBottom:"var(--space-6u)",fontWeight:500},children:"Service Provider Details"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:p==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"ACS URL:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:P}),t.jsx(_a,{onClick:()=>L(P,"acs"),children:g==="acs"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"Metadata:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:I}),t.jsx(_a,{onClick:()=>L(I,"metadata"),children:g==="metadata"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{minWidth:"var(--size-40u)",fontSize:"var(--font-size-sm)"},children:"Callback:"}),t.jsx("code",{style:{flex:1,fontSize:"var(--font-size-xs)"},children:A}),t.jsx(_a,{onClick:()=>L(A,"callback"),children:g==="callback"?t.jsx(ct,{size:12}):t.jsx(Yr,{size:12})})]})})]}),t.jsxs("div",{style:{marginTop:"var(--space-12u)"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-6u)"},children:[t.jsx(ko,{style:{margin:0},children:u?`${u.name} Configuration`:"Configuration"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)"},children:[u&&u.docUrl&&t.jsxs("a",{href:u.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"var(--font-size-sm)",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"var(--space-1u)",alignItems:"center"},children:[t.jsx(hf,{size:12})," Docs"]}),t.jsx(N,{type:"button",$outline:!0,onClick:$,disabled:j||!u,style:{padding:"var(--space-4u) var(--space-8u)"},children:j?t.jsx(ze,{size:16}):"Test Connection"}),t.jsx(N,{type:"submit",disabled:h||k.length===0||!u,style:{width:"auto",padding:"var(--space-4u) var(--space-8u)"},children:h?t.jsx(ze,{size:16}):"Create Connection"})]})]}),C&&(()=>{const z={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 t.jsxs("div",{style:{padding:"var(--space-8u)",marginBottom:"var(--space-8u)",borderRadius:"var(--radius-md)",background:C.success?"var(--color-success-background)":"var(--color-error-background)",border:`var(--border-width-thin) solid ${C.success?"var(--color-success)":"var(--color-error)"}`},children:[t.jsx("div",{style:{fontWeight:600,marginBottom:"var(--space-6u)",fontSize:"var(--font-size-lg)",color:C.success?"var(--color-success)":"var(--color-error)"},children:C.success?"✓ All checks passed":"✗ Some checks failed"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:Object.entries(C.checks).map(([H,F])=>{var O;return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-4u)",padding:"var(--space-4u) var(--space-6u)",background:"var(--color-background)",borderRadius:"var(--radius-xs)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx("span",{style:{color:F?"var(--color-success)":"var(--color-error)",fontWeight:600,fontSize:"var(--font-size-lg)",minWidth:"var(--size-8u)"},children:F?"✓":"✗"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"var(--font-size-md)"},children:z[H]||H.replace(/_/g," ").replace(/\b\w/g,Z=>Z.toUpperCase())}),((O=C.errors)==null?void 0:O[H])&&t.jsx("div",{style:{color:"var(--color-error)",fontSize:"var(--font-size-sm)",marginTop:"var(--space-2u)"},children:C.errors[H]})]})]},H)})})]})})(),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"var(--space-8u)"},children:[!u&&t.jsxs(Se,{children:[t.jsx(be,{children:"Protocol *"}),t.jsxs(mc,{value:p,onChange:z=>m(z.target.value),children:[t.jsx("option",{value:"saml",children:"SAML"}),t.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),t.jsxs(Se,{style:{gridColumn:"1 / -1"},children:[t.jsx(be,{children:"Domain *"}),y?t.jsx("div",{style:{padding:"var(--space-5u)",color:"var(--color-muted)"},children:"Loading domains..."}):k.length===0?t.jsx(dc,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):t.jsxs(mc,{value:b.domain_id,onChange:z=>E({...b,domain_id:z.target.value}),required:!0,children:[t.jsx("option",{value:"",children:"Select a verified domain"}),k.map(z=>t.jsx("option",{value:z.id,children:z.fqdn},z.id))]})]}),p==="saml"?t.jsxs(t.Fragment,{children:[t.jsxs(Se,{children:[t.jsx(be,{children:"IdP Entity ID *"}),t.jsx(ue,{type:"text",value:b.idp_entity_id,onChange:z=>E({...b,idp_entity_id:z.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"IdP SSO URL *"}),t.jsx(ue,{type:"url",value:b.idp_sso_url,onChange:z=>E({...b,idp_sso_url:z.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),t.jsxs(Se,{style:{gridColumn:"1 / -1"},children:[t.jsx(be,{children:"X.509 Certificate *"}),t.jsx(N6,{value:b.idp_certificate,onChange:z=>E({...b,idp_certificate:z.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(Se,{children:[t.jsx(be,{children:"Issuer URL *"}),t.jsx(ue,{type:"url",value:b.oidc_issuer_url,onChange:z=>E({...b,oidc_issuer_url:z.target.value}),placeholder:"https://login.example.com",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Client ID *"}),t.jsx(ue,{type:"text",value:b.oidc_client_id,onChange:z=>E({...b,oidc_client_id:z.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Client Secret *"}),t.jsx(ue,{type:"password",value:b.oidc_client_secret,onChange:z=>E({...b,oidc_client_secret:z.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Scopes"}),t.jsx(ue,{type:"text",value:b.oidc_scopes,onChange:z=>E({...b,oidc_scopes:z.target.value}),placeholder:"openid profile email"})]})]}),t.jsx(Se,{style:{gridColumn:"1 / -1"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{children:[t.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)",marginTop:"var(--space-2u)"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),t.jsx(Tr,{checked:b.jit_enabled,onChange:()=>E({...b,jit_enabled:!b.jit_enabled})})]})}),t.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"var(--space-4u)",marginBottom:"var(--space-12u)"},children:[t.jsxs("div",{onClick:()=>x(!w),style:{display:"flex",alignItems:"center",gap:"var(--space-4u)",cursor:"pointer",color:"var(--color-primary)",fontSize:"var(--font-size-md)",fontWeight:500,marginBottom:w?"var(--space-8u)":"0"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-2xs)"},children:w?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),w&&t.jsxs("div",{style:{padding:"var(--space-8u)",background:"var(--color-background-subtle)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)",marginBottom:"var(--space-6u)"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"var(--space-6u)"},children:[t.jsxs(Se,{children:[t.jsx(be,{children:"First Name Attribute"}),t.jsx(ue,{type:"text",value:b.attr_first_name,onChange:z=>E({...b,attr_first_name:z.target.value}),placeholder:p==="saml"?"givenName":"given_name"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Last Name Attribute"}),t.jsx(ue,{type:"text",value:b.attr_last_name,onChange:z=>E({...b,attr_last_name:z.target.value}),placeholder:p==="saml"?"surname":"family_name"})]}),t.jsxs(Se,{children:[t.jsx(be,{children:"Email Attribute"}),t.jsx(ue,{type:"text",value:b.attr_email,onChange:z=>E({...b,attr_email:z.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})};mt`
2752
2752
  0% { transform: rotate(0deg); }
2753
2753
  100% { transform: rotate(360deg); }
2754
2754
  `;const gc=l.div`
@@ -3160,10 +3160,10 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
3160
3160
  color: var(--color-secondary-text);
3161
3161
  margin-top: 2px;
3162
3162
  line-height: 1.4;
3163
- `,iv=({organization:e})=>{var I,R,T,$,z,H;const{switchOrganization:r,refetch:a}=ot(),{workspaces:n}=sr(),{deployment:s}=Ae(),{deleteOrganization:i,updateOrganization:h}=It(),{toast:d}=gt(),[u,f]=c.useState((e==null?void 0:e.name)||""),[p,m]=c.useState((e==null?void 0:e.description)||""),[g,v]=c.useState(!1),[w,x]=c.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,E]=c.useState(""),[j,S]=c.useState(!1),[C,_]=c.useState(!1),k=c.useRef({name:u,description:p,security:w,isSaving:g});c.useEffect(()=>{k.current={name:u,description:p,security:w,isSaving:g}},[u,p,w,g]);const y=c.useCallback(async()=>{if(!e)return;const P=k.current;try{v(!0),await h(e,{name:P.name,description:P.description,whitelisted_ips:P.security.allowed_ips.split(`
3164
- `).filter(O=>O.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),d("Changes saved","info")}catch(O){d(O.message||"Failed to save changes","error")}finally{v(!1)}},[e,h,d]),M=c.useCallback(()=>{k.current.isSaving||y()},[y]);c.useEffect(()=>{var P;e&&(f(e.name||""),m(e.description||""),x({allowed_ips:((P=e.whitelisted_ips)==null?void 0:P.join(`
3165
- `))||"",ip_restrictions:e.enable_ip_restriction||!1,mfa_required:e.enforce_mfa||!1,default_workspace_id:e.auto_assigned_workspace_id||""}))},[e]);const A=c.useMemo(()=>n.filter(P=>P.organization.id===(e==null?void 0:e.id)),[n,e==null?void 0:e.id]),F=async()=>{if(!(!e||b!==e.name))try{S(!0),await r(""),await i(e),await a(),d("Organization deleted","info")}catch{d("Failed to delete organization","error")}finally{S(!1),E("")}};return e?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)",paddingBottom:"var(--size-20u)"},children:[t.jsxs(Co,{children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"name",children:"Organization name"}),t.jsx(ue,{id:"name",value:u,onChange:P=>f(P.target.value),onBlur:M,placeholder:"Organization name",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"description",children:"Description"}),t.jsx(ue,{id:"description",as:"textarea",value:p,onChange:P=>m(P.target.value),onBlur:M,placeholder:"Optional description",style:{minHeight:"var(--size-40u)",resize:"vertical"}})]}),((I=s==null?void 0:s.b2b_settings)==null?void 0:I.workspaces_enabled)&&A.length>0&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"default_workspace",children:"Default workspace"}),t.jsx(Zn,{options:A.map(P=>({value:P.id,label:P.name})),value:w.default_workspace_id,onChange:P=>{x(O=>({...O,default_workspace_id:P})),setTimeout(M,0)},placeholder:"Select default workspace"})]})]}),(((R=s==null?void 0:s.b2b_settings)==null?void 0:R.enforce_mfa_per_org_enabled)||((T=s==null?void 0:s.b2b_settings)==null?void 0:T.ip_allowlist_per_org_enabled))&&t.jsxs(Co,{children:[t.jsx(wc,{children:"Security"}),(($=s==null?void 0:s.b2b_settings)==null?void 0:$.enforce_mfa_per_org_enabled)&&t.jsxs(vc,{style:{padding:0},children:[t.jsxs(xc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"Multi-factor authentication"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Require all members to set up MFA for added security."})]}),t.jsx(bc,{children:t.jsx(Tr,{checked:w.mfa_required,onChange:()=>{const P=!w.mfa_required;x(O=>({...O,mfa_required:P})),setTimeout(M,0)}})})]}),((z=s==null?void 0:s.b2b_settings)==null?void 0:z.ip_allowlist_per_org_enabled)&&t.jsxs(t.Fragment,{children:[t.jsxs(vc,{style:{padding:0},children:[t.jsxs(xc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"IP restrictions"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Only allow access from specific IP addresses."})]}),t.jsx(bc,{children:t.jsx(Tr,{checked:w.ip_restrictions,onChange:()=>{const P=!w.ip_restrictions;x(O=>({...O,ip_restrictions:P})),setTimeout(M,0)}})})]}),w.ip_restrictions&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ue,{id:"allowed_ips",as:"textarea",value:w.allowed_ips,onChange:P=>x(O=>({...O,allowed_ips:P.target.value})),onBlur:M,placeholder:`192.168.1.1
3166
- 10.0.0.0/24`,style:{minHeight:"var(--size-40u)",fontFamily:"monospace"}})]})]})]}),((H=s==null?void 0:s.b2b_settings)==null?void 0:H.allow_org_deletion)&&t.jsxs(Co,{children:[t.jsx(wc,{children:"Danger zone"}),t.jsxs(av,{children:[t.jsxs(nv,{children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx(ov,{children:"Delete organization"}),t.jsx(sv,{children:"Once you delete this organization, there is no going back."})]}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!C),E("")},children:C?"Cancel":"Delete organization"})]}),C&&t.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(ue,{id:"confirm_org_name",type:"text",value:b,onChange:P=>E(P.target.value),placeholder:e.name})]}),t.jsx(N,{$size:"sm",$destructive:!0,onClick:F,disabled:b!==e.name||j,children:j?t.jsx(ze,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(ze,{})},Ot=l.table`
3163
+ `,iv=({organization:e})=>{var P,L,T,$,z,H;const{switchOrganization:r,refetch:a}=ot(),{workspaces:n}=sr(),{deployment:s}=Ae(),{deleteOrganization:i,updateOrganization:h}=It(),{toast:d}=gt(),[u,f]=c.useState((e==null?void 0:e.name)||""),[p,m]=c.useState((e==null?void 0:e.description)||""),[g,v]=c.useState(!1),[w,x]=c.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[b,E]=c.useState(""),[j,S]=c.useState(!1),[C,_]=c.useState(!1),k=c.useRef({name:u,description:p,security:w,isSaving:g});c.useEffect(()=>{k.current={name:u,description:p,security:w,isSaving:g}},[u,p,w,g]);const y=c.useCallback(async()=>{if(!e)return;const F=k.current;try{v(!0),await h(e,{name:F.name,description:F.description,whitelisted_ips:F.security.allowed_ips.split(`
3164
+ `).filter(O=>O.trim()),enable_ip_restriction:F.security.ip_restrictions,enforce_mfa:F.security.mfa_required,auto_assigned_workspace_id:F.security.default_workspace_id||"0"}),d("Changes saved","info")}catch(O){d(O.message||"Failed to save changes","error")}finally{v(!1)}},[e,h,d]),M=c.useCallback(()=>{k.current.isSaving||y()},[y]);c.useEffect(()=>{var F;e&&(f(e.name||""),m(e.description||""),x({allowed_ips:((F=e.whitelisted_ips)==null?void 0:F.join(`
3165
+ `))||"",ip_restrictions:e.enable_ip_restriction||!1,mfa_required:e.enforce_mfa||!1,default_workspace_id:e.auto_assigned_workspace_id||""}))},[e]);const A=c.useMemo(()=>n.filter(F=>F.organization.id===(e==null?void 0:e.id)),[n,e==null?void 0:e.id]),I=async()=>{if(!(!e||b!==e.name))try{S(!0),await r(""),await i(e),await a(),d("Organization deleted","info")}catch{d("Failed to delete organization","error")}finally{S(!1),E("")}};return e?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)",paddingBottom:"var(--size-20u)"},children:[t.jsxs(Co,{children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"name",children:"Organization name"}),t.jsx(ue,{id:"name",value:u,onChange:F=>f(F.target.value),onBlur:M,placeholder:"Organization name",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"description",children:"Description"}),t.jsx(ue,{id:"description",as:"textarea",value:p,onChange:F=>m(F.target.value),onBlur:M,placeholder:"Optional description",style:{minHeight:"var(--size-40u)",resize:"vertical"}})]}),((P=s==null?void 0:s.b2b_settings)==null?void 0:P.workspaces_enabled)&&A.length>0&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"default_workspace",children:"Default workspace"}),t.jsx(Zn,{options:A.map(F=>({value:F.id,label:F.name})),value:w.default_workspace_id,onChange:F=>{x(O=>({...O,default_workspace_id:F})),setTimeout(M,0)},placeholder:"Select default workspace"})]})]}),(((L=s==null?void 0:s.b2b_settings)==null?void 0:L.enforce_mfa_per_org_enabled)||((T=s==null?void 0:s.b2b_settings)==null?void 0:T.ip_allowlist_per_org_enabled))&&t.jsxs(Co,{children:[t.jsx(wc,{children:"Security"}),(($=s==null?void 0:s.b2b_settings)==null?void 0:$.enforce_mfa_per_org_enabled)&&t.jsxs(vc,{style:{padding:0},children:[t.jsxs(xc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"Multi-factor authentication"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Require all members to set up MFA for added security."})]}),t.jsx(bc,{children:t.jsx(Tr,{checked:w.mfa_required,onChange:()=>{const F=!w.mfa_required;x(O=>({...O,mfa_required:F})),setTimeout(M,0)}})})]}),((z=s==null?void 0:s.b2b_settings)==null?void 0:z.ip_allowlist_per_org_enabled)&&t.jsxs(t.Fragment,{children:[t.jsxs(vc,{style:{padding:0},children:[t.jsxs(xc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"IP restrictions"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Only allow access from specific IP addresses."})]}),t.jsx(bc,{children:t.jsx(Tr,{checked:w.ip_restrictions,onChange:()=>{const F=!w.ip_restrictions;x(O=>({...O,ip_restrictions:F})),setTimeout(M,0)}})})]}),w.ip_restrictions&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ue,{id:"allowed_ips",as:"textarea",value:w.allowed_ips,onChange:F=>x(O=>({...O,allowed_ips:F.target.value})),onBlur:M,placeholder:`192.168.1.1
3166
+ 10.0.0.0/24`,style:{minHeight:"var(--size-40u)",fontFamily:"monospace"}})]})]})]}),((H=s==null?void 0:s.b2b_settings)==null?void 0:H.allow_org_deletion)&&t.jsxs(Co,{children:[t.jsx(wc,{children:"Danger zone"}),t.jsxs(av,{children:[t.jsxs(nv,{children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx(ov,{children:"Delete organization"}),t.jsx(sv,{children:"Once you delete this organization, there is no going back."})]}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{_(!C),E("")},children:C?"Cancel":"Delete organization"})]}),C&&t.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"confirm_org_name",children:["Type"," ",t.jsx("strong",{children:e.name})," ","to confirm"]}),t.jsx(ue,{id:"confirm_org_name",type:"text",value:b,onChange:F=>E(F.target.value),placeholder:e.name})]}),t.jsx(N,{$size:"sm",$destructive:!0,onClick:I,disabled:b!==e.name||j,children:j?t.jsx(ze,{size:12}):"Delete forever"})]})]})]})]}):t.jsx(ze,{})},Ot=l.table`
3167
3167
  width: 100%;
3168
3168
  border-collapse: separate;
3169
3169
  border-spacing: 0;
@@ -3355,7 +3355,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
3355
3355
  justify-content: flex-end;
3356
3356
  flex-wrap: nowrap;
3357
3357
  white-space: nowrap;
3358
- `,xv=({organization:e})=>{const{getOrganizationMembers:r,getOrganizationRoles:a,addRoleToOrganizationMember:n,removeRoleFromOrganizationMember:s,removeOrganizationMember:i}=It(),{session:h}=ot(),{toast:d}=gt(),[u,f]=c.useState(""),[p,m]=c.useState(1),[g]=c.useState(10),[v,w]=c.useState(!1),[x,b]=c.useState(new Set),E=c.useRef(null),[j,S]=c.useState(u);c.useEffect(()=>{const $=setTimeout(()=>{S(u),m(1)},500);return()=>clearTimeout($)},[u]);const{data:C,mutate:_}=$e(e?`wacht-api-organizations:${e.id}:members:${p}:${g}:${j}`:null,()=>r==null?void 0:r(e,{page:p,limit:g,search:j}),{keepPreviousData:!0}),k=(C==null?void 0:C.data)||[],y=(C==null?void 0:C.meta)||{total:0,limit:10},M=Math.ceil(y.total/(y.limit||10)),{data:A=[]}=$e(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),F=A,I=($,z)=>{b(H=>{const P=new Set(H);return z?P.add($):P.delete($),P})},R=async($,z,H)=>{I($.id,!0);try{H?(await s(e,$,z),d("Role removed","info")):(await n(e,$,z),d("Role added","info")),_()}catch(P){d(P.message||"Failed to update role","error")}finally{I($.id,!1)}},T=async $=>{I($.id,!0);try{await i(e,$),_(),d("Member removed","info")}catch(z){d(z.message||"Failed to remove member","error")}finally{I($.id,!1)}};return C?t.jsxs(t.Fragment,{children:[t.jsxs(Hn,{children:[t.jsx("div",{style:{flex:1},children:t.jsx(x1,{value:u,onChange:f,placeholder:"Search members..."})}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",alignItems:"center"},children:[y.total>0&&t.jsxs("div",{style:{fontSize:13,color:"var(--color-secondary-text)"},children:[y.total," member",y.total!==1?"s":""]}),t.jsx(N,{ref:E,onClick:()=>w(!0),$size:"sm",children:"Invite"})]})]}),v&&t.jsx(O1,{onClose:()=>w(!1),onSuccess:()=>{_(),w(!1)},roles:F,triggerRef:E}),k.length===0?t.jsx(At,{title:u?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(Vn,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Roles"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:k.map($=>{var P,O;const z=((P=$.user)==null?void 0:P.id)===((O=h==null?void 0:h.active_signin)==null?void 0:O.user_id),H=x.has($.id);return t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsx(bv,{member:$,isCurrentUser:z})}),t.jsx(Ye,{style:{color:"var(--color-secondary-text)"},children:new Date($.created_at).toLocaleDateString()}),t.jsx(Ye,{children:t.jsx(wv,{member:$,roles:F,onToggle:R,disabled:H})}),t.jsx(Dt,{children:t.jsx(vv,{children:t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,disabled:H||z,onClick:()=>T($),title:z?"You cannot remove yourself":"Remove member",children:H?t.jsx(ze,{size:12}):"Remove"})})})]},$.id)})})]})}),M>1&&t.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"var(--space-8u)",marginTop:"var(--space-12u)"},children:[t.jsx(N,{onClick:()=>m($=>Math.max(1,$-1)),disabled:p===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{style:{fontSize:13,color:"var(--color-secondary-text)"},children:[p," / ",M]}),t.jsx(N,{onClick:()=>m($=>Math.min(M,$+1)),disabled:p===M,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(ze,{})},bv=({member:e,isCurrentUser:r})=>{var i,h;const a=e.user,n=(d="",u="")=>`${d[0]||""}${u[0]||""}`.toUpperCase()||"?",s=a?`${a.first_name||""} ${a.last_name||""}`.trim()||((i=a.primary_email_address)==null?void 0:i.email):"Unknown";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[t.jsx(gv,{children:a!=null&&a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:s}):n(a==null?void 0:a.first_name,a==null?void 0:a.last_name)}),t.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-card-foreground)"},children:s}),r&&t.jsx(rr,{$variant:"neutral",children:"You"})]}),t.jsx("span",{style:{fontSize:12,color:"var(--color-secondary-text)"},children:(h=a==null?void 0:a.primary_email_address)==null?void 0:h.email})]})]})},wv=({member:e,roles:r,onToggle:a,disabled:n})=>{var d;const s=e.roles||[],i=u=>s.some(f=>f.id===u),h=s.length===0?"No role":s.length===1?(d=s[0])==null?void 0:d.name:`${s.length} roles`;return t.jsxs(Ma,{children:[t.jsx(Ra,{children:t.jsxs(N,{$size:"sm",$outline:!0,disabled:n,style:{minWidth:150,justifyContent:"space-between"},children:[h,t.jsx(cr,{size:12,style:{marginLeft:6}})]})}),t.jsx(La,{style:{minWidth:180},children:r.length===0?t.jsx("div",{style:{padding:"10px 14px",fontSize:12,color:"var(--color-secondary-text)"},children:"No roles configured"}):r.map(u=>{const f=i(u.id);return t.jsx(nr,{onClick:()=>a(e,u,f),children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:10},children:[t.jsx("span",{children:u.name}),f&&t.jsx(ct,{size:13,color:"var(--color-primary)"})]})},u.id)})})]})},yv=l.div`
3358
+ `,xv=({organization:e})=>{const{getOrganizationMembers:r,getOrganizationRoles:a,addRoleToOrganizationMember:n,removeRoleFromOrganizationMember:s,removeOrganizationMember:i}=It(),{session:h}=ot(),{toast:d}=gt(),[u,f]=c.useState(""),[p,m]=c.useState(1),[g]=c.useState(10),[v,w]=c.useState(!1),[x,b]=c.useState(new Set),E=c.useRef(null),[j,S]=c.useState(u);c.useEffect(()=>{const $=setTimeout(()=>{S(u),m(1)},500);return()=>clearTimeout($)},[u]);const{data:C,mutate:_}=$e(e?`wacht-api-organizations:${e.id}:members:${p}:${g}:${j}`:null,()=>r==null?void 0:r(e,{page:p,limit:g,search:j}),{keepPreviousData:!0}),k=(C==null?void 0:C.data)||[],y=(C==null?void 0:C.meta)||{total:0,limit:10},M=Math.ceil(y.total/(y.limit||10)),{data:A=[]}=$e(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(a==null?void 0:a(e))||[]),I=A,P=($,z)=>{b(H=>{const F=new Set(H);return z?F.add($):F.delete($),F})},L=async($,z,H)=>{P($.id,!0);try{H?(await s(e,$,z),d("Role removed","info")):(await n(e,$,z),d("Role added","info")),_()}catch(F){d(F.message||"Failed to update role","error")}finally{P($.id,!1)}},T=async $=>{P($.id,!0);try{await i(e,$),_(),d("Member removed","info")}catch(z){d(z.message||"Failed to remove member","error")}finally{P($.id,!1)}};return C?t.jsxs(t.Fragment,{children:[t.jsxs(Hn,{children:[t.jsx("div",{style:{flex:1},children:t.jsx(x1,{value:u,onChange:f,placeholder:"Search members..."})}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",alignItems:"center"},children:[y.total>0&&t.jsxs("div",{style:{fontSize:13,color:"var(--color-secondary-text)"},children:[y.total," member",y.total!==1?"s":""]}),t.jsx(N,{ref:E,onClick:()=>w(!0),$size:"sm",children:"Invite"})]})]}),v&&t.jsx(O1,{onClose:()=>w(!1),onSuccess:()=>{_(),w(!1)},roles:I,triggerRef:E}),k.length===0?t.jsx(At,{title:u?"No members match":"No members yet",description:"Invite someone or connect a corporate domain to auto-join."}):t.jsx(Vn,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Roles"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:k.map($=>{var F,O;const z=((F=$.user)==null?void 0:F.id)===((O=h==null?void 0:h.active_signin)==null?void 0:O.user_id),H=x.has($.id);return t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsx(bv,{member:$,isCurrentUser:z})}),t.jsx(Ye,{style:{color:"var(--color-secondary-text)"},children:new Date($.created_at).toLocaleDateString()}),t.jsx(Ye,{children:t.jsx(wv,{member:$,roles:I,onToggle:L,disabled:H})}),t.jsx(Dt,{children:t.jsx(vv,{children:t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,disabled:H||z,onClick:()=>T($),title:z?"You cannot remove yourself":"Remove member",children:H?t.jsx(ze,{size:12}):"Remove"})})})]},$.id)})})]})}),M>1&&t.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"var(--space-8u)",marginTop:"var(--space-12u)"},children:[t.jsx(N,{onClick:()=>m($=>Math.max(1,$-1)),disabled:p===1,$size:"sm",$outline:!0,children:"Previous"}),t.jsxs("span",{style:{fontSize:13,color:"var(--color-secondary-text)"},children:[p," / ",M]}),t.jsx(N,{onClick:()=>m($=>Math.min(M,$+1)),disabled:p===M,$size:"sm",$outline:!0,children:"Next"})]})]}):t.jsx(ze,{})},bv=({member:e,isCurrentUser:r})=>{var i,h;const a=e.user,n=(d="",u="")=>`${d[0]||""}${u[0]||""}`.toUpperCase()||"?",s=a?`${a.first_name||""} ${a.last_name||""}`.trim()||((i=a.primary_email_address)==null?void 0:i.email):"Unknown";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[t.jsx(gv,{children:a!=null&&a.profile_picture_url?t.jsx("img",{src:a.profile_picture_url,alt:s}):n(a==null?void 0:a.first_name,a==null?void 0:a.last_name)}),t.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-card-foreground)"},children:s}),r&&t.jsx(rr,{$variant:"neutral",children:"You"})]}),t.jsx("span",{style:{fontSize:12,color:"var(--color-secondary-text)"},children:(h=a==null?void 0:a.primary_email_address)==null?void 0:h.email})]})]})},wv=({member:e,roles:r,onToggle:a,disabled:n})=>{var d;const s=e.roles||[],i=u=>s.some(f=>f.id===u),h=s.length===0?"No role":s.length===1?(d=s[0])==null?void 0:d.name:`${s.length} roles`;return t.jsxs(Ma,{children:[t.jsx(Ra,{children:t.jsxs(N,{$size:"sm",$outline:!0,disabled:n,style:{minWidth:150,justifyContent:"space-between"},children:[h,t.jsx(cr,{size:12,style:{marginLeft:6}})]})}),t.jsx(La,{style:{minWidth:180},children:r.length===0?t.jsx("div",{style:{padding:"10px 14px",fontSize:12,color:"var(--color-secondary-text)"},children:"No roles configured"}):r.map(u=>{const f=i(u.id);return t.jsx(nr,{onClick:()=>a(e,u,f),children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:10},children:[t.jsx("span",{children:u.name}),f&&t.jsx(ct,{size:13,color:"var(--color-primary)"})]})},u.id)})})]})},yv=l.div`
3359
3359
  display: flex;
3360
3360
  align-items: center;
3361
3361
  gap: 6px;
@@ -3430,7 +3430,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
3430
3430
  text-overflow: ellipsis;
3431
3431
  white-space: nowrap;
3432
3432
  max-width: 340px;
3433
- `,Rv=({organization:e})=>{var _;const{getOrganizationRoles:r,removeOrganizationRoles:a}=It(),{deployment:n}=Ae(),[s,i]=c.useState({isOpen:!1}),[h,d]=c.useState(null),[u,f]=c.useState(null),[p,m]=c.useState(new Set),g=c.useRef(null),v=c.useRef(new Map),{data:w=[],isLoading:x,mutate:b}=$e(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(r==null?void 0:r(e))||[]),E=(k,y)=>{m(M=>{const A=new Set(M);return y?A.add(k):A.delete(k),A})},j=async k=>{try{await new Promise(y=>setTimeout(y,500)),d({text:`Role ${k.id?"updated":"created"} successfully`,type:"success"}),i({isOpen:!1}),b()}catch(y){const M=y instanceof Error?y.message:"Failed to save role";d({text:M,type:"error"})}finally{setTimeout(()=>d(null),3e3)}},S=async k=>{E(k.id,!0);try{await a(e,k),b()}finally{E(k.id,!1),f(null)}};if(x&&w.length===0)return t.jsx(ze,{});const C=k=>{const y=Av(k),M=p.has(k.id),A=k.permissions.length;return t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs($v,{children:[k.name,!y&&t.jsx(rr,{$variant:"neutral",children:"Default"})]})}),t.jsx(Ye,{children:A===0?t.jsx(rr,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[t.jsxs(rr,{$variant:"primary",children:[A," ",A===1?"permission":"permissions"]}),t.jsx(Lv,{children:k.permissions.join(", ")})]})}),t.jsx(Dt,{children:y?t.jsxs(Mv,{children:[t.jsx(N,{ref:F=>{F&&v.current.set(k.id,F)},$size:"sm",$outline:!0,disabled:M,onClick:()=>i({isOpen:!0,role:k,triggerElement:v.current.get(k.id)??null}),children:"Edit"}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,disabled:M,onClick:()=>f(k.id),children:M?t.jsx(ze,{size:12}):"Delete"})]}):t.jsx("span",{style:{fontSize:12,color:"var(--color-secondary-text)"},children:"Read-only"})})]},k.id)};return t.jsxs(t.Fragment,{children:[h&&t.jsxs(zv,{$type:h.type,children:[h.type==="success"?"✓":t.jsx(oa,{size:13}),h.text]}),t.jsxs(Hn,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Roles"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Define granular permissions for members."})]}),((_=n==null?void 0:n.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(N,{ref:g,onClick:()=>i({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),s.isOpen&&!s.role&&t.jsx($c,{onClose:()=>i({isOpen:!1}),onSuccess:j,triggerRef:{current:s.triggerElement||g.current}}),w.length===0?t.jsx(At,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(Vn,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:w.map(C)})]})})}),u&&t.jsx(Xr,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const k=w.find(y=>y.id===u);k&&S(k)},onCancel:()=>f(null)}),s.isOpen&&s.role&&t.jsx($c,{role:s.role,onClose:()=>i({isOpen:!1}),onSuccess:j,triggerRef:{current:s.triggerElement||null}})]})},Pv=()=>{const{activeOrganization:e,loading:r}=or(),[a,n]=c.useState(null);return c.useEffect(()=>{e?n(e):!r&&!e&&a&&n(null)},[e,r,a]),{activeOrganization:a||e,loading:r}},Tv=l(ds)`
3433
+ `,Rv=({organization:e})=>{var _;const{getOrganizationRoles:r,removeOrganizationRoles:a}=It(),{deployment:n}=Ae(),[s,i]=c.useState({isOpen:!1}),[h,d]=c.useState(null),[u,f]=c.useState(null),[p,m]=c.useState(new Set),g=c.useRef(null),v=c.useRef(new Map),{data:w=[],isLoading:x,mutate:b}=$e(e?`wacht-api-organizations:${e.id}:roles`:null,()=>(r==null?void 0:r(e))||[]),E=(k,y)=>{m(M=>{const A=new Set(M);return y?A.add(k):A.delete(k),A})},j=async k=>{try{await new Promise(y=>setTimeout(y,500)),d({text:`Role ${k.id?"updated":"created"} successfully`,type:"success"}),i({isOpen:!1}),b()}catch(y){const M=y instanceof Error?y.message:"Failed to save role";d({text:M,type:"error"})}finally{setTimeout(()=>d(null),3e3)}},S=async k=>{E(k.id,!0);try{await a(e,k),b()}finally{E(k.id,!1),f(null)}};if(x&&w.length===0)return t.jsx(ze,{});const C=k=>{const y=Av(k),M=p.has(k.id),A=k.permissions.length;return t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs($v,{children:[k.name,!y&&t.jsx(rr,{$variant:"neutral",children:"Default"})]})}),t.jsx(Ye,{children:A===0?t.jsx(rr,{$variant:"neutral",children:"No permissions"}):t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[t.jsxs(rr,{$variant:"primary",children:[A," ",A===1?"permission":"permissions"]}),t.jsx(Lv,{children:k.permissions.join(", ")})]})}),t.jsx(Dt,{children:y?t.jsxs(Mv,{children:[t.jsx(N,{ref:I=>{I&&v.current.set(k.id,I)},$size:"sm",$outline:!0,disabled:M,onClick:()=>i({isOpen:!0,role:k,triggerElement:v.current.get(k.id)??null}),children:"Edit"}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,disabled:M,onClick:()=>f(k.id),children:M?t.jsx(ze,{size:12}):"Delete"})]}):t.jsx("span",{style:{fontSize:12,color:"var(--color-secondary-text)"},children:"Read-only"})})]},k.id)};return t.jsxs(t.Fragment,{children:[h&&t.jsxs(zv,{$type:h.type,children:[h.type==="success"?"✓":t.jsx(oa,{size:13}),h.text]}),t.jsxs(Hn,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Roles"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Define granular permissions for members."})]}),((_=n==null?void 0:n.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&t.jsx(N,{ref:g,onClick:()=>i({isOpen:!0,triggerElement:g.current}),$size:"sm",children:"Add role"})]}),s.isOpen&&!s.role&&t.jsx($c,{onClose:()=>i({isOpen:!1}),onSuccess:j,triggerRef:{current:s.triggerElement||g.current}}),w.length===0?t.jsx(At,{title:"No roles yet",description:"Define custom roles to manage granular permissions."}):t.jsx(t.Fragment,{children:t.jsx(Vn,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Role"}),t.jsx(Oe,{children:"Permissions"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:w.map(C)})]})})}),u&&t.jsx(Xr,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const k=w.find(y=>y.id===u);k&&S(k)},onCancel:()=>f(null)}),s.isOpen&&s.role&&t.jsx($c,{role:s.role,onClose:()=>i({isOpen:!1}),onSuccess:j,triggerRef:{current:s.triggerElement||null}})]})},Pv=()=>{const{activeOrganization:e,loading:r}=or(),[a,n]=c.useState(null);return c.useEffect(()=>{e?n(e):!r&&!e&&a&&n(null)},[e,r,a]),{activeOrganization:a||e,loading:r}},Tv=l(ds)`
3434
3434
  display: flex;
3435
3435
  justify-content: center;
3436
3436
  align-items: center;
@@ -3826,7 +3826,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
3826
3826
  align-items: center;
3827
3827
  justify-content: center;
3828
3828
  color: var(--color-primary);
3829
- `,Ps=({organizationId:e,onSuccess:r,onCancel:a,onCreateOrganization:n})=>{var z;const[s,i]=c.useState(""),[h,d]=c.useState(""),[u,f]=c.useState(),[p,m]=c.useState(null),[g,v]=c.useState(!1),[w,x]=c.useState(!1),[b,E]=c.useState(e),j=c.useRef(null),S=c.useRef(null),{toast:C}=gt(),{createWorkspace:_}=sr(),{refetch:k}=ot(),{organizationMemberships:y}=Kt(),M=(z=y==null?void 0:y.find(H=>H.organization.id===b))==null?void 0:z.organization,A=H=>{if(H.target.files&&H.target.files[0]){const P=H.target.files[0];if(P.size>2*1024*1024){C("File size cannot exceed 2MB","error");return}if(!P.type.startsWith("image/")){C("Please select a valid image file","error");return}p&&URL.revokeObjectURL(p),f(P),m(URL.createObjectURL(P))}},F=()=>{var H;(H=j.current)==null||H.click()},I=H=>H.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2)||"W",R=H=>H.trim().replace(/[<>\"'&]/g,""),T=H=>H.length>=2&&H.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(H),$=async()=>{const H=R(s),P=R(h);if(!H||!b){C("Please enter a workspace name","error");return}if(!T(H)){C("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(P.length>500){C("Description must be less than 500 characters","error");return}v(!0);try{const O=await _(b,H,u,P);await k(),r==null||r(O)}catch(O){const Z=O.message||"Failed to create workspace. Please try again.";C(Z,"error")}finally{v(!1)}};return c.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),c.useEffect(()=>{const H=P=>{S.current&&!S.current.contains(P.target)&&x(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]),t.jsx(ge,{children:t.jsxs(Nv,{children:[t.jsxs(Uv,{children:[t.jsxs(U1,{hasImage:!!p,onClick:F,children:[p?t.jsx(Wv,{src:p,alt:"Workspace logo"}):t.jsx(Gv,{children:I(s||"W")}),t.jsx(s3,{children:t.jsx(i3,{children:"Upload Logo"})})]}),t.jsx(o3,{type:"file",ref:j,onChange:A,accept:"image/png, image/jpeg, image/gif",disabled:g}),t.jsx(qv,{children:"Create new workspace"}),t.jsx(Kv,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),t.jsxs(Bv,{children:[t.jsxs(Yv,{children:[t.jsx(Qv,{children:"Choose your workspace name"}),t.jsx(Jv,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),t.jsxs(Xv,{children:[t.jsxs(So,{children:[t.jsx(Eo,{children:"Organization"}),t.jsxs(c3,{ref:S,children:[t.jsxs(l3,{type:"button",onClick:()=>x(!w),disabled:g,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Mc,{children:M!=null&&M.image_url?t.jsx(Lc,{src:M.image_url,alt:M.name}):I((M==null?void 0:M.name)||"O").charAt(0)}),t.jsx("span",{children:(M==null?void 0:M.name)||"Select organization"})]}),t.jsx(cr,{size:16,style:{color:"var(--color-secondary-text)"}})]}),w&&t.jsxs(d3,{children:[y==null?void 0:y.map(H=>{var O,Z,L;const P=((O=H.eligibility_restriction)==null?void 0:O.type)&&((Z=H.eligibility_restriction)==null?void 0:Z.type)!=="none";return t.jsxs(B1,{onClick:()=>{P||(E(H.organization.id),x(!1))},disabled:P,style:{opacity:P?.6:1,cursor:P?"not-allowed":"pointer"},title:P?(L=H.eligibility_restriction)==null?void 0:L.message:void 0,children:[t.jsx(Mc,{children:H.organization.image_url?t.jsx(Lc,{src:H.organization.image_url,alt:H.organization.name}):I(H.organization.name).charAt(0)}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-1u)"},children:[t.jsx("span",{children:H.organization.name}),P&&t.jsx("span",{style:{fontSize:"var(--font-size-2xs)",color:"var(--color-error)"},children:"Restricted"})]})]},H.organization.id)}),t.jsxs(u3,{onClick:()=>{x(!1),n==null||n()},children:[t.jsx(p3,{children:t.jsx(jt,{size:12})}),t.jsx("span",{children:"Create new organization"})]})]})]})]}),t.jsxs(So,{children:[t.jsx(Eo,{children:"Workspace name"}),t.jsx(e3,{type:"text",value:s,onChange:H=>i(H.target.value),placeholder:"Workspace Name",disabled:g})]}),t.jsxs(So,{children:[t.jsx(Eo,{children:"Description (optional)"}),t.jsx(t3,{value:h,onChange:H=>d(H.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),t.jsxs(r3,{children:[a?t.jsxs(a3,{onClick:a,disabled:g,children:[t.jsx(na,{size:16}),"Back"]}):t.jsx("div",{}),t.jsx(n3,{onClick:$,disabled:g||!s.trim(),children:g?"Creating...":"Create"})]})]})]})})},Ts=({isOpen:e,onClose:r,onCreated:a,organizationId:n})=>{const[s,i]=c.useState(!1),[h,d]=c.useState(n),{refetch:u,organizationMemberships:f}=Kt(),p=()=>{a==null||a(),r==null||r()},m=()=>{i(!0)},g=async()=>{await u(),setTimeout(()=>{if(f&&f.length>0){const v=f[f.length-1];d(v.organization.id)}i(!1)},500)};return t.jsx(ge,{children:t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsx(He.Content,{style:{width:"calc(calc(var(--size-50u) * 8) - var(--space-8u))",maxWidth:"90vw"},children:t.jsx(He.Body,{style:{padding:0},children:s?t.jsx(On,{onSuccess:g,onCancel:()=>i(!1)}):t.jsx(Ps,{organizationId:h||n,onSuccess:p,onCancel:r,onCreateOrganization:m})})})})})})};mt`
3829
+ `,Ps=({organizationId:e,onSuccess:r,onCancel:a,onCreateOrganization:n})=>{var z;const[s,i]=c.useState(""),[h,d]=c.useState(""),[u,f]=c.useState(),[p,m]=c.useState(null),[g,v]=c.useState(!1),[w,x]=c.useState(!1),[b,E]=c.useState(e),j=c.useRef(null),S=c.useRef(null),{toast:C}=gt(),{createWorkspace:_}=sr(),{refetch:k}=ot(),{organizationMemberships:y}=Kt(),M=(z=y==null?void 0:y.find(H=>H.organization.id===b))==null?void 0:z.organization,A=H=>{if(H.target.files&&H.target.files[0]){const F=H.target.files[0];if(F.size>2*1024*1024){C("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){C("Please select a valid image file","error");return}p&&URL.revokeObjectURL(p),f(F),m(URL.createObjectURL(F))}},I=()=>{var H;(H=j.current)==null||H.click()},P=H=>H.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",L=H=>H.trim().replace(/[<>\"'&]/g,""),T=H=>H.length>=2&&H.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(H),$=async()=>{const H=L(s),F=L(h);if(!H||!b){C("Please enter a workspace name","error");return}if(!T(H)){C("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){C("Description must be less than 500 characters","error");return}v(!0);try{const O=await _(b,H,u,F);await k(),r==null||r(O)}catch(O){const Z=O.message||"Failed to create workspace. Please try again.";C(Z,"error")}finally{v(!1)}};return c.useEffect(()=>()=>{p&&URL.revokeObjectURL(p)},[p]),c.useEffect(()=>{const H=F=>{S.current&&!S.current.contains(F.target)&&x(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[]),t.jsx(ge,{children:t.jsxs(Nv,{children:[t.jsxs(Uv,{children:[t.jsxs(U1,{hasImage:!!p,onClick:I,children:[p?t.jsx(Wv,{src:p,alt:"Workspace logo"}):t.jsx(Gv,{children:P(s||"W")}),t.jsx(s3,{children:t.jsx(i3,{children:"Upload Logo"})})]}),t.jsx(o3,{type:"file",ref:j,onChange:A,accept:"image/png, image/jpeg, image/gif",disabled:g}),t.jsx(qv,{children:"Create new workspace"}),t.jsx(Kv,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),t.jsxs(Bv,{children:[t.jsxs(Yv,{children:[t.jsx(Qv,{children:"Choose your workspace name"}),t.jsx(Jv,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),t.jsxs(Xv,{children:[t.jsxs(So,{children:[t.jsx(Eo,{children:"Organization"}),t.jsxs(c3,{ref:S,children:[t.jsxs(l3,{type:"button",onClick:()=>x(!w),disabled:g,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Mc,{children:M!=null&&M.image_url?t.jsx(Lc,{src:M.image_url,alt:M.name}):P((M==null?void 0:M.name)||"O").charAt(0)}),t.jsx("span",{children:(M==null?void 0:M.name)||"Select organization"})]}),t.jsx(cr,{size:16,style:{color:"var(--color-secondary-text)"}})]}),w&&t.jsxs(d3,{children:[y==null?void 0:y.map(H=>{var O,Z,R;const F=((O=H.eligibility_restriction)==null?void 0:O.type)&&((Z=H.eligibility_restriction)==null?void 0:Z.type)!=="none";return t.jsxs(B1,{onClick:()=>{F||(E(H.organization.id),x(!1))},disabled:F,style:{opacity:F?.6:1,cursor:F?"not-allowed":"pointer"},title:F?(R=H.eligibility_restriction)==null?void 0:R.message:void 0,children:[t.jsx(Mc,{children:H.organization.image_url?t.jsx(Lc,{src:H.organization.image_url,alt:H.organization.name}):P(H.organization.name).charAt(0)}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-1u)"},children:[t.jsx("span",{children:H.organization.name}),F&&t.jsx("span",{style:{fontSize:"var(--font-size-2xs)",color:"var(--color-error)"},children:"Restricted"})]})]},H.organization.id)}),t.jsxs(u3,{onClick:()=>{x(!1),n==null||n()},children:[t.jsx(p3,{children:t.jsx(jt,{size:12})}),t.jsx("span",{children:"Create new organization"})]})]})]})]}),t.jsxs(So,{children:[t.jsx(Eo,{children:"Workspace name"}),t.jsx(e3,{type:"text",value:s,onChange:H=>i(H.target.value),placeholder:"Workspace Name",disabled:g})]}),t.jsxs(So,{children:[t.jsx(Eo,{children:"Description (optional)"}),t.jsx(t3,{value:h,onChange:H=>d(H.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),t.jsxs(r3,{children:[a?t.jsxs(a3,{onClick:a,disabled:g,children:[t.jsx(na,{size:16}),"Back"]}):t.jsx("div",{}),t.jsx(n3,{onClick:$,disabled:g||!s.trim(),children:g?"Creating...":"Create"})]})]})]})})},Ts=({isOpen:e,onClose:r,onCreated:a,organizationId:n})=>{const[s,i]=c.useState(!1),[h,d]=c.useState(n),{refetch:u,organizationMemberships:f}=Kt(),p=()=>{a==null||a(),r==null||r()},m=()=>{i(!0)},g=async()=>{await u(),setTimeout(()=>{if(f&&f.length>0){const v=f[f.length-1];d(v.organization.id)}i(!1)},500)};return t.jsx(ge,{children:t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsx(He.Content,{style:{width:"calc(calc(var(--size-50u) * 8) - var(--space-8u))",maxWidth:"90vw"},children:t.jsx(He.Body,{style:{padding:0},children:s?t.jsx(On,{onSuccess:g,onCancel:()=>i(!1)}):t.jsx(Ps,{organizationId:h||n,onSuccess:p,onCancel:r,onCreateOrganization:m})})})})})})};mt`
3830
3830
  0% { transform: rotate(0deg); }
3831
3831
  100% { transform: rotate(360deg); }
3832
3832
  `;const h3=l.div`
@@ -4243,10 +4243,10 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
4243
4243
  color: var(--color-secondary-text);
4244
4244
  margin-top: 2px;
4245
4245
  line-height: 1.4;
4246
- `,C3=()=>{var M,A;const{activeWorkspace:e,loading:r,updateWorkspace:a}=Zt(),{deleteWorkspace:n}=sr(),{deployment:s}=Ae(),{toast:i}=gt(),[h,d]=c.useState((e==null?void 0:e.name)||""),[u,f]=c.useState((e==null?void 0:e.description)||""),[p,m]=c.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[g,v]=c.useState(!1),[w,x]=c.useState(""),[b,E]=c.useState(!1),[j,S]=c.useState(!1);c.useEffect(()=>{var F;e&&(d(e.name||""),f(e.description||""),m({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((F=e.whitelisted_ips)==null?void 0:F.join(`
4246
+ `,C3=()=>{var M,A;const{activeWorkspace:e,loading:r,updateWorkspace:a}=Zt(),{deleteWorkspace:n}=sr(),{deployment:s}=Ae(),{toast:i}=gt(),[h,d]=c.useState((e==null?void 0:e.name)||""),[u,f]=c.useState((e==null?void 0:e.description)||""),[p,m]=c.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[g,v]=c.useState(!1),[w,x]=c.useState(""),[b,E]=c.useState(!1),[j,S]=c.useState(!1);c.useEffect(()=>{var I;e&&(d(e.name||""),f(e.description||""),m({mfa_required:e.enforce_2fa||!1,ip_restrictions:e.enable_ip_restriction||!1,allowed_ips:((I=e.whitelisted_ips)==null?void 0:I.join(`
4247
4247
  `))||""}))},[e]);const C=async()=>{if(!(!e||g))try{v(!0),await a({name:h,description:u,enforce_2fa:p.mfa_required,enable_ip_restriction:p.ip_restrictions,whitelisted_ips:p.allowed_ips.split(`
4248
- `).filter(F=>F.trim())}),i("Changes saved","info")}catch(F){i(F.message||"Failed to save changes","error")}finally{v(!1)}},_=async()=>{if(!(!e||w!==e.name))try{E(!0),await n(e),i("Workspace deleted","info")}catch{i("Failed to delete workspace","error")}finally{E(!1),x("")}};if(r&&!e)return t.jsx(ze,{});if(!e)return null;const k=(M=s==null?void 0:s.b2b_settings)==null?void 0:M.enforce_mfa_per_workspace_enabled,y=(A=s==null?void 0:s.b2b_settings)==null?void 0:A.ip_allowlist_per_workspace_enabled;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)",paddingBottom:"var(--size-20u)"},children:[t.jsxs(Ao,{children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"name",children:"Workspace name"}),t.jsx(ue,{id:"name",value:h,onChange:F=>d(F.target.value),onBlur:C,placeholder:"Workspace name",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"description",children:"Description"}),t.jsx(ue,{id:"description",as:"textarea",value:u,onChange:F=>f(F.target.value),onBlur:C,placeholder:"Optional description",style:{minHeight:"var(--size-40u)",resize:"vertical"}})]})]}),(k||y)&&t.jsxs(Ao,{children:[t.jsx(Ic,{children:"Security"}),k&&t.jsxs(Pc,{style:{padding:0},children:[t.jsxs(Tc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"Multi-factor authentication"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Require all workspace members to set up MFA."})]}),t.jsx(Fc,{children:t.jsx(Tr,{checked:p.mfa_required,onChange:()=>{m(F=>({...F,mfa_required:!F.mfa_required})),setTimeout(C,0)}})})]}),y&&t.jsxs(t.Fragment,{children:[t.jsxs(Pc,{style:{padding:0},children:[t.jsxs(Tc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"IP restrictions"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Only allow access from specific IP addresses."})]}),t.jsx(Fc,{children:t.jsx(Tr,{checked:p.ip_restrictions,onChange:()=>{m(F=>({...F,ip_restrictions:!F.ip_restrictions})),setTimeout(C,0)}})})]}),p.ip_restrictions&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ue,{id:"allowed_ips",as:"textarea",value:p.allowed_ips,onChange:F=>m(I=>({...I,allowed_ips:F.target.value})),onBlur:C,placeholder:`192.168.1.1
4249
- 10.0.0.0/24`,style:{minHeight:"var(--size-40u)",fontFamily:"monospace"}})]})]})]}),t.jsxs(Ao,{children:[t.jsx(Ic,{children:"Danger zone"}),t.jsxs(y3,{children:[t.jsxs(j3,{children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx(_3,{children:"Delete workspace"}),t.jsx(k3,{children:"Once you delete this workspace, there is no going back."})]}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{S(!j),x("")},children:j?"Cancel":"Delete workspace"})]}),j&&t.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(ue,{id:"confirm_workspace_name",type:"text",value:w,onChange:F=>x(F.target.value),placeholder:e.name})]}),t.jsx(N,{$size:"sm",$destructive:!0,onClick:_,disabled:w!==e.name||b,children:b?t.jsx(ze,{size:12}):"Delete forever"})]})]})]})]})},S3=l.div`
4248
+ `).filter(I=>I.trim())}),i("Changes saved","info")}catch(I){i(I.message||"Failed to save changes","error")}finally{v(!1)}},_=async()=>{if(!(!e||w!==e.name))try{E(!0),await n(e),i("Workspace deleted","info")}catch{i("Failed to delete workspace","error")}finally{E(!1),x("")}};if(r&&!e)return t.jsx(ze,{});if(!e)return null;const k=(M=s==null?void 0:s.b2b_settings)==null?void 0:M.enforce_mfa_per_workspace_enabled,y=(A=s==null?void 0:s.b2b_settings)==null?void 0:A.ip_allowlist_per_workspace_enabled;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)",paddingBottom:"var(--size-20u)"},children:[t.jsxs(Ao,{children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"name",children:"Workspace name"}),t.jsx(ue,{id:"name",value:h,onChange:I=>d(I.target.value),onBlur:C,placeholder:"Workspace name",required:!0})]}),t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"description",children:"Description"}),t.jsx(ue,{id:"description",as:"textarea",value:u,onChange:I=>f(I.target.value),onBlur:C,placeholder:"Optional description",style:{minHeight:"var(--size-40u)",resize:"vertical"}})]})]}),(k||y)&&t.jsxs(Ao,{children:[t.jsx(Ic,{children:"Security"}),k&&t.jsxs(Pc,{style:{padding:0},children:[t.jsxs(Tc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"Multi-factor authentication"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Require all workspace members to set up MFA."})]}),t.jsx(Fc,{children:t.jsx(Tr,{checked:p.mfa_required,onChange:()=>{m(I=>({...I,mfa_required:!I.mfa_required})),setTimeout(C,0)}})})]}),y&&t.jsxs(t.Fragment,{children:[t.jsxs(Pc,{style:{padding:0},children:[t.jsxs(Tc,{children:[t.jsx(be,{style:{fontSize:13,fontWeight:500,marginBottom:4,display:"block"},children:"IP restrictions"}),t.jsx("p",{style:{fontSize:12,color:"var(--color-secondary-text)",margin:0},children:"Only allow access from specific IP addresses."})]}),t.jsx(Fc,{children:t.jsx(Tr,{checked:p.ip_restrictions,onChange:()=>{m(I=>({...I,ip_restrictions:!I.ip_restrictions})),setTimeout(C,0)}})})]}),p.ip_restrictions&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"allowed_ips",children:"Allowed IP addresses"}),t.jsx(ue,{id:"allowed_ips",as:"textarea",value:p.allowed_ips,onChange:I=>m(P=>({...P,allowed_ips:I.target.value})),onBlur:C,placeholder:`192.168.1.1
4249
+ 10.0.0.0/24`,style:{minHeight:"var(--size-40u)",fontFamily:"monospace"}})]})]})]}),t.jsxs(Ao,{children:[t.jsx(Ic,{children:"Danger zone"}),t.jsxs(y3,{children:[t.jsxs(j3,{children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx(_3,{children:"Delete workspace"}),t.jsx(k3,{children:"Once you delete this workspace, there is no going back."})]}),t.jsx(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>{S(!j),x("")},children:j?"Cancel":"Delete workspace"})]}),j&&t.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:10},children:[t.jsxs(Se,{children:[t.jsxs(be,{htmlFor:"confirm_workspace_name",children:["Type ",t.jsx("strong",{children:e.name})," to confirm"]}),t.jsx(ue,{id:"confirm_workspace_name",type:"text",value:w,onChange:I=>x(I.target.value),placeholder:e.name})]}),t.jsx(N,{$size:"sm",$destructive:!0,onClick:_,disabled:w!==e.name||b,children:b?t.jsx(ze,{size:12}):"Delete forever"})]})]})]})]})},S3=l.div`
4250
4250
  position: fixed;
4251
4251
  width: calc(var(--space-10u) * 18);
4252
4252
  max-width: calc(100vw - var(--space-24u));
@@ -4312,7 +4312,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
4312
4312
  font-weight: 400;
4313
4313
  font-size: var(--font-size-lg);
4314
4314
  overflow: hidden;
4315
- `,T3=()=>{const{activeWorkspace:e,getMembers:r,getRoles:a,removeMember:n,addMemberRole:s,removeMemberRole:i}=Zt(),{session:h}=ot(),{toast:d}=gt(),[u,f]=c.useState(""),[p,m]=c.useState(1),[g]=c.useState(10),[v,w]=c.useState(""),[x,b]=c.useState(!1),E=c.useRef(null);c.useEffect(()=>{const I=setTimeout(()=>{w(u),m(1)},500);return()=>clearTimeout(I)},[u]);const{data:j,mutate:S}=$e(e?`wacht - api - workspaces:${e.id}: members:${p}:${g}:${v} `:null,()=>r==null?void 0:r({page:p,limit:g,search:v}),{keepPreviousData:!0}),C=(j==null?void 0:j.data)||[],_=(j==null?void 0:j.meta)||{total:0,limit:10},k=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=$e(e?`wacht - api - workspaces:${e.id}: roles`:null,()=>a()||[]),M=y,A=async(I,R,T)=>{try{T?(await i(I,R),d("Role removed","info")):(await s(I,R),d("Role added","info")),S()}catch{d("Failed to update role","error")}},F=async I=>{try{await n(I),d("Member removed","info"),S()}catch{d("Failed to remove member","error")}};return j?t.jsxs(t.Fragment,{children:[t.jsxs(Fs,{children:[t.jsx("div",{style:{flex:1},children:t.jsx(x1,{value:u,onChange:f,placeholder:"Search members..."})}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",alignItems:"center"},children:[_.total>0&&t.jsxs("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)"},children:[_.total," member",_.total!==1?"s":""]}),t.jsx(N,{ref:E,onClick:()=>b(!0),children:"Invite"})]})]}),x&&t.jsx(R3,{onClose:()=>b(!1),onSuccess:()=>{S(),b(!1)},roles:M,triggerRef:E}),C.length===0?t.jsx(At,{title:u?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx(Is,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Role"})]})}),t.jsx(Vt,{children:C.map(I=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsx(F3,{member:I,session:h})}),t.jsx(Ye,{children:new Date(I.created_at).toLocaleDateString()}),t.jsx(Dt,{children:t.jsx(I3,{member:I,roles:M,onToggle:(R,T)=>A(I.id,R,T),onRemove:()=>F(I.id)})})]},I.id))})]})})}),k>1&&t.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"var(--space-8u)",marginTop:"var(--space-12u)"},children:[t.jsx(N,{onClick:()=>m(I=>Math.max(1,I-1)),disabled:p===1,$size:"sm",children:"Previous"}),t.jsxs("span",{style:{fontSize:"var(--font-size-md)"},children:[p," / ",k]}),t.jsx(N,{onClick:()=>m(I=>Math.min(k,I+1)),disabled:p===k,$size:"sm",children:"Next"})]})]}):t.jsx(ze,{})},F3=({member:e,session:r,subtitle:a})=>{var h,d,u;const n=e.public_user_data||e.user,s=(n==null?void 0:n.id)===((h=r==null?void 0:r.active_signin)==null?void 0:h.user_id),i=(f="",p="")=>`${f[0]||""}${p[0]||""} `.toUpperCase();return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)"},children:[t.jsx(P3,{children:n!=null&&n.profile_picture_url?t.jsx("img",{src:n.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):i(n==null?void 0:n.first_name,n==null?void 0:n.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-lg)",fontWeight:"400"},children:n?`${n.first_name||""} ${n.last_name||""} `.trim()||((d=n.primary_email_address)==null?void 0:d.email):"Unknown"}),s&&t.jsx("span",{style:{fontSize:"var(--font-size-2xs)",padding:"var(--space-1u) var(--space-2u)",background:"var(--color-background-subtle)",color:"var(--color-muted)",borderRadius:"calc(var(--radius-2xs) - var(--border-width-thin))",fontWeight:"400"},children:"You"})]}),t.jsxs("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"var(--space-2u) var(--space-4u)"},children:[t.jsx("span",{children:(u=n==null?void 0:n.primary_email_address)==null?void 0:u.email}),a&&t.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",a]})]})]})]})},I3=({member:e,roles:r,onToggle:a,onRemove:n})=>{var d;const s=e.roles||[],i=u=>s.some(f=>f.id===u),h="calc(var(--size-50u) + var(--size-40u))";return t.jsxs(Ma,{children:[t.jsx(Ra,{children:t.jsxs(N,{$outline:!0,style:{color:"var(--color-foreground)",minWidth:h,justifyContent:"space-between"},children:[s.length>0?(d=s==null?void 0:s[0])==null?void 0:d.name:"No role"," ",t.jsx(cr,{size:14,style:{marginLeft:"var(--space-2u)"}})]})}),t.jsxs(La,{style:{minWidth:h},children:[r.map(u=>{const f=i(u.id);return t.jsx(nr,{onClick:()=>a(u.id,f),children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"var(--space-6u)"},children:[t.jsx("span",{children:u.name}),f&&t.jsx(ct,{size:14,color:"var(--color-success)"})]})},u.id)}),t.jsx(v1,{}),t.jsx(nr,{$destructive:!0,onClick:n,children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(zs,{size:14})," Remove Member"]})})]})]})},Z3=l.div`
4315
+ `,T3=()=>{const{activeWorkspace:e,getMembers:r,getRoles:a,removeMember:n,addMemberRole:s,removeMemberRole:i}=Zt(),{session:h}=ot(),{toast:d}=gt(),[u,f]=c.useState(""),[p,m]=c.useState(1),[g]=c.useState(10),[v,w]=c.useState(""),[x,b]=c.useState(!1),E=c.useRef(null);c.useEffect(()=>{const P=setTimeout(()=>{w(u),m(1)},500);return()=>clearTimeout(P)},[u]);const{data:j,mutate:S}=$e(e?`wacht - api - workspaces:${e.id}: members:${p}:${g}:${v} `:null,()=>r==null?void 0:r({page:p,limit:g,search:v}),{keepPreviousData:!0}),C=(j==null?void 0:j.data)||[],_=(j==null?void 0:j.meta)||{total:0,limit:10},k=Math.ceil(_.total/(_.limit||10)),{data:y=[]}=$e(e?`wacht - api - workspaces:${e.id}: roles`:null,()=>a()||[]),M=y,A=async(P,L,T)=>{try{T?(await i(P,L),d("Role removed","info")):(await s(P,L),d("Role added","info")),S()}catch{d("Failed to update role","error")}},I=async P=>{try{await n(P),d("Member removed","info"),S()}catch{d("Failed to remove member","error")}};return j?t.jsxs(t.Fragment,{children:[t.jsxs(Fs,{children:[t.jsx("div",{style:{flex:1},children:t.jsx(x1,{value:u,onChange:f,placeholder:"Search members..."})}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",alignItems:"center"},children:[_.total>0&&t.jsxs("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)"},children:[_.total," member",_.total!==1?"s":""]}),t.jsx(N,{ref:E,onClick:()=>b(!0),children:"Invite"})]})]}),x&&t.jsx(R3,{onClose:()=>b(!1),onSuccess:()=>{S(),b(!1)},roles:M,triggerRef:E}),C.length===0?t.jsx(At,{title:u?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):t.jsx(t.Fragment,{children:t.jsx(Is,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Member"}),t.jsx(Oe,{children:"Joined"}),t.jsx(Oe,{children:"Role"})]})}),t.jsx(Vt,{children:C.map(P=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsx(F3,{member:P,session:h})}),t.jsx(Ye,{children:new Date(P.created_at).toLocaleDateString()}),t.jsx(Dt,{children:t.jsx(I3,{member:P,roles:M,onToggle:(L,T)=>A(P.id,L,T),onRemove:()=>I(P.id)})})]},P.id))})]})})}),k>1&&t.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"var(--space-8u)",marginTop:"var(--space-12u)"},children:[t.jsx(N,{onClick:()=>m(P=>Math.max(1,P-1)),disabled:p===1,$size:"sm",children:"Previous"}),t.jsxs("span",{style:{fontSize:"var(--font-size-md)"},children:[p," / ",k]}),t.jsx(N,{onClick:()=>m(P=>Math.min(k,P+1)),disabled:p===k,$size:"sm",children:"Next"})]})]}):t.jsx(ze,{})},F3=({member:e,session:r,subtitle:a})=>{var h,d,u;const n=e.public_user_data||e.user,s=(n==null?void 0:n.id)===((h=r==null?void 0:r.active_signin)==null?void 0:h.user_id),i=(f="",p="")=>`${f[0]||""}${p[0]||""} `.toUpperCase();return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-6u)"},children:[t.jsx(P3,{children:n!=null&&n.profile_picture_url?t.jsx("img",{src:n.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):i(n==null?void 0:n.first_name,n==null?void 0:n.last_name)||"?"}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx("span",{style:{fontSize:"var(--font-size-lg)",fontWeight:"400"},children:n?`${n.first_name||""} ${n.last_name||""} `.trim()||((d=n.primary_email_address)==null?void 0:d.email):"Unknown"}),s&&t.jsx("span",{style:{fontSize:"var(--font-size-2xs)",padding:"var(--space-1u) var(--space-2u)",background:"var(--color-background-subtle)",color:"var(--color-muted)",borderRadius:"calc(var(--radius-2xs) - var(--border-width-thin))",fontWeight:"400"},children:"You"})]}),t.jsxs("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"var(--space-2u) var(--space-4u)"},children:[t.jsx("span",{children:(u=n==null?void 0:n.primary_email_address)==null?void 0:u.email}),a&&t.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",a]})]})]})]})},I3=({member:e,roles:r,onToggle:a,onRemove:n})=>{var d;const s=e.roles||[],i=u=>s.some(f=>f.id===u),h="calc(var(--size-50u) + var(--size-40u))";return t.jsxs(Ma,{children:[t.jsx(Ra,{children:t.jsxs(N,{$outline:!0,style:{color:"var(--color-foreground)",minWidth:h,justifyContent:"space-between"},children:[s.length>0?(d=s==null?void 0:s[0])==null?void 0:d.name:"No role"," ",t.jsx(cr,{size:14,style:{marginLeft:"var(--space-2u)"}})]})}),t.jsxs(La,{style:{minWidth:h},children:[r.map(u=>{const f=i(u.id);return t.jsx(nr,{onClick:()=>a(u.id,f),children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"var(--space-6u)"},children:[t.jsx("span",{children:u.name}),f&&t.jsx(ct,{size:14,color:"var(--color-success)"})]})},u.id)}),t.jsx(v1,{}),t.jsx(nr,{$destructive:!0,onClick:n,children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(zs,{size:14})," Remove Member"]})})]})]})},Z3=l.div`
4316
4316
  position: fixed;
4317
4317
  background: var(--color-popover);
4318
4318
  border-radius: 10px;
@@ -4383,7 +4383,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
4383
4383
  grid-template-columns: 1fr 1fr;
4384
4384
  gap: 6px;
4385
4385
  & > button { width: 100%; }
4386
- `,Dc=({onClose:e,onSuccess:r,role:a,triggerRef:n})=>{var k,y;const s=c.useRef(null),[i,h]=c.useState((a==null?void 0:a.name)||""),[d,u]=c.useState((a==null?void 0:a.permissions)||[]),[f,p]=c.useState(!1),[m,g]=c.useState(!1),{deployment:v}=Ae(),{toast:w}=gt(),x=xt({triggerRef:n??{current:null},isOpen:m,minWidth:400,defaultMaxHeight:500}),b=!!a,E=((k=v==null?void 0:v.b2b_settings)==null?void 0:k.workspace_permissions)||((y=v==null?void 0:v.b2b_settings)==null?void 0:y.organization_permissions)||[],j=Array.isArray(E)?E.map(M=>({value:M,label:M})):[];c.useEffect(()=>{g(!0);const M=I=>{s.current&&!s.current.contains(I.target)&&(e==null||e())},A=I=>{I.key==="Escape"&&(e==null||e())},F=setTimeout(()=>{document.addEventListener("mousedown",M),document.addEventListener("keydown",A)},100);return()=>{clearTimeout(F),document.removeEventListener("mousedown",M),document.removeEventListener("keydown",A)}},[e]);const S=M=>M.trim().replace(/[<>"'&]/g,""),C=M=>M.length>=2&&M.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(M),_=async()=>{const M=S(i);if(!M){w("Please enter a role name","error");return}if(!C(M)){w("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(d.length===0){w("Please select at least one permission","error");return}p(!0);try{const A={id:a==null?void 0:a.id,name:M,permissions:d};r==null||r(A)}catch(A){w(A.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{p(!1)}};return m?t.jsxs(U3,{ref:s,style:{top:(x==null?void 0:x.top)!==void 0?`${x.top}px`:void 0,bottom:(x==null?void 0:x.bottom)!==void 0?`${x.bottom}px`:void 0,left:(x==null?void 0:x.left)!==void 0?`${x.left}px`:void 0,right:(x==null?void 0:x.right)!==void 0?`${x.right}px`:void 0,visibility:x?"visible":"hidden"},onClick:M=>M.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsx(B3,{id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs(Hc,{children:[t.jsx(Vc,{children:"Name"}),t.jsx(ue,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:i,onChange:M=>h(M.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs(Hc,{children:[t.jsx(Vc,{children:"Permissions"}),t.jsx(C1,{options:j,value:d,onChange:u,placeholder:"Select permissions","aria-label":"Select permissions for role"})]}),t.jsxs(W3,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:_,disabled:!i||f,children:f?t.jsx(ze,{size:12}):b?"Update":"Create"})]})]}):null},G3=l.div`
4386
+ `,Dc=({onClose:e,onSuccess:r,role:a,triggerRef:n})=>{var k,y;const s=c.useRef(null),[i,h]=c.useState((a==null?void 0:a.name)||""),[d,u]=c.useState((a==null?void 0:a.permissions)||[]),[f,p]=c.useState(!1),[m,g]=c.useState(!1),{deployment:v}=Ae(),{toast:w}=gt(),x=xt({triggerRef:n??{current:null},isOpen:m,minWidth:400,defaultMaxHeight:500}),b=!!a,E=((k=v==null?void 0:v.b2b_settings)==null?void 0:k.workspace_permissions)||((y=v==null?void 0:v.b2b_settings)==null?void 0:y.organization_permissions)||[],j=Array.isArray(E)?E.map(M=>({value:M,label:M})):[];c.useEffect(()=>{g(!0);const M=P=>{s.current&&!s.current.contains(P.target)&&(e==null||e())},A=P=>{P.key==="Escape"&&(e==null||e())},I=setTimeout(()=>{document.addEventListener("mousedown",M),document.addEventListener("keydown",A)},100);return()=>{clearTimeout(I),document.removeEventListener("mousedown",M),document.removeEventListener("keydown",A)}},[e]);const S=M=>M.trim().replace(/[<>"'&]/g,""),C=M=>M.length>=2&&M.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(M),_=async()=>{const M=S(i);if(!M){w("Please enter a role name","error");return}if(!C(M)){w("Role name must be 2–50 characters, letters/numbers/spaces only.","error");return}if(d.length===0){w("Please select at least one permission","error");return}p(!0);try{const A={id:a==null?void 0:a.id,name:M,permissions:d};r==null||r(A)}catch(A){w(A.message||`Failed to ${b?"update":"create"} role. Please try again.`,"error")}finally{p(!1)}};return m?t.jsxs(U3,{ref:s,style:{top:(x==null?void 0:x.top)!==void 0?`${x.top}px`:void 0,bottom:(x==null?void 0:x.bottom)!==void 0?`${x.bottom}px`:void 0,left:(x==null?void 0:x.left)!==void 0?`${x.left}px`:void 0,right:(x==null?void 0:x.right)!==void 0?`${x.right}px`:void 0,visibility:x?"visible":"hidden"},onClick:M=>M.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[t.jsx(B3,{id:"role-dialog-title",children:b?"Edit role":"New role"}),t.jsxs(Hc,{children:[t.jsx(Vc,{children:"Name"}),t.jsx(ue,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:i,onChange:M=>h(M.target.value),autoFocus:!0,"aria-label":"Role name"})]}),t.jsxs(Hc,{children:[t.jsx(Vc,{children:"Permissions"}),t.jsx(C1,{options:j,value:d,onChange:u,placeholder:"Select permissions","aria-label":"Select permissions for role"})]}),t.jsxs(W3,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:_,disabled:!i||f,children:f?t.jsx(ze,{size:12}):b?"Update":"Create"})]})]}):null},G3=l.div`
4387
4387
  display: flex;
4388
4388
  align-items: center;
4389
4389
  gap: var(--space-4u);
@@ -4792,7 +4792,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
4792
4792
  display: flex;
4793
4793
  align-items: center;
4794
4794
  gap: 8px;
4795
- `,J1=({showPersonal:e=!0})=>{var Te,Ve,Ue;const[r,a]=c.useState(!1),[n,s]=c.useState(!1),[i,h]=c.useState(new Set),d=c.useRef(null),u=c.useRef(null),f=xt({triggerRef:d,isOpen:r,minWidth:300}),p=Bt(!1),m=Bt(!1),g=Bt(!1),v=Bt(!1),[w,x]=c.useState(null),[b,E]=c.useState(null),[j,S]=c.useState(null),[C,_]=c.useState("org"),{organizationMemberships:k,loading:y,refetch:M}=Kt(),{activeOrganization:A,activeMembership:F,leave:I}=or(),{activeWorkspace:R,activeMembership:T,leave:$}=Zt(),{workspaces:z,loading:H}=sr(),{session:P,switchOrganization:O,switchWorkspace:Z}=ot(),{deployment:L}=Ae(),W=L==null?void 0:L.b2b_settings.organizations_enabled,D=L==null?void 0:L.b2b_settings.workspaces_enabled,B=L==null?void 0:L.b2b_settings.allow_users_to_create_orgs,Y=!F,X=c.useMemo(()=>{var J,le;return Y?{name:"Personal account",image_url:(le=(J=P==null?void 0:P.active_signin)==null?void 0:J.user)==null?void 0:le.profile_picture_url,isPersonal:!0}:{name:D&&R?`${A==null?void 0:A.name} / ${R.name}`:(A==null?void 0:A.name)||"",image_url:A==null?void 0:A.image_url,isPersonal:!1}},[Y,A,R,P,D]);if(c.useEffect(()=>{A&&D&&h(ve=>{if(ve.has(A.id))return ve;const J=new Set(ve);return J.add(A.id),J})},[A,D]),c.useEffect(()=>{_(D&&R?"ws":"org")},[D,R==null?void 0:R.id]),c.useEffect(()=>{if(!r)return;let ve=null;const J=setTimeout(()=>{const le=oe=>{var pe,fe;const G=oe.target;(pe=d.current)!=null&&pe.contains(G)||(fe=u.current)!=null&&fe.contains(G)||(a(!1),E(null))};document.addEventListener("mousedown",le),ve=()=>document.removeEventListener("mousedown",le)},50);return()=>{clearTimeout(J),ve==null||ve()}},[r]),c.useEffect(()=>{if(!b)return;const ve=setTimeout(()=>E(null),5e3);return()=>clearTimeout(ve)},[b]),!W)return null;const ce=ve=>ve.split(" ").map(J=>J[0]).join("").toUpperCase().slice(0,2),me=ve=>{s(!0),O(ve).finally(()=>s(!1))},te=ve=>{s(!0),Z(ve).finally(()=>s(!1))},xe=ve=>{h(J=>{const le=new Set(J);return le.has(ve)?le.delete(ve):le.add(ve),le})},re=!!((Te=F==null?void 0:F.eligibility_restriction)!=null&&Te.type)&&F.eligibility_restriction.type!=="none";return!!!P||y||D&&H?t.jsx(ge,{children:t.jsx(Nc,{children:t.jsxs(px,{children:[t.jsx(sn,{w:"20px",h:"20px",r:"5px"}),t.jsx(sn,{w:"120px",h:"12px"})]})})}):t.jsx(ge,{children:t.jsxs(Nc,{children:[t.jsxs(nx,{ref:d,onClick:()=>{a(!r),r||E(null)},disabled:n,children:[t.jsx(ox,{$personal:X.isPersonal,children:X.image_url?t.jsx("img",{src:X.image_url,alt:X.name}):X.isPersonal?t.jsx(Ea,{size:11}):ce(X.name)}),t.jsx(sx,{children:X.name}),t.jsx(mf,{size:13,color:"var(--color-secondary-text)"})]}),typeof window<"u"&&En.createPortal(t.jsx(ge,{children:t.jsxs(ix,{ref:u,$isOpen:r,$position:f,children:[(()=>{var Q,se,he,je;const ve=D&&!!R,J=!!A&&!re&&Hs(F),le=ve&&!re&&Ds(T),oe=()=>{m.open(),a(!1)},G=()=>{v.open(),a(!1)},pe=async()=>{if(I){S("org"),E(null);try{await I(),await M(),a(!1)}catch(ke){E(ke instanceof Error?ke.message:"Failed to leave organization")}finally{S(null)}}},fe=async()=>{if($){S("ws"),E(null);try{await $(),a(!1)}catch(ke){E(ke instanceof Error?ke.message:"Failed to leave workspace")}finally{S(null)}}};if(Y)return null;const q=ve,de=q?C:"org",Be=(se=(Q=F==null?void 0:F.roles)==null?void 0:Q[0])==null?void 0:se.name,We=(je=(he=T==null?void 0:T.roles)==null?void 0:he[0])==null?void 0:je.name;return t.jsxs(lx,{children:[q&&t.jsxs(dx,{children:[t.jsx(Uc,{type:"button",$active:de==="org","data-active":de==="org",onClick:()=>_("org"),children:"Organization"}),t.jsx(Uc,{type:"button",$active:de==="ws","data-active":de==="ws",onClick:()=>_("ws"),children:"Workspace"})]}),de==="org"&&A&&t.jsxs(Bc,{children:[t.jsx(Wc,{children:A.image_url?t.jsx("img",{src:A.image_url,alt:A.name}):ce(A.name)}),t.jsxs(Gc,{children:[t.jsx(qc,{children:A.name}),Be&&t.jsx(Kc,{children:Be})]}),t.jsxs(Yc,{children:[J&&t.jsx(on,{onClick:oe,title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ar,{size:14})}),t.jsx(on,{$destructive:!0,onClick:pe,disabled:j==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(zr,{size:14})})]})]}),de==="ws"&&ve&&t.jsxs(Bc,{children:[t.jsx(Wc,{children:R.image_url?t.jsx("img",{src:R.image_url,alt:R.name}):ce(R.name)}),t.jsxs(Gc,{children:[t.jsx(qc,{children:R.name}),We&&t.jsx(Kc,{children:We})]}),t.jsxs(Yc,{children:[le&&t.jsx(on,{onClick:G,title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ar,{size:14})}),t.jsx(on,{$destructive:!0,onClick:fe,disabled:j==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(zr,{size:14})})]})]})]})})(),b&&t.jsxs(fx,{children:[t.jsx($r,{size:13}),b]}),t.jsx(cx,{children:y||H?t.jsx(t.Fragment,{children:[1,2,3].map(ve=>t.jsxs(hx,{children:[t.jsx(sn,{w:"22px",h:"22px",r:"5px"}),t.jsx(sn,{w:ve===2?"60%":"80%",h:"11px"})]},ve))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs(Qc,{$active:Y,onClick:()=>{Y||me()},disabled:n||Y,children:[t.jsx(Xc,{$personal:!0,children:(Ue=(Ve=P==null?void 0:P.active_signin)==null?void 0:Ve.user)!=null&&Ue.profile_picture_url?t.jsx("img",{src:P.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(Ea,{size:12})}),t.jsx(hs,{children:"Personal account"}),Y&&t.jsx(zo,{children:t.jsx("span",{className:"row-check",style:{display:"inline-flex"},children:t.jsx($o,{size:13})})})]}),k==null?void 0:k.map(ve=>{var fe,q;const J=ve.organization,le=J.id===(A==null?void 0:A.id),oe=i.has(J.id),G=D?(z==null?void 0:z.filter(de=>de.organization.id===J.id))||[]:[],pe=!!((fe=ve.eligibility_restriction)!=null&&fe.type)&&ve.eligibility_restriction.type!=="none";return t.jsxs(c.Fragment,{children:[t.jsxs(Qc,{$active:le,onClick:()=>{pe||(D?xe(J.id):le||me(J.id))},disabled:n,style:pe?{opacity:.55,cursor:"not-allowed"}:le&&!D?{cursor:"default"}:void 0,title:(q=ve.eligibility_restriction)==null?void 0:q.message,children:[t.jsx(Xc,{children:J.image_url?t.jsx("img",{src:J.image_url,alt:J.name}):ce(J.name)}),t.jsx(hs,{children:J.name}),t.jsxs(zo,{children:[pe&&t.jsx($r,{size:12,color:"var(--color-error)"}),le&&!D&&t.jsx($o,{size:13}),D&&t.jsx(ux,{size:11,$open:oe})]})]}),D&&oe&&t.jsxs(t.Fragment,{children:[G.map(de=>{var Q,se;const Be=le&&(R==null?void 0:R.id)===de.id,We=((Q=de.eligibility_restriction)==null?void 0:Q.type)&&de.eligibility_restriction.type!=="none";return t.jsxs(Jc,{$active:Be,onClick:()=>{!Be&&!We&&te(de.id)},disabled:n,style:We||pe?{opacity:.55,cursor:"not-allowed"}:Be?{cursor:"default"}:void 0,title:(se=de.eligibility_restriction)==null?void 0:se.message,children:[t.jsx(el,{children:de.image_url?t.jsx("img",{src:de.image_url,alt:de.name}):ce(de.name).charAt(0)}),t.jsx(tl,{children:de.name}),t.jsxs(zo,{children:[We&&t.jsx($r,{size:12,color:"var(--color-error)"}),Be&&t.jsx($o,{size:12})]})]},de.id)}),!pe&&t.jsxs(Jc,{onClick:()=>{x(J.id),g.open()},disabled:n,children:[t.jsx(el,{style:{background:"transparent",border:"1px dashed var(--color-border)"},children:t.jsx(jt,{size:10})}),t.jsx(tl,{children:"New workspace"})]})]})]},J.id)})]})}),D?t.jsx(rl,{children:t.jsxs(al,{onClick:()=>{x(A&&!re?A.id:null),g.open()},disabled:n||!A||re,children:[t.jsx(nl,{children:t.jsx(jt,{size:12})}),"New workspace"]})}):B&&t.jsx(rl,{children:t.jsxs(al,{onClick:()=>p.open(),disabled:n,children:[t.jsx(nl,{children:t.jsx(jt,{size:12})}),"New organization"]})})]})}),document.body),W&&B&&t.jsx(Z1,{isOpen:p.isOpen,onClose:p.close,onCreated:M}),t.jsx(N1,{isOpen:m.isOpen,onClose:m.close}),D&&t.jsxs(t.Fragment,{children:[t.jsx(Zs,{isOpen:v.isOpen,onClose:v.close}),t.jsx(Ts,{isOpen:g.isOpen,onClose:()=>{g.close(),x(null)},organizationId:w||void 0})]})]})})},X1=c.createContext(void 0),Yt=()=>{const e=c.useContext(X1);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},mx=mt`
4795
+ `,J1=({showPersonal:e=!0})=>{var Te,Ve,Ue;const[r,a]=c.useState(!1),[n,s]=c.useState(!1),[i,h]=c.useState(new Set),d=c.useRef(null),u=c.useRef(null),f=xt({triggerRef:d,isOpen:r,minWidth:300}),p=Bt(!1),m=Bt(!1),g=Bt(!1),v=Bt(!1),[w,x]=c.useState(null),[b,E]=c.useState(null),[j,S]=c.useState(null),[C,_]=c.useState("org"),{organizationMemberships:k,loading:y,refetch:M}=Kt(),{activeOrganization:A,activeMembership:I,leave:P}=or(),{activeWorkspace:L,activeMembership:T,leave:$}=Zt(),{workspaces:z,loading:H}=sr(),{session:F,switchOrganization:O,switchWorkspace:Z}=ot(),{deployment:R}=Ae(),W=R==null?void 0:R.b2b_settings.organizations_enabled,D=R==null?void 0:R.b2b_settings.workspaces_enabled,B=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,Y=!I,X=c.useMemo(()=>{var J,le;return Y?{name:"Personal account",image_url:(le=(J=F==null?void 0:F.active_signin)==null?void 0:J.user)==null?void 0:le.profile_picture_url,isPersonal:!0}:{name:D&&L?`${A==null?void 0:A.name} / ${L.name}`:(A==null?void 0:A.name)||"",image_url:A==null?void 0:A.image_url,isPersonal:!1}},[Y,A,L,F,D]);if(c.useEffect(()=>{A&&D&&h(ve=>{if(ve.has(A.id))return ve;const J=new Set(ve);return J.add(A.id),J})},[A,D]),c.useEffect(()=>{_(D&&L?"ws":"org")},[D,L==null?void 0:L.id]),c.useEffect(()=>{if(!r)return;let ve=null;const J=setTimeout(()=>{const le=oe=>{var pe,fe;const G=oe.target;(pe=d.current)!=null&&pe.contains(G)||(fe=u.current)!=null&&fe.contains(G)||(a(!1),E(null))};document.addEventListener("mousedown",le),ve=()=>document.removeEventListener("mousedown",le)},50);return()=>{clearTimeout(J),ve==null||ve()}},[r]),c.useEffect(()=>{if(!b)return;const ve=setTimeout(()=>E(null),5e3);return()=>clearTimeout(ve)},[b]),!W)return null;const ce=ve=>ve.split(" ").map(J=>J[0]).join("").toUpperCase().slice(0,2),me=ve=>{s(!0),O(ve).finally(()=>s(!1))},te=ve=>{s(!0),Z(ve).finally(()=>s(!1))},xe=ve=>{h(J=>{const le=new Set(J);return le.has(ve)?le.delete(ve):le.add(ve),le})},re=!!((Te=I==null?void 0:I.eligibility_restriction)!=null&&Te.type)&&I.eligibility_restriction.type!=="none";return!!!F||y||D&&H?t.jsx(ge,{children:t.jsx(Nc,{children:t.jsxs(px,{children:[t.jsx(sn,{w:"20px",h:"20px",r:"5px"}),t.jsx(sn,{w:"120px",h:"12px"})]})})}):t.jsx(ge,{children:t.jsxs(Nc,{children:[t.jsxs(nx,{ref:d,onClick:()=>{a(!r),r||E(null)},disabled:n,children:[t.jsx(ox,{$personal:X.isPersonal,children:X.image_url?t.jsx("img",{src:X.image_url,alt:X.name}):X.isPersonal?t.jsx(Ea,{size:11}):ce(X.name)}),t.jsx(sx,{children:X.name}),t.jsx(mf,{size:13,color:"var(--color-secondary-text)"})]}),typeof window<"u"&&En.createPortal(t.jsx(ge,{children:t.jsxs(ix,{ref:u,$isOpen:r,$position:f,children:[(()=>{var Q,se,he,je;const ve=D&&!!L,J=!!A&&!re&&Hs(I),le=ve&&!re&&Ds(T),oe=()=>{m.open(),a(!1)},G=()=>{v.open(),a(!1)},pe=async()=>{if(P){S("org"),E(null);try{await P(),await M(),a(!1)}catch(ke){E(ke instanceof Error?ke.message:"Failed to leave organization")}finally{S(null)}}},fe=async()=>{if($){S("ws"),E(null);try{await $(),a(!1)}catch(ke){E(ke instanceof Error?ke.message:"Failed to leave workspace")}finally{S(null)}}};if(Y)return null;const q=ve,de=q?C:"org",Be=(se=(Q=I==null?void 0:I.roles)==null?void 0:Q[0])==null?void 0:se.name,We=(je=(he=T==null?void 0:T.roles)==null?void 0:he[0])==null?void 0:je.name;return t.jsxs(lx,{children:[q&&t.jsxs(dx,{children:[t.jsx(Uc,{type:"button",$active:de==="org","data-active":de==="org",onClick:()=>_("org"),children:"Organization"}),t.jsx(Uc,{type:"button",$active:de==="ws","data-active":de==="ws",onClick:()=>_("ws"),children:"Workspace"})]}),de==="org"&&A&&t.jsxs(Bc,{children:[t.jsx(Wc,{children:A.image_url?t.jsx("img",{src:A.image_url,alt:A.name}):ce(A.name)}),t.jsxs(Gc,{children:[t.jsx(qc,{children:A.name}),Be&&t.jsx(Kc,{children:Be})]}),t.jsxs(Yc,{children:[J&&t.jsx(on,{onClick:oe,title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ar,{size:14})}),t.jsx(on,{$destructive:!0,onClick:pe,disabled:j==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(zr,{size:14})})]})]}),de==="ws"&&ve&&t.jsxs(Bc,{children:[t.jsx(Wc,{children:L.image_url?t.jsx("img",{src:L.image_url,alt:L.name}):ce(L.name)}),t.jsxs(Gc,{children:[t.jsx(qc,{children:L.name}),We&&t.jsx(Kc,{children:We})]}),t.jsxs(Yc,{children:[le&&t.jsx(on,{onClick:G,title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ar,{size:14})}),t.jsx(on,{$destructive:!0,onClick:fe,disabled:j==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(zr,{size:14})})]})]})]})})(),b&&t.jsxs(fx,{children:[t.jsx($r,{size:13}),b]}),t.jsx(cx,{children:y||H?t.jsx(t.Fragment,{children:[1,2,3].map(ve=>t.jsxs(hx,{children:[t.jsx(sn,{w:"22px",h:"22px",r:"5px"}),t.jsx(sn,{w:ve===2?"60%":"80%",h:"11px"})]},ve))}):t.jsxs(t.Fragment,{children:[e&&t.jsxs(Qc,{$active:Y,onClick:()=>{Y||me()},disabled:n||Y,children:[t.jsx(Xc,{$personal:!0,children:(Ue=(Ve=F==null?void 0:F.active_signin)==null?void 0:Ve.user)!=null&&Ue.profile_picture_url?t.jsx("img",{src:F.active_signin.user.profile_picture_url,alt:"Personal"}):t.jsx(Ea,{size:12})}),t.jsx(hs,{children:"Personal account"}),Y&&t.jsx(zo,{children:t.jsx("span",{className:"row-check",style:{display:"inline-flex"},children:t.jsx($o,{size:13})})})]}),k==null?void 0:k.map(ve=>{var fe,q;const J=ve.organization,le=J.id===(A==null?void 0:A.id),oe=i.has(J.id),G=D?(z==null?void 0:z.filter(de=>de.organization.id===J.id))||[]:[],pe=!!((fe=ve.eligibility_restriction)!=null&&fe.type)&&ve.eligibility_restriction.type!=="none";return t.jsxs(c.Fragment,{children:[t.jsxs(Qc,{$active:le,onClick:()=>{pe||(D?xe(J.id):le||me(J.id))},disabled:n,style:pe?{opacity:.55,cursor:"not-allowed"}:le&&!D?{cursor:"default"}:void 0,title:(q=ve.eligibility_restriction)==null?void 0:q.message,children:[t.jsx(Xc,{children:J.image_url?t.jsx("img",{src:J.image_url,alt:J.name}):ce(J.name)}),t.jsx(hs,{children:J.name}),t.jsxs(zo,{children:[pe&&t.jsx($r,{size:12,color:"var(--color-error)"}),le&&!D&&t.jsx($o,{size:13}),D&&t.jsx(ux,{size:11,$open:oe})]})]}),D&&oe&&t.jsxs(t.Fragment,{children:[G.map(de=>{var Q,se;const Be=le&&(L==null?void 0:L.id)===de.id,We=((Q=de.eligibility_restriction)==null?void 0:Q.type)&&de.eligibility_restriction.type!=="none";return t.jsxs(Jc,{$active:Be,onClick:()=>{!Be&&!We&&te(de.id)},disabled:n,style:We||pe?{opacity:.55,cursor:"not-allowed"}:Be?{cursor:"default"}:void 0,title:(se=de.eligibility_restriction)==null?void 0:se.message,children:[t.jsx(el,{children:de.image_url?t.jsx("img",{src:de.image_url,alt:de.name}):ce(de.name).charAt(0)}),t.jsx(tl,{children:de.name}),t.jsxs(zo,{children:[We&&t.jsx($r,{size:12,color:"var(--color-error)"}),Be&&t.jsx($o,{size:12})]})]},de.id)}),!pe&&t.jsxs(Jc,{onClick:()=>{x(J.id),g.open()},disabled:n,children:[t.jsx(el,{style:{background:"transparent",border:"1px dashed var(--color-border)"},children:t.jsx(jt,{size:10})}),t.jsx(tl,{children:"New workspace"})]})]})]},J.id)})]})}),D?t.jsx(rl,{children:t.jsxs(al,{onClick:()=>{x(A&&!re?A.id:null),g.open()},disabled:n||!A||re,children:[t.jsx(nl,{children:t.jsx(jt,{size:12})}),"New workspace"]})}):B&&t.jsx(rl,{children:t.jsxs(al,{onClick:()=>p.open(),disabled:n,children:[t.jsx(nl,{children:t.jsx(jt,{size:12})}),"New organization"]})})]})}),document.body),W&&B&&t.jsx(Z1,{isOpen:p.isOpen,onClose:p.close,onCreated:M}),t.jsx(N1,{isOpen:m.isOpen,onClose:m.close}),D&&t.jsxs(t.Fragment,{children:[t.jsx(Zs,{isOpen:v.isOpen,onClose:v.close}),t.jsx(Ts,{isOpen:g.isOpen,onClose:()=>{g.close(),x(null)},organizationId:w||void 0})]})]})})},X1=c.createContext(void 0),Yt=()=>{const e=c.useContext(X1);if(!e)throw new Error("useScreenContext must be used within a ScreenProvider");return e},mx=mt`
4796
4796
  0% { transform: rotate(0deg); }
4797
4797
  100% { transform: rotate(360deg); }
4798
4798
  `,gx=l.div`
@@ -5336,7 +5336,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5336
5336
  color: var(--color-secondary-text);
5337
5337
  text-transform: uppercase;
5338
5338
  letter-spacing: 0.07em;
5339
- `;const Mx=()=>{var R,T;const{deployment:e}=Ae(),{refetch:r}=ot(),{user:a,updateProfile:n,deleteAccount:s}=ir(),{toast:i}=Yt(),[h,d]=c.useState(""),[u,f]=c.useState(""),[p,m]=c.useState(""),[g,v]=c.useState(!1),[w,x]=c.useState(!1),[b,E]=c.useState(!1),[j,S]=c.useState("");c.useEffect(()=>{a&&!g&&(d(a.first_name||""),f(a.last_name||""),m(a.username||""),v(!0))},[a,g]);const C=c.useCallback(async()=>{if(a)try{const $={};h!==a.first_name&&($.first_name=h),u!==a.last_name&&($.last_name=u),p!==a.username&&($.username=p),Object.keys($).length>0&&await n($)}catch($){i($.message||"Failed to save profile changes","error")}},[a,n,h,u,p,i]),_=$=>{d($.target.value)},k=$=>{f($.target.value)},y=$=>{m($.target.value)},M=()=>{C()},A=()=>{C()},F=()=>{C()};if(!a)return t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--size-20u) 0"},children:t.jsx(ze,{})});const I=async()=>{if(!(!a||j!=="delete this account")){E(!0);try{await s(""),i("Account deleted successfully","info"),await r()}catch($){i($.message||"Failed to delete account","error")}finally{E(!1),S(""),x(!1)}}};return t.jsx(t.Fragment,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-12u)"},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{marginBottom:"var(--space-6u)"},children:[t.jsx("h3",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-foreground)",margin:"0 0 var(--space-1u) 0"},children:"Profile Details"}),t.jsx("p",{style:{fontSize:"var(--font-size-md)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)"},children:[t.jsxs(kx,{children:[t.jsxs(Se,{style:{flex:1},children:[t.jsx(be,{htmlFor:"firstName",children:"First Name"}),t.jsx(ue,{id:"firstName",type:"text",value:h,onChange:_,onBlur:M,placeholder:"Enter your first name",required:!0})]}),t.jsxs(Se,{style:{flex:1},children:[t.jsx(be,{htmlFor:"lastName",children:"Last Name"}),t.jsx(ue,{id:"lastName",type:"text",value:u,onChange:k,onBlur:A,placeholder:"Enter your last name",required:!0})]})]}),((T=(R=e==null?void 0:e.auth_settings)==null?void 0:R.username)==null?void 0:T.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"username",children:"Username"}),t.jsx(ue,{id:"username",type:"text",value:p,onChange:y,onBlur:F,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{style:{position:"relative",height:"var(--border-width-thin)",background:"var(--color-divider)",margin:"0"}}),t.jsxs("div",{children:[t.jsxs("div",{style:{marginBottom:"var(--space-8u)"},children:[t.jsx("h3",{style:{fontSize:"var(--font-size-xl)",color:"var(--color-foreground)",margin:"0 0 var(--space-2u) 0"},children:"Danger Zone"}),t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),t.jsxs("div",{style:{padding:"var(--space-10u)",border:"var(--border-width-thin) solid var(--color-error)",borderRadius:"var(--radius-md)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:w?"var(--space-10u)":"0"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-foreground)",marginBottom:"var(--space-2u)",fontWeight:"500"},children:"Delete Account"}),t.jsx("div",{style:{fontSize:"var(--font-size-md)",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(N,{onClick:()=>{w?(x(!1),S("")):x(!0)},style:{background:"var(--color-error)",color:"var(--color-foreground-inverse)",border:"none",padding:"var(--space-3u) var(--space-6u)",fontSize:"var(--font-size-md)",height:"calc(var(--size-8u) * 2)",width:"auto"},children:w?"Cancel":"Delete"})]}),w&&t.jsxs("div",{style:{width:"100%",marginTop:"var(--space-8u)"},children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(ue,{id:"confirm_username",type:"text",value:j,onChange:$=>S($.target.value),placeholder:"delete this account",style:{width:"100%"}})]}),t.jsx(N,{onClick:I,disabled:j!=="delete this account"||b,style:{background:j==="delete this account"?"var(--color-error)":"transparent",color:j==="delete this account"?"var(--color-foreground-inverse)":"var(--color-muted)",border:"var(--border-width-thin) solid var(--color-border)",padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",height:"var(--size-18u)",cursor:j==="delete this account"?"pointer":"not-allowed",opacity:j==="delete this account"?1:.6,marginTop:"var(--space-6u)",width:"100%"},children:b?t.jsx(ze,{size:12}):"Delete Forever"})]})]})]})]})})},Lx=l.div`
5339
+ `;const Mx=()=>{var L,T;const{deployment:e}=Ae(),{refetch:r}=ot(),{user:a,updateProfile:n,deleteAccount:s}=ir(),{toast:i}=Yt(),[h,d]=c.useState(""),[u,f]=c.useState(""),[p,m]=c.useState(""),[g,v]=c.useState(!1),[w,x]=c.useState(!1),[b,E]=c.useState(!1),[j,S]=c.useState("");c.useEffect(()=>{a&&!g&&(d(a.first_name||""),f(a.last_name||""),m(a.username||""),v(!0))},[a,g]);const C=c.useCallback(async()=>{if(a)try{const $={};h!==a.first_name&&($.first_name=h),u!==a.last_name&&($.last_name=u),p!==a.username&&($.username=p),Object.keys($).length>0&&await n($)}catch($){i($.message||"Failed to save profile changes","error")}},[a,n,h,u,p,i]),_=$=>{d($.target.value)},k=$=>{f($.target.value)},y=$=>{m($.target.value)},M=()=>{C()},A=()=>{C()},I=()=>{C()};if(!a)return t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--size-20u) 0"},children:t.jsx(ze,{})});const P=async()=>{if(!(!a||j!=="delete this account")){E(!0);try{await s(""),i("Account deleted successfully","info"),await r()}catch($){i($.message||"Failed to delete account","error")}finally{E(!1),S(""),x(!1)}}};return t.jsx(t.Fragment,{children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-12u)"},children:[t.jsxs("div",{children:[t.jsxs("div",{style:{marginBottom:"var(--space-6u)"},children:[t.jsx("h3",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-foreground)",margin:"0 0 var(--space-1u) 0"},children:"Profile Details"}),t.jsx("p",{style:{fontSize:"var(--font-size-md)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-8u)"},children:[t.jsxs(kx,{children:[t.jsxs(Se,{style:{flex:1},children:[t.jsx(be,{htmlFor:"firstName",children:"First Name"}),t.jsx(ue,{id:"firstName",type:"text",value:h,onChange:_,onBlur:M,placeholder:"Enter your first name",required:!0})]}),t.jsxs(Se,{style:{flex:1},children:[t.jsx(be,{htmlFor:"lastName",children:"Last Name"}),t.jsx(ue,{id:"lastName",type:"text",value:u,onChange:k,onBlur:A,placeholder:"Enter your last name",required:!0})]})]}),((T=(L=e==null?void 0:e.auth_settings)==null?void 0:L.username)==null?void 0:T.enabled)&&t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"username",children:"Username"}),t.jsx(ue,{id:"username",type:"text",value:p,onChange:y,onBlur:I,placeholder:"Enter your username",required:!0})]})]})]}),t.jsx("div",{style:{position:"relative",height:"var(--border-width-thin)",background:"var(--color-divider)",margin:"0"}}),t.jsxs("div",{children:[t.jsxs("div",{style:{marginBottom:"var(--space-8u)"},children:[t.jsx("h3",{style:{fontSize:"var(--font-size-xl)",color:"var(--color-foreground)",margin:"0 0 var(--space-2u) 0"},children:"Danger Zone"}),t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),t.jsxs("div",{style:{padding:"var(--space-10u)",border:"var(--border-width-thin) solid var(--color-error)",borderRadius:"var(--radius-md)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:w?"var(--space-10u)":"0"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-foreground)",marginBottom:"var(--space-2u)",fontWeight:"500"},children:"Delete Account"}),t.jsx("div",{style:{fontSize:"var(--font-size-md)",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),t.jsx(N,{onClick:()=>{w?(x(!1),S("")):x(!0)},style:{background:"var(--color-error)",color:"var(--color-foreground-inverse)",border:"none",padding:"var(--space-3u) var(--space-6u)",fontSize:"var(--font-size-md)",height:"calc(var(--size-8u) * 2)",width:"auto"},children:w?"Cancel":"Delete"})]}),w&&t.jsxs("div",{style:{width:"100%",marginTop:"var(--space-8u)"},children:[t.jsxs(Se,{children:[t.jsx(be,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),t.jsx(ue,{id:"confirm_username",type:"text",value:j,onChange:$=>S($.target.value),placeholder:"delete this account",style:{width:"100%"}})]}),t.jsx(N,{onClick:P,disabled:j!=="delete this account"||b,style:{background:j==="delete this account"?"var(--color-error)":"transparent",color:j==="delete this account"?"var(--color-foreground-inverse)":"var(--color-muted)",border:"var(--border-width-thin) solid var(--color-border)",padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",height:"var(--size-18u)",cursor:j==="delete this account"?"pointer":"not-allowed",opacity:j==="delete this account"?1:.6,marginTop:"var(--space-6u)",width:"100%"},children:b?t.jsx(ze,{size:12}):"Delete Forever"})]})]})]})]})})},Lx=l.div`
5340
5340
  position: fixed;
5341
5341
  background: var(--color-popover);
5342
5342
  border-radius: 10px;
@@ -5401,7 +5401,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5401
5401
  `,Fx=l.span`
5402
5402
  font-size: 12px;
5403
5403
  color: var(--color-secondary-text);
5404
- `,Ix=()=>{var A,F,I,R;const{deployment:e}=Ae(),{toast:r}=Yt(),[a,n]=c.useState(""),[s,i]=c.useState(!1),[h,d]=c.useState(null),[u,f]=c.useState(new Set),p=c.useRef(null),m=c.useRef({}),{user:g,createEmailAddress:v,deleteEmailAddress:w,prepareEmailVerification:x,attemptEmailVerification:b,makeEmailPrimary:E}=ir();if(!((F=(A=e==null?void 0:e.auth_settings)==null?void 0:A.email_address)!=null&&F.enabled))return null;const j=(T,$)=>{f(z=>{const H=new Set(z);return $?H.add(T):H.delete(T),H})},S=async T=>{j(T,!0);try{await E(T),await g.refetch(),r("Primary email updated","info")}catch($){r($.message||"Failed to update primary email","error")}finally{j(T,!1)}},C=async T=>{if(T===(g==null?void 0:g.primary_email_address_id)){r("Cannot delete primary email. Set another email as primary first.","error");return}j(T,!0);try{await w(T),await g.refetch(),r("Email removed","info")}catch($){r($.message||"Failed to delete email address. Please try again.","error")}finally{j(T,!1)}},_=async T=>{j(T,!0);try{await x(T),await g.refetch(),d(T)}catch($){r($.message||"Failed to send verification","error")}finally{j(T,!1)}},k=(g==null?void 0:g.user_email_addresses)||[],y=T=>T.id===(g==null?void 0:g.primary_email_address_id)?t.jsx(Mr,{$variant:"success",children:"Primary"}):T.verified?t.jsx(Mr,{$variant:"neutral",children:"Backup"}):t.jsx(Mr,{$variant:"warning",children:"Pending verification"}),M=T=>{const $=T.id===(g==null?void 0:g.primary_email_address_id),z=u.has(T.id);return $?t.jsx(Fx,{children:"Cannot remove"}):t.jsxs(Tx,{children:[T.verified&&t.jsx(N,{$size:"sm",$outline:!0,disabled:z,onClick:()=>S(T.id),children:"Make primary"}),!T.verified&&t.jsx(N,{ref:H=>{H&&(m.current[T.id]=H)},$size:"sm",$outline:!0,disabled:z,onClick:()=>_(T.id),children:"Resend"}),t.jsx(N,{$size:"sm",$destructive:!0,disabled:z,onClick:()=>C(T.id),children:z?t.jsx(ze,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(tu,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Email addresses"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{style:{position:"relative",flexShrink:0},children:[t.jsx(N,{ref:p,$size:"sm",onClick:()=>i(!0),children:"Add email"}),s&&t.jsx(cl,{triggerRef:p,onClose:()=>i(!1),onAddEmail:async T=>{const $=await v(T);n($.data.id),await x($.data.id),g.refetch()},onPrepareVerification:async()=>{await x(a),g.refetch()},onAttemptVerification:async T=>{await b(a,T),g.refetch(),i(!1),n(""),r("Email added and verified","info")}})]})]}),k.length?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Email address"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:k.map(T=>t.jsxs(lt,{children:[t.jsx(Ye,{children:T.email}),t.jsx(Ye,{children:y(T)}),t.jsx(Dt,{children:M(T)})]},T.id))})]})})}):t.jsx(At,{title:"No email addresses",description:"Add an email address to get started."}),h&&t.jsx(cl,{existingEmail:(R=(I=g==null?void 0:g.user_email_addresses)==null?void 0:I.find(T=>T.id===h))==null?void 0:R.email,triggerRef:{current:m.current[h]},onClose:()=>d(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await x(h),g.refetch()},onAttemptVerification:async T=>{await b(h,T),g.refetch(),d(null),r("Email verified","info")}})]})},Zx=l.div`
5404
+ `,Ix=()=>{var A,I,P,L;const{deployment:e}=Ae(),{toast:r}=Yt(),[a,n]=c.useState(""),[s,i]=c.useState(!1),[h,d]=c.useState(null),[u,f]=c.useState(new Set),p=c.useRef(null),m=c.useRef({}),{user:g,createEmailAddress:v,deleteEmailAddress:w,prepareEmailVerification:x,attemptEmailVerification:b,makeEmailPrimary:E}=ir();if(!((I=(A=e==null?void 0:e.auth_settings)==null?void 0:A.email_address)!=null&&I.enabled))return null;const j=(T,$)=>{f(z=>{const H=new Set(z);return $?H.add(T):H.delete(T),H})},S=async T=>{j(T,!0);try{await E(T),await g.refetch(),r("Primary email updated","info")}catch($){r($.message||"Failed to update primary email","error")}finally{j(T,!1)}},C=async T=>{if(T===(g==null?void 0:g.primary_email_address_id)){r("Cannot delete primary email. Set another email as primary first.","error");return}j(T,!0);try{await w(T),await g.refetch(),r("Email removed","info")}catch($){r($.message||"Failed to delete email address. Please try again.","error")}finally{j(T,!1)}},_=async T=>{j(T,!0);try{await x(T),await g.refetch(),d(T)}catch($){r($.message||"Failed to send verification","error")}finally{j(T,!1)}},k=(g==null?void 0:g.user_email_addresses)||[],y=T=>T.id===(g==null?void 0:g.primary_email_address_id)?t.jsx(Mr,{$variant:"success",children:"Primary"}):T.verified?t.jsx(Mr,{$variant:"neutral",children:"Backup"}):t.jsx(Mr,{$variant:"warning",children:"Pending verification"}),M=T=>{const $=T.id===(g==null?void 0:g.primary_email_address_id),z=u.has(T.id);return $?t.jsx(Fx,{children:"Cannot remove"}):t.jsxs(Tx,{children:[T.verified&&t.jsx(N,{$size:"sm",$outline:!0,disabled:z,onClick:()=>S(T.id),children:"Make primary"}),!T.verified&&t.jsx(N,{ref:H=>{H&&(m.current[T.id]=H)},$size:"sm",$outline:!0,disabled:z,onClick:()=>_(T.id),children:"Resend"}),t.jsx(N,{$size:"sm",$destructive:!0,disabled:z,onClick:()=>C(T.id),children:z?t.jsx(ze,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(tu,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Email addresses"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Sign in and receive notifications at these addresses."})]}),t.jsxs("div",{style:{position:"relative",flexShrink:0},children:[t.jsx(N,{ref:p,$size:"sm",onClick:()=>i(!0),children:"Add email"}),s&&t.jsx(cl,{triggerRef:p,onClose:()=>i(!1),onAddEmail:async T=>{const $=await v(T);n($.data.id),await x($.data.id),g.refetch()},onPrepareVerification:async()=>{await x(a),g.refetch()},onAttemptVerification:async T=>{await b(a,T),g.refetch(),i(!1),n(""),r("Email added and verified","info")}})]})]}),k.length?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Email address"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:k.map(T=>t.jsxs(lt,{children:[t.jsx(Ye,{children:T.email}),t.jsx(Ye,{children:y(T)}),t.jsx(Dt,{children:M(T)})]},T.id))})]})})}):t.jsx(At,{title:"No email addresses",description:"Add an email address to get started."}),h&&t.jsx(cl,{existingEmail:(L=(P=g==null?void 0:g.user_email_addresses)==null?void 0:P.find(T=>T.id===h))==null?void 0:L.email,triggerRef:{current:m.current[h]},onClose:()=>d(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await x(h),g.refetch()},onAttemptVerification:async T=>{await b(h,T),g.refetch(),d(null),r("Email verified","info")}})]})},Zx=l.div`
5405
5405
  position: fixed;
5406
5406
  background: var(--color-popover);
5407
5407
  border-radius: 10px;
@@ -5455,7 +5455,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5455
5455
  grid-template-columns: 1fr 1fr;
5456
5456
  gap: 6px;
5457
5457
  & > button { width: 100%; }
5458
- `,pl=({onClose:e,onAddPhone:r,onAttemptVerification:a,existingPhone:n,onPrepareVerification:s,triggerRef:i})=>{var y;const h=c.useRef(null),[d,u]=c.useState(!1),{toast:f}=Yt(),p=xt({triggerRef:i??{current:null},isOpen:d,minWidth:340,defaultMaxHeight:360});c.useEffect(()=>{u(!0);const M=F=>{h.current&&!h.current.contains(F.target)&&e()},A=F=>{F.key==="Escape"&&e()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",A)}},[e]);const[m,g]=c.useState(n?"otp":"phone"),[v,w]=c.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[x,b]=c.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[E,j]=c.useState(""),[S,C]=c.useState(!1),_=async()=>{if(!(!v||S)){C(!0);try{await r(v,x||""),g("otp")}catch(M){f(M.message||"Failed to add phone number. Please try again.","error")}finally{C(!1)}}},k=async()=>{C(!0);try{await a(E),e()}catch(M){f(M.message||"Failed to verify phone. Check the code and try again.","error")}finally{C(!1)}};return d?t.jsx(Zx,{ref:h,style:{top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p?"visible":"hidden"},onClick:M=>M.stopPropagation(),children:m==="phone"?t.jsxs(t.Fragment,{children:[t.jsx(ll,{children:t.jsx(dl,{children:"Add phone number"})}),t.jsx($a,{value:v,onChange:M=>w(M.target.value),error:"",countryCode:x,setCountryCode:b}),t.jsxs(ul,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:_,disabled:!v||S,children:S?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(ll,{children:n?t.jsx("span",{}):t.jsxs(Ox,{onClick:()=>g("phone"),children:[t.jsx(na,{size:11})," Back"]})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx(dl,{children:"Verify phone number"}),t.jsxs(Hx,{children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:n||v})]})]}),t.jsx(lr,{onComplete:M=>j(M),onResend:async()=>s(),isSubmitting:S}),t.jsxs(ul,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:k,disabled:E.length!==6||S,children:S?"Verifying…":"Verify"})]})]})}):null},Vx=l.div`
5458
+ `,pl=({onClose:e,onAddPhone:r,onAttemptVerification:a,existingPhone:n,onPrepareVerification:s,triggerRef:i})=>{var y;const h=c.useRef(null),[d,u]=c.useState(!1),{toast:f}=Yt(),p=xt({triggerRef:i??{current:null},isOpen:d,minWidth:340,defaultMaxHeight:360});c.useEffect(()=>{u(!0);const M=I=>{h.current&&!h.current.contains(I.target)&&e()},A=I=>{I.key==="Escape"&&e()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",A)}},[e]);const[m,g]=c.useState(n?"otp":"phone"),[v,w]=c.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[x,b]=c.useState((y=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:y.pop()),[E,j]=c.useState(""),[S,C]=c.useState(!1),_=async()=>{if(!(!v||S)){C(!0);try{await r(v,x||""),g("otp")}catch(M){f(M.message||"Failed to add phone number. Please try again.","error")}finally{C(!1)}}},k=async()=>{C(!0);try{await a(E),e()}catch(M){f(M.message||"Failed to verify phone. Check the code and try again.","error")}finally{C(!1)}};return d?t.jsx(Zx,{ref:h,style:{top:(p==null?void 0:p.top)!==void 0?`${p.top}px`:void 0,bottom:(p==null?void 0:p.bottom)!==void 0?`${p.bottom}px`:void 0,left:(p==null?void 0:p.left)!==void 0?`${p.left}px`:void 0,right:(p==null?void 0:p.right)!==void 0?`${p.right}px`:void 0,visibility:p?"visible":"hidden"},onClick:M=>M.stopPropagation(),children:m==="phone"?t.jsxs(t.Fragment,{children:[t.jsx(ll,{children:t.jsx(dl,{children:"Add phone number"})}),t.jsx($a,{value:v,onChange:M=>w(M.target.value),error:"",countryCode:x,setCountryCode:b}),t.jsxs(ul,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:_,disabled:!v||S,children:S?"Sending…":"Send code"})]})]}):t.jsxs(t.Fragment,{children:[t.jsx(ll,{children:n?t.jsx("span",{}):t.jsxs(Ox,{onClick:()=>g("phone"),children:[t.jsx(na,{size:11})," Back"]})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx(dl,{children:"Verify phone number"}),t.jsxs(Hx,{children:["Enter the 6-digit code sent to ",t.jsx("strong",{children:n||v})]})]}),t.jsx(lr,{onComplete:M=>j(M),onResend:async()=>s(),isSubmitting:S}),t.jsxs(ul,{children:[t.jsx(N,{$size:"sm",$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{$size:"sm",onClick:k,disabled:E.length!==6||S,children:S?"Verifying…":"Verify"})]})]})}):null},Vx=l.div`
5459
5459
  display: flex;
5460
5460
  align-items: center;
5461
5461
  gap: 6px;
@@ -5473,7 +5473,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5473
5473
  font-size: 13px;
5474
5474
  & .flag { font-size: 14px; line-height: 1; }
5475
5475
  & .code { color: var(--color-secondary-text); }
5476
- `,Ux=()=>{var F,I,R,T;const{deployment:e}=Ae(),{toast:r}=Yt(),[a,n]=c.useState(""),[s,i]=c.useState(!1),[h,d]=c.useState(null),[u,f]=c.useState(new Set),p=c.useRef(null),m=c.useRef({}),{user:g,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:x,attemptPhoneVerification:b,makePhonePrimary:E}=ir();if(!((I=(F=e==null?void 0:e.auth_settings)==null?void 0:F.phone_number)!=null&&I.enabled))return null;const j=($,z)=>{f(H=>{const P=new Set(H);return z?P.add($):P.delete($),P})},S=$=>{const z=bn.find(H=>H.dialCode===$);return(z==null?void 0:z.flag)||"🌍"},C=async $=>{j($,!0);try{await E($),await g.refetch(),r("Primary phone updated","info")}catch(z){r(z.message||"Failed to update primary phone","error")}finally{j($,!1)}},_=async $=>{if($===(g==null?void 0:g.primary_phone_number_id)){r("Cannot delete primary phone. Set another phone as primary first.","error");return}j($,!0);try{await w($),await g.refetch(),r("Phone removed","info")}catch(z){r(z.message||"Failed to delete phone. Please try again.","error")}finally{j($,!1)}},k=async $=>{j($,!0);try{await x($),await g.refetch(),d($)}catch(z){r(z.message||"Failed to send verification","error")}finally{j($,!1)}},y=(g==null?void 0:g.user_phone_numbers)||[],M=$=>$.id===(g==null?void 0:g.primary_phone_number_id)?t.jsx(Mr,{$variant:"success",children:"Primary"}):$.verified?t.jsx(Mr,{$variant:"neutral",children:"Backup"}):t.jsx(Mr,{$variant:"warning",children:"Pending verification"}),A=$=>{const z=$.id===(g==null?void 0:g.primary_phone_number_id),H=u.has($.id);return z?t.jsx(Dx,{children:"Cannot remove"}):t.jsxs(Vx,{children:[$.verified&&t.jsx(N,{$size:"sm",$outline:!0,disabled:H,onClick:()=>C($.id),children:"Make primary"}),!$.verified&&t.jsx(N,{ref:P=>{P&&(m.current[$.id]=P)},$size:"sm",$outline:!0,disabled:H,onClick:()=>k($.id),children:"Resend"}),t.jsx(N,{$size:"sm",$destructive:!0,disabled:H,onClick:()=>_($.id),children:H?t.jsx(ze,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(tu,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Phone numbers"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{style:{position:"relative",flexShrink:0},children:[t.jsx(N,{ref:p,$size:"sm",onClick:()=>i(!0),children:"Add phone"}),s&&t.jsx(pl,{triggerRef:p,onClose:()=>i(!1),onAddPhone:async($,z)=>{const H=await v($,z);n(H.data.id),await x(H.data.id)},onPrepareVerification:async()=>{await x(a),g.refetch()},onAttemptVerification:async $=>{await b(a,$),g.refetch(),i(!1),n(""),r("Phone added and verified","info")}}),h&&t.jsx(pl,{existingPhone:(T=(R=g==null?void 0:g.user_phone_numbers)==null?void 0:R.find($=>$.id===h))==null?void 0:T.phone_number,triggerRef:{current:m.current[h]},onClose:()=>d(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await x(h),g.refetch()},onAttemptVerification:async $=>{await b(h,$),g.refetch(),d(null),r("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Phone number"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:y.map($=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs(Nx,{children:[t.jsx("span",{className:"flag",children:S($.country_code)}),t.jsx("span",{className:"code",children:$.country_code}),t.jsx("span",{children:$.phone_number})]})}),t.jsx(Ye,{children:M($)}),t.jsx(Dt,{children:A($)})]},$.id))})]})})}):t.jsx(At,{title:"No phone numbers",description:"Add a phone number to get started."})]})},Bx=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),Wx={google_oauth:{icon:t.jsx(i1,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(Bx,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(s1,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(d1,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(l1,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(u1,{}),label:"Discord"},x_oauth:{icon:t.jsx(c1,{}),label:"X"}},Gx=l.div`
5476
+ `,Ux=()=>{var I,P,L,T;const{deployment:e}=Ae(),{toast:r}=Yt(),[a,n]=c.useState(""),[s,i]=c.useState(!1),[h,d]=c.useState(null),[u,f]=c.useState(new Set),p=c.useRef(null),m=c.useRef({}),{user:g,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:x,attemptPhoneVerification:b,makePhonePrimary:E}=ir();if(!((P=(I=e==null?void 0:e.auth_settings)==null?void 0:I.phone_number)!=null&&P.enabled))return null;const j=($,z)=>{f(H=>{const F=new Set(H);return z?F.add($):F.delete($),F})},S=$=>{const z=bn.find(H=>H.dialCode===$);return(z==null?void 0:z.flag)||"🌍"},C=async $=>{j($,!0);try{await E($),await g.refetch(),r("Primary phone updated","info")}catch(z){r(z.message||"Failed to update primary phone","error")}finally{j($,!1)}},_=async $=>{if($===(g==null?void 0:g.primary_phone_number_id)){r("Cannot delete primary phone. Set another phone as primary first.","error");return}j($,!0);try{await w($),await g.refetch(),r("Phone removed","info")}catch(z){r(z.message||"Failed to delete phone. Please try again.","error")}finally{j($,!1)}},k=async $=>{j($,!0);try{await x($),await g.refetch(),d($)}catch(z){r(z.message||"Failed to send verification","error")}finally{j($,!1)}},y=(g==null?void 0:g.user_phone_numbers)||[],M=$=>$.id===(g==null?void 0:g.primary_phone_number_id)?t.jsx(Mr,{$variant:"success",children:"Primary"}):$.verified?t.jsx(Mr,{$variant:"neutral",children:"Backup"}):t.jsx(Mr,{$variant:"warning",children:"Pending verification"}),A=$=>{const z=$.id===(g==null?void 0:g.primary_phone_number_id),H=u.has($.id);return z?t.jsx(Dx,{children:"Cannot remove"}):t.jsxs(Vx,{children:[$.verified&&t.jsx(N,{$size:"sm",$outline:!0,disabled:H,onClick:()=>C($.id),children:"Make primary"}),!$.verified&&t.jsx(N,{ref:F=>{F&&(m.current[$.id]=F)},$size:"sm",$outline:!0,disabled:H,onClick:()=>k($.id),children:"Resend"}),t.jsx(N,{$size:"sm",$destructive:!0,disabled:H,onClick:()=>_($.id),children:H?t.jsx(ze,{size:12}):"Remove"})]})};return t.jsxs(t.Fragment,{children:[t.jsxs(tu,{style:{marginBottom:"var(--space-6u)"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--color-card-foreground)"},children:"Phone numbers"}),t.jsx("div",{style:{fontSize:12,color:"var(--color-secondary-text)",marginTop:2},children:"Used for sign-in and two-factor authentication."})]}),t.jsxs("div",{style:{position:"relative",flexShrink:0},children:[t.jsx(N,{ref:p,$size:"sm",onClick:()=>i(!0),children:"Add phone"}),s&&t.jsx(pl,{triggerRef:p,onClose:()=>i(!1),onAddPhone:async($,z)=>{const H=await v($,z);n(H.data.id),await x(H.data.id)},onPrepareVerification:async()=>{await x(a),g.refetch()},onAttemptVerification:async $=>{await b(a,$),g.refetch(),i(!1),n(""),r("Phone added and verified","info")}}),h&&t.jsx(pl,{existingPhone:(T=(L=g==null?void 0:g.user_phone_numbers)==null?void 0:L.find($=>$.id===h))==null?void 0:T.phone_number,triggerRef:{current:m.current[h]},onClose:()=>d(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await x(h),g.refetch()},onAttemptVerification:async $=>{await b(h,$),g.refetch(),d(null),r("Phone verified","info")}})]})]}),y.length?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Phone number"}),t.jsx(Oe,{children:"Status"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:y.map($=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs(Nx,{children:[t.jsx("span",{className:"flag",children:S($.country_code)}),t.jsx("span",{className:"code",children:$.country_code}),t.jsx("span",{children:$.phone_number})]})}),t.jsx(Ye,{children:M($)}),t.jsx(Dt,{children:A($)})]},$.id))})]})})}):t.jsx(At,{title:"No phone numbers",description:"Add a phone number to get started."})]})},Bx=e=>t.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...e,children:[t.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),t.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),t.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),t.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),Wx={google_oauth:{icon:t.jsx(i1,{}),label:"Google"},microsoft_oauth:{icon:t.jsx(Bx,{}),label:"Microsoft"},github_oauth:{icon:t.jsx(s1,{}),label:"GitHub"},gitlab_oauth:{icon:t.jsx(d1,{}),label:"GitLab"},linkedin_oauth:{icon:t.jsx(l1,{}),label:"LinkedIn"},discord_oauth:{icon:t.jsx(u1,{}),label:"Discord"},x_oauth:{icon:t.jsx(c1,{}),label:"X"}},Gx=l.div`
5477
5477
  display: flex;
5478
5478
  align-items: center;
5479
5479
  gap: var(--space-4u);
@@ -5588,7 +5588,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5588
5588
  * @license qrcode.react
5589
5589
  * Copyright (c) Paul O'Shannessy
5590
5590
  * SPDX-License-Identifier: ISC
5591
- */var d5={L:qr.QrCode.Ecc.LOW,M:qr.QrCode.Ecc.MEDIUM,Q:qr.QrCode.Ecc.QUARTILE,H:qr.QrCode.Ecc.HIGH},nu=128,ou="L",su="#FFFFFF",iu="#000000",cu=!1,lu=1,u5=4,p5=0,h5=.1;function du(e,r=0){const a=[];return e.forEach(function(n,s){let i=null;n.forEach(function(h,d){if(!h&&i!==null){a.push(`M${i+r} ${s+r}h${d-i}v1H${i+r}z`),i=null;return}if(d===n.length-1){if(!h)return;i===null?a.push(`M${d+r},${s+r} h1v1H${d+r}z`):a.push(`M${i+r},${s+r} h${d+1-i}v1H${i+r}z`);return}h&&i===null&&(i=d)})}),a.join("")}function uu(e,r){return e.slice().map((a,n)=>n<r.y||n>=r.y+r.h?a:a.map((s,i)=>i<r.x||i>=r.x+r.w?s:!1))}function f5(e,r,a,n){if(n==null)return null;const s=e.length+a*2,i=Math.floor(r*h5),h=s/r,d=(n.width||i)*h,u=(n.height||i)*h,f=n.x==null?e.length/2-d/2:n.x*h,p=n.y==null?e.length/2-u/2:n.y*h,m=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let w=Math.floor(f),x=Math.floor(p),b=Math.ceil(d+f-w),E=Math.ceil(u+p-x);g={x:w,y:x,w:b,h:E}}const v=n.crossOrigin;return{x:f,y:p,h:u,w:d,excavation:g,opacity:m,crossOrigin:v}}function m5(e,r){return r!=null?Math.max(Math.floor(r),0):e?u5:p5}function pu({value:e,level:r,minVersion:a,includeMargin:n,marginSize:s,imageSettings:i,size:h,boostLevel:d}){let u=c.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((x,b)=>(x.push(...qr.QrSegment.makeSegments(b)),x),[]);return qr.QrCode.encodeSegments(w,d5[r],a,void 0,void 0,d)},[e,r,a,d]);const{cells:f,margin:p,numCells:m,calculatedImageSettings:g}=c.useMemo(()=>{let v=u.getModules();const w=m5(n,s),x=v.length+w*2,b=f5(v,h,w,i);return{cells:v,margin:w,numCells:x,calculatedImageSettings:b}},[u,h,i,n,s]);return{qrcode:u,margin:p,cells:f,numCells:m,calculatedImageSettings:g}}var g5=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),v5=c.forwardRef(function(r,a){const n=r,{value:s,size:i=nu,level:h=ou,bgColor:d=su,fgColor:u=iu,includeMargin:f=cu,minVersion:p=lu,boostLevel:m,marginSize:g,imageSettings:v}=n,x=ms(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=x,E=ms(x,["style"]),j=v==null?void 0:v.src,S=c.useRef(null),C=c.useRef(null),_=c.useCallback($=>{S.current=$,typeof a=="function"?a($):a&&(a.current=$)},[a]),[k,y]=c.useState(!1),{margin:M,cells:A,numCells:F,calculatedImageSettings:I}=pu({value:s,level:h,minVersion:p,boostLevel:m,includeMargin:f,marginSize:g,imageSettings:v,size:i});c.useEffect(()=>{if(S.current!=null){const $=S.current,z=$.getContext("2d");if(!z)return;let H=A;const P=C.current,O=I!=null&&P!==null&&P.complete&&P.naturalHeight!==0&&P.naturalWidth!==0;O&&I.excavation!=null&&(H=uu(A,I.excavation));const Z=window.devicePixelRatio||1;$.height=$.width=i*Z;const L=i/F*Z;z.scale(L,L),z.fillStyle=d,z.fillRect(0,0,F,F),z.fillStyle=u,g5?z.fill(new Path2D(du(H,M))):A.forEach(function(W,D){W.forEach(function(B,Y){B&&z.fillRect(Y+M,D+M,1,1)})}),I&&(z.globalAlpha=I.opacity),O&&z.drawImage(P,I.x+M,I.y+M,I.w,I.h)}}),c.useEffect(()=>{y(!1)},[j]);const R=fs({height:i,width:i},b);let T=null;return j!=null&&(T=c.createElement("img",{src:j,key:j,style:{display:"none"},onLoad:()=>{y(!0)},ref:C,crossOrigin:I==null?void 0:I.crossOrigin})),c.createElement(c.Fragment,null,c.createElement("canvas",fs({style:R,height:i,width:i,ref:_,role:"img"},E)),T)});v5.displayName="QRCodeCanvas";var Us=c.forwardRef(function(r,a){const n=r,{value:s,size:i=nu,level:h=ou,bgColor:d=su,fgColor:u=iu,includeMargin:f=cu,minVersion:p=lu,boostLevel:m,title:g,marginSize:v,imageSettings:w}=n,x=ms(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:E,numCells:j,calculatedImageSettings:S}=pu({value:s,level:h,minVersion:p,boostLevel:m,includeMargin:f,marginSize:v,imageSettings:w,size:i});let C=E,_=null;w!=null&&S!=null&&(S.excavation!=null&&(C=uu(E,S.excavation)),_=c.createElement("image",{href:w.src,height:S.h,width:S.w,x:S.x+b,y:S.y+b,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const k=du(C,b);return c.createElement("svg",fs({height:i,width:i,viewBox:`0 0 ${j} ${j}`,ref:a,role:"img"},x),!!g&&c.createElement("title",null,g),c.createElement("path",{fill:d,d:`M0,0 h${j}v${j}H0z`,shapeRendering:"crispEdges"}),c.createElement("path",{fill:u,d:k,shapeRendering:"crispEdges"}),_)});Us.displayName="QRCodeSVG";const x5=l.div`
5591
+ */var d5={L:qr.QrCode.Ecc.LOW,M:qr.QrCode.Ecc.MEDIUM,Q:qr.QrCode.Ecc.QUARTILE,H:qr.QrCode.Ecc.HIGH},nu=128,ou="L",su="#FFFFFF",iu="#000000",cu=!1,lu=1,u5=4,p5=0,h5=.1;function du(e,r=0){const a=[];return e.forEach(function(n,s){let i=null;n.forEach(function(h,d){if(!h&&i!==null){a.push(`M${i+r} ${s+r}h${d-i}v1H${i+r}z`),i=null;return}if(d===n.length-1){if(!h)return;i===null?a.push(`M${d+r},${s+r} h1v1H${d+r}z`):a.push(`M${i+r},${s+r} h${d+1-i}v1H${i+r}z`);return}h&&i===null&&(i=d)})}),a.join("")}function uu(e,r){return e.slice().map((a,n)=>n<r.y||n>=r.y+r.h?a:a.map((s,i)=>i<r.x||i>=r.x+r.w?s:!1))}function f5(e,r,a,n){if(n==null)return null;const s=e.length+a*2,i=Math.floor(r*h5),h=s/r,d=(n.width||i)*h,u=(n.height||i)*h,f=n.x==null?e.length/2-d/2:n.x*h,p=n.y==null?e.length/2-u/2:n.y*h,m=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let w=Math.floor(f),x=Math.floor(p),b=Math.ceil(d+f-w),E=Math.ceil(u+p-x);g={x:w,y:x,w:b,h:E}}const v=n.crossOrigin;return{x:f,y:p,h:u,w:d,excavation:g,opacity:m,crossOrigin:v}}function m5(e,r){return r!=null?Math.max(Math.floor(r),0):e?u5:p5}function pu({value:e,level:r,minVersion:a,includeMargin:n,marginSize:s,imageSettings:i,size:h,boostLevel:d}){let u=c.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((x,b)=>(x.push(...qr.QrSegment.makeSegments(b)),x),[]);return qr.QrCode.encodeSegments(w,d5[r],a,void 0,void 0,d)},[e,r,a,d]);const{cells:f,margin:p,numCells:m,calculatedImageSettings:g}=c.useMemo(()=>{let v=u.getModules();const w=m5(n,s),x=v.length+w*2,b=f5(v,h,w,i);return{cells:v,margin:w,numCells:x,calculatedImageSettings:b}},[u,h,i,n,s]);return{qrcode:u,margin:p,cells:f,numCells:m,calculatedImageSettings:g}}var g5=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),v5=c.forwardRef(function(r,a){const n=r,{value:s,size:i=nu,level:h=ou,bgColor:d=su,fgColor:u=iu,includeMargin:f=cu,minVersion:p=lu,boostLevel:m,marginSize:g,imageSettings:v}=n,x=ms(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=x,E=ms(x,["style"]),j=v==null?void 0:v.src,S=c.useRef(null),C=c.useRef(null),_=c.useCallback($=>{S.current=$,typeof a=="function"?a($):a&&(a.current=$)},[a]),[k,y]=c.useState(!1),{margin:M,cells:A,numCells:I,calculatedImageSettings:P}=pu({value:s,level:h,minVersion:p,boostLevel:m,includeMargin:f,marginSize:g,imageSettings:v,size:i});c.useEffect(()=>{if(S.current!=null){const $=S.current,z=$.getContext("2d");if(!z)return;let H=A;const F=C.current,O=P!=null&&F!==null&&F.complete&&F.naturalHeight!==0&&F.naturalWidth!==0;O&&P.excavation!=null&&(H=uu(A,P.excavation));const Z=window.devicePixelRatio||1;$.height=$.width=i*Z;const R=i/I*Z;z.scale(R,R),z.fillStyle=d,z.fillRect(0,0,I,I),z.fillStyle=u,g5?z.fill(new Path2D(du(H,M))):A.forEach(function(W,D){W.forEach(function(B,Y){B&&z.fillRect(Y+M,D+M,1,1)})}),P&&(z.globalAlpha=P.opacity),O&&z.drawImage(F,P.x+M,P.y+M,P.w,P.h)}}),c.useEffect(()=>{y(!1)},[j]);const L=fs({height:i,width:i},b);let T=null;return j!=null&&(T=c.createElement("img",{src:j,key:j,style:{display:"none"},onLoad:()=>{y(!0)},ref:C,crossOrigin:P==null?void 0:P.crossOrigin})),c.createElement(c.Fragment,null,c.createElement("canvas",fs({style:L,height:i,width:i,ref:_,role:"img"},E)),T)});v5.displayName="QRCodeCanvas";var Us=c.forwardRef(function(r,a){const n=r,{value:s,size:i=nu,level:h=ou,bgColor:d=su,fgColor:u=iu,includeMargin:f=cu,minVersion:p=lu,boostLevel:m,title:g,marginSize:v,imageSettings:w}=n,x=ms(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:E,numCells:j,calculatedImageSettings:S}=pu({value:s,level:h,minVersion:p,boostLevel:m,includeMargin:f,marginSize:v,imageSettings:w,size:i});let C=E,_=null;w!=null&&S!=null&&(S.excavation!=null&&(C=uu(E,S.excavation)),_=c.createElement("image",{href:w.src,height:S.h,width:S.w,x:S.x+b,y:S.y+b,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const k=du(C,b);return c.createElement("svg",fs({height:i,width:i,viewBox:`0 0 ${j} ${j}`,ref:a,role:"img"},x),!!g&&c.createElement("title",null,g),c.createElement("path",{fill:d,d:`M0,0 h${j}v${j}H0z`,shapeRendering:"crispEdges"}),c.createElement("path",{fill:u,d:k,shapeRendering:"crispEdges"}),_)});Us.displayName="QRCodeSVG";const x5=l.div`
5592
5592
  position: fixed;
5593
5593
  background: var(--color-popover);
5594
5594
  border-radius: var(--radius-md);
@@ -5639,7 +5639,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5639
5639
  color: var(--color-error);
5640
5640
  font-size: var(--font-size-sm);
5641
5641
  margin-top: var(--space-2u);
5642
- `,fl=({onClose:e,onChangePassword:r,triggerRef:a,isSetup:n=!1})=>{const s=c.useRef(null),[i,h]=c.useState(!1),[d,u]=c.useState(""),[f,p]=c.useState(""),[m,g]=c.useState(""),[v,w]=c.useState(!1),[x,b]=c.useState(!1),[E,j]=c.useState(!1),[S,C]=c.useState(!1),[_,k]=c.useState({}),y=xt({triggerRef:a??{current:null},isOpen:i,minWidth:380,defaultMaxHeight:420});c.useEffect(()=>{h(!0);const A=I=>{s.current&&!s.current.contains(I.target)&&e()},F=I=>{I.key==="Escape"&&e()};return document.addEventListener("mousedown",A),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",F)}},[e]);const M=async()=>{if(S)return;const A={};if(!n&&!d&&(A.currentPassword="Current password is required"),f?f.length<8&&(A.newPassword="Password must be at least 8 characters"):A.newPassword="New password is required",f!==m&&(A.confirmPassword="Passwords do not match"),Object.keys(A).length>0){k(A);return}C(!0);try{await r(n?"":d,f),e()}catch(F){k({form:F.message||"Failed to update password"})}finally{C(!1)}};return i?t.jsxs(x5,{ref:s,style:{top:(y==null?void 0:y.top)!==void 0?`${y.top}px`:void 0,bottom:(y==null?void 0:y.bottom)!==void 0?`${y.bottom}px`:void 0,left:(y==null?void 0:y.left)!==void 0?`${y.left}px`:void 0,right:(y==null?void 0:y.right)!==void 0?`${y.right}px`:void 0,maxHeight:y!=null&&y.maxHeight?`${y.maxHeight}px`:void 0,visibility:y?"visible":"hidden"},onClick:A=>A.stopPropagation(),children:[t.jsx(w5,{children:n?"Set Password":"Change Password"}),t.jsx("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)",marginBottom:"var(--space-8u)"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&t.jsxs(Mo,{children:[t.jsx(be,{children:"Current Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:v?"text":"password",placeholder:"Enter your current password",value:d,onChange:A=>u(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>w(!v),"aria-label":v?"Hide current password":"Show current password",children:v?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.currentPassword&&t.jsx(cn,{children:_.currentPassword})]}),t.jsxs(Mo,{children:[t.jsx(be,{children:n?"Password":"New Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:x?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:f,onChange:A=>p(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>b(!x),"aria-label":x?"Hide new password":"Show new password",children:x?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.newPassword&&t.jsx(cn,{children:_.newPassword})]}),t.jsxs(Mo,{children:[t.jsx(be,{children:"Confirm New Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:E?"text":"password",placeholder:"Confirm your new password",value:m,onChange:A=>g(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>j(!E),"aria-label":E?"Hide confirm password":"Show confirm password",children:E?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.confirmPassword&&t.jsx(cn,{children:_.confirmPassword})]}),_.form&&t.jsx(cn,{children:_.form}),t.jsxs(b5,{children:[t.jsx(N,{$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{onClick:M,disabled:S,children:S?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},y5=l.div`
5642
+ `,fl=({onClose:e,onChangePassword:r,triggerRef:a,isSetup:n=!1})=>{const s=c.useRef(null),[i,h]=c.useState(!1),[d,u]=c.useState(""),[f,p]=c.useState(""),[m,g]=c.useState(""),[v,w]=c.useState(!1),[x,b]=c.useState(!1),[E,j]=c.useState(!1),[S,C]=c.useState(!1),[_,k]=c.useState({}),y=xt({triggerRef:a??{current:null},isOpen:i,minWidth:380,defaultMaxHeight:420});c.useEffect(()=>{h(!0);const A=P=>{s.current&&!s.current.contains(P.target)&&e()},I=P=>{P.key==="Escape"&&e()};return document.addEventListener("mousedown",A),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",I)}},[e]);const M=async()=>{if(S)return;const A={};if(!n&&!d&&(A.currentPassword="Current password is required"),f?f.length<8&&(A.newPassword="Password must be at least 8 characters"):A.newPassword="New password is required",f!==m&&(A.confirmPassword="Passwords do not match"),Object.keys(A).length>0){k(A);return}C(!0);try{await r(n?"":d,f),e()}catch(I){k({form:I.message||"Failed to update password"})}finally{C(!1)}};return i?t.jsxs(x5,{ref:s,style:{top:(y==null?void 0:y.top)!==void 0?`${y.top}px`:void 0,bottom:(y==null?void 0:y.bottom)!==void 0?`${y.bottom}px`:void 0,left:(y==null?void 0:y.left)!==void 0?`${y.left}px`:void 0,right:(y==null?void 0:y.right)!==void 0?`${y.right}px`:void 0,maxHeight:y!=null&&y.maxHeight?`${y.maxHeight}px`:void 0,visibility:y?"visible":"hidden"},onClick:A=>A.stopPropagation(),children:[t.jsx(w5,{children:n?"Set Password":"Change Password"}),t.jsx("div",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-muted)",marginBottom:"var(--space-8u)"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&t.jsxs(Mo,{children:[t.jsx(be,{children:"Current Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:v?"text":"password",placeholder:"Enter your current password",value:d,onChange:A=>u(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>w(!v),"aria-label":v?"Hide current password":"Show current password",children:v?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.currentPassword&&t.jsx(cn,{children:_.currentPassword})]}),t.jsxs(Mo,{children:[t.jsx(be,{children:n?"Password":"New Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:x?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:f,onChange:A=>p(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>b(!x),"aria-label":x?"Hide new password":"Show new password",children:x?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.newPassword&&t.jsx(cn,{children:_.newPassword})]}),t.jsxs(Mo,{children:[t.jsx(be,{children:"Confirm New Password"}),t.jsxs(Lo,{children:[t.jsx(ue,{type:E?"text":"password",placeholder:"Confirm your new password",value:m,onChange:A=>g(A.target.value),style:{paddingRight:"var(--size-20u)"}}),t.jsx("button",{type:"button",onClick:()=>j(!E),"aria-label":E?"Hide confirm password":"Show confirm password",children:E?t.jsx(io,{size:16}):t.jsx(so,{size:16})})]}),_.confirmPassword&&t.jsx(cn,{children:_.confirmPassword})]}),_.form&&t.jsx(cn,{children:_.form}),t.jsxs(b5,{children:[t.jsx(N,{$outline:!0,onClick:e,children:"Cancel"}),t.jsx(N,{onClick:M,disabled:S,children:S?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},y5=l.div`
5643
5643
  position: fixed;
5644
5644
  background: var(--color-popover);
5645
5645
  border-radius: var(--radius-md);
@@ -5787,9 +5787,9 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5787
5787
  color: var(--color-secondary-text);
5788
5788
  padding: ${e=>e.$first?"0":"var(--space-8u) 0 0"};
5789
5789
  margin-bottom: var(--space-4u);
5790
- `,N5=()=>{var ye,Me,De,et,rt,ft,_t;const{deployment:e}=Ae(),{user:r,updatePassword:a,removePassword:n,setupAuthenticator:s,verifyAuthenticator:i,deleteAuthenticator:h,generateBackupCodes:d,regenerateBackupCodes:u,updateProfile:f,getPasskeys:p,registerPasskey:m,deletePasskey:g}=ir(),{toast:v}=Yt(),[w,x]=c.useState((r==null?void 0:r.second_factor_policy)||"none"),[b,E]=c.useState(!1),j=async ae=>{try{await f({second_factor_policy:ae}),x(ae),v("2FA requirement updated successfully","info")}catch(Re){v(Re.message||"Failed to update 2FA requirement","error")}},[S,C]=c.useState(!1),[_,k]=c.useState(!1),[y,M]=c.useState(!1),[A,F]=c.useState(!1),I=c.useRef(null),R=c.useRef(null),T=c.useRef(null),$=c.useRef(null),[z,H]=c.useState([]),[P,O]=c.useState(!1),[Z,L]=c.useState(!1),[W,D]=c.useState(!1),[B,Y]=c.useState(!1),[X,ce]=c.useState(null),me=c.useRef(null),[te,xe]=c.useState("table"),[re,U]=c.useState(""),[Qe,Te]=c.useState(""),[Ve,Ue]=c.useState(""),[ve,J]=c.useState(["",""]),[le,oe]=c.useState([]),[G,pe]=c.useState(!1),[fe,q]=c.useState(!1),[de]=c.useState(!1),[Be,We]=c.useState(!1),Q=(ye=e==null?void 0:e.auth_settings)==null?void 0:ye.auth_factors_enabled,se=(De=(Me=e==null?void 0:e.auth_settings)==null?void 0:Me.password)==null?void 0:De.enabled;if(!(Q!=null&&Q.authenticator)&&!(Q!=null&&Q.backup_code)&&!se)return null;const he=async(ae,Re)=>{await a(ae,Re),await r.refetch(),v("Password updated successfully","info")},je=async ae=>{await n(ae),await r.refetch(),v("Password removed successfully","info")},ke=()=>{var K,ee,ne,Fe,Pe,at;if(!r)return!1;const ae=(K=r.user_email_addresses)==null?void 0:K.some(vt=>vt.verified),Re=(ee=r.user_phone_numbers)==null?void 0:ee.some(vt=>vt.verified),tt=r.social_connections&&r.social_connections.length>0,qe=e==null?void 0:e.auth_settings;return(qe==null?void 0:qe.first_factor)==="email_otp"&&ae||((ne=qe==null?void 0:qe.magic_link)==null?void 0:ne.enabled)&&ae||((Fe=qe==null?void 0:qe.passkey)==null?void 0:Fe.enabled)||((Pe=qe==null?void 0:qe.auth_factors_enabled)==null?void 0:Pe.phone_otp)&&Re||tt&&((at=e==null?void 0:e.social_connections)==null?void 0:at.some(vt=>vt.enabled))},Ge=async()=>{if(ve.some(ae=>ae.length!==6)){v("Please enter both 6-digit verification codes","error");return}try{if(q(!0),await i(Ve,ve),await r.refetch(),Q!=null&&Q.backup_code){const ae=await d();oe(ae),await r.refetch(),xe("backup")}else xe("success")}catch(ae){v(ae.message||"Invalid verification codes","error")}finally{q(!1)}},dt=()=>{xe("table"),U(""),Te(""),Ue(""),J(["",""]),oe([]),v("Two-factor authentication setup completed successfully!","info")},dr=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{We(!0),await h(r.user_authenticator.id),await r.refetch(),E(!1),v("Two-factor authentication removed successfully","info")}catch(Re){v(Re.message||"Failed to remove authenticator","error")}finally{We(!1)}},ur=async()=>{if(!G)try{pe(!0);const ae=await u();oe(ae),await r.refetch(),F(!0),v("New backup codes generated","info")}catch(ae){v(ae.message||"Failed to generate backup codes","error")}finally{pe(!1)}},Qt=()=>{const ae=le.join(`
5790
+ `,N5=()=>{var ye,Me,De,et,rt,ft,_t;const{deployment:e}=Ae(),{user:r,updatePassword:a,removePassword:n,setupAuthenticator:s,verifyAuthenticator:i,deleteAuthenticator:h,generateBackupCodes:d,regenerateBackupCodes:u,updateProfile:f,getPasskeys:p,registerPasskey:m,deletePasskey:g}=ir(),{toast:v}=Yt(),[w,x]=c.useState((r==null?void 0:r.second_factor_policy)||"none"),[b,E]=c.useState(!1),j=async ae=>{try{await f({second_factor_policy:ae}),x(ae),v("2FA requirement updated successfully","info")}catch(Re){v(Re.message||"Failed to update 2FA requirement","error")}},[S,C]=c.useState(!1),[_,k]=c.useState(!1),[y,M]=c.useState(!1),[A,I]=c.useState(!1),P=c.useRef(null),L=c.useRef(null),T=c.useRef(null),$=c.useRef(null),[z,H]=c.useState([]),[F,O]=c.useState(!1),[Z,R]=c.useState(!1),[W,D]=c.useState(!1),[B,Y]=c.useState(!1),[X,ce]=c.useState(null),me=c.useRef(null),[te,xe]=c.useState("table"),[re,U]=c.useState(""),[Qe,Te]=c.useState(""),[Ve,Ue]=c.useState(""),[ve,J]=c.useState(["",""]),[le,oe]=c.useState([]),[G,pe]=c.useState(!1),[fe,q]=c.useState(!1),[de]=c.useState(!1),[Be,We]=c.useState(!1),Q=(ye=e==null?void 0:e.auth_settings)==null?void 0:ye.auth_factors_enabled,se=(De=(Me=e==null?void 0:e.auth_settings)==null?void 0:Me.password)==null?void 0:De.enabled;if(!(Q!=null&&Q.authenticator)&&!(Q!=null&&Q.backup_code)&&!se)return null;const he=async(ae,Re)=>{await a(ae,Re),await r.refetch(),v("Password updated successfully","info")},je=async ae=>{await n(ae),await r.refetch(),v("Password removed successfully","info")},ke=()=>{var K,ee,ne,Fe,Pe,at;if(!r)return!1;const ae=(K=r.user_email_addresses)==null?void 0:K.some(vt=>vt.verified),Re=(ee=r.user_phone_numbers)==null?void 0:ee.some(vt=>vt.verified),tt=r.social_connections&&r.social_connections.length>0,qe=e==null?void 0:e.auth_settings;return(qe==null?void 0:qe.first_factor)==="email_otp"&&ae||((ne=qe==null?void 0:qe.magic_link)==null?void 0:ne.enabled)&&ae||((Fe=qe==null?void 0:qe.passkey)==null?void 0:Fe.enabled)||((Pe=qe==null?void 0:qe.auth_factors_enabled)==null?void 0:Pe.phone_otp)&&Re||tt&&((at=e==null?void 0:e.social_connections)==null?void 0:at.some(vt=>vt.enabled))},Ge=async()=>{if(ve.some(ae=>ae.length!==6)){v("Please enter both 6-digit verification codes","error");return}try{if(q(!0),await i(Ve,ve),await r.refetch(),Q!=null&&Q.backup_code){const ae=await d();oe(ae),await r.refetch(),xe("backup")}else xe("success")}catch(ae){v(ae.message||"Invalid verification codes","error")}finally{q(!1)}},dt=()=>{xe("table"),U(""),Te(""),Ue(""),J(["",""]),oe([]),v("Two-factor authentication setup completed successfully!","info")},dr=async()=>{var ae;if((ae=r==null?void 0:r.user_authenticator)!=null&&ae.id)try{We(!0),await h(r.user_authenticator.id),await r.refetch(),E(!1),v("Two-factor authentication removed successfully","info")}catch(Re){v(Re.message||"Failed to remove authenticator","error")}finally{We(!1)}},ur=async()=>{if(!G)try{pe(!0);const ae=await u();oe(ae),await r.refetch(),I(!0),v("New backup codes generated","info")}catch(ae){v(ae.message||"Failed to generate backup codes","error")}finally{pe(!1)}},Qt=()=>{const ae=le.join(`
5791
5791
  `);navigator.clipboard.writeText(ae).then(()=>{v("Backup codes copied to clipboard","info")}).catch(()=>{v("Failed to copy backup codes","error")})},Jt=()=>{const ae=le.join(`
5792
- `),Re=new Blob([ae],{type:"text/plain"}),tt=URL.createObjectURL(Re),qe=document.createElement("a");qe.href=tt,qe.download="wacht-backup-codes.txt",qe.click(),URL.revokeObjectURL(tt),v("Backup codes downloaded","info")},Nt=async()=>{var ae,Re;if((Re=(ae=e==null?void 0:e.auth_settings)==null?void 0:ae.passkey)!=null&&Re.enabled)try{O(!0);const tt=await p();H(tt.data||[])}catch{v("Failed to load passkeys","error")}finally{O(!1)}},pr=async ae=>{try{L(!0),await m(ae||void 0),await Nt(),v("Passkey registered successfully!","info")}catch(Re){throw v(Re.message||"Failed to register passkey","error"),Re}finally{L(!1)}},hr=async ae=>{try{await g(ae),await Nt(),v("Passkey removed","info")}catch(Re){v(Re.message||"Failed to remove passkey","error")}};c.useEffect(()=>{Nt()},[(rt=(et=e==null?void 0:e.auth_settings)==null?void 0:et.passkey)==null?void 0:rt.enabled]);const bt=[];se&&bt.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"],group:"sign-in"}),(_t=(ft=e==null?void 0:e.auth_settings)==null?void 0:ft.passkey)!=null&&_t.enabled&&bt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:z.length>0?`${z.length} registered`:"",actions:z.length>0?["manage","add"]:["add"],group:"sign-in"}),Q!=null&&Q.authenticator&&bt.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"],group:"sign-in"}),r!=null&&r.user_authenticator&&bt.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"],group:"recovery"}),r!=null&&r.user_authenticator&&bt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:w==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"});const ie=ae=>{switch(ae){case"password":return r!=null&&r.has_password?{variant:"success",label:"Active"}:{variant:"warning",label:"Not set up"};case"passkey":return z.length>0?{variant:"neutral",label:`${z.length} registered`}:{variant:"warning",label:"None"};case"authenticator":return r!=null&&r.user_authenticator?{variant:"success",label:"Enabled"}:{variant:"warning",label:"Not set up"};case"backup_codes":return r!=null&&r.backup_codes_generated?{variant:"success",label:"Generated"}:{variant:"warning",label:"Not generated"};case"second_factor_policy":return w==="enforced"?{variant:"success",label:"Enforced"}:{variant:"neutral",label:"Optional"};default:return null}};return te!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(wx,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Rt,{size:16}),t.jsxs("span",{style:{fontSize:"var(--font-size-lg)",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!"]})]}),t.jsx(N,{onClick:()=>xe("table"),style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),t.jsxs("div",{style:{maxWidth:"calc(var(--size-50u) * 5)",margin:"0 auto",textAlign:"center",padding:"var(--space-12u)"},children:[te==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"var(--space-12u)"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"var(--space-12u)"},children:de?t.jsx("div",{style:{width:"calc(var(--size-50u) * 2)",height:"calc(var(--size-50u) * 2)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:{width:"var(--size-12u)",height:"var(--size-12u)",border:"var(--border-width-regular) solid var(--color-border)",borderTop:"var(--border-width-regular) solid var(--color-primary)",borderRadius:"50%",animation:`${mx} 1s linear infinite`,margin:"0 auto var(--space-4u)"}}),t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):re?t.jsx("div",{style:{border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-8u)",background:"var(--color-background)"},children:t.jsx(Us,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{style:{width:"calc(var(--size-50u) * 2)",height:"calc(var(--size-50u) * 2)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"var(--font-size-lg)",textAlign:"center"},children:"QR Code Not Available"})}),t.jsxs("div",{style:{background:"var(--color-input-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-6u)",marginBottom:"var(--space-12u)"},children:[t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-secondary-text)",margin:"0 0 var(--space-4u) 0"},children:"Or enter this code manually:"}),t.jsx("code",{style:{fontFamily:"monospace",fontSize:"var(--font-size-lg)",wordBreak:"break-all"},children:Qe||"Loading..."})]}),t.jsx(N,{onClick:()=>xe("verify"),disabled:!re||!Qe,style:{padding:"var(--space-5u) var(--space-10u)",background:!re||!Qe?"var(--color-border)":"var(--color-primary)",color:!re||!Qe?"var(--color-secondary-text)":"var(--color-background)",border:`var(--border-width-thin) solid ${!re||!Qe?"var(--color-border)":"var(--color-primary)"}`,cursor:!re||!Qe?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"var(--space-12u)"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center",marginBottom:"var(--space-12u)"},children:[t.jsx(ue,{type:"text",placeholder:"000000",value:ve[0],onChange:ae=>{const Re=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);J([Re,ve[1]])},maxLength:6,style:{width:"var(--size-50u)",textAlign:"center",fontFamily:"monospace"}}),t.jsx(ue,{type:"text",placeholder:"000000",value:ve[1],onChange:ae=>{const Re=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);J([ve[0],Re])},maxLength:6,style:{width:"var(--size-50u)",textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center"},children:[t.jsx(N,{onClick:()=>xe("qr"),style:{padding:"var(--space-4u) var(--space-8u)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:"Back"}),t.jsx(N,{onClick:Ge,disabled:fe||ve.some(ae=>ae.length!==6),style:{padding:"var(--space-4u) var(--space-8u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:fe?"Verifying...":"Verify & Continue"})]})]}),te==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{background:"var(--color-warning-background)",border:"var(--border-width-thin) solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"var(--space-8u)",marginBottom:"var(--space-12u)",display:"flex",alignItems:"flex-start",gap:"var(--space-6u)",textAlign:"left"},children:[t.jsx(oa,{size:16,style:{color:"var(--color-warning)",marginTop:"var(--space-1u)"}}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500,marginBottom:"var(--space-2u)"},children:"Important!"}),t.jsx("div",{style:{fontSize:"var(--font-size-lg)",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."})]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"var(--space-4u)",marginBottom:"var(--space-12u)",maxWidth:"calc(var(--size-50u) * 3)",margin:"0 auto var(--space-12u) auto"},children:le.map((ae,Re)=>t.jsx("div",{style:{background:"var(--color-input-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-4u)",fontFamily:"monospace",fontSize:"var(--font-size-sm)",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(ae),children:ae},Re))}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center",marginBottom:"var(--space-12u)"},children:[t.jsx(N,{onClick:Qt,style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:"Copy All"}),t.jsxs(N,{onClick:Jt,style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx(zd,{size:16,style:{marginRight:"var(--space-2u)"}}),"DownloadSimple"]})]}),t.jsx(N,{onClick:dt,style:{padding:"var(--space-5u) var(--space-10u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{marginBottom:"var(--space-12u)"},children:[t.jsx(ct,{size:48,style:{color:"var(--color-success)",marginBottom:"var(--space-8u)"}}),t.jsx("h3",{style:{fontSize:"var(--font-size-2xl)",fontWeight:600,margin:"0 0 var(--space-4u) 0"},children:"All Set!"}),t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),t.jsx(N,{onClick:dt,style:{padding:"var(--space-5u) var(--space-10u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:bt.length?t.jsx("div",{children:bt.map((ae,Re)=>{const tt=Re>0?bt[Re-1].group:null,qe=ae.group!==tt,kt=bt[Re+1],K=kt&&kt.group===ae.group,ee=ie(ae.id);return t.jsxs("div",{children:[qe&&t.jsx(D5,{$first:Re===0,children:ae.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(yx,{style:qe?{paddingTop:0}:void 0,children:[t.jsxs(jx,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",fontWeight:400,color:"var(--color-foreground)"},children:[t.jsx("span",{children:ae.name}),ee&&t.jsx(Mr,{$variant:ee.variant,children:ee.label})]}),t.jsx("div",{style:{fontSize:"var(--font-size-md)",color:"var(--color-secondary-text)"},children:ae.description})]}),t.jsx(_x,{children:t.jsxs("div",{style:{position:"relative"},children:[ae.id==="password"&&t.jsx(t.Fragment,{children:r!=null&&r.has_password?t.jsxs("div",{style:{display:"flex",gap:"var(--space-4u)"},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:R,onClick:()=>k(!0),children:"Change"}),_&&t.jsx(fl,{triggerRef:R,onClose:()=>k(!1),onChangePassword:he})]}),ke()&&t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,$size:"sm",ref:T,onClick:()=>M(!0),children:"Remove"}),y&&t.jsx(S5,{triggerRef:T,onClose:()=>M(!1),onRemovePassword:je})]})]}):t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:R,onClick:()=>k(!0),children:"Setup"}),_&&t.jsx(fl,{triggerRef:R,onClose:()=>k(!1),onChangePassword:he,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:I,onClick:()=>C(!0),disabled:de,children:de?"Setting up...":"Setup"}),S&&t.jsx(A5,{triggerRef:I,onClose:()=>C(!1),onSetupTOTP:async()=>{const ne=await s();return Ue(ne.id),ne},onVerifyTOTP:async ne=>{await i(Ve,ne),await r.refetch(),v("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,onClick:()=>E(!0),disabled:Be,style:{cursor:Be?"not-allowed":"pointer",opacity:Be?.6:1},children:Be?"Removing...":"Remove"}),b&&t.jsx(Xr,{title:"Remove MFA and reset policy to default?",onConfirm:dr,onCancel:()=>E(!1)})]}),ae.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:$,onClick:ur,disabled:G,children:G?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),A&&t.jsx(T5,{triggerRef:$,codes:le,onClose:()=>F(!1),onCopy:Qt,onDownload:Jt})]})}),ae.id==="second_factor_policy"&&t.jsx(Tr,{checked:w==="enforced",onChange:ne=>{j(ne?"enforced":"none")}}),ae.id==="passkey"&&t.jsxs("div",{style:{display:"flex",gap:"var(--space-4u)",alignItems:"center"},children:[t.jsxs(N,{$outline:!0,$size:"sm",onClick:()=>D(!W),style:{color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--space-3u)",whiteSpace:"nowrap",flexShrink:0,width:"calc(var(--size-50u) + var(--space-5u))",height:"var(--size-18u)"},children:[W?"Hide":"Manage"," ","(",z.length,")",t.jsx(cr,{size:14,style:{transform:W?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:me,onClick:()=>Y(!0),disabled:Z,style:{cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1,whiteSpace:"nowrap",minWidth:"var(--size-40u)",width:"auto",height:"var(--size-18u)"},children:Z?"Adding...":"Add"}),B&&t.jsx(V5,{triggerRef:me,onClose:()=>Y(!1),onAddPasskey:pr})]})]})]})})]}),ae.id==="passkey"&&W&&t.jsx("div",{style:{padding:"var(--space-6u) 0",borderTop:"var(--border-width-thin) solid var(--color-border)",marginTop:"var(--space-4u)"},children:P?t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--space-8u)"},children:t.jsx(ze,{})}):z.length===0?t.jsx("div",{style:{textAlign:"center",padding:"var(--space-8u)",color:"var(--color-secondary-text)",fontSize:"var(--font-size-md)"},children:"No passkeys registered yet"}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:z.map(ne=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"var(--space-5u) var(--space-6u)",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-1u)"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"var(--font-size-md)",color:"var(--color-foreground)"},children:ne.name||"Unnamed Passkey"}),t.jsxs("span",{style:{fontSize:"var(--font-size-xs)",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()}`]})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,$size:"sm",onClick:()=>ce(ne.id),style:{flexShrink:0,width:"auto"},children:"Remove"}),X===ne.id&&t.jsx(Xr,{title:`Remove "${ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{hr(ne.id),ce(null)},onCancel:()=>ce(null)})]})]},ne.id))})}),K&&t.jsx("div",{style:{height:"var(--border-width-thin)",background:"var(--color-border)",margin:"0"}})]},ae.id)})}):t.jsx(At,{title:"No security features available",description:"Contact your administrator to enable security features."})})},U5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),t.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),t.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),B5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),t.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),t.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),t.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),t.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),t.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),t.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),t.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),W5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),t.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),t.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),G5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),q5=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),K5=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),t.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),Y5=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.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"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Q5=({browser:e})=>{const r=(e==null?void 0:e.toLowerCase())||"",a={width:20,height:20};return r.includes("chrome")?t.jsx(U5,{...a}):r.includes("firefox")?t.jsx(B5,{...a}):r.includes("safari")?t.jsx(W5,{...a}):r.includes("edge")?t.jsx(G5,{...a}):r.includes("opera")?t.jsx(q5,{...a}):r.includes("brave")?t.jsx(K5,{...a}):t.jsx(Y5,{})},J5=()=>{const{signins:e,removeSignin:r,refetch:a,loading:n}=m0(),{refetch:s}=ot(),{toast:i}=Yt(),h=e,d=async f=>{try{await r(f),await Promise.all([a(),s()]),i("Session ended successfully","info")}catch(p){i(p.message||"Failed to end session. Please try again.","error")}},u=f=>{if(!f||f.trim()==="")return"Unknown";const p=new Date(f);if(isNaN(p.getTime()))return"Unknown";const g=Math.floor((new Date().getTime()-p.getTime())/(1e3*60));return g<1?"Just now":g<60?`${g}m ago`:g<1440?`${Math.floor(g/60)}h ago`:p.toLocaleDateString()};return n?t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--space-10u)"},children:t.jsx(ze,{})}):t.jsx("div",{children:h&&h.length>0?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Browser & Device"}),t.jsx(Oe,{children:"Location"}),t.jsx(Oe,{children:"Last Active"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:h.map(f=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Cx,{children:t.jsx(Q5,{browser:f.browser||"Unknown"})}),t.jsxs("div",{children:[t.jsx("div",{children:f.browser||"Unknown Browser"}),f.device&&t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)"},children:f.device})]})]})}),t.jsx(Ye,{children:t.jsxs("div",{children:[t.jsx("div",{children:f.city&&f.country?`${f.city}, ${f.country}`:"Unknown location"}),f.ip_address&&t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)"},children:f.ip_address})]})}),t.jsx(Ye,{children:u(f.last_active_at)}),t.jsx(Dt,{children:t.jsxs(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>d(f.id),children:[t.jsx(zr,{size:12,style:{marginRight:4}}),"Sign out"]})})]},f.id))})]})})}):t.jsx(At,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},X5=l(eu)`
5792
+ `),Re=new Blob([ae],{type:"text/plain"}),tt=URL.createObjectURL(Re),qe=document.createElement("a");qe.href=tt,qe.download="wacht-backup-codes.txt",qe.click(),URL.revokeObjectURL(tt),v("Backup codes downloaded","info")},Nt=async()=>{var ae,Re;if((Re=(ae=e==null?void 0:e.auth_settings)==null?void 0:ae.passkey)!=null&&Re.enabled)try{O(!0);const tt=await p();H(tt.data||[])}catch{v("Failed to load passkeys","error")}finally{O(!1)}},pr=async ae=>{try{R(!0),await m(ae||void 0),await Nt(),v("Passkey registered successfully!","info")}catch(Re){throw v(Re.message||"Failed to register passkey","error"),Re}finally{R(!1)}},hr=async ae=>{try{await g(ae),await Nt(),v("Passkey removed","info")}catch(Re){v(Re.message||"Failed to remove passkey","error")}};c.useEffect(()=>{Nt()},[(rt=(et=e==null?void 0:e.auth_settings)==null?void 0:et.passkey)==null?void 0:rt.enabled]);const bt=[];se&&bt.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"],group:"sign-in"}),(_t=(ft=e==null?void 0:e.auth_settings)==null?void 0:ft.passkey)!=null&&_t.enabled&&bt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:z.length>0?`${z.length} registered`:"",actions:z.length>0?["manage","add"]:["add"],group:"sign-in"}),Q!=null&&Q.authenticator&&bt.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"],group:"sign-in"}),r!=null&&r.user_authenticator&&bt.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"],group:"recovery"}),r!=null&&r.user_authenticator&&bt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:w==="enforced"?"Enforced":"Optional",actions:["toggle"],group:"recovery"});const ie=ae=>{switch(ae){case"password":return r!=null&&r.has_password?{variant:"success",label:"Active"}:{variant:"warning",label:"Not set up"};case"passkey":return z.length>0?{variant:"neutral",label:`${z.length} registered`}:{variant:"warning",label:"None"};case"authenticator":return r!=null&&r.user_authenticator?{variant:"success",label:"Enabled"}:{variant:"warning",label:"Not set up"};case"backup_codes":return r!=null&&r.backup_codes_generated?{variant:"success",label:"Generated"}:{variant:"warning",label:"Not generated"};case"second_factor_policy":return w==="enforced"?{variant:"success",label:"Enforced"}:{variant:"neutral",label:"Optional"};default:return null}};return te!=="table"?t.jsxs(t.Fragment,{children:[t.jsxs(wx,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Rt,{size:16}),t.jsxs("span",{style:{fontSize:"var(--font-size-lg)",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!"]})]}),t.jsx(N,{onClick:()=>xe("table"),style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),t.jsxs("div",{style:{maxWidth:"calc(var(--size-50u) * 5)",margin:"0 auto",textAlign:"center",padding:"var(--space-12u)"},children:[te==="qr"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"var(--space-12u)"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),t.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"var(--space-12u)"},children:de?t.jsx("div",{style:{width:"calc(var(--size-50u) * 2)",height:"calc(var(--size-50u) * 2)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("div",{style:{width:"var(--size-12u)",height:"var(--size-12u)",border:"var(--border-width-regular) solid var(--color-border)",borderTop:"var(--border-width-regular) solid var(--color-primary)",borderRadius:"50%",animation:`${mx} 1s linear infinite`,margin:"0 auto var(--space-4u)"}}),t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):re?t.jsx("div",{style:{border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-8u)",background:"var(--color-background)"},children:t.jsx(Us,{value:re,size:200,level:"M",marginSize:0})}):t.jsx("div",{style:{width:"calc(var(--size-50u) * 2)",height:"calc(var(--size-50u) * 2)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"var(--font-size-lg)",textAlign:"center"},children:"QR Code Not Available"})}),t.jsxs("div",{style:{background:"var(--color-input-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-6u)",marginBottom:"var(--space-12u)"},children:[t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-secondary-text)",margin:"0 0 var(--space-4u) 0"},children:"Or enter this code manually:"}),t.jsx("code",{style:{fontFamily:"monospace",fontSize:"var(--font-size-lg)",wordBreak:"break-all"},children:Qe||"Loading..."})]}),t.jsx(N,{onClick:()=>xe("verify"),disabled:!re||!Qe,style:{padding:"var(--space-5u) var(--space-10u)",background:!re||!Qe?"var(--color-border)":"var(--color-primary)",color:!re||!Qe?"var(--color-secondary-text)":"var(--color-background)",border:`var(--border-width-thin) solid ${!re||!Qe?"var(--color-border)":"var(--color-primary)"}`,cursor:!re||!Qe?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),te==="verify"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"var(--space-12u)"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center",marginBottom:"var(--space-12u)"},children:[t.jsx(ue,{type:"text",placeholder:"000000",value:ve[0],onChange:ae=>{const Re=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);J([Re,ve[1]])},maxLength:6,style:{width:"var(--size-50u)",textAlign:"center",fontFamily:"monospace"}}),t.jsx(ue,{type:"text",placeholder:"000000",value:ve[1],onChange:ae=>{const Re=ae.target.value.replace(/[^0-9]/g,"").substring(0,6);J([ve[0],Re])},maxLength:6,style:{width:"var(--size-50u)",textAlign:"center",fontFamily:"monospace"}})]}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center"},children:[t.jsx(N,{onClick:()=>xe("qr"),style:{padding:"var(--space-4u) var(--space-8u)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:"Back"}),t.jsx(N,{onClick:Ge,disabled:fe||ve.some(ae=>ae.length!==6),style:{padding:"var(--space-4u) var(--space-8u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:fe?"Verifying...":"Verify & Continue"})]})]}),te==="backup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{background:"var(--color-warning-background)",border:"var(--border-width-thin) solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"var(--space-8u)",marginBottom:"var(--space-12u)",display:"flex",alignItems:"flex-start",gap:"var(--space-6u)",textAlign:"left"},children:[t.jsx(oa,{size:16,style:{color:"var(--color-warning)",marginTop:"var(--space-1u)"}}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:500,marginBottom:"var(--space-2u)"},children:"Important!"}),t.jsx("div",{style:{fontSize:"var(--font-size-lg)",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."})]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"var(--space-4u)",marginBottom:"var(--space-12u)",maxWidth:"calc(var(--size-50u) * 3)",margin:"0 auto var(--space-12u) auto"},children:le.map((ae,Re)=>t.jsx("div",{style:{background:"var(--color-input-background)",border:"var(--border-width-thin) solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-4u)",fontFamily:"monospace",fontSize:"var(--font-size-sm)",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(ae),children:ae},Re))}),t.jsxs("div",{style:{display:"flex",gap:"var(--space-6u)",justifyContent:"center",marginBottom:"var(--space-12u)"},children:[t.jsx(N,{onClick:Qt,style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:"Copy All"}),t.jsxs(N,{onClick:Jt,style:{padding:"var(--space-4u) var(--space-8u)",fontSize:"var(--font-size-lg)",background:"var(--color-background)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsx(zd,{size:16,style:{marginRight:"var(--space-2u)"}}),"DownloadSimple"]})]}),t.jsx(N,{onClick:dt,style:{padding:"var(--space-5u) var(--space-10u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:"Complete Setup"})]}),te==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{marginBottom:"var(--space-12u)"},children:[t.jsx(ct,{size:48,style:{color:"var(--color-success)",marginBottom:"var(--space-8u)"}}),t.jsx("h3",{style:{fontSize:"var(--font-size-2xl)",fontWeight:600,margin:"0 0 var(--space-4u) 0"},children:"All Set!"}),t.jsx("p",{style:{fontSize:"var(--font-size-lg)",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),t.jsx(N,{onClick:dt,style:{padding:"var(--space-5u) var(--space-10u)",background:"var(--color-primary)",color:"var(--color-foreground-inverse)",border:"var(--border-width-thin) solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):t.jsx(t.Fragment,{children:bt.length?t.jsx("div",{children:bt.map((ae,Re)=>{const tt=Re>0?bt[Re-1].group:null,qe=ae.group!==tt,kt=bt[Re+1],K=kt&&kt.group===ae.group,ee=ie(ae.id);return t.jsxs("div",{children:[qe&&t.jsx(D5,{$first:Re===0,children:ae.group==="sign-in"?"Sign-in methods":"Recovery"}),t.jsxs(yx,{style:qe?{paddingTop:0}:void 0,children:[t.jsxs(jx,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",fontWeight:400,color:"var(--color-foreground)"},children:[t.jsx("span",{children:ae.name}),ee&&t.jsx(Mr,{$variant:ee.variant,children:ee.label})]}),t.jsx("div",{style:{fontSize:"var(--font-size-md)",color:"var(--color-secondary-text)"},children:ae.description})]}),t.jsx(_x,{children:t.jsxs("div",{style:{position:"relative"},children:[ae.id==="password"&&t.jsx(t.Fragment,{children:r!=null&&r.has_password?t.jsxs("div",{style:{display:"flex",gap:"var(--space-4u)"},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:L,onClick:()=>k(!0),children:"Change"}),_&&t.jsx(fl,{triggerRef:L,onClose:()=>k(!1),onChangePassword:he})]}),ke()&&t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,$size:"sm",ref:T,onClick:()=>M(!0),children:"Remove"}),y&&t.jsx(S5,{triggerRef:T,onClose:()=>M(!1),onRemovePassword:je})]})]}):t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:L,onClick:()=>k(!0),children:"Setup"}),_&&t.jsx(fl,{triggerRef:L,onClose:()=>k(!1),onChangePassword:he,isSetup:!0})]})}),ae.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&t.jsx(t.Fragment,{children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:P,onClick:()=>C(!0),disabled:de,children:de?"Setting up...":"Setup"}),S&&t.jsx(A5,{triggerRef:P,onClose:()=>C(!1),onSetupTOTP:async()=>{const ne=await s();return Ue(ne.id),ne},onVerifyTOTP:async ne=>{await i(Ve,ne),await r.refetch(),v("Two-factor authentication enabled successfully!","info")}})]})}),ae.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,onClick:()=>E(!0),disabled:Be,style:{cursor:Be?"not-allowed":"pointer",opacity:Be?.6:1},children:Be?"Removing...":"Remove"}),b&&t.jsx(Xr,{title:"Remove MFA and reset policy to default?",onConfirm:dr,onCancel:()=>E(!1)})]}),ae.id==="backup_codes"&&t.jsx(t.Fragment,{children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:$,onClick:ur,disabled:G,children:G?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),A&&t.jsx(T5,{triggerRef:$,codes:le,onClose:()=>I(!1),onCopy:Qt,onDownload:Jt})]})}),ae.id==="second_factor_policy"&&t.jsx(Tr,{checked:w==="enforced",onChange:ne=>{j(ne?"enforced":"none")}}),ae.id==="passkey"&&t.jsxs("div",{style:{display:"flex",gap:"var(--space-4u)",alignItems:"center"},children:[t.jsxs(N,{$outline:!0,$size:"sm",onClick:()=>D(!W),style:{color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--space-3u)",whiteSpace:"nowrap",flexShrink:0,width:"calc(var(--size-50u) + var(--space-5u))",height:"var(--size-18u)"},children:[W?"Hide":"Manage"," ","(",z.length,")",t.jsx(cr,{size:14,style:{transform:W?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$size:"sm",ref:me,onClick:()=>Y(!0),disabled:Z,style:{cursor:Z?"not-allowed":"pointer",opacity:Z?.7:1,whiteSpace:"nowrap",minWidth:"var(--size-40u)",width:"auto",height:"var(--size-18u)"},children:Z?"Adding...":"Add"}),B&&t.jsx(V5,{triggerRef:me,onClose:()=>Y(!1),onAddPasskey:pr})]})]})]})})]}),ae.id==="passkey"&&W&&t.jsx("div",{style:{padding:"var(--space-6u) 0",borderTop:"var(--border-width-thin) solid var(--color-border)",marginTop:"var(--space-4u)"},children:F?t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--space-8u)"},children:t.jsx(ze,{})}):z.length===0?t.jsx("div",{style:{textAlign:"center",padding:"var(--space-8u)",color:"var(--color-secondary-text)",fontSize:"var(--font-size-md)"},children:"No passkeys registered yet"}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-4u)"},children:z.map(ne=>t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"var(--space-5u) var(--space-6u)",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"var(--border-width-thin) solid var(--color-border)"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-1u)"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"var(--font-size-md)",color:"var(--color-foreground)"},children:ne.name||"Unnamed Passkey"}),t.jsxs("span",{style:{fontSize:"var(--font-size-xs)",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()}`]})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(N,{$destructive:!0,$size:"sm",onClick:()=>ce(ne.id),style:{flexShrink:0,width:"auto"},children:"Remove"}),X===ne.id&&t.jsx(Xr,{title:`Remove "${ne.name||"Unnamed Passkey"}"?`,onConfirm:()=>{hr(ne.id),ce(null)},onCancel:()=>ce(null)})]})]},ne.id))})}),K&&t.jsx("div",{style:{height:"var(--border-width-thin)",background:"var(--color-border)",margin:"0"}})]},ae.id)})}):t.jsx(At,{title:"No security features available",description:"Contact your administrator to enable security features."})})},U5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#d93025"}),t.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),t.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#fcc934"}),t.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),t.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),t.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),t.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),t.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),t.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),t.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),t.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),t.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),B5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[t.jsx("stop",{offset:.1,stopColor:"#ffe226"}),t.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),t.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[t.jsx("stop",{offset:.3,stopColor:"#960e18"}),t.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),t.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),t.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),t.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),t.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[t.jsx("stop",{offset:.13,stopColor:"#fff44f"}),t.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),t.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[t.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),t.jsx("stop",{offset:.67,stopColor:"#9059ff"}),t.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),t.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[t.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),t.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),t.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[t.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),t.jsx("stop",{offset:.28,stopColor:"#ff980e"}),t.jsx("stop",{offset:.47,stopColor:"#ff3750"}),t.jsx("stop",{offset:.78,stopColor:"#eb0878"}),t.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),t.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[t.jsx("stop",{offset:.11,stopColor:"#fff44f"}),t.jsx("stop",{offset:.46,stopColor:"#ff980e"}),t.jsx("stop",{offset:.72,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[t.jsx("stop",{offset:0,stopColor:"#fff44f"}),t.jsx("stop",{offset:.3,stopColor:"#ff980e"}),t.jsx("stop",{offset:.57,stopColor:"#ff3647"}),t.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[t.jsx("stop",{offset:.14,stopColor:"#fff44f"}),t.jsx("stop",{offset:.48,stopColor:"#ff980e"}),t.jsx("stop",{offset:.66,stopColor:"#ff3647"}),t.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),t.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[t.jsx("stop",{offset:.09,stopColor:"#fff44f"}),t.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),t.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[t.jsx("stop",{offset:.05,stopColor:"#fff44f"}),t.jsx("stop",{offset:.37,stopColor:"#ff980e"}),t.jsx("stop",{offset:.53,stopColor:"#ff3647"}),t.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),t.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[t.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),t.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),t.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),t.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),t.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),t.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),t.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),t.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),t.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),t.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),t.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),t.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),W5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...e,children:[t.jsxs("defs",{children:[t.jsxs("linearGradient",{id:"b",children:[t.jsx("stop",{offset:0,stopColor:"#06c2e7"}),t.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),t.jsx("stop",{offset:.5,stopColor:"#12aef1"}),t.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),t.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),t.jsxs("linearGradient",{id:"a",children:[t.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),t.jsx("stop",{offset:1,stopColor:"#fff"})]}),t.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),t.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:.958})}),t.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:t.jsx("feGaussianBlur",{stdDeviation:3.564})}),t.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),t.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),t.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),t.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),t.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),t.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),t.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),G5=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...e,children:[t.jsxs("defs",{children:[t.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.7,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.8,stopOpacity:0}),t.jsx("stop",{offset:.9,stopOpacity:.5}),t.jsx("stop",{offset:1})]}),t.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#35c1f1"}),t.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),t.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),t.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),t.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),t.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#66eb6e"}),t.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),t.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#0c59a4"}),t.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),t.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:0,stopColor:"#1b9de2"}),t.jsx("stop",{offset:.2,stopColor:"#1595df"}),t.jsx("stop",{offset:.7,stopColor:"#0680d7"}),t.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),t.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),q5=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Opera",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),t.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),t.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),t.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),t.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),K5=e=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e,role:"img","aria-label":"Brave",children:[t.jsx("defs",{children:t.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[t.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),t.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),t.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),t.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),t.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),t.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),Y5=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[t.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),t.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"}),t.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),t.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Q5=({browser:e})=>{const r=(e==null?void 0:e.toLowerCase())||"",a={width:20,height:20};return r.includes("chrome")?t.jsx(U5,{...a}):r.includes("firefox")?t.jsx(B5,{...a}):r.includes("safari")?t.jsx(W5,{...a}):r.includes("edge")?t.jsx(G5,{...a}):r.includes("opera")?t.jsx(q5,{...a}):r.includes("brave")?t.jsx(K5,{...a}):t.jsx(Y5,{})},J5=()=>{const{signins:e,removeSignin:r,refetch:a,loading:n}=m0(),{refetch:s}=ot(),{toast:i}=Yt(),h=e,d=async f=>{try{await r(f),await Promise.all([a(),s()]),i("Session ended successfully","info")}catch(p){i(p.message||"Failed to end session. Please try again.","error")}},u=f=>{if(!f||f.trim()==="")return"Unknown";const p=new Date(f);if(isNaN(p.getTime()))return"Unknown";const g=Math.floor((new Date().getTime()-p.getTime())/(1e3*60));return g<1?"Just now":g<60?`${g}m ago`:g<1440?`${Math.floor(g/60)}h ago`:p.toLocaleDateString()};return n?t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"var(--space-10u)"},children:t.jsx(ze,{})}):t.jsx("div",{children:h&&h.length>0?t.jsx(t.Fragment,{children:t.jsx(Ns,{children:t.jsxs(Ot,{children:[t.jsx(Ht,{children:t.jsxs(lt,{children:[t.jsx(Oe,{children:"Browser & Device"}),t.jsx(Oe,{children:"Location"}),t.jsx(Oe,{children:"Last Active"}),t.jsx(Oe,{})]})}),t.jsx(Vt,{children:h.map(f=>t.jsxs(lt,{children:[t.jsx(Ye,{children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-4u)"},children:[t.jsx(Cx,{children:t.jsx(Q5,{browser:f.browser||"Unknown"})}),t.jsxs("div",{children:[t.jsx("div",{children:f.browser||"Unknown Browser"}),f.device&&t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)"},children:f.device})]})]})}),t.jsx(Ye,{children:t.jsxs("div",{children:[t.jsx("div",{children:f.city&&f.country?`${f.city}, ${f.country}`:"Unknown location"}),f.ip_address&&t.jsx("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-muted)"},children:f.ip_address})]})}),t.jsx(Ye,{children:u(f.last_active_at)}),t.jsx(Dt,{children:t.jsxs(N,{$size:"sm",$outline:!0,$destructive:!0,onClick:()=>d(f.id),children:[t.jsx(zr,{size:12,style:{marginRight:4}}),"Sign out"]})})]},f.id))})]})})}):t.jsx(At,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})},X5=l(eu)`
5793
5793
  display: flex;
5794
5794
  justify-content: center;
5795
5795
  align-items: center;
@@ -5851,7 +5851,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
5851
5851
  `,ab=l.span`
5852
5852
  font-size: var(--font-size-lg);
5853
5853
  color: var(--color-popover-foreground);
5854
- `,nb=(e,r)=>`${(e==null?void 0:e[0])||""}${(r==null?void 0:r[0])||""}`.toUpperCase()||"U",hu=()=>{var C,_,k,y,M,A,F,I;const{loading:e,user:r,updateProfilePicture:a}=ir(),{deployment:n}=Ae(),[s,i]=c.useState("profile"),[h,d]=c.useState(null),[u,f]=c.useState("info"),[p,m]=c.useState(!1),g=c.useRef(null),v=c.useCallback((R,T="info")=>{d(R),f(T),setTimeout(()=>d(null),3e3)},[d]),w=async R=>{var $;const T=($=R.target.files)==null?void 0:$[0];if(T){if(T.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!T.type.startsWith("image/")){v("Please select a valid image file","error");return}try{m(!0),await a(T),await(r==null?void 0:r.refetch()),v("Profile picture updated","info")}catch(z){v((z==null?void 0:z.message)||"Failed to update profile picture","error")}finally{m(!1),g.current&&(g.current.value="")}}};if(e)return t.jsx(ge,{children:t.jsx(X5,{children:t.jsx(ze,{})})});const x=n==null?void 0:n.auth_settings,b=(C=x==null?void 0:x.email_address)==null?void 0:C.enabled,E=(_=x==null?void 0:x.phone_number)==null?void 0:_.enabled,j=((k=n==null?void 0:n.social_connections)==null?void 0:k.some(R=>R.enabled))||!1,S=((y=x==null?void 0:x.password)==null?void 0:y.enabled)||((M=x==null?void 0:x.auth_factors_enabled)==null?void 0:M.authenticator)||((A=x==null?void 0:x.auth_factors_enabled)==null?void 0:A.phone_otp)||((F=x==null?void 0:x.auth_factors_enabled)==null?void 0:F.backup_code);return t.jsx(ge,{children:t.jsx(gx,{children:t.jsx(X1.Provider,{value:{screen:null,setScreen:()=>{},toast:v},children:t.jsxs(eu,{children:[r&&t.jsxs(Sx,{className:"mac-page-header",children:[t.jsxs(eb,{type:"button",onClick:()=>{var R;return(R=g.current)==null?void 0:R.click()},disabled:p,title:"Change profile picture","aria-label":"Change profile picture",children:[r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:""}):nb(r.first_name,r.last_name),t.jsx("span",{className:"hover-overlay",children:p?t.jsx(ze,{size:14}):t.jsx(Es,{size:16})})]}),t.jsx("input",{ref:g,type:"file",accept:"image/*",style:{display:"none"},onChange:w}),t.jsxs(Ex,{children:[t.jsx(Ax,{children:`${r.first_name||""} ${r.last_name||""}`.trim()||r.username||"Account"}),((I=r.primary_email_address)==null?void 0:I.email)&&t.jsx(zx,{children:r.primary_email_address.email})]})]}),t.jsx(vx,{children:t.jsxs(xx,{children:[t.jsx(Br,{$isActive:s==="profile",onClick:()=>i("profile"),children:t.jsxs(Wr,{children:[t.jsx(Ea,{size:16}),"Profile"]})}),b&&t.jsx(Br,{$isActive:s==="email",onClick:()=>i("email"),children:t.jsxs(Wr,{children:[t.jsx(In,{size:16}),"Email"]})}),E&&t.jsx(Br,{$isActive:s==="phone",onClick:()=>i("phone"),children:t.jsxs(Wr,{children:[t.jsx(Sf,{size:16}),"Phone"]})}),j&&t.jsx(Br,{$isActive:s==="social",onClick:()=>i("social"),children:t.jsxs(Wr,{children:[t.jsx(_f,{size:16}),"Connections"]})}),S&&t.jsx(Br,{$isActive:s==="security",onClick:()=>i("security"),children:t.jsxs(Wr,{children:[t.jsx(Rt,{size:16}),"Security"]})}),t.jsx(Br,{$isActive:s==="sessions",onClick:()=>i("sessions"),children:t.jsxs(Wr,{children:[t.jsx(Ef,{size:16}),"Sessions"]})})]})}),t.jsxs(bx,{children:[s==="profile"&&t.jsx(Mx,{}),s==="email"&&b&&t.jsx(Ix,{}),s==="phone"&&E&&t.jsx(Ux,{}),s==="social"&&j&&t.jsx(c5,{}),s==="security"&&S&&t.jsx(N5,{}),s==="sessions"&&t.jsx(J5,{})]}),h&&t.jsx(tb,{children:t.jsxs(rb,{children:[u==="error"?t.jsx(oa,{size:16,color:"var(--color-error)"}):t.jsx(ct,{size:16,color:"var(--color-success)"}),t.jsx(ab,{children:h})]})})]})})})})},fu=({isOpen:e,onClose:r,title:a,showHeader:n,headerContent:s,footerContent:i,customContent:h,children:d,showCloseButton:u})=>t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsxs(He.Content,{style:{width:"900px",maxWidth:"min(90vw, 100vw - 16px)"},children:[n&&t.jsx(He.Header,{showCloseButton:u,children:s||a}),h||d||t.jsx(hu,{}),i&&t.jsx(He.Footer,{children:i})]})})}),ob=l.div`
5854
+ `,nb=(e,r)=>`${(e==null?void 0:e[0])||""}${(r==null?void 0:r[0])||""}`.toUpperCase()||"U",hu=()=>{var C,_,k,y,M,A,I,P;const{loading:e,user:r,updateProfilePicture:a}=ir(),{deployment:n}=Ae(),[s,i]=c.useState("profile"),[h,d]=c.useState(null),[u,f]=c.useState("info"),[p,m]=c.useState(!1),g=c.useRef(null),v=c.useCallback((L,T="info")=>{d(L),f(T),setTimeout(()=>d(null),3e3)},[d]),w=async L=>{var $;const T=($=L.target.files)==null?void 0:$[0];if(T){if(T.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!T.type.startsWith("image/")){v("Please select a valid image file","error");return}try{m(!0),await a(T),await(r==null?void 0:r.refetch()),v("Profile picture updated","info")}catch(z){v((z==null?void 0:z.message)||"Failed to update profile picture","error")}finally{m(!1),g.current&&(g.current.value="")}}};if(e)return t.jsx(ge,{children:t.jsx(X5,{children:t.jsx(ze,{})})});const x=n==null?void 0:n.auth_settings,b=(C=x==null?void 0:x.email_address)==null?void 0:C.enabled,E=(_=x==null?void 0:x.phone_number)==null?void 0:_.enabled,j=((k=n==null?void 0:n.social_connections)==null?void 0:k.some(L=>L.enabled))||!1,S=((y=x==null?void 0:x.password)==null?void 0:y.enabled)||((M=x==null?void 0:x.auth_factors_enabled)==null?void 0:M.authenticator)||((A=x==null?void 0:x.auth_factors_enabled)==null?void 0:A.phone_otp)||((I=x==null?void 0:x.auth_factors_enabled)==null?void 0:I.backup_code);return t.jsx(ge,{children:t.jsx(gx,{children:t.jsx(X1.Provider,{value:{screen:null,setScreen:()=>{},toast:v},children:t.jsxs(eu,{children:[r&&t.jsxs(Sx,{className:"mac-page-header",children:[t.jsxs(eb,{type:"button",onClick:()=>{var L;return(L=g.current)==null?void 0:L.click()},disabled:p,title:"Change profile picture","aria-label":"Change profile picture",children:[r.profile_picture_url?t.jsx("img",{src:r.profile_picture_url,alt:""}):nb(r.first_name,r.last_name),t.jsx("span",{className:"hover-overlay",children:p?t.jsx(ze,{size:14}):t.jsx(Es,{size:16})})]}),t.jsx("input",{ref:g,type:"file",accept:"image/*",style:{display:"none"},onChange:w}),t.jsxs(Ex,{children:[t.jsx(Ax,{children:`${r.first_name||""} ${r.last_name||""}`.trim()||r.username||"Account"}),((P=r.primary_email_address)==null?void 0:P.email)&&t.jsx(zx,{children:r.primary_email_address.email})]})]}),t.jsx(vx,{children:t.jsxs(xx,{children:[t.jsx(Br,{$isActive:s==="profile",onClick:()=>i("profile"),children:t.jsxs(Wr,{children:[t.jsx(Ea,{size:16}),"Profile"]})}),b&&t.jsx(Br,{$isActive:s==="email",onClick:()=>i("email"),children:t.jsxs(Wr,{children:[t.jsx(In,{size:16}),"Email"]})}),E&&t.jsx(Br,{$isActive:s==="phone",onClick:()=>i("phone"),children:t.jsxs(Wr,{children:[t.jsx(Sf,{size:16}),"Phone"]})}),j&&t.jsx(Br,{$isActive:s==="social",onClick:()=>i("social"),children:t.jsxs(Wr,{children:[t.jsx(_f,{size:16}),"Connections"]})}),S&&t.jsx(Br,{$isActive:s==="security",onClick:()=>i("security"),children:t.jsxs(Wr,{children:[t.jsx(Rt,{size:16}),"Security"]})}),t.jsx(Br,{$isActive:s==="sessions",onClick:()=>i("sessions"),children:t.jsxs(Wr,{children:[t.jsx(Ef,{size:16}),"Sessions"]})})]})}),t.jsxs(bx,{children:[s==="profile"&&t.jsx(Mx,{}),s==="email"&&b&&t.jsx(Ix,{}),s==="phone"&&E&&t.jsx(Ux,{}),s==="social"&&j&&t.jsx(c5,{}),s==="security"&&S&&t.jsx(N5,{}),s==="sessions"&&t.jsx(J5,{})]}),h&&t.jsx(tb,{children:t.jsxs(rb,{children:[u==="error"?t.jsx(oa,{size:16,color:"var(--color-error)"}):t.jsx(ct,{size:16,color:"var(--color-success)"}),t.jsx(ab,{children:h})]})})]})})})})},fu=({isOpen:e,onClose:r,title:a,showHeader:n,headerContent:s,footerContent:i,customContent:h,children:d,showCloseButton:u})=>t.jsx(He,{isOpen:e,onClose:r,children:t.jsx(He.Overlay,{children:t.jsxs(He.Content,{style:{width:"900px",maxWidth:"min(90vw, 100vw - 16px)"},children:[n&&t.jsx(He.Header,{showCloseButton:u,children:s||a}),h||d||t.jsx(hu,{}),i&&t.jsx(He.Footer,{children:i})]})})}),ob=l.div`
5855
5855
  position: relative;
5856
5856
  `,sb=l.button`
5857
5857
  display: flex;
@@ -6410,7 +6410,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
6410
6410
  align-items: center;
6411
6411
  justify-content: center;
6412
6412
  flex-shrink: 0;
6413
- `,Bs=({showName:e=!0,onCreateOrg:r,showOrgSwitcher:a=!0,narrowBreakpoint:n=640})=>{var ke,Ge,dt,dr,ur,Qt,Jt,Nt,pr,hr,bt;const[s,i]=c.useState(!1),[h,d]=c.useState(!1),[u,f]=c.useState(typeof window<"u"&&window.innerWidth<n),[p,m]=c.useState(!1),[g,v]=c.useState("org"),[w,x]=c.useState(null),[b,E]=c.useState({top:0,left:0,maxHeight:400}),[j,S]=c.useState(new Set),[C,_]=c.useState(null),k=c.useRef(null),y=c.useRef(null),M=c.useRef(null),A=xt({triggerRef:k,isOpen:s,minWidth:300}),F=Bt(!1),I=Bt(!1),R=Bt(!1),T=Bt(!1),$=Bt(!1),{session:z,signOut:H,switchSignIn:P,switchOrganization:O,switchWorkspace:Z,refetch:L}=ot(),{navigateToSignIn:W}=yt(),{deployment:D}=Ae(),{activeOrganization:B,activeMembership:Y,leave:X}=or(),{organizationMemberships:ce}=Kt(),{workspaces:me}=sr(),{activeWorkspace:te,activeMembership:xe,leave:re}=Zt(),U=(ke=z==null?void 0:z.active_signin)==null?void 0:ke.user,Qe=((dt=(Ge=D==null?void 0:D.auth_settings)==null?void 0:Ge.multi_session_support)==null?void 0:dt.enabled)??!1,Te=((dr=D==null?void 0:D.b2b_settings)==null?void 0:dr.workspaces_enabled)??!1,Ve=((ur=D==null?void 0:D.b2b_settings)==null?void 0:ur.allow_users_to_create_orgs)??!1,Ue=!B,ve=c.useMemo(()=>{var ye;const ie={};for(const Me of me||[]){const De=(ye=Me.organization)==null?void 0:ye.id;De&&(ie[De]||(ie[De]=[]),ie[De].push(Me))}return ie},[me]),J=ce||[],le=c.useCallback(()=>{if(!y.current)return;const ie=y.current.getBoundingClientRect(),ye=300,Me=8,De=window.innerWidth<n;if(f(De),De){E({top:ie.top,left:ie.left,maxHeight:ie.height});return}const et=Math.min(Math.max(ie.height,520),window.innerHeight-ie.top-16),rt=ie.right+Me+ye<=window.innerWidth-8;E({top:ie.top,left:rt?ie.right+Me:ie.left-Me-ye,maxHeight:et})},[n]),oe=c.useCallback(()=>{le(),d(!0)},[le]),G=c.useCallback(ie=>{S(ye=>{const Me=new Set(ye);return Me.has(ie)?Me.delete(ie):Me.add(ie),Me})},[]);c.useEffect(()=>{B&&Te&&S(ie=>{if(ie.has(B.id))return ie;const ye=new Set(ie);return ye.add(B.id),ye})},[B,Te]),c.useEffect(()=>{v(Te&&te?"ws":"org")},[Te,te==null?void 0:te.id]),c.useEffect(()=>{const ie=()=>{f(window.innerWidth<n),h&&le()};return window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[n,h,le]),c.useEffect(()=>{s||(d(!1),m(!1))},[s]),c.useEffect(()=>{if(!s)return;const ie=setTimeout(()=>{const ye=Me=>{var et,rt,ft;const De=Me.target;(et=k.current)!=null&&et.contains(De)||(rt=y.current)!=null&&rt.contains(De)||(ft=M.current)!=null&&ft.contains(De)||i(!1)};return document.addEventListener("mousedown",ye),()=>document.removeEventListener("mousedown",ye)},50);return()=>clearTimeout(ie)},[s]);const pe=ie=>ie.split(" ").filter(Boolean).map(ye=>ye[0]).join("").toUpperCase().slice(0,2),fe=(ie,ye,Me,De,et)=>t.jsx(et,{children:ie?t.jsx("img",{src:ye,alt:Me}):pe(`${Me||""} ${De||""}`)}),q=async ie=>{try{await H(ie),await L(),i(!1)}catch{}},de=async ie=>{try{await P(ie),await L(),i(!1)}catch{}},Be=async ie=>{if(!p){m(!0);try{await O(ie),await L(),d(!1)}catch{}finally{m(!1)}}},We=async ie=>{if(!p){m(!0);try{await Z(ie),await L(),d(!1)}catch{}finally{m(!1)}}},Q=()=>{F.open(),i(!1)},se=[...(z==null?void 0:z.signins)||[]].sort((ie,ye)=>{const Me=ie.user.id===(U==null?void 0:U.id),De=ye.user.id===(U==null?void 0:U.id);return Me===De?0:Me?-1:1}),he=((Qt=se.find(ie=>ie.user.id===(U==null?void 0:U.id)))==null?void 0:Qt.id)||"",je=((Nt=(Jt=Y==null?void 0:Y.roles)==null?void 0:Jt[0])==null?void 0:Nt.name)??null;return t.jsx(ge,{children:t.jsxs(ob,{children:[t.jsxs(sb,{ref:k,onClick:()=>i(!s),children:[fe(U==null?void 0:U.has_profile_picture,U==null?void 0:U.profile_picture_url,U==null?void 0:U.first_name,U==null?void 0:U.last_name,mu),e&&t.jsx(ib,{children:`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`.trim()})]}),typeof window<"u"&&En.createPortal(t.jsxs(ge,{children:[t.jsxs(cb,{ref:y,$position:A,$isOpen:s&&!(u&&h),$maxHeight:A==null?void 0:A.maxHeight,children:[t.jsx(db,{children:t.jsxs(ub,{children:[fe(U==null?void 0:U.has_profile_picture,U==null?void 0:U.profile_picture_url,U==null?void 0:U.first_name,U==null?void 0:U.last_name,pb),t.jsxs(hb,{children:[t.jsx(fb,{children:`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`.trim()}),t.jsx(mb,{children:(pr=U==null?void 0:U.primary_email_address)==null?void 0:pr.email})]})]})}),t.jsxs(wb,{children:[a&&t.jsxs(gb,{$active:h,onClick:oe,style:{marginBottom:"var(--space-2u)"},children:[t.jsx(vb,{children:B?B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):(hr=B.name)==null?void 0:hr.charAt(0).toUpperCase():U!=null&&U.has_profile_picture?t.jsx("img",{src:U.profile_picture_url,alt:U.first_name}):pe(`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`)}),t.jsx(xb,{children:(B==null?void 0:B.name)??"Personal account"}),je&&t.jsx(bb,{children:je})]}),t.jsxs(yb,{onClick:Q,children:[t.jsx(Ar,{}),t.jsx(jb,{children:"Manage account"}),t.jsx(_b,{children:"⌘,"})]})]}),t.jsx(vl,{}),t.jsxs(kb,{children:[t.jsx(Cb,{children:"Accounts"}),Qe?se.map(({user:ie,id:ye})=>{var De;const Me=ie.id===(U==null?void 0:U.id);return t.jsxs(Ro,{$active:Me,onClick:Me?void 0:()=>de(ye),children:[Me?t.jsx(Po,{children:t.jsx(ct,{})}):t.jsx(Sb,{}),t.jsx(To,{children:(De=ie.primary_email_address)==null?void 0:De.email}),Me&&t.jsx(xl,{children:"Current"})]},ie.id)}):U&&t.jsxs(Ro,{$active:!0,children:[t.jsx(Po,{children:t.jsx(ct,{})}),t.jsx(To,{children:(bt=U.primary_email_address)==null?void 0:bt.email}),t.jsx(xl,{children:"Current"})]}),Qe&&t.jsxs(Ro,{onClick:()=>{W(),i(!1)},children:[t.jsx(Po,{style:{color:"var(--color-secondary-text)"},children:t.jsx(jt,{})}),t.jsx(To,{style:{color:"var(--color-secondary-text)"},children:"Add account"})]})]}),t.jsx(vl,{}),t.jsx(Eb,{children:t.jsxs(Ab,{onClick:()=>q(he),children:[t.jsx(zr,{}),"Sign out"]})})]}),t.jsxs(lb,{ref:M,$top:b.top,$left:b.left,$isOpen:s&&h,$maxHeight:b.maxHeight,children:[u&&t.jsxs(zb,{onClick:()=>d(!1),children:[t.jsx(na,{size:13}),"Back"]}),(()=>{var Re,tt,qe,kt,K;if(Ue)return null;const ie=Te&&!!te,ye=!!((Re=Y==null?void 0:Y.eligibility_restriction)!=null&&Re.type)&&Y.eligibility_restriction.type!=="none",Me=!!B&&!ye&&Hs(Y),De=ie&&!ye&&Ds(xe),et=ie?g:"org",rt=(qe=(tt=Y==null?void 0:Y.roles)==null?void 0:tt[0])==null?void 0:qe.name,ft=(K=(kt=xe==null?void 0:xe.roles)==null?void 0:kt[0])==null?void 0:K.name,_t=async()=>{if(X){x("org");try{await X(),await L(),d(!1)}catch{}finally{x(null)}}},ae=async()=>{if(re){x("ws");try{await re(),d(!1)}catch{}finally{x(null)}}};return t.jsxs(Lb,{children:[ie&&t.jsxs(Rb,{children:[t.jsx(kl,{type:"button",$active:et==="org","data-active":et==="org",onClick:()=>v("org"),children:"Organization"}),t.jsx(kl,{type:"button",$active:et==="ws","data-active":et==="ws",onClick:()=>v("ws"),children:"Workspace"})]}),et==="org"&&B&&t.jsxs(Cl,{children:[t.jsx(Sl,{children:B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):pe(B.name)}),t.jsxs(El,{children:[t.jsx(Al,{children:B.name}),rt&&t.jsx(zl,{children:rt})]}),t.jsxs($l,{children:[Me&&t.jsx(ln,{onClick:()=>{R.open(),i(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ar,{size:14})}),t.jsx(ln,{$destructive:!0,onClick:_t,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(zr,{size:14})})]})]}),et==="ws"&&ie&&t.jsxs(Cl,{children:[t.jsx(Sl,{children:te.image_url?t.jsx("img",{src:te.image_url,alt:te.name}):pe(te.name)}),t.jsxs(El,{children:[t.jsx(Al,{children:te.name}),ft&&t.jsx(zl,{children:ft})]}),t.jsxs($l,{children:[De&&t.jsx(ln,{onClick:()=>{$.open(),i(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ar,{size:14})}),t.jsx(ln,{$destructive:!0,onClick:ae,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(zr,{size:14})})]})]})]})})(),t.jsxs($b,{children:[t.jsxs(bl,{$active:Ue,onClick:()=>{Ue||Be(void 0)},disabled:p,style:Ue?{cursor:"default"}:void 0,children:[t.jsx(yl,{$personal:!0,children:U!=null&&U.has_profile_picture?t.jsx("img",{src:U.profile_picture_url,alt:U.first_name}):t.jsx(Ea,{size:12})}),t.jsx(gs,{children:"Personal account"}),Ue&&t.jsx(Fo,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(Io,{size:13})})})]}),J.map(ie=>{var ft,_t;const ye=ie.organization,Me=ye.id===(B==null?void 0:B.id),De=j.has(ye.id),et=Te?ve[ye.id]||[]:[],rt=!!((ft=ie.eligibility_restriction)!=null&&ft.type)&&ie.eligibility_restriction.type!=="none";return t.jsxs(c.Fragment,{children:[t.jsxs(bl,{$active:Me,onClick:()=>{rt||(Te?G(ye.id):Me||Be(ye.id))},disabled:p,style:rt?{opacity:.55,cursor:"not-allowed"}:Me&&!Te?{cursor:"default"}:void 0,title:(_t=ie.eligibility_restriction)==null?void 0:_t.message,children:[t.jsx(yl,{children:ye.image_url?t.jsx("img",{src:ye.image_url,alt:ye.name}):pe(ye.name)}),t.jsx(gs,{children:ye.name}),t.jsxs(Fo,{children:[rt&&t.jsx($r,{size:12,color:"var(--color-error)"}),Me&&!Te&&t.jsx(Io,{size:13}),Te&&t.jsx(Mb,{size:11,$open:De})]})]}),Te&&De&&t.jsxs(t.Fragment,{children:[et.map(ae=>{var kt,K;const Re=Me&&(te==null?void 0:te.id)===ae.id,tt=ae,qe=((kt=tt.eligibility_restriction)==null?void 0:kt.type)&&tt.eligibility_restriction.type!=="none";return t.jsxs(wl,{$active:Re,onClick:()=>{!Re&&!qe&&We(ae.id)},disabled:p,style:qe||rt?{opacity:.55,cursor:"not-allowed"}:Re?{cursor:"default"}:void 0,title:(K=tt.eligibility_restriction)==null?void 0:K.message,children:[t.jsx(jl,{children:tt.image_url?t.jsx("img",{src:tt.image_url,alt:tt.name}):pe(tt.name).charAt(0)}),t.jsx(_l,{children:tt.name}),t.jsxs(Fo,{children:[qe&&t.jsx($r,{size:12,color:"var(--color-error)"}),Re&&t.jsx(Io,{size:12})]})]},ae.id)}),!rt&&t.jsxs(wl,{onClick:()=>{_(ye.id),T.open()},disabled:p,children:[t.jsx(jl,{style:{background:"transparent",border:"1px dashed var(--color-border)"},children:t.jsx(jt,{size:10})}),t.jsx(_l,{children:"New workspace"})]})]})]},ye.id)})]}),(()=>{var rt,ft,_t;const ie=((ce==null?void 0:ce.length)??0)>0,ye=()=>Ve&&t.jsx(Ml,{children:t.jsxs(Ll,{onClick:()=>{r?(r(),i(!1)):I.open()},disabled:p,children:[t.jsx(Rl,{children:t.jsx(jt,{size:12})}),"New organization"]})});if(!Te||!ie)return ye();const Me=!!((rt=Y==null?void 0:Y.eligibility_restriction)!=null&&rt.type)&&Y.eligibility_restriction.type!=="none",De=((_t=(ft=ce==null?void 0:ce[0])==null?void 0:ft.organization)==null?void 0:_t.id)??null,et=B&&!Me?B.id:De;return t.jsx(Ml,{children:t.jsxs(Ll,{onClick:()=>{_(et),T.open()},disabled:p,children:[t.jsx(Rl,{children:t.jsx(jt,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(fu,{isOpen:F.isOpen,onClose:F.close}),a&&t.jsxs(t.Fragment,{children:[t.jsx(Z1,{isOpen:I.isOpen,onClose:I.close}),t.jsx(N1,{isOpen:R.isOpen,onClose:R.close}),Te&&t.jsxs(t.Fragment,{children:[t.jsx(Ts,{isOpen:T.isOpen,onClose:()=>{T.close(),_(null)},organizationId:C||void 0}),t.jsx(Zs,{isOpen:$.isOpen,onClose:$.close})]})]})]})})},Pb=l.div`
6413
+ `,Bs=({showName:e=!0,onCreateOrg:r,showOrgSwitcher:a=!0,narrowBreakpoint:n=640})=>{var ke,Ge,dt,dr,ur,Qt,Jt,Nt,pr,hr,bt;const[s,i]=c.useState(!1),[h,d]=c.useState(!1),[u,f]=c.useState(typeof window<"u"&&window.innerWidth<n),[p,m]=c.useState(!1),[g,v]=c.useState("org"),[w,x]=c.useState(null),[b,E]=c.useState({top:0,left:0,maxHeight:400}),[j,S]=c.useState(new Set),[C,_]=c.useState(null),k=c.useRef(null),y=c.useRef(null),M=c.useRef(null),A=xt({triggerRef:k,isOpen:s,minWidth:300}),I=Bt(!1),P=Bt(!1),L=Bt(!1),T=Bt(!1),$=Bt(!1),{session:z,signOut:H,switchSignIn:F,switchOrganization:O,switchWorkspace:Z,refetch:R}=ot(),{navigateToSignIn:W}=yt(),{deployment:D}=Ae(),{activeOrganization:B,activeMembership:Y,leave:X}=or(),{organizationMemberships:ce}=Kt(),{workspaces:me}=sr(),{activeWorkspace:te,activeMembership:xe,leave:re}=Zt(),U=(ke=z==null?void 0:z.active_signin)==null?void 0:ke.user,Qe=((dt=(Ge=D==null?void 0:D.auth_settings)==null?void 0:Ge.multi_session_support)==null?void 0:dt.enabled)??!1,Te=((dr=D==null?void 0:D.b2b_settings)==null?void 0:dr.workspaces_enabled)??!1,Ve=((ur=D==null?void 0:D.b2b_settings)==null?void 0:ur.allow_users_to_create_orgs)??!1,Ue=!B,ve=c.useMemo(()=>{var ye;const ie={};for(const Me of me||[]){const De=(ye=Me.organization)==null?void 0:ye.id;De&&(ie[De]||(ie[De]=[]),ie[De].push(Me))}return ie},[me]),J=ce||[],le=c.useCallback(()=>{if(!y.current)return;const ie=y.current.getBoundingClientRect(),ye=300,Me=8,De=window.innerWidth<n;if(f(De),De){E({top:ie.top,left:ie.left,maxHeight:ie.height});return}const et=Math.min(Math.max(ie.height,520),window.innerHeight-ie.top-16),rt=ie.right+Me+ye<=window.innerWidth-8;E({top:ie.top,left:rt?ie.right+Me:ie.left-Me-ye,maxHeight:et})},[n]),oe=c.useCallback(()=>{le(),d(!0)},[le]),G=c.useCallback(ie=>{S(ye=>{const Me=new Set(ye);return Me.has(ie)?Me.delete(ie):Me.add(ie),Me})},[]);c.useEffect(()=>{B&&Te&&S(ie=>{if(ie.has(B.id))return ie;const ye=new Set(ie);return ye.add(B.id),ye})},[B,Te]),c.useEffect(()=>{v(Te&&te?"ws":"org")},[Te,te==null?void 0:te.id]),c.useEffect(()=>{const ie=()=>{f(window.innerWidth<n),h&&le()};return window.addEventListener("resize",ie),()=>window.removeEventListener("resize",ie)},[n,h,le]),c.useEffect(()=>{s||(d(!1),m(!1))},[s]),c.useEffect(()=>{if(!s)return;const ie=setTimeout(()=>{const ye=Me=>{var et,rt,ft;const De=Me.target;(et=k.current)!=null&&et.contains(De)||(rt=y.current)!=null&&rt.contains(De)||(ft=M.current)!=null&&ft.contains(De)||i(!1)};return document.addEventListener("mousedown",ye),()=>document.removeEventListener("mousedown",ye)},50);return()=>clearTimeout(ie)},[s]);const pe=ie=>ie.split(" ").filter(Boolean).map(ye=>ye[0]).join("").toUpperCase().slice(0,2),fe=(ie,ye,Me,De,et)=>t.jsx(et,{children:ie?t.jsx("img",{src:ye,alt:Me}):pe(`${Me||""} ${De||""}`)}),q=async ie=>{try{await H(ie),await R(),i(!1)}catch{}},de=async ie=>{try{await F(ie),await R(),i(!1)}catch{}},Be=async ie=>{if(!p){m(!0);try{await O(ie),await R(),d(!1)}catch{}finally{m(!1)}}},We=async ie=>{if(!p){m(!0);try{await Z(ie),await R(),d(!1)}catch{}finally{m(!1)}}},Q=()=>{I.open(),i(!1)},se=[...(z==null?void 0:z.signins)||[]].sort((ie,ye)=>{const Me=ie.user.id===(U==null?void 0:U.id),De=ye.user.id===(U==null?void 0:U.id);return Me===De?0:Me?-1:1}),he=((Qt=se.find(ie=>ie.user.id===(U==null?void 0:U.id)))==null?void 0:Qt.id)||"",je=((Nt=(Jt=Y==null?void 0:Y.roles)==null?void 0:Jt[0])==null?void 0:Nt.name)??null;return t.jsx(ge,{children:t.jsxs(ob,{children:[t.jsxs(sb,{ref:k,onClick:()=>i(!s),children:[fe(U==null?void 0:U.has_profile_picture,U==null?void 0:U.profile_picture_url,U==null?void 0:U.first_name,U==null?void 0:U.last_name,mu),e&&t.jsx(ib,{children:`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`.trim()})]}),typeof window<"u"&&En.createPortal(t.jsxs(ge,{children:[t.jsxs(cb,{ref:y,$position:A,$isOpen:s&&!(u&&h),$maxHeight:A==null?void 0:A.maxHeight,children:[t.jsx(db,{children:t.jsxs(ub,{children:[fe(U==null?void 0:U.has_profile_picture,U==null?void 0:U.profile_picture_url,U==null?void 0:U.first_name,U==null?void 0:U.last_name,pb),t.jsxs(hb,{children:[t.jsx(fb,{children:`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`.trim()}),t.jsx(mb,{children:(pr=U==null?void 0:U.primary_email_address)==null?void 0:pr.email})]})]})}),t.jsxs(wb,{children:[a&&t.jsxs(gb,{$active:h,onClick:oe,style:{marginBottom:"var(--space-2u)"},children:[t.jsx(vb,{children:B?B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):(hr=B.name)==null?void 0:hr.charAt(0).toUpperCase():U!=null&&U.has_profile_picture?t.jsx("img",{src:U.profile_picture_url,alt:U.first_name}):pe(`${(U==null?void 0:U.first_name)||""} ${(U==null?void 0:U.last_name)||""}`)}),t.jsx(xb,{children:(B==null?void 0:B.name)??"Personal account"}),je&&t.jsx(bb,{children:je})]}),t.jsxs(yb,{onClick:Q,children:[t.jsx(Ar,{}),t.jsx(jb,{children:"Manage account"}),t.jsx(_b,{children:"⌘,"})]})]}),t.jsx(vl,{}),t.jsxs(kb,{children:[t.jsx(Cb,{children:"Accounts"}),Qe?se.map(({user:ie,id:ye})=>{var De;const Me=ie.id===(U==null?void 0:U.id);return t.jsxs(Ro,{$active:Me,onClick:Me?void 0:()=>de(ye),children:[Me?t.jsx(Po,{children:t.jsx(ct,{})}):t.jsx(Sb,{}),t.jsx(To,{children:(De=ie.primary_email_address)==null?void 0:De.email}),Me&&t.jsx(xl,{children:"Current"})]},ie.id)}):U&&t.jsxs(Ro,{$active:!0,children:[t.jsx(Po,{children:t.jsx(ct,{})}),t.jsx(To,{children:(bt=U.primary_email_address)==null?void 0:bt.email}),t.jsx(xl,{children:"Current"})]}),Qe&&t.jsxs(Ro,{onClick:()=>{W(),i(!1)},children:[t.jsx(Po,{style:{color:"var(--color-secondary-text)"},children:t.jsx(jt,{})}),t.jsx(To,{style:{color:"var(--color-secondary-text)"},children:"Add account"})]})]}),t.jsx(vl,{}),t.jsx(Eb,{children:t.jsxs(Ab,{onClick:()=>q(he),children:[t.jsx(zr,{}),"Sign out"]})})]}),t.jsxs(lb,{ref:M,$top:b.top,$left:b.left,$isOpen:s&&h,$maxHeight:b.maxHeight,children:[u&&t.jsxs(zb,{onClick:()=>d(!1),children:[t.jsx(na,{size:13}),"Back"]}),(()=>{var Re,tt,qe,kt,K;if(Ue)return null;const ie=Te&&!!te,ye=!!((Re=Y==null?void 0:Y.eligibility_restriction)!=null&&Re.type)&&Y.eligibility_restriction.type!=="none",Me=!!B&&!ye&&Hs(Y),De=ie&&!ye&&Ds(xe),et=ie?g:"org",rt=(qe=(tt=Y==null?void 0:Y.roles)==null?void 0:tt[0])==null?void 0:qe.name,ft=(K=(kt=xe==null?void 0:xe.roles)==null?void 0:kt[0])==null?void 0:K.name,_t=async()=>{if(X){x("org");try{await X(),await R(),d(!1)}catch{}finally{x(null)}}},ae=async()=>{if(re){x("ws");try{await re(),d(!1)}catch{}finally{x(null)}}};return t.jsxs(Lb,{children:[ie&&t.jsxs(Rb,{children:[t.jsx(kl,{type:"button",$active:et==="org","data-active":et==="org",onClick:()=>v("org"),children:"Organization"}),t.jsx(kl,{type:"button",$active:et==="ws","data-active":et==="ws",onClick:()=>v("ws"),children:"Workspace"})]}),et==="org"&&B&&t.jsxs(Cl,{children:[t.jsx(Sl,{children:B.image_url?t.jsx("img",{src:B.image_url,alt:B.name}):pe(B.name)}),t.jsxs(El,{children:[t.jsx(Al,{children:B.name}),rt&&t.jsx(zl,{children:rt})]}),t.jsxs($l,{children:[Me&&t.jsx(ln,{onClick:()=>{L.open(),i(!1)},title:"Organization settings","aria-label":"Organization settings",children:t.jsx(Ar,{size:14})}),t.jsx(ln,{$destructive:!0,onClick:_t,disabled:w==="org",title:"Leave organization","aria-label":"Leave organization",children:t.jsx(zr,{size:14})})]})]}),et==="ws"&&ie&&t.jsxs(Cl,{children:[t.jsx(Sl,{children:te.image_url?t.jsx("img",{src:te.image_url,alt:te.name}):pe(te.name)}),t.jsxs(El,{children:[t.jsx(Al,{children:te.name}),ft&&t.jsx(zl,{children:ft})]}),t.jsxs($l,{children:[De&&t.jsx(ln,{onClick:()=>{$.open(),i(!1)},title:"Workspace settings","aria-label":"Workspace settings",children:t.jsx(Ar,{size:14})}),t.jsx(ln,{$destructive:!0,onClick:ae,disabled:w==="ws",title:"Leave workspace","aria-label":"Leave workspace",children:t.jsx(zr,{size:14})})]})]})]})})(),t.jsxs($b,{children:[t.jsxs(bl,{$active:Ue,onClick:()=>{Ue||Be(void 0)},disabled:p,style:Ue?{cursor:"default"}:void 0,children:[t.jsx(yl,{$personal:!0,children:U!=null&&U.has_profile_picture?t.jsx("img",{src:U.profile_picture_url,alt:U.first_name}):t.jsx(Ea,{size:12})}),t.jsx(gs,{children:"Personal account"}),Ue&&t.jsx(Fo,{children:t.jsx("span",{className:"sp-check",style:{display:"inline-flex"},children:t.jsx(Io,{size:13})})})]}),J.map(ie=>{var ft,_t;const ye=ie.organization,Me=ye.id===(B==null?void 0:B.id),De=j.has(ye.id),et=Te?ve[ye.id]||[]:[],rt=!!((ft=ie.eligibility_restriction)!=null&&ft.type)&&ie.eligibility_restriction.type!=="none";return t.jsxs(c.Fragment,{children:[t.jsxs(bl,{$active:Me,onClick:()=>{rt||(Te?G(ye.id):Me||Be(ye.id))},disabled:p,style:rt?{opacity:.55,cursor:"not-allowed"}:Me&&!Te?{cursor:"default"}:void 0,title:(_t=ie.eligibility_restriction)==null?void 0:_t.message,children:[t.jsx(yl,{children:ye.image_url?t.jsx("img",{src:ye.image_url,alt:ye.name}):pe(ye.name)}),t.jsx(gs,{children:ye.name}),t.jsxs(Fo,{children:[rt&&t.jsx($r,{size:12,color:"var(--color-error)"}),Me&&!Te&&t.jsx(Io,{size:13}),Te&&t.jsx(Mb,{size:11,$open:De})]})]}),Te&&De&&t.jsxs(t.Fragment,{children:[et.map(ae=>{var kt,K;const Re=Me&&(te==null?void 0:te.id)===ae.id,tt=ae,qe=((kt=tt.eligibility_restriction)==null?void 0:kt.type)&&tt.eligibility_restriction.type!=="none";return t.jsxs(wl,{$active:Re,onClick:()=>{!Re&&!qe&&We(ae.id)},disabled:p,style:qe||rt?{opacity:.55,cursor:"not-allowed"}:Re?{cursor:"default"}:void 0,title:(K=tt.eligibility_restriction)==null?void 0:K.message,children:[t.jsx(jl,{children:tt.image_url?t.jsx("img",{src:tt.image_url,alt:tt.name}):pe(tt.name).charAt(0)}),t.jsx(_l,{children:tt.name}),t.jsxs(Fo,{children:[qe&&t.jsx($r,{size:12,color:"var(--color-error)"}),Re&&t.jsx(Io,{size:12})]})]},ae.id)}),!rt&&t.jsxs(wl,{onClick:()=>{_(ye.id),T.open()},disabled:p,children:[t.jsx(jl,{style:{background:"transparent",border:"1px dashed var(--color-border)"},children:t.jsx(jt,{size:10})}),t.jsx(_l,{children:"New workspace"})]})]})]},ye.id)})]}),(()=>{var rt,ft,_t;const ie=((ce==null?void 0:ce.length)??0)>0,ye=()=>Ve&&t.jsx(Ml,{children:t.jsxs(Ll,{onClick:()=>{r?(r(),i(!1)):P.open()},disabled:p,children:[t.jsx(Rl,{children:t.jsx(jt,{size:12})}),"New organization"]})});if(!Te||!ie)return ye();const Me=!!((rt=Y==null?void 0:Y.eligibility_restriction)!=null&&rt.type)&&Y.eligibility_restriction.type!=="none",De=((_t=(ft=ce==null?void 0:ce[0])==null?void 0:ft.organization)==null?void 0:_t.id)??null,et=B&&!Me?B.id:De;return t.jsx(Ml,{children:t.jsxs(Ll,{onClick:()=>{_(et),T.open()},disabled:p,children:[t.jsx(Rl,{children:t.jsx(jt,{size:12})}),"New workspace"]})})})()]})]}),document.body),t.jsx(fu,{isOpen:I.isOpen,onClose:I.close}),a&&t.jsxs(t.Fragment,{children:[t.jsx(Z1,{isOpen:P.isOpen,onClose:P.close}),t.jsx(N1,{isOpen:L.isOpen,onClose:L.close}),Te&&t.jsxs(t.Fragment,{children:[t.jsx(Ts,{isOpen:T.isOpen,onClose:()=>{T.close(),_(null)},organizationId:C||void 0}),t.jsx(Zs,{isOpen:$.isOpen,onClose:$.close})]})]})]})})},Pb=l.div`
6414
6414
  padding: var(--space-6u) var(--space-8u);
6415
6415
  background: ${e=>e.$unread?"var(--color-accent)":"transparent"};
6416
6416
  transition: background-color 0.2s ease;
@@ -6658,7 +6658,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
6658
6658
  color: var(--color-secondary-text);
6659
6659
  margin: 0;
6660
6660
  line-height: 1.4;
6661
- `,xu=c.forwardRef(({scope:e="all",onAction:r,fullWidth:a,maxHeight:n,className:s},i)=>{const[h,d]=c.useState("inbox"),[u,f]=c.useState(!1),[p,m]=c.useState(!1),g=c.useRef(null),v={scope:e,limit:20,is_archived:h==="archive",is_starred:h==="starred",is_read:u?!1:void 0},{notifications:w,loading:x,error:b,hasMore:E,loadMore:j,markAsRead:S,markAsUnread:C,markAllAsRead:_,archiveAllRead:k,archiveNotification:y,starNotification:M}=j0(v);c.useEffect(()=>{if(!p)return;const R=T=>{g.current&&!g.current.contains(T.target)&&m(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[p]);const A=async R=>{switch(R.type){case"read":await S(R.id);break;case"unread":await C(R.id);break;case"archive":await y(R.id);break;case"star":await M(R.id);break;case"custom":r==null||r(R.payload);break}},F=()=>{_(),m(!1)},I=()=>{k(),m(!1)};return t.jsxs(Vb,{ref:i,$fullWidth:a,$maxHeight:n,className:s,children:[t.jsxs(Db,{children:[t.jsxs(Nb,{children:[t.jsx(dn,{$active:h==="inbox",onClick:()=>d("inbox"),children:"Inbox"}),t.jsx(dn,{$active:h==="archive",onClick:()=>d("archive"),children:"Archive"}),t.jsx(dn,{$active:h==="starred",onClick:()=>d("starred"),children:"Starred"})]}),t.jsxs(Wb,{onClick:()=>f(!u),children:[t.jsx(Gb,{$active:u}),t.jsx(qb,{children:"Unread Only"})]}),t.jsx(Ub,{onClick:()=>m(!p),style:{padding:"var(--space-2u)"},children:t.jsx(bf,{size:16})}),p&&t.jsxs(Bb,{ref:g,style:{top:"var(--size-18u)",right:"var(--space-6u)"},children:[h==="inbox"&&t.jsxs(Pl,{onClick:F,children:[t.jsx(vf,{})," Mark all as read"]}),t.jsxs(Pl,{onClick:I,children:[t.jsx(sd,{})," Archive all read"]})]})]}),t.jsx(Kb,{children:x?t.jsx(Yb,{children:t.jsx(ze,{})}):b?t.jsxs(Tl,{children:[t.jsx(Fl,{children:t.jsx(Si,{size:24,style:{color:"var(--color-error)"}})}),t.jsx(Il,{children:"Failed to load notifications"}),t.jsx(Zl,{children:b.message||"An unexpected error occurred."})]}):w.length===0?t.jsxs(Tl,{children:[t.jsx(Fl,{children:t.jsx(Si,{size:24})}),t.jsx(Il,{children:"No notifications"}),t.jsx(Zl,{children:"You're all caught up!"})]}):t.jsxs(t.Fragment,{children:[w.map(R=>t.jsx(vu,{notification:R,onAction:A},R.id)),E&&t.jsx("div",{style:{padding:"var(--space-6u)",display:"flex",justifyContent:"center"},children:t.jsx(dn,{$active:!1,onClick:j,style:{fontSize:"var(--font-size-sm)"},children:"Load more"})})]})})]})}),Qb=l.div`
6661
+ `,xu=c.forwardRef(({scope:e="all",onAction:r,fullWidth:a,maxHeight:n,className:s},i)=>{const[h,d]=c.useState("inbox"),[u,f]=c.useState(!1),[p,m]=c.useState(!1),g=c.useRef(null),v={scope:e,limit:20,is_archived:h==="archive",is_starred:h==="starred",is_read:u?!1:void 0},{notifications:w,loading:x,error:b,hasMore:E,loadMore:j,markAsRead:S,markAsUnread:C,markAllAsRead:_,archiveAllRead:k,archiveNotification:y,starNotification:M}=j0(v);c.useEffect(()=>{if(!p)return;const L=T=>{g.current&&!g.current.contains(T.target)&&m(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[p]);const A=async L=>{switch(L.type){case"read":await S(L.id);break;case"unread":await C(L.id);break;case"archive":await y(L.id);break;case"star":await M(L.id);break;case"custom":r==null||r(L.payload);break}},I=()=>{_(),m(!1)},P=()=>{k(),m(!1)};return t.jsxs(Vb,{ref:i,$fullWidth:a,$maxHeight:n,className:s,children:[t.jsxs(Db,{children:[t.jsxs(Nb,{children:[t.jsx(dn,{$active:h==="inbox",onClick:()=>d("inbox"),children:"Inbox"}),t.jsx(dn,{$active:h==="archive",onClick:()=>d("archive"),children:"Archive"}),t.jsx(dn,{$active:h==="starred",onClick:()=>d("starred"),children:"Starred"})]}),t.jsxs(Wb,{onClick:()=>f(!u),children:[t.jsx(Gb,{$active:u}),t.jsx(qb,{children:"Unread Only"})]}),t.jsx(Ub,{onClick:()=>m(!p),style:{padding:"var(--space-2u)"},children:t.jsx(bf,{size:16})}),p&&t.jsxs(Bb,{ref:g,style:{top:"var(--size-18u)",right:"var(--space-6u)"},children:[h==="inbox"&&t.jsxs(Pl,{onClick:I,children:[t.jsx(vf,{})," Mark all as read"]}),t.jsxs(Pl,{onClick:P,children:[t.jsx(sd,{})," Archive all read"]})]})]}),t.jsx(Kb,{children:x?t.jsx(Yb,{children:t.jsx(ze,{})}):b?t.jsxs(Tl,{children:[t.jsx(Fl,{children:t.jsx(Si,{size:24,style:{color:"var(--color-error)"}})}),t.jsx(Il,{children:"Failed to load notifications"}),t.jsx(Zl,{children:b.message||"An unexpected error occurred."})]}):w.length===0?t.jsxs(Tl,{children:[t.jsx(Fl,{children:t.jsx(Si,{size:24})}),t.jsx(Il,{children:"No notifications"}),t.jsx(Zl,{children:"You're all caught up!"})]}):t.jsxs(t.Fragment,{children:[w.map(L=>t.jsx(vu,{notification:L,onAction:A},L.id)),E&&t.jsx("div",{style:{padding:"var(--space-6u)",display:"flex",justifyContent:"center"},children:t.jsx(dn,{$active:!1,onClick:j,style:{fontSize:"var(--font-size-sm)"},children:"Load more"})})]})})]})}),Qb=l.div`
6662
6662
  position: fixed;
6663
6663
  ${e=>{var r;return((r=e.$position)==null?void 0:r.top)!==void 0?`top: ${e.$position.top}px;`:""}}
6664
6664
  ${e=>{var r;return((r=e.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${e.$position.bottom}px;`:""}}
@@ -7000,7 +7000,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
7000
7000
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-secondary) 50%, var(--color-accent) 100%);
7001
7001
  background-size: calc(var(--size-50u) * 10) 100%;
7002
7002
  animation: ${yu} 2s infinite linear;
7003
- `,zw=({onAccountSelect:e,showAddAccount:r=!0})=>{var y,M,A,F,I;const{session:a,loading:n,switchSignIn:s,signOut:i}=ot(),{deployment:h}=Ae(),{navigateToSignIn:d,navigate:u}=yt(),[f,p]=c.useState(null),[m,g]=c.useState(null),v=a==null?void 0:a.active_signin,w=(a==null?void 0:a.signins)||[],x=((M=(y=h==null?void 0:h.auth_settings)==null?void 0:y.multi_session_support)==null?void 0:M.enabled)??!1,b=(A=h==null?void 0:h.ui_settings)==null?void 0:A.logo_image_url,E=(F=h==null?void 0:h.ui_settings)==null?void 0:F.app_name;c.useEffect(()=>{n||w.length||d()},[n,w,d]);const j=R=>R.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),S=async R=>{var T;g(R);try{if(await s(R),e)e(R),g(null);else{let $=new URLSearchParams(window.location.search).get("redirect_uri");if($||($=(T=h.ui_settings)==null?void 0:T.after_signin_redirect_url),$){let z;try{z=new URL($)}catch{z=new URL($,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&z.searchParams.set("__dev_session__",ht(h.backend_host)??""),u(z.toString())}else g(null)}}catch{g(null)}},C=async(R,T)=>{R.stopPropagation(),p(T);try{await i(T)}catch{}finally{p(null)}},_=()=>{var T;let R=new URLSearchParams(window.location.search).get("redirect_uri");R||(R=(T=h.ui_settings)==null?void 0:T.after_signin_redirect_url),d(R)},k=()=>t.jsxs(iw,{children:[t.jsxs(cw,{children:[b?t.jsx(lw,{src:b,alt:E||"App"}):t.jsx(dw,{children:t.jsx(zf,{size:20})}),t.jsxs(uw,{children:[t.jsx(pw,{children:E||"Your App"}),t.jsx(hw,{children:"Select or switch between your accounts"})]})]}),t.jsx(fw,{})]});return n?t.jsx(ge,{children:t.jsxs(Hl,{children:[k(),t.jsxs(Vl,{children:[t.jsx(Dl,{children:t.jsx(Zo,{$width:"55%"})}),t.jsx(Nl,{children:[1,2,3].map(R=>t.jsxs(Sw,{children:[t.jsx(Ew,{}),t.jsxs(Aw,{children:[t.jsx(Zo,{$width:"45%"}),t.jsx(Zo,{$width:"65%"})]})]},R))})]})]})}):w.length?t.jsx(ge,{children:t.jsxs(Hl,{children:[k(),t.jsxs(Vl,{children:[t.jsxs(Dl,{children:[t.jsx(mw,{children:"Your accounts"}),t.jsx(gw,{children:"Select one to continue"})]}),t.jsxs(Nl,{children:[w.map(({user:R,id:T})=>{var L,W;if(!R)return null;const $=T===(v==null?void 0:v.id),z=m===T,H=f===T,P=`${R.first_name||""} ${R.last_name||""}`.trim(),O=P||((L=R.primary_email_address)==null?void 0:L.email)||R.username||"User",Z=((W=R.primary_email_address)==null?void 0:W.email)||R.username;return t.jsxs(vw,{$isActive:$,$isSwitching:z,$clickable:!$,onClick:()=>!$&&S(T),children:[t.jsx(xw,{$isActive:$,children:z?t.jsx(Ol,{size:14}):R.has_profile_picture?t.jsx("img",{src:R.profile_picture_url,alt:P}):j(O)}),t.jsxs(bw,{children:[t.jsx(ww,{children:O}),Z&&Z!==O&&t.jsx(yw,{children:Z})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3u)",flexShrink:0},children:[$&&t.jsx(gf,{size:16,weight:"fill",style:{color:"var(--color-primary)"}}),t.jsx(jw,{onClick:D=>C(D,T),disabled:H,title:"Sign out",children:H?t.jsx(Ol,{size:13}):t.jsx(zr,{size:13})})]})]},T)}),r&&x&&t.jsxs(ju,{onClick:_,children:[t.jsx(_w,{children:t.jsx(jt,{size:13})}),"Add account"]})]}),t.jsxs(kw,{children:["Don't have an account?"," ",t.jsx(Cw,{children:t.jsx(Pt,{to:`${(I=h.ui_settings)==null?void 0:I.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})}):null},$w=()=>{const{navigateToSignIn:e}=yt();return c.useEffect(()=>{e()},[e]),null},Mw=()=>{const{navigateToSignUp:e}=yt();return c.useEffect(()=>{e()},[e]),null},Lw=l.div`
7003
+ `,zw=({onAccountSelect:e,showAddAccount:r=!0})=>{var y,M,A,I,P;const{session:a,loading:n,switchSignIn:s,signOut:i}=ot(),{deployment:h}=Ae(),{navigateToSignIn:d,navigate:u}=yt(),[f,p]=c.useState(null),[m,g]=c.useState(null),v=a==null?void 0:a.active_signin,w=(a==null?void 0:a.signins)||[],x=((M=(y=h==null?void 0:h.auth_settings)==null?void 0:y.multi_session_support)==null?void 0:M.enabled)??!1,b=(A=h==null?void 0:h.ui_settings)==null?void 0:A.logo_image_url,E=(I=h==null?void 0:h.ui_settings)==null?void 0:I.app_name;c.useEffect(()=>{n||w.length||d()},[n,w,d]);const j=L=>L.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),S=async L=>{var T;g(L);try{if(await s(L),e)e(L),g(null);else{let $=new URLSearchParams(window.location.search).get("redirect_uri");if($||($=(T=h.ui_settings)==null?void 0:T.after_signin_redirect_url),$){let z;try{z=new URL($)}catch{z=new URL($,window.location.origin)}(h==null?void 0:h.mode)==="staging"&&z.searchParams.set("__dev_session__",ht(h.backend_host)??""),u(z.toString())}else g(null)}}catch{g(null)}},C=async(L,T)=>{L.stopPropagation(),p(T);try{await i(T)}catch{}finally{p(null)}},_=()=>{var T;let L=new URLSearchParams(window.location.search).get("redirect_uri");L||(L=(T=h.ui_settings)==null?void 0:T.after_signin_redirect_url),d(L)},k=()=>t.jsxs(iw,{children:[t.jsxs(cw,{children:[b?t.jsx(lw,{src:b,alt:E||"App"}):t.jsx(dw,{children:t.jsx(zf,{size:20})}),t.jsxs(uw,{children:[t.jsx(pw,{children:E||"Your App"}),t.jsx(hw,{children:"Select or switch between your accounts"})]})]}),t.jsx(fw,{})]});return n?t.jsx(ge,{children:t.jsxs(Hl,{children:[k(),t.jsxs(Vl,{children:[t.jsx(Dl,{children:t.jsx(Zo,{$width:"55%"})}),t.jsx(Nl,{children:[1,2,3].map(L=>t.jsxs(Sw,{children:[t.jsx(Ew,{}),t.jsxs(Aw,{children:[t.jsx(Zo,{$width:"45%"}),t.jsx(Zo,{$width:"65%"})]})]},L))})]})]})}):w.length?t.jsx(ge,{children:t.jsxs(Hl,{children:[k(),t.jsxs(Vl,{children:[t.jsxs(Dl,{children:[t.jsx(mw,{children:"Your accounts"}),t.jsx(gw,{children:"Select one to continue"})]}),t.jsxs(Nl,{children:[w.map(({user:L,id:T})=>{var R,W;if(!L)return null;const $=T===(v==null?void 0:v.id),z=m===T,H=f===T,F=`${L.first_name||""} ${L.last_name||""}`.trim(),O=F||((R=L.primary_email_address)==null?void 0:R.email)||L.username||"User",Z=((W=L.primary_email_address)==null?void 0:W.email)||L.username;return t.jsxs(vw,{$isActive:$,$isSwitching:z,$clickable:!$,onClick:()=>!$&&S(T),children:[t.jsx(xw,{$isActive:$,children:z?t.jsx(Ol,{size:14}):L.has_profile_picture?t.jsx("img",{src:L.profile_picture_url,alt:F}):j(O)}),t.jsxs(bw,{children:[t.jsx(ww,{children:O}),Z&&Z!==O&&t.jsx(yw,{children:Z})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3u)",flexShrink:0},children:[$&&t.jsx(gf,{size:16,weight:"fill",style:{color:"var(--color-primary)"}}),t.jsx(jw,{onClick:D=>C(D,T),disabled:H,title:"Sign out",children:H?t.jsx(Ol,{size:13}):t.jsx(zr,{size:13})})]})]},T)}),r&&x&&t.jsxs(ju,{onClick:_,children:[t.jsx(_w,{children:t.jsx(jt,{size:13})}),"Add account"]})]}),t.jsxs(kw,{children:["Don't have an account?"," ",t.jsx(Cw,{children:t.jsx(Pt,{to:`${(P=h.ui_settings)==null?void 0:P.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})}):null},$w=()=>{const{navigateToSignIn:e}=yt();return c.useEffect(()=>{e()},[e]),null},Mw=()=>{const{navigateToSignUp:e}=yt();return c.useEffect(()=>{e()},[e]),null},Lw=l.div`
7004
7004
  width: 100%;
7005
7005
  max-width: 100%;
7006
7006
  height: calc(calc(var(--size-50u) * 4) + calc(var(--size-50u) * 2));
@@ -7268,7 +7268,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
7268
7268
  margin: 0 auto;
7269
7269
  padding: var(--space-3u) var(--space-8u);
7270
7270
  font-size: var(--font-size-md);
7271
- `,Uw=()=>{var I,R;const{organizationMemberships:e,refetch:r,loading:a}=Kt(),{workspaces:n}=sr(),{switchOrganization:s,switchWorkspace:i}=ot(),{deployment:h}=Ae(),[d,u]=c.useState(null),[f,p]=c.useState("orgList"),[m,g]=c.useState(null),v=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,w=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,x=c.useRef(!1);c.useEffect(()=>{if(!(x.current||!e)){if(x.current=!0,e.length===0){p("createOrg");return}if(!v){p("orgList");return}if(!n||n.length===0){const T=e.find($=>{var z,H;return!((z=$.eligibility_restriction)!=null&&z.type)||((H=$.eligibility_restriction)==null?void 0:H.type)==="none"});if(T){g(T.organization.id),p("createWorkspace");return}}p("orgList")}},[e,n,v]);const b=T=>T.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),E=async T=>{if(v){g(T.id),p("workspaceList");return}u(T.id);try{await s(T.id)}finally{u(null)}},j=async T=>{u(T.id);try{await i(T.id)}finally{u(null)}},S=async T=>{var z;await r();const $=((z=T==null?void 0:T.data)==null?void 0:z.organization)||(T==null?void 0:T.organization)||T;if(!v){p("orgList");return}$!=null&&$.id?(g($.id),p("createWorkspace")):p("orgList")},C=()=>{},_=async()=>{g(null),p("orgList")},k=(I=e==null?void 0:e.find(T=>T.organization.id===m))==null?void 0:I.organization,y=m?n==null?void 0:n.filter(T=>T.organization.id===m):[];if(a)return null;if(f==="createOrg")return t.jsx(He.Body,{style:{padding:0},children:t.jsx(On,{onSuccess:S,onCancel:()=>p("orgList")})});if(f==="createWorkspace"&&m)return t.jsx(He.Body,{style:{padding:0},children:t.jsx(Ps,{organizationId:m,onSuccess:C,onCancel:()=>p("workspaceList"),onCreateOrganization:()=>p("createOrg")})});const M=f==="workspaceList",A=M?"Select a workspace":"Select an organization",F=M?`Choose a workspace in ${(k==null?void 0:k.name)||""}`:`to continue to ${((R=h==null?void 0:h.ui_settings)==null?void 0:R.app_name)||"App"}`;return t.jsxs(Lw,{children:[t.jsxs(Rw,{children:[t.jsxs(Pw,{children:[t.jsx(Je,{placement:"left"}),t.jsxs(Hw,{children:[t.jsx(Vw,{children:A}),t.jsx(Dw,{children:F})]})]}),t.jsx(Bs,{showName:!0})]}),t.jsxs(Tw,{children:[t.jsxs(Fw,{children:[t.jsxs(Iw,{children:[M&&t.jsx(Ow,{onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(na,{})}),t.jsx(Zw,{children:M?"Workspaces":"Your organizations"})]}),t.jsx(Nw,{children:M?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(T=>{var z,H,P;const $=((z=T.eligibility_restriction)==null?void 0:z.type)!=="none"&&((H=T.eligibility_restriction)==null?void 0:H.type)!==void 0;return t.jsxs(Ul,{onClick:()=>!$&&j(T),disabled:d===T.id||$,style:{opacity:$?.6:1},children:[$&&t.jsx(Bl,{className:"warning-popover",children:(P=T.eligibility_restriction)==null?void 0:P.message}),t.jsx(Wl,{children:T.image_url?t.jsx(Gl,{src:T.image_url,alt:T.name}):b(T.name).charAt(0)}),t.jsxs(ql,{children:[t.jsx(Kl,{children:T.name}),t.jsxs(Yl,{children:[t.jsx(_n,{}),"Workspace"]})]}),t.jsxs(Ql,{children:[$&&t.jsx($r,{size:16,style:{color:"var(--color-error)"}}),t.jsx(Sa,{})]})]},T.id)}):t.jsxs(Jl,{children:[t.jsx(Xl,{children:"No workspaces yet"}),t.jsxs(e0,{children:["Create your first workspace for"," ",(k==null?void 0:k.name)||"this organization"]}),t.jsxs(t0,{onClick:()=>p("createWorkspace"),children:[t.jsx(jt,{}),"Create workspace"]})]})}):e&&e.length>0?e.map(T=>{var D,B,Y,X,ce;const $=T.organization,z=n==null?void 0:n.filter(me=>me.organization.id===$.id),H=(z==null?void 0:z.length)||0,P=$.member_count,O=((B=(D=T.roles)==null?void 0:D[0])==null?void 0:B.name)||"No role",Z=T.roles.length-1,L=Z>0?`${O.charAt(0).toUpperCase()+O.slice(1)} +${Z}`:O.charAt(0).toUpperCase()+O.slice(1),W=((Y=T.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return t.jsxs(Ul,{onClick:()=>!W&&E($),disabled:d===$.id||W,style:{opacity:W?.6:1},children:[W&&t.jsx(Bl,{className:"warning-popover",children:(ce=T.eligibility_restriction)==null?void 0:ce.message}),t.jsx(Wl,{children:$.image_url?t.jsx(Gl,{src:$.image_url,alt:$.name}):b($.name)}),t.jsxs(ql,{children:[t.jsx(Kl,{children:$.name}),t.jsx(Yl,{children:v?t.jsxs(t.Fragment,{children:[t.jsx(_n,{}),H," ","workspace",H!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(pd,{}),L," •"," ",P," member",P!==1?"s":""]})})]}),t.jsxs(Ql,{children:[W&&t.jsx($r,{size:16,style:{color:"var(--color-error)"}}),t.jsx(Sa,{})]})]},$.id)}):t.jsxs(Jl,{children:[t.jsx(Xl,{children:"No organizations yet"}),t.jsx(e0,{children:w?"Create your first organization to get started":"You don't have access to any organizations yet"}),w&&t.jsxs(t0,{onClick:()=>p("createOrg"),children:[t.jsx(jt,{}),"Create organization"]})]})})]}),M&&m&&t.jsxs(N,{$outline:!0,style:{marginTop:"var(--space-4u)"},onClick:()=>p("createWorkspace"),disabled:d!==null,children:[t.jsx(jt,{size:12}),"Create workspace"]}),!M&&e&&e.length>0&&w&&t.jsxs(N,{$outline:!0,style:{marginTop:v?"var(--space-4u)":"var(--space-6u)"},onClick:()=>p("createOrg"),disabled:d!==null,children:[t.jsx(jt,{size:12}),"Create new organization"]})]})]})},Bw=l(He.Content)`
7271
+ `,Uw=()=>{var P,L;const{organizationMemberships:e,refetch:r,loading:a}=Kt(),{workspaces:n}=sr(),{switchOrganization:s,switchWorkspace:i}=ot(),{deployment:h}=Ae(),[d,u]=c.useState(null),[f,p]=c.useState("orgList"),[m,g]=c.useState(null),v=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,w=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,x=c.useRef(!1);c.useEffect(()=>{if(!(x.current||!e)){if(x.current=!0,e.length===0){p("createOrg");return}if(!v){p("orgList");return}if(!n||n.length===0){const T=e.find($=>{var z,H;return!((z=$.eligibility_restriction)!=null&&z.type)||((H=$.eligibility_restriction)==null?void 0:H.type)==="none"});if(T){g(T.organization.id),p("createWorkspace");return}}p("orgList")}},[e,n,v]);const b=T=>T.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),E=async T=>{if(v){g(T.id),p("workspaceList");return}u(T.id);try{await s(T.id)}finally{u(null)}},j=async T=>{u(T.id);try{await i(T.id)}finally{u(null)}},S=async T=>{var z;await r();const $=((z=T==null?void 0:T.data)==null?void 0:z.organization)||(T==null?void 0:T.organization)||T;if(!v){p("orgList");return}$!=null&&$.id?(g($.id),p("createWorkspace")):p("orgList")},C=()=>{},_=async()=>{g(null),p("orgList")},k=(P=e==null?void 0:e.find(T=>T.organization.id===m))==null?void 0:P.organization,y=m?n==null?void 0:n.filter(T=>T.organization.id===m):[];if(a)return null;if(f==="createOrg")return t.jsx(He.Body,{style:{padding:0},children:t.jsx(On,{onSuccess:S,onCancel:()=>p("orgList")})});if(f==="createWorkspace"&&m)return t.jsx(He.Body,{style:{padding:0},children:t.jsx(Ps,{organizationId:m,onSuccess:C,onCancel:()=>p("workspaceList"),onCreateOrganization:()=>p("createOrg")})});const M=f==="workspaceList",A=M?"Select a workspace":"Select an organization",I=M?`Choose a workspace in ${(k==null?void 0:k.name)||""}`:`to continue to ${((L=h==null?void 0:h.ui_settings)==null?void 0:L.app_name)||"App"}`;return t.jsxs(Lw,{children:[t.jsxs(Rw,{children:[t.jsxs(Pw,{children:[t.jsx(Je,{placement:"left"}),t.jsxs(Hw,{children:[t.jsx(Vw,{children:A}),t.jsx(Dw,{children:I})]})]}),t.jsx(Bs,{showName:!0})]}),t.jsxs(Tw,{children:[t.jsxs(Fw,{children:[t.jsxs(Iw,{children:[M&&t.jsx(Ow,{onClick:_,"aria-label":"Go back",title:"Go back",children:t.jsx(na,{})}),t.jsx(Zw,{children:M?"Workspaces":"Your organizations"})]}),t.jsx(Nw,{children:M?t.jsx(t.Fragment,{children:y&&y.length>0?y.map(T=>{var z,H,F;const $=((z=T.eligibility_restriction)==null?void 0:z.type)!=="none"&&((H=T.eligibility_restriction)==null?void 0:H.type)!==void 0;return t.jsxs(Ul,{onClick:()=>!$&&j(T),disabled:d===T.id||$,style:{opacity:$?.6:1},children:[$&&t.jsx(Bl,{className:"warning-popover",children:(F=T.eligibility_restriction)==null?void 0:F.message}),t.jsx(Wl,{children:T.image_url?t.jsx(Gl,{src:T.image_url,alt:T.name}):b(T.name).charAt(0)}),t.jsxs(ql,{children:[t.jsx(Kl,{children:T.name}),t.jsxs(Yl,{children:[t.jsx(_n,{}),"Workspace"]})]}),t.jsxs(Ql,{children:[$&&t.jsx($r,{size:16,style:{color:"var(--color-error)"}}),t.jsx(Sa,{})]})]},T.id)}):t.jsxs(Jl,{children:[t.jsx(Xl,{children:"No workspaces yet"}),t.jsxs(e0,{children:["Create your first workspace for"," ",(k==null?void 0:k.name)||"this organization"]}),t.jsxs(t0,{onClick:()=>p("createWorkspace"),children:[t.jsx(jt,{}),"Create workspace"]})]})}):e&&e.length>0?e.map(T=>{var D,B,Y,X,ce;const $=T.organization,z=n==null?void 0:n.filter(me=>me.organization.id===$.id),H=(z==null?void 0:z.length)||0,F=$.member_count,O=((B=(D=T.roles)==null?void 0:D[0])==null?void 0:B.name)||"No role",Z=T.roles.length-1,R=Z>0?`${O.charAt(0).toUpperCase()+O.slice(1)} +${Z}`:O.charAt(0).toUpperCase()+O.slice(1),W=((Y=T.eligibility_restriction)==null?void 0:Y.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return t.jsxs(Ul,{onClick:()=>!W&&E($),disabled:d===$.id||W,style:{opacity:W?.6:1},children:[W&&t.jsx(Bl,{className:"warning-popover",children:(ce=T.eligibility_restriction)==null?void 0:ce.message}),t.jsx(Wl,{children:$.image_url?t.jsx(Gl,{src:$.image_url,alt:$.name}):b($.name)}),t.jsxs(ql,{children:[t.jsx(Kl,{children:$.name}),t.jsx(Yl,{children:v?t.jsxs(t.Fragment,{children:[t.jsx(_n,{}),H," ","workspace",H!==1?"s":""]}):t.jsxs(t.Fragment,{children:[t.jsx(pd,{}),R," •"," ",F," member",F!==1?"s":""]})})]}),t.jsxs(Ql,{children:[W&&t.jsx($r,{size:16,style:{color:"var(--color-error)"}}),t.jsx(Sa,{})]})]},$.id)}):t.jsxs(Jl,{children:[t.jsx(Xl,{children:"No organizations yet"}),t.jsx(e0,{children:w?"Create your first organization to get started":"You don't have access to any organizations yet"}),w&&t.jsxs(t0,{onClick:()=>p("createOrg"),children:[t.jsx(jt,{}),"Create organization"]})]})})]}),M&&m&&t.jsxs(N,{$outline:!0,style:{marginTop:"var(--space-4u)"},onClick:()=>p("createWorkspace"),disabled:d!==null,children:[t.jsx(jt,{size:12}),"Create workspace"]}),!M&&e&&e.length>0&&w&&t.jsxs(N,{$outline:!0,style:{marginTop:v?"var(--space-4u)":"var(--space-6u)"},onClick:()=>p("createOrg"),disabled:d!==null,children:[t.jsx(jt,{size:12}),"Create new organization"]})]})]})},Bw=l(He.Content)`
7272
7272
  padding: 0;
7273
7273
  width: calc(var(--size-50u) * 9);
7274
7274
  max-width: 90vw;